Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4771,15 +4771,15 @@ VMPTR_OBJECTHANDLE DacDbiInterfaceImpl::GetThreadObject(VMPTR_Thread vmThread)
}
}

void DacDbiInterfaceImpl::GetThreadAllocInfo(VMPTR_Thread vmThread,
void DacDbiInterfaceImpl::GetThreadAllocInfo(VMPTR_Thread vmThread,
DacThreadAllocInfo* threadAllocInfo)
{
DD_ENTER_MAY_THROW;

Thread * pThread = vmThread.GetDacPtr();
gc_alloc_context* allocContext = pThread->GetAllocContext();
threadAllocInfo->m_allocBytesSOH = (ULONG)(allocContext->alloc_bytes - (allocContext->alloc_limit - allocContext->alloc_ptr));
threadAllocInfo->m_allocBytesUOH = (ULONG)allocContext->alloc_bytes_uoh;
threadAllocInfo->m_allocBytesSOH = allocContext->alloc_bytes - (allocContext->alloc_limit - allocContext->alloc_ptr);
threadAllocInfo->m_allocBytesUOH = allocContext->alloc_bytes_uoh;
}

// Set and reset the TSNC_DebuggerUserSuspend bit on the state of the specified thread
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/debug/di/rspriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -6045,7 +6045,8 @@ struct GetActiveInternalFramesData
class CordbThread : public CordbBase, public ICorDebugThread,
public ICorDebugThread2,
public ICorDebugThread3,
public ICorDebugThread4
public ICorDebugThread4,
public ICorDebugThread5
{
public:
CordbThread(CordbProcess * pProcess, VMPTR_Thread);
Expand Down Expand Up @@ -6116,6 +6117,10 @@ class CordbThread : public CordbBase, public ICorDebugThread,
// ICorDebugThread4
COM_METHOD HasUnhandledException();

// ICorDebugThread5
COM_METHOD GetBytesAllocated(ULONG64 *pSohAllocatedBytes,
ULONG64 *pUohAllocatedBytes);

COM_METHOD GetBlockingObjects(ICorDebugBlockingObjectEnum **ppBlockingObjectEnum);

// Gets the current CustomNotification object from the thread or NULL if no such object exists
Expand Down
41 changes: 40 additions & 1 deletion src/coreclr/debug/di/rsthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ HRESULT CordbThread::QueryInterface(REFIID id, void ** ppInterface)
{
*ppInterface = static_cast<ICorDebugThread4*>(this);
}
else if (id == IID_ICorDebugThread5)
{
*ppInterface = static_cast<ICorDebugThread5*>(this);
}
else if (id == IID_IUnknown)
{
*ppInterface = static_cast<IUnknown *>(static_cast<ICorDebugThread *>(this));
Expand Down Expand Up @@ -2457,6 +2461,42 @@ HRESULT CordbThread::GetCurrentCustomDebuggerNotification(ICorDebugValue ** ppNo
return hr;
}

// ICorDebugThread5

/*
* GetBytesAllocated
*
* Returns S_OK if it was possible to obtain the allocation information for the thread
* and sets the corresponding SOH and UOH allocations.
*/
HRESULT CordbThread::GetBytesAllocated(ULONG64 *pSohAllocatedBytes,
ULONG64 *pUohAllocatedBytes)
{
PUBLIC_API_ENTRY(this);
FAIL_IF_NEUTERED(this);
ATT_REQUIRE_STOPPED_MAY_FAIL(GetProcess());

HRESULT hr = S_OK;
EX_TRY
{
DacThreadAllocInfo threadAllocInfo = { 0 };

if (pSohAllocatedBytes == NULL || pUohAllocatedBytes == NULL)
{
ThrowHR(E_INVALIDARG);
}

IDacDbiInterface * pDAC = GetProcess()->GetDAC();
pDAC->GetThreadAllocInfo(m_vmThreadToken, &threadAllocInfo);

*pSohAllocatedBytes = threadAllocInfo.m_allocBytesSOH;
*pUohAllocatedBytes = threadAllocInfo.m_allocBytesUOH;
}
EX_CATCH_HRESULT(hr);

return hr;
} // CordbThread::GetBytesAllocated

/*
*
* SetRemapIP
Expand Down Expand Up @@ -10775,4 +10815,3 @@ HRESULT CordbCodeEnum::Next(ULONG celt, ICorDebugCode *values[], ULONG *pceltFet

return hr;
}

4 changes: 2 additions & 2 deletions src/coreclr/debug/inc/dacdbistructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,8 @@ struct MSLAYOUT DacSharedReJitInfo
// These represent the allocated bytes so far on the thread.
struct MSLAYOUT DacThreadAllocInfo
{
ULONG m_allocBytesSOH;
ULONG m_allocBytesUOH;
ULONG64 m_allocBytesSOH;
ULONG64 m_allocBytesUOH;
};

#include "dacdbistructures.inl"
Expand Down
21 changes: 21 additions & 0 deletions src/coreclr/inc/cordebug.idl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ interface ICorDebugThread;
interface ICorDebugThread2;
interface ICorDebugThread3;
interface ICorDebugThread4;
interface ICorDebugThread5;
interface ICorDebugStackWalk;
interface ICorDebugChain;
interface ICorDebugFrame;
Expand Down Expand Up @@ -4376,6 +4377,26 @@ interface ICorDebugThread4 : IUnknown
HRESULT GetCurrentCustomDebuggerNotification([out] ICorDebugValue ** ppNotificationObject);
};

/*
* ICorDebugThread5 is a logical extension to ICorDebugThread.
*/
[
object,
local,
uuid(F98421C4-E506-4D24-916F-0237EE853EC6),
pointer_default(unique)
]
interface ICorDebugThread5 : IUnknown
{
/*
* Returns S_OK if it was possible to obtain the allocation information for the thread
* and sets the corresponding SOH and UOH allocations.
* Returns E_INVALIDARG if any of the pointers for the outputs is null.
* Can return E_FAIL if the process is not properly stopped.
*/
HRESULT GetBytesAllocated([out] ULONG64 *pSohAllocatedBytes, [out] ULONG64 *pUohAllocatedBytes);
};

/*
* The new V3.0 stackwalking API.
*/
Expand Down
16 changes: 9 additions & 7 deletions src/coreclr/pal/prebuilt/idl/cordebug_i.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.


/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */
Expand All @@ -7,10 +9,10 @@

/* File created by MIDL compiler version 8.01.0622 */
/* Compiler settings for cordebug.idl:
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0622
Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.01.0622
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
Expand All @@ -21,7 +23,7 @@

#ifdef __cplusplus
extern "C"{
#endif
#endif


#include <rpc.h>
Expand Down Expand Up @@ -251,6 +253,9 @@ MIDL_DEFINE_GUID(IID, IID_ICorDebugThread3,0xF8544EC3,0x5E4E,0x46c7,0x8D,0x3E,0x
MIDL_DEFINE_GUID(IID, IID_ICorDebugThread4,0x1A1F204B,0x1C66,0x4637,0x82,0x3F,0x3E,0xE6,0xC7,0x44,0xA6,0x9C);


MIDL_DEFINE_GUID(IID, IID_ICorDebugThread5,0xF98421C4,0xE506,0x4D24,0x91,0x6F,0x02,0x37,0xEE,0x85,0x3E,0xC6);


MIDL_DEFINE_GUID(IID, IID_ICorDebugStackWalk,0xA0647DE9,0x55DE,0x4816,0x92,0x9C,0x38,0x52,0x71,0xC6,0x4C,0xF7);


Expand Down Expand Up @@ -480,6 +485,3 @@ MIDL_DEFINE_GUID(CLSID, CLSID_EmbeddedCLRCorDebug,0x211f1254,0xbc7e,0x4af5,0xb9,
#ifdef __cplusplus
}
#endif



Loading