From: Andrew Au Date: Tue, 22 Mar 2022 15:23:51 +0000 (-0700) Subject: Fix heap walking with global allocation context (#2949) X-Git-Tag: accepted/tizen/unified/20221103.165810~28^2^2~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e79541eba16b522497abfdb96144de2fc6e98391;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Fix heap walking with global allocation context (#2949) --- diff --git a/src/SOS/Strike/util.cpp b/src/SOS/Strike/util.cpp index f6c277ac0..54a8de308 100644 --- a/src/SOS/Strike/util.cpp +++ b/src/SOS/Strike/util.cpp @@ -4287,7 +4287,7 @@ void GetAllocContextPtrs(AllocInfo *pallocInfo) int numThread = ThreadStore.threadCount; if (numThread) { - pallocInfo->array = new needed_alloc_context[numThread]; + pallocInfo->array = new needed_alloc_context[numThread + 1]; if (pallocInfo->array == NULL) { return; @@ -4329,6 +4329,19 @@ void GetAllocContextPtrs(AllocInfo *pallocInfo) CurThread = Thread.nextThread; } + + CLRDATA_ADDRESS allocPtr; + CLRDATA_ADDRESS allocLimit; + + ReleaseHolder sos12; + if (SUCCEEDED(g_sos->QueryInterface(__uuidof(ISOSDacInterface12), &sos12)) && + SUCCEEDED(sos12->GetGlobalAllocationContext(&allocPtr, &allocLimit)) && + allocPtr != 0) + { + int j = pallocInfo->num ++; + pallocInfo->array[j].alloc_ptr = (BYTE *) allocPtr; + pallocInfo->array[j].alloc_limit = (BYTE *) allocLimit; + } } HRESULT ReadVirtualCache::Read(TADDR address, PVOID buffer, ULONG bufferSize, PULONG lpcbBytesRead) diff --git a/src/shared/pal/prebuilt/inc/sospriv.h b/src/shared/pal/prebuilt/inc/sospriv.h index 5c8f17a7f..20496876b 100644 --- a/src/shared/pal/prebuilt/inc/sospriv.h +++ b/src/shared/pal/prebuilt/inc/sospriv.h @@ -2988,10 +2988,88 @@ EXTERN_C const IID IID_ISOSDacInterface11; #endif /* C style interface */ +#endif /* __ISOSDacInterface11_INTERFACE_DEFINED__ */ + +#ifndef __ISOSDacInterface12_INTERFACE_DEFINED__ +#define __ISOSDacInterface12_INTERFACE_DEFINED__ +/* interface ISOSDacInterface12 */ +/* [uuid][local][object] */ -#endif /* __ISOSDacInterface11_INTERFACE_DEFINED__ */ +EXTERN_C const IID IID_ISOSDacInterface12; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("1b93bacc-8ca4-432d-943a-3e6e7ec0b0a3") + ISOSDacInterface12 : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE GetGlobalAllocationContext( + CLRDATA_ADDRESS *allocPtr, + CLRDATA_ADDRESS *allocLimit) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ISOSDacInterface12Vtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ISOSDacInterface12 * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ISOSDacInterface12 * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ISOSDacInterface12 * This); + + HRESULT ( STDMETHODCALLTYPE *GetGlobalAllocationContext )( + ISOSDacInterface12 * This, + CLRDATA_ADDRESS *allocPtr, + CLRDATA_ADDRESS *allocLimit); + + END_INTERFACE + } ISOSDacInterface12Vtbl; + + interface ISOSDacInterface12 + { + CONST_VTBL struct ISOSDacInterface12Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ISOSDacInterface12_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ISOSDacInterface12_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ISOSDacInterface12_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ISOSDacInterface12_GetGlobalAllocationContext(This,allocPtr,allocLimit) \ + ( (This)->lpVtbl -> GetGlobalAllocationContext(This,allocPtr,allocLimit) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ISOSDacInterface12_INTERFACE_DEFINED__ */ /* Additional Prototypes for ALL interfaces */