diff options
Diffstat (limited to 'src/debug/di')
-rw-r--r-- | src/debug/di/breakpoint.cpp | 2 | ||||
-rw-r--r-- | src/debug/di/module.cpp | 377 | ||||
-rw-r--r-- | src/debug/di/process.cpp | 14 | ||||
-rw-r--r-- | src/debug/di/rsenumerator.hpp | 6 | ||||
-rw-r--r-- | src/debug/di/rsmain.cpp | 2 | ||||
-rw-r--r-- | src/debug/di/rspriv.h | 86 | ||||
-rw-r--r-- | src/debug/di/rspriv.inl | 2 | ||||
-rw-r--r-- | src/debug/di/rsthread.cpp | 11 | ||||
-rw-r--r-- | src/debug/di/rstype.cpp | 122 |
9 files changed, 600 insertions, 22 deletions
diff --git a/src/debug/di/breakpoint.cpp b/src/debug/di/breakpoint.cpp index 1e381a5f83..e3e4fb04a5 100644 --- a/src/debug/di/breakpoint.cpp +++ b/src/debug/di/breakpoint.cpp @@ -15,7 +15,7 @@ CordbBreakpoint::CordbBreakpoint(CordbProcess * pProcess, CordbBreakpointType bpType) : CordbBase(pProcess, 0, enumCordbBreakpoint), - m_active(false), m_type(bpType) + m_active(false), m_pAppDomain(NULL), m_type(bpType) { } diff --git a/src/debug/di/module.cpp b/src/debug/di/module.cpp index 6717e8575f..36cc6f5f9e 100644 --- a/src/debug/di/module.cpp +++ b/src/debug/di/module.cpp @@ -3755,7 +3755,269 @@ HRESULT FindNativeInfoInILVariableArray(DWORD return CORDBG_E_IL_VAR_NOT_AVAILABLE; } // FindNativeInfoInILVariableArray -//* ------------------------------------------------------------------------- * + +// * ------------------------------------------------------------------------- * +// * Variable Enum class +// * ------------------------------------------------------------------------- * +//----------------------------------------------------------------------------- +// CordbVariableHome constructor +// Arguments: +// Input: +// pCode - CordbNativeCode instance containing this variable home +// pNativeVarInfo - native location, lifetime, and index information for +// this variable +// isLocal - indicates whether the instance is a local variable, +// as opposed to an argument +// index - the argument or slot index +// Output: +// fields of the CordbVariableHome instance have been initialized +//----------------------------------------------------------------------------- +CordbVariableHome::CordbVariableHome(CordbNativeCode *pCode, + const ICorDebugInfo::NativeVarInfo nativeVarInfo, + BOOL isLocal, + ULONG index) : + CordbBase(pCode->GetModule()->GetProcess(), 0) +{ + _ASSERTE(pCode != NULL); + + m_pCode.Assign(pCode); + m_nativeVarInfo = nativeVarInfo; + m_isLocal = isLocal; + m_index = index; +} + +CordbVariableHome::~CordbVariableHome() +{ + _ASSERTE(this->IsNeutered()); +} + +void CordbVariableHome::Neuter() +{ + m_pCode.Clear(); + CordbBase::Neuter(); +} + +//----------------------------------------------------------------------------- +// Public method for IUnknown::QueryInterface. +// Has standard QI semantics. +//----------------------------------------------------------------------------- +HRESULT CordbVariableHome::QueryInterface(REFIID id, void **pInterface) +{ + if (id == IID_ICorDebugVariableHome) + { + *pInterface = static_cast<ICorDebugVariableHome *>(this); + } + else if (id == IID_IUnknown) + { + *pInterface = static_cast<IUnknown *>(static_cast<ICorDebugVariableHome *>(this)); + } + else + { + *pInterface = NULL; + return E_NOINTERFACE; + } + + ExternalAddRef(); + return S_OK; +} + +//----------------------------------------------------------------------------- +// CordbVariableHome::GetCode +// Public method to get the Code object containing this variable home. +// +// Parameters: +// ppCode - OUT: returns the Code object for this variable home. +// +// Returns: +// S_OK - on success. +//----------------------------------------------------------------------------- +HRESULT CordbVariableHome::GetCode(ICorDebugCode **ppCode) +{ + PUBLIC_REENTRANT_API_ENTRY(this); + FAIL_IF_NEUTERED(this); + VALIDATE_POINTER_TO_OBJECT(ppCode, ICorDebugCode **); + ATT_REQUIRE_STOPPED_MAY_FAIL(m_pCode->GetProcess()); + + HRESULT hr = m_pCode->QueryInterface(IID_ICorDebugCode, (LPVOID*)ppCode); + + return hr; +} + +//----------------------------------------------------------------------------- +// CordbVariableHome::GetSlotIndex +// Public method to get the slot index for this variable home. +// +// Parameters: +// pSlotIndex - OUT: returns the managed slot-index of this variable home. +// +// Returns: +// S_OK - on success +// E_FAIL - if the variable is not a local variable, but an argument +//----------------------------------------------------------------------------- +HRESULT CordbVariableHome::GetSlotIndex(ULONG32 *pSlotIndex) +{ + PUBLIC_REENTRANT_API_ENTRY(this); + FAIL_IF_NEUTERED(this); + VALIDATE_POINTER_TO_OBJECT(pSlotIndex, ULONG32 *); + ATT_REQUIRE_STOPPED_MAY_FAIL(m_pCode->GetProcess()); + + if (!m_isLocal) + { + return E_FAIL; + } + *pSlotIndex = m_index; + return S_OK; +} + +//----------------------------------------------------------------------------- +// CordbVariableHome::GetArgumentIndex +// Public method to get the slot index for this variable home. +// +// Parameters: +// pSlotIndex - OUT: returns the managed argument-index of this variable home. +// +// Returns: +// S_OK - on success +// E_FAIL - if the variable is not an argument, but a local variable +//----------------------------------------------------------------------------- +HRESULT CordbVariableHome::GetArgumentIndex(ULONG32 *pArgumentIndex) +{ + PUBLIC_REENTRANT_API_ENTRY(this); + FAIL_IF_NEUTERED(this); + VALIDATE_POINTER_TO_OBJECT(pArgumentIndex, ULONG32 *); + ATT_REQUIRE_STOPPED_MAY_FAIL(m_pCode->GetProcess()); + + if (m_isLocal) + { + return E_FAIL; + } + *pArgumentIndex = m_index; + return S_OK; +} + +//----------------------------------------------------------------------------- +// CordbVariableHome::GetLiveRange +// Public method to get the native range over which this variable is live. +// +// Parameters: +// pStartOffset - OUT: returns the logical offset at which the variable is +// first live +// pEndOffset - OUT: returns the logical offset immediately after that at +// which the variable is last live +// +// Returns: +// S_OK - on success +//----------------------------------------------------------------------------- +HRESULT CordbVariableHome::GetLiveRange(ULONG32 *pStartOffset, + ULONG32 *pEndOffset) +{ + PUBLIC_REENTRANT_API_ENTRY(this); + FAIL_IF_NEUTERED(this); + VALIDATE_POINTER_TO_OBJECT(pStartOffset, ULONG32 *); + VALIDATE_POINTER_TO_OBJECT(pEndOffset, ULONG32 *); + ATT_REQUIRE_STOPPED_MAY_FAIL(m_pCode->GetProcess()); + + *pStartOffset = m_nativeVarInfo.startOffset; + *pEndOffset = m_nativeVarInfo.endOffset; + return S_OK; +} + +//----------------------------------------------------------------------------- +// CordbVariableHome::GetLocationType +// Public method to get the type of native location for this variable home. +// +// Parameters: +// pLocationType - OUT: the type of native location +// +// Returns: +// S_OK - on success +//----------------------------------------------------------------------------- +HRESULT CordbVariableHome::GetLocationType(VariableLocationType *pLocationType) +{ + PUBLIC_REENTRANT_API_ENTRY(this); + FAIL_IF_NEUTERED(this); + VALIDATE_POINTER_TO_OBJECT(pLocationType, VariableLocationType *); + ATT_REQUIRE_STOPPED_MAY_FAIL(m_pCode->GetProcess()); + + switch (m_nativeVarInfo.loc.vlType) + { + case ICorDebugInfo::VLT_REG: + *pLocationType = VLT_REGISTER; + break; + case ICorDebugInfo::VLT_STK: + *pLocationType = VLT_REGISTER_RELATIVE; + break; + default: + *pLocationType = VLT_INVALID; + } + return S_OK; +} + +//----------------------------------------------------------------------------- +// CordbVariableHome::GetRegister +// Public method to get the register or base register for this variable hom. +// +// Parameters: +// pRegister - OUT: for VLT_REGISTER location types, gives the register. +// for VLT_REGISTER_RELATIVE location types, gives the base +// register. +// +// Returns: +// S_OK - on success +// E_FAIL - for VLT_INVALID location types +//----------------------------------------------------------------------------- +HRESULT CordbVariableHome::GetRegister(CorDebugRegister *pRegister) +{ + PUBLIC_REENTRANT_API_ENTRY(this); + FAIL_IF_NEUTERED(this); + VALIDATE_POINTER_TO_OBJECT(pRegister, CorDebugRegister *); + ATT_REQUIRE_STOPPED_MAY_FAIL(m_pCode->GetProcess()); + + switch (m_nativeVarInfo.loc.vlType) + { + case ICorDebugInfo::VLT_REG: + *pRegister = ConvertRegNumToCorDebugRegister(m_nativeVarInfo.loc.vlReg.vlrReg); + break; + case ICorDebugInfo::VLT_STK: + *pRegister = ConvertRegNumToCorDebugRegister(m_nativeVarInfo.loc.vlStk.vlsBaseReg); + break; + default: + return E_FAIL; + } + return S_OK; +} + +//----------------------------------------------------------------------------- +// CordbVariableHome::GetOffset +// Public method to get the offset from the base register for this variable home. +// +// Parameters: +// pOffset - OUT: gives the offset from the base register +// +// Returns: +// S_OK - on success +// E_FAIL - for location types other than VLT_REGISTER_RELATIVE +//----------------------------------------------------------------------------- +HRESULT CordbVariableHome::GetOffset(LONG *pOffset) +{ + PUBLIC_REENTRANT_API_ENTRY(this); + FAIL_IF_NEUTERED(this); + VALIDATE_POINTER_TO_OBJECT(pOffset, LONG *); + ATT_REQUIRE_STOPPED_MAY_FAIL(m_pCode->GetProcess()); + + switch (m_nativeVarInfo.loc.vlType) + { + case ICorDebugInfo::VLT_STK: + *pOffset = m_nativeVarInfo.loc.vlStk.vlsOffset; + break; + default: + return E_FAIL; + } + return S_OK; +} + + +// * ------------------------------------------------------------------------- * // * Native Code class // * ------------------------------------------------------------------------- */ @@ -3780,7 +4042,7 @@ CordbNativeCode::CordbNativeCode(CordbFunction * pFunction, m_fIsInstantiatedGeneric(fIsInstantiatedGeneric != FALSE) { _ASSERTE(GetVersion() >= CorDB_DEFAULT_ENC_FUNCTION_VERSION); - + for (CodeBlobRegion region = kHot; region < MAX_REGIONS; ++region) { m_rgCodeRegions[region] = pJitData->m_rgCodeRegions[region]; @@ -3805,6 +4067,10 @@ HRESULT CordbNativeCode::QueryInterface(REFIID id, void ** pInterface) { *pInterface = static_cast<ICorDebugCode3 *>(this); } + else if (id == IID_ICorDebugCode4) + { + *pInterface = static_cast<ICorDebugCode4 *>(this); + } else if (id == IID_IUnknown) { *pInterface = static_cast<IUnknown *>(static_cast<ICorDebugCode *>(this)); @@ -4111,6 +4377,113 @@ HRESULT CordbNativeCode::GetReturnValueLiveOffset(ULONG32 ILoffset, ULONG32 buff return hr; } +//----------------------------------------------------------------------------- +// CordbNativeCode::EnumerateVariableHomes +// Public method to get an enumeration of native variable homes. This may +// include multiple ICorDebugVariableHomes for the same slot or argument index +// if they have different homes at different points in the function. +// +// Parameters: +// ppEnum - OUT: returns the enum of variable homes. +// +// Returns: +// HRESULT for success or failure. +//----------------------------------------------------------------------------- +HRESULT CordbNativeCode::EnumerateVariableHomes(ICorDebugVariableHomeEnum **ppEnum) +{ + PUBLIC_REENTRANT_API_ENTRY(this); + FAIL_IF_NEUTERED(this); + VALIDATE_POINTER_TO_OBJECT(ppEnum, ICorDebugVariableHomeEnum **); + ATT_REQUIRE_STOPPED_MAY_FAIL(GetProcess()); + + HRESULT hr = S_OK; + + // Get the argument count + ULONG argCount = 0; + CordbFunction *func = GetFunction(); + _ASSERTE(func != NULL); + IfFailRet(func->GetSig(NULL, &argCount, NULL)); + +#ifdef _DEBUG + // Get the number of locals + ULONG localCount = 0; + EX_TRY + { + GetFunction()->GetILCode()->GetLocalVarSig(NULL, &localCount); + } + EX_CATCH_HRESULT(hr); + IfFailRet(hr); +#endif + + RSSmartPtr<CordbVariableHome> *rsHomes = NULL; + + EX_TRY + { + CordbProcess *pProcess = GetProcess(); + _ASSERTE(pProcess != NULL); + + const DacDbiArrayList<ICorDebugInfo::NativeVarInfo> *pOffsetInfoList = m_nativeVarData.GetOffsetInfoList(); + _ASSERTE(pOffsetInfoList != NULL); + DWORD countHomes = 0; + for (int i = 0; i < pOffsetInfoList->Count(); i++) + { + const ICorDebugInfo::NativeVarInfo *pNativeVarInfo = &((*pOffsetInfoList)[i]); + _ASSERTE(pNativeVarInfo != NULL); + + // The variable information list can include variables + // with special varNumbers representing, for instance, the + // parameter types for generic methods. Here we are only + // interested in local variables and arguments. + if (pNativeVarInfo->varNumber < (DWORD)ICorDebugInfo::MAX_ILNUM) + { + countHomes++; + } + } + rsHomes = new RSSmartPtr<CordbVariableHome>[countHomes]; + + DWORD varHomeInd = 0; + for (int i = 0; i < pOffsetInfoList->Count(); i++) + { + const ICorDebugInfo::NativeVarInfo *pNativeVarInfo = &((*pOffsetInfoList)[i]); + + // Again, only look for native var info representing local + // variables and arguments. + if (pNativeVarInfo->varNumber < (DWORD)ICorDebugInfo::MAX_ILNUM) + { + // determine whether this variable home represents and argument or local variable + BOOL isLocal = ((ULONG)pNativeVarInfo->varNumber >= argCount); + + // determine the argument-index or slot-index of this variable home + ULONG argOrSlotIndex; + if (isLocal) { + argOrSlotIndex = pNativeVarInfo->varNumber - argCount; + _ASSERTE(argOrSlotIndex < localCount); + } else { + argOrSlotIndex = pNativeVarInfo->varNumber; + } + + RSInitHolder<CordbVariableHome> pCVH(new CordbVariableHome(this, + (*pOffsetInfoList)[i], + isLocal, + argOrSlotIndex)); + pProcess->GetContinueNeuterList()->Add(pProcess, pCVH); + _ASSERTE(varHomeInd < countHomes); + rsHomes[varHomeInd].Assign(pCVH); + pCVH.ClearAndMarkDontNeuter(); + varHomeInd++; + } + } + + RSInitHolder<CordbVariableHomeEnumerator> pCDVHE( + new CordbVariableHomeEnumerator(GetProcess(), &rsHomes, countHomes)); + pProcess->GetContinueNeuterList()->Add(pProcess, pCDVHE); + pCDVHE.TransferOwnershipExternal(ppEnum); + } + EX_CATCH_HRESULT(hr); + + return hr; +} + int CordbNativeCode::GetCallInstructionLength(BYTE *ip, ULONG32 count) { #if defined(DBG_TARGET_ARM) diff --git a/src/debug/di/process.cpp b/src/debug/di/process.cpp index 44e4a0c667..a5496eee54 100644 --- a/src/debug/di/process.cpp +++ b/src/debug/di/process.cpp @@ -7334,6 +7334,7 @@ CordbUnmanagedThread *CordbProcess::HandleUnmanagedCreateThread(DWORD dwThreadId if (!SUCCEEDED(hr)) { delete ut; + ut = NULL; LOG((LF_CORDB, LL_INFO10000, "Failed adding unmanaged thread to process!\n")); CORDBSetUnrecoverableError(this, hr, 0); @@ -8119,7 +8120,9 @@ void CordbProcess::DispatchUnmanagedInBandEvent() break; // Get the thread for this event + _ASSERTE(pUnmanagedThread == NULL); pUnmanagedThread = pUnmanagedEvent->m_owner; + _ASSERTE(pUnmanagedThread != NULL); // We better not have dispatched it yet! _ASSERTE(!pUnmanagedEvent->IsDispatched()); @@ -8177,13 +8180,10 @@ void CordbProcess::DispatchUnmanagedInBandEvent() m_pShim->GetWin32EventThread()->DoDbgContinue(this, pUnmanagedEvent); // Release our reference to the unmanaged thread that we dispatched - if (pUnmanagedThread) - { - // This event should have been continued long ago... - _ASSERTE(!pUnmanagedThread->IBEvent()->IsEventWaitingForContinue()); - pUnmanagedThread->InternalRelease(); - pUnmanagedThread = NULL; - } + // This event should have been continued long ago... + _ASSERTE(!pUnmanagedThread->IBEvent()->IsEventWaitingForContinue()); + pUnmanagedThread->InternalRelease(); + pUnmanagedThread = NULL; } m_dispatchingUnmanagedEvent = false; diff --git a/src/debug/di/rsenumerator.hpp b/src/debug/di/rsenumerator.hpp index eb7a225a5d..84e6194c4d 100644 --- a/src/debug/di/rsenumerator.hpp +++ b/src/debug/di/rsenumerator.hpp @@ -99,8 +99,8 @@ CordbEnumerator<ElemType, ElemType **items, DWORD countItems) : CordbBase(pProcess, 0, enumCordbEnumerator), -m_nextIndex(0), -m_countItems(countItems) +m_countItems(countItems), +m_nextIndex(0) { _ASSERTE(items != NULL); m_items = *items; @@ -108,7 +108,7 @@ m_countItems(countItems) } // Destructor -template< typename ElemType, +template< typename ElemType, typename ElemPublicType, typename EnumInterfaceType, ElemPublicType (*GetPublicType)(ElemType)> diff --git a/src/debug/di/rsmain.cpp b/src/debug/di/rsmain.cpp index b5685750db..0f5778789f 100644 --- a/src/debug/di/rsmain.cpp +++ b/src/debug/di/rsmain.cpp @@ -40,6 +40,8 @@ RSDebuggingInfo g_RSDebuggingInfo_OutOfProc = {0 }; // set to NULL RSDebuggingInfo * g_pRSDebuggingInfo = &g_RSDebuggingInfo_OutOfProc; +// The following instances are used for invoking overloaded new/delete +forDbiWorker forDbi; #ifdef _DEBUG // For logs, we can print the string name for the debug codes. diff --git a/src/debug/di/rspriv.h b/src/debug/di/rspriv.h index 853767804a..18920add5d 100644 --- a/src/debug/di/rspriv.h +++ b/src/debug/di/rspriv.h @@ -85,6 +85,7 @@ class CordbJITILFrame; class CordbInternalFrame; class CordbContext; class CordbThread; +class CordbVariableHome; #ifdef FEATURE_INTEROP_DEBUGGING class CordbUnmanagedThread; @@ -176,7 +177,7 @@ private: USHORT m_usPort; }; -#define forDbi (*(forDbiWorker *)NULL) +extern forDbiWorker forDbi; // for dbi we just default to new, but we need to have these defined for both dac and dbi inline void * operator new(size_t lenBytes, const forDbiWorker &) @@ -1586,7 +1587,7 @@ template< typename ElemType, typename ElemPublicType, typename EnumInterfaceType, ElemPublicType (*GetPublicType)(ElemType)> -class CordbEnumerator : public CordbBase, EnumInterfaceType +class CordbEnumerator : public CordbBase, public EnumInterfaceType { private: // the list of items being enumerated over @@ -1680,6 +1681,11 @@ typedef CordbEnumerator<RsGuidToTypeMapping, ICorDebugGuidToTypeEnum, GuidToTypeMappingConvert > CordbGuidToTypeEnumerator; +typedef CordbEnumerator<RSSmartPtr<CordbVariableHome>, + ICorDebugVariableHome*, + ICorDebugVariableHomeEnum, + QueryInterfaceConvert<RSSmartPtr<CordbVariableHome>, ICorDebugVariableHome> > CordbVariableHomeEnumerator; + // ---------------------------------------------------------------------------- // Hash table for CordbBase objects. // - Uses Internal AddRef/Release (not external) @@ -2920,7 +2926,7 @@ class CordbProcess : public ICorDebugProcess4, public ICorDebugProcess5, public ICorDebugProcess7, - public ICorDebugProcess8, + public ICorDebugProcess8, public IDacDbiInterface::IAllocator, public IDacDbiInterface::IMetaDataLookup, public IProcessShimHooks @@ -4696,7 +4702,7 @@ public: // See definition of ICorDebugType for further invariants on types. // -class CordbType : public CordbBase, public ICorDebugType +class CordbType : public CordbBase, public ICorDebugType, public ICorDebugType2 { public: CordbType(CordbAppDomain *appdomain, CorElementType ty, unsigned int rank); @@ -4736,6 +4742,11 @@ public: COM_METHOD GetRank(ULONG32 *pnRank); //----------------------------------------------------------- + // ICorDebugType2 + //----------------------------------------------------------- + COM_METHOD GetTypeID(COR_TYPEID *pId); + + //----------------------------------------------------------- // Non-COM members //----------------------------------------------------------- @@ -5812,7 +5823,10 @@ private: * code, including an optional set of mappings from IL to offsets in the native Code. * ------------------------------------------------------------------------- */ -class CordbNativeCode : public CordbCode, public ICorDebugCode2, public ICorDebugCode3 +class CordbNativeCode : public CordbCode, + public ICorDebugCode2, + public ICorDebugCode3, + public ICorDebugCode4 { public: CordbNativeCode(CordbFunction * pFunction, @@ -5853,6 +5867,11 @@ public: //----------------------------------------------------------- + // ICorDebugCode4 + //----------------------------------------------------------- + COM_METHOD EnumerateVariableHomes(ICorDebugVariableHomeEnum **ppEnum); + + //----------------------------------------------------------- // Internal members //----------------------------------------------------------- @@ -8539,6 +8558,63 @@ private: typedef enum {kUnboxed, kBoxed} BoxedValue; #define EMPTY_BUFFER TargetBuffer(PTR_TO_CORDB_ADDRESS((void *)NULL), 0) +/* ------------------------------------------------------------------------- * + * Variable Home class + * ------------------------------------------------------------------------- */ +class CordbVariableHome : public CordbBase, public ICorDebugVariableHome +{ +public: + CordbVariableHome(CordbNativeCode *pCode, + const ICorDebugInfo::NativeVarInfo nativeVarInfo, + BOOL isLoc, + ULONG index); + ~CordbVariableHome(); + virtual void Neuter(); + +#ifdef _DEBUG + virtual const char * DbgGetName() { return "CordbVariableHome"; } +#endif + + //----------------------------------------------------------- + // IUnknown + //----------------------------------------------------------- + ULONG STDMETHODCALLTYPE AddRef() + { + return (BaseAddRef()); + } + ULONG STDMETHODCALLTYPE Release() + { + return (BaseRelease()); + } + + COM_METHOD QueryInterface(REFIID riid, void **ppInterface); + + //----------------------------------------------------------- + // ICorDebugVariableHome + //----------------------------------------------------------- + + COM_METHOD GetCode(ICorDebugCode **ppCode); + + COM_METHOD GetSlotIndex(ULONG32 *pSlotIndex); + + COM_METHOD GetArgumentIndex(ULONG32* pArgumentIndex); + + COM_METHOD GetLiveRange(ULONG32* pStartOffset, + ULONG32 *pEndOffset); + + COM_METHOD GetLocationType(VariableLocationType *pLocationType); + + COM_METHOD GetRegister(CorDebugRegister *pRegister); + + COM_METHOD GetOffset(LONG *pOffset); +private: + RSSmartPtr<CordbNativeCode> m_pCode; + ICorDebugInfo::NativeVarInfo m_nativeVarInfo; + BOOL m_isLocal; + ULONG m_index; +}; + + // for an inheritance graph of the ICDValue types, // See file:./ICorDebugValueTypes.vsd for a diagram of the types. /* ------------------------------------------------------------------------- * * Value class diff --git a/src/debug/di/rspriv.inl b/src/debug/di/rspriv.inl index 00e4c233b6..5de99c6284 100644 --- a/src/debug/di/rspriv.inl +++ b/src/debug/di/rspriv.inl @@ -162,7 +162,7 @@ void CordbProcess::ForceDacFlush() { if (m_pDacPrimitives != NULL) { - STRESS_LOG1(LF_CORDB, LL_INFO1000, "Flush() - old counter: %d", m_flushCounter); + STRESS_LOG1(LF_CORDB, LL_INFO1000, "Flush() - old counter: %d\n", m_flushCounter); m_flushCounter++; HRESULT hr = S_OK; EX_TRY diff --git a/src/debug/di/rsthread.cpp b/src/debug/di/rsthread.cpp index ae9b43cd01..a4660be570 100644 --- a/src/debug/di/rsthread.cpp +++ b/src/debug/di/rsthread.cpp @@ -1493,7 +1493,7 @@ void CordbThread::Get32bitFPRegisters(CONTEXT * pContext) for (i = 0; i <= floatStackTop; i++) { - long double td; + double td = 0.0; __asm fstp td // copy out the double m_floatValues[i] = td; } @@ -4585,7 +4585,7 @@ void CordbUnmanagedThread::SaveRaiseExceptionEntryContext() LOG((LF_CORDB, LL_INFO1000, "CP::SREEC: failed to read exception information pointer.\n")); return; } -#elif +#else _ASSERTE(!"Implement this for your platform"); return; #endif @@ -8935,8 +8935,13 @@ HRESULT CordbJITILFrame::GetReturnValueForILOffsetImpl(ULONG32 ILoffset, ICorDeb bool found = false; ULONG32 currentOffset = m_nativeFrame->GetIPOffset(); for (ULONG32 i = 0; i < count; ++i) - if ((found = currentOffset == offsets[i])) + { + if (currentOffset == offsets[i]) + { + found = true; break; + } + } if (!found) return E_UNEXPECTED; diff --git a/src/debug/di/rstype.cpp b/src/debug/di/rstype.cpp index b183fdf39e..e537613412 100644 --- a/src/debug/di/rstype.cpp +++ b/src/debug/di/rstype.cpp @@ -276,6 +276,8 @@ HRESULT CordbType::QueryInterface(REFIID id, void **pInterface) { if (id == IID_ICorDebugType) *pInterface = static_cast<ICorDebugType*>(this); + else if (id == IID_ICorDebugType2) + *pInterface = static_cast<ICorDebugType2*>(this); else if (id == IID_IUnknown) *pInterface = static_cast<IUnknown*>(static_cast<ICorDebugType*>(this)); else @@ -2280,6 +2282,126 @@ HRESULT CordbType::GetBase(ICorDebugType ** ppType) return hr; } +//----------------------------------------------------------------------------- +// CordbType::GetTypeID +// Method to get the COR_TYPEID corresponding to this CordbType. +// +// Parameters: +// pId - OUT: gives the COR_TYPEID for this CordbType +// +// Returns: +// S_OK if succeeded. +// CORDBG_E_CLASS_NOT_LOADED if the type which this CordbType represents has +// not been loaded in the runtime. +// E_POINTER if pId is NULL +// CORDBG_E_UNSUPPORTED for unsupported types. +// +HRESULT CordbType::GetTypeID(COR_TYPEID *pId) +{ + LOG((LF_CORDB, LL_INFO1000, "GetTypeID\n")); + if (pId == NULL) + return E_POINTER; + + HRESULT hr = S_OK; + + PUBLIC_API_ENTRY(this); + RSLockHolder stopGoLock(GetProcess()->GetStopGoLock()); + RSLockHolder procLock(GetProcess()->GetProcessLock()); + + EX_TRY + { + hr = Init(FALSE); + IfFailThrow(hr); + + VMPTR_TypeHandle vmTypeHandle; + + CorElementType et = GetElementType(); + switch (et) + { + case ELEMENT_TYPE_OBJECT: + case ELEMENT_TYPE_VOID: + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R4: + case ELEMENT_TYPE_R8: + case ELEMENT_TYPE_STRING: + case ELEMENT_TYPE_TYPEDBYREF: + case ELEMENT_TYPE_I: + case ELEMENT_TYPE_U: + { + mdTypeDef mdToken; + VMPTR_Module vmModule = VMPTR_Module::NullPtr(); + VMPTR_DomainFile vmDomainFile = VMPTR_DomainFile::NullPtr(); + + // get module and token of the simple type + GetProcess()->GetDAC()->GetSimpleType(GetAppDomain()->GetADToken(), + et, + &mdToken, + &vmModule, + &vmDomainFile); + + vmTypeHandle = GetProcess()->GetDAC()->GetTypeHandle(vmModule, mdToken); + } + break; + case ELEMENT_TYPE_ARRAY: + case ELEMENT_TYPE_SZARRAY: + { + LOG((LF_CORDB, LL_INFO1000, "GetTypeID: parameterized type\n")); + if (m_typeHandleExact.IsNull()) + { + hr = InitInstantiationTypeHandle(FALSE); + IfFailThrow(hr); + } + vmTypeHandle = m_typeHandleExact; + } + break; + case ELEMENT_TYPE_CLASS: + { + ICorDebugClass *pICDClass = NULL; + hr = GetClass(&pICDClass); + IfFailThrow(hr); + CordbClass *pClass = (CordbClass*)pICDClass; + _ASSERTE(pClass != NULL); + + if (pClass->HasTypeParams()) + { + vmTypeHandle = m_typeHandleExact; + } + else + { + mdTypeDef mdToken; + hr = pClass->GetToken(&mdToken); + IfFailThrow(hr); + + VMPTR_Module vmModule = GetModule(); + vmTypeHandle = GetProcess()->GetDAC()->GetTypeHandle(vmModule, mdToken); + } + } + break; + case ELEMENT_TYPE_PTR: + case ELEMENT_TYPE_BYREF: + case ELEMENT_TYPE_FNPTR: + IfFailThrow(CORDBG_E_UNSUPPORTED); + default: + _ASSERTE(!"unexpected element type!"); + IfFailThrow(CORDBG_E_UNSUPPORTED); + break; + } + + GetProcess()->GetDAC()->GetTypeIDForType(vmTypeHandle, pId); + } + EX_CATCH_HRESULT(hr); + + return hr; +} //----------------------------------------------------------------------------- // Get rich field information given a token. |