From d5d41105716703845d61a6f8c26724381b959c7d Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Thu, 20 Aug 2015 15:43:16 -0700 Subject: Enabled GCInfo, EEHeap, DumpRuntimeTypes and EHInfo SOS commands. Added some aliases for the most common commands: bpmd -> sos bpmd clrstack -> sos ClrStack clrthreads -> sos Threads dumpheap -> sos DumpHeap dumpobj -> sos DumpObj dso -> sos DumpStackObjects eeheap -> sos EEHeap gcroot -> sos GCRoot ip2md -> sos IP2MD printexception -> sos PrintException Updated the debugging documentation. Remove the "build.out" file unintentionally added. --- src/ToolBox/SOS/Strike/CMakeLists.txt | 50 ++++++++++++++------------ src/ToolBox/SOS/Strike/disasm.cpp | 50 +++++--------------------- src/ToolBox/SOS/Strike/disasm.h | 7 +++- src/ToolBox/SOS/Strike/disasmX86.cpp | 16 +++++++-- src/ToolBox/SOS/Strike/eeheap.cpp | 10 ++---- src/ToolBox/SOS/Strike/exts.h | 2 ++ src/ToolBox/SOS/Strike/sildasm.cpp | 46 ++++++++++++------------ src/ToolBox/SOS/Strike/strike.cpp | 24 ++++--------- src/ToolBox/SOS/Strike/util.cpp | 6 +--- src/ToolBox/SOS/lldbplugin/soscommand.cpp | 58 ++++++++++++++++++++----------- 10 files changed, 128 insertions(+), 141 deletions(-) (limited to 'src/ToolBox') diff --git a/src/ToolBox/SOS/Strike/CMakeLists.txt b/src/ToolBox/SOS/Strike/CMakeLists.txt index 3ab4072318..78ada3332f 100644 --- a/src/ToolBox/SOS/Strike/CMakeLists.txt +++ b/src/ToolBox/SOS/Strike/CMakeLists.txt @@ -19,11 +19,12 @@ add_definitions(-DSTRIKE) remove_definitions(-DUNICODE) remove_definitions(-D_UNICODE) +include_directories(BEFORE ${VM_DIR}) +include_directories(${CLR_DIR}/src/gcdump) +include_directories(${CLR_DIR}/src/debug/shim) + if(WIN32) - include_directories(inc) - include_directories(BEFORE ${VM_DIR}) - include_directories(${CLR_DIR}/src/gcdump) - include_directories(${CLR_DIR}/src/debug/shim) + include_directories("inc") include_directories("$ENV{VSInstallDir}/DIA SDK/include") add_definitions(-DUSE_STL) @@ -51,22 +52,6 @@ if(WIN32) Native.rc ) - if(CLR_CMAKE_PLATFORM_ARCH_AMD64) - set(SOS_SOURCES_ARCH - disasmX86.cpp - ) - elseif(CLR_CMAKE_PLATFORM_ARCH_I386) - set(SOS_SOURCES_ARCH - disasmX86.cpp - ) - elseif(CLR_CMAKE_PLATFORM_ARCH_ARM) - set(SOS_SOURCES_ARCH - disasmARM.cpp - ) - endif() - - list(APPEND SOS_SOURCES ${SOS_SOURCES_ARCH}) - add_definitions(-DFX_VER_INTERNALNAME_STR=SOS.dll) #Preprocess exports definition file @@ -91,13 +76,15 @@ if(WIN32) ntdll.lib ) else(WIN32) + if(NOT CLR_CMAKE_PLATFORM_ARCH_AMD64) + clr_unknown_arch() + endif() + add_definitions(-DPAL_STDCPP_COMPAT=1) add_compile_options(-Wno-null-arithmetic) add_compile_options(-Wno-format) - include_directories(../lldbplugin/inc) - include_directories(BEFORE ${VM_DIR}) - include_directories(${CLR_DIR}/src/debug/shim) + include_directories(BEFORE ../lldbplugin/inc) add_compile_options(-fPIC) @@ -108,6 +95,7 @@ else(WIN32) exts.cpp gcroot.cpp metadata.cpp + sildasm.cpp stressLogDump.cpp strike.cpp sos.cpp @@ -123,6 +111,22 @@ else(WIN32) ) endif(WIN32) +if(CLR_CMAKE_PLATFORM_ARCH_AMD64) + set(SOS_SOURCES_ARCH + disasmX86.cpp + ) +elseif(CLR_CMAKE_PLATFORM_ARCH_I386) + set(SOS_SOURCES_ARCH + disasmX86.cpp + ) +elseif(CLR_CMAKE_PLATFORM_ARCH_ARM) + set(SOS_SOURCES_ARCH + disasmARM.cpp + ) +endif() + +list(APPEND SOS_SOURCES ${SOS_SOURCES_ARCH}) + add_library(sos SHARED ${SOS_SOURCES}) add_dependencies(sos mscordaccore) target_link_libraries(sos ${SOS_LIBRARY}) diff --git a/src/ToolBox/SOS/Strike/disasm.cpp b/src/ToolBox/SOS/Strike/disasm.cpp index fa0463f72d..4adbd2cd75 100644 --- a/src/ToolBox/SOS/Strike/disasm.cpp +++ b/src/ToolBox/SOS/Strike/disasm.cpp @@ -434,7 +434,6 @@ void UnassemblyUnmanaged(DWORD_PTR IP, BOOL bSuppressLines) } - void DisasmAndClean (DWORD_PTR &IP, __out_ecount_opt(length) char *line, ULONG length) { ULONG64 vIP = TO_CDADDR(IP); @@ -444,9 +443,11 @@ void DisasmAndClean (DWORD_PTR &IP, __out_ecount_opt(length) char *line, ULONG l char *ptr = strrchr (line, '\n'); if (ptr != NULL) ptr[0] = '\0'; - } +#endif // FEATURE_PAL + + // If byref, move to pass the byref prefix BOOL IsByRef (__deref_inout_z char *& ptr) { @@ -584,8 +585,7 @@ INT_PTR GetValueFromExpr(__in_z char *ptr, INT_PTR &value) { char *endptr; value = ParseHexNumber(myPtr, &endptr); - if (!bByRef && IsTermSep (endptr[0]) - || bByRef && endptr[0] == ']') + if ((!bByRef && IsTermSep(endptr[0])) || (bByRef && endptr[0] == ']')) { if (bNegative) value = -value; @@ -710,7 +710,7 @@ LPCWSTR EHTypedClauseTypeName(___in const DACEHInfo* pEHInfo) _ASSERTE(pEHInfo != NULL); if ((pEHInfo->clauseType == EHTyped) && pEHInfo->isCatchAllHandler) { - return L"..."; + return W("..."); } // is there a method table or a token to look at? @@ -839,6 +839,7 @@ void SOSEHInfo::FormatForDisassembly(CLRDATA_ADDRESS offSet) // use the IS_DBG_TARGET_XYZ macro. // +#ifndef FEATURE_PAL // Return TRUE if we have printed something. BOOL PrintCallInfo (DWORD_PTR vEBP, DWORD_PTR IP, @@ -921,6 +922,7 @@ BOOL PrintCallInfo (DWORD_PTR vEBP, DWORD_PTR IP, ExtOut ("%s", Symbol); if (Displacement) ExtOut ("+%#x", Displacement); +#ifndef FEATURE_PAL if (!DSFlag.fSuppressSrcInfo) { ULONG line; @@ -929,6 +931,7 @@ BOOL PrintCallInfo (DWORD_PTR vEBP, DWORD_PTR IP, if (SUCCEEDED (hr)) ExtOut (" [%s:%d]", filename, line); } +#endif } else { @@ -1032,8 +1035,7 @@ void DumpStackWorker (DumpStackFlag &DSFlag) } } -#endif // !FEATURE_PAL - +#endif // FEATURE_PAL #ifdef SOS_TARGET_X86 /// @@ -1118,40 +1120,6 @@ void AMD64Machine::DumpGCInfo(BYTE* pTable, unsigned methodSize, printfFtn gcPri #endif // FEATURE_PAL } -#ifdef FEATURE_PAL -void AMD64Machine::Unassembly( - TADDR IPBegin, - TADDR IPEnd, - TADDR IPAskedFor, - TADDR GCStressCodeCopy, - GCEncodingInfo *pGCEncodingInfo, - SOSEHInfo *pEHInfo, - BOOL bSuppressLines, - BOOL bDisplayOffsets) const -{ - ExtErr("AMD64Machine::Unassembly not implemented\n"); -} - -void AMD64Machine::IsReturnAddress( - TADDR retAddr, - TADDR* whereCalled) const -{ - ExtErr("AMD64Machine::IsReturnAddress not implemented\n"); -} - -BOOL AMD64Machine::GetExceptionContext( - TADDR stack, - TADDR PC, - TADDR *cxrAddr, - CROSS_PLATFORM_CONTEXT * cxr, - TADDR *exrAddr, - PEXCEPTION_RECORD exr) const -{ - ExtErr("AMD64Machine::GetExceptionContext not implemented\n"); - return FALSE; -} -#endif // FEATURE_PAL - #endif // SOS_TARGET_AMD64 #ifdef SOS_TARGET_ARM64 diff --git a/src/ToolBox/SOS/Strike/disasm.h b/src/ToolBox/SOS/Strike/disasm.h index c5aa1323e0..5883e36cef 100644 --- a/src/ToolBox/SOS/Strike/disasm.h +++ b/src/ToolBox/SOS/Strike/disasm.h @@ -70,6 +70,8 @@ struct SOSEHInfo BOOL IsClonedFinally(DACEHInfo *pEHInfo); +#ifndef FEATURE_PAL + void DumpStackWorker (DumpStackFlag &DSFlag); void UnassemblyUnmanaged (DWORD_PTR IP, BOOL bSuppressLines); @@ -95,13 +97,14 @@ enum eTargetType { ettUnk = 0, ettNative = 1, ettJitHelp = 2, ettStub = 3, ettMD // This is currently only called on x64 eTargetType GetFinalTarget(DWORD_PTR callee, DWORD_PTR* finalMDorIP); +#endif // FEATURE_PAL + #ifdef _MSC_VER // SOS is essentially single-threaded. ignore "construction of local static object is not thread-safe" #pragma warning(push) #pragma warning(disable:4640) #endif // _MSC_VER - //----------------------------------------------------------------------------------------- // // Implementations for the supported target platforms @@ -256,6 +259,7 @@ public: ULONG GetPlatform() const { return IMAGE_FILE_MACHINE_AMD64; } ULONG GetContextSize() const { return sizeof(AMD64_CONTEXT); } +#ifndef FEATURE_PAL virtual void Unassembly( TADDR IPBegin, TADDR IPEnd, @@ -265,6 +269,7 @@ public: SOSEHInfo *pEHInfo, BOOL bSuppressLines, BOOL bDisplayOffsets) const; +#endif virtual void IsReturnAddress( TADDR retAddr, TADDR* whereCalled) const; diff --git a/src/ToolBox/SOS/Strike/disasmX86.cpp b/src/ToolBox/SOS/Strike/disasmX86.cpp index 0cdd8a23fa..d3b2e7681c 100644 --- a/src/ToolBox/SOS/Strike/disasmX86.cpp +++ b/src/ToolBox/SOS/Strike/disasmX86.cpp @@ -168,6 +168,8 @@ inline RegIndex FindReg (___in __in_z char *ptr, __out_opt int *plen = NULL, __o return NONE; } +#ifndef FEATURE_PAL + // Find the value of an expression. inline BOOL FindSrc (__in_z char *ptr, ___in Register *reg, INT_PTR &value, BOOL &bDigit) { @@ -335,7 +337,6 @@ void DecodeAddressTerm (___in __in_z char *term, InstData& arg) } } - // Return 0 for non-managed call. Otherwise return MD address. TADDR MDForCall (TADDR callee) { @@ -754,6 +755,8 @@ void } } +#endif // FEATURE_PAL + // Find the real callee site. Handle JMP instruction. // Return TRUE if we get the address, FALSE if not. @@ -807,7 +810,7 @@ BOOL GetCalleeSite (TADDR IP, TADDR &IPCallee) } } - +#ifndef FEATURE_PAL // GetFinalTarget is based on HandleCall, but avoids printing anything to the output. // This is currently only called on x64 @@ -864,6 +867,7 @@ eTargetType GetFinalTarget(TADDR callee, TADDR* finalMDorIP) return ettNative; } + void ExpFuncStateInit (TADDR *IPRetAddr) { ULONG64 offset; @@ -904,6 +908,8 @@ void ExpFuncStateInit (TADDR *IPRetAddr) } } +#endif // FEATURE_PAL + /**********************************************************************\ * Routine Description: * * * @@ -925,6 +931,7 @@ BOOL TADDR * exrAddr, PEXCEPTION_RECORD exr) const { +#ifndef FEATURE_PAL #ifdef SOS_TARGET_X86 X86_CONTEXT * cxr = &pcxr->X86Context; size_t contextSize = offsetof(CONTEXT, ExtendedRegisters); @@ -1006,8 +1013,11 @@ BOOL } #endif - return TRUE; +#else + ExtErr("AMD64Machine::GetExceptionContext not implemented\n"); + return FALSE; +#endif // FEATURE_PAL } diff --git a/src/ToolBox/SOS/Strike/eeheap.cpp b/src/ToolBox/SOS/Strike/eeheap.cpp index e0ca39cbd7..4b4fa1716e 100644 --- a/src/ToolBox/SOS/Strike/eeheap.cpp +++ b/src/ToolBox/SOS/Strike/eeheap.cpp @@ -434,8 +434,6 @@ size_t AlignLarge(size_t nbytes) return (nbytes + ALIGNCONSTLARGE) & ~ALIGNCONSTLARGE; } -#ifndef FEATURE_PAL - /**********************************************************************\ * Routine Description: * * * @@ -851,8 +849,6 @@ BOOL GCHeapUsageStats(const DacpGcHeapDetails& heap, BOOL bIncUnreachable, HeapU return TRUE; } -#endif // FEATURE_PAL - DWORD GetNumComponents(TADDR obj) { // The number of components is always the second pointer in the object. @@ -1576,7 +1572,6 @@ int GCHeapSnapshot::GetGeneration(CLRDATA_ADDRESS objectPointer) return 2; } -#ifndef FEATURE_PAL DWORD_PTR g_trav_totalSize = 0; DWORD_PTR g_trav_wastedSize = 0; @@ -1721,6 +1716,7 @@ DWORD_PTR JitHeapInfo() return totalSize; } + /**********************************************************************\ * Routine Description: * * * @@ -1914,6 +1910,4 @@ DWORD_PTR PrintModuleHeapInfo(__out_ecount(count) DWORD_PTR *moduleList, int cou *outWasted += wasted; return toReturn; -} - -#endif // !FEATURE_PAL \ No newline at end of file +} \ No newline at end of file diff --git a/src/ToolBox/SOS/Strike/exts.h b/src/ToolBox/SOS/Strike/exts.h index 73125ba666..ff9d4b2621 100644 --- a/src/ToolBox/SOS/Strike/exts.h +++ b/src/ToolBox/SOS/Strike/exts.h @@ -315,6 +315,7 @@ public: // Returns the size of the CONTEXT for the target machine virtual ULONG GetContextSize() const = 0; +#ifndef FEATURE_PAL // Disassembles a managed method specified by the IPBegin-IPEnd range virtual void Unassembly( TADDR IPBegin, @@ -325,6 +326,7 @@ public: SOSEHInfo *pEHInfo, BOOL bSuppressLines, BOOL bDisplayOffsets) const = 0; +#endif // Validates whether retAddr represents a return address by unassembling backwards. // If the instruction before retAddr represents a target-specific call instruction diff --git a/src/ToolBox/SOS/Strike/sildasm.cpp b/src/ToolBox/SOS/Strike/sildasm.cpp index ff71833bbc..6875436616 100644 --- a/src/ToolBox/SOS/Strike/sildasm.cpp +++ b/src/ToolBox/SOS/Strike/sildasm.cpp @@ -106,7 +106,7 @@ void DisassembleToken(IMetaDataImport *i, hr = i->GetTypeDefProps(token, szName, 49, &cLen, NULL, NULL); if (FAILED(hr)) - StringCchCopyW(szName, COUNTOF(szName), L""); + StringCchCopyW(szName, COUNTOF(szName), W("")); printf("%S", szName); } @@ -120,7 +120,7 @@ void DisassembleToken(IMetaDataImport *i, hr = i->GetTypeRefProps(token, NULL, szName, 49, &cLen); if (FAILED(hr)) - StringCchCopyW(szName, COUNTOF(szName), L""); + StringCchCopyW(szName, COUNTOF(szName), W("")); printf("%S", szName); } @@ -137,13 +137,13 @@ void DisassembleToken(IMetaDataImport *i, NULL, NULL, NULL, NULL, NULL, NULL); if (FAILED(hr)) - StringCchCopyW(szFieldName, COUNTOF(szFieldName), L""); + StringCchCopyW(szFieldName, COUNTOF(szFieldName), W("")); hr = i->GetTypeDefProps(mdClass, szClassName, 49, &cLen, NULL, NULL); if (FAILED(hr)) - StringCchCopyW(szClassName, COUNTOF(szClassName), L""); + StringCchCopyW(szClassName, COUNTOF(szClassName), W("")); printf("%S::%S", szClassName, szFieldName); } @@ -160,13 +160,13 @@ void DisassembleToken(IMetaDataImport *i, NULL, NULL, NULL, NULL, NULL); if (FAILED(hr)) - StringCchCopyW(szFieldName, COUNTOF(szFieldName), L""); + StringCchCopyW(szFieldName, COUNTOF(szFieldName), W("")); hr = i->GetTypeDefProps(mdClass, szClassName, 49, &cLen, NULL, NULL); if (FAILED(hr)) - StringCchCopyW(szClassName, COUNTOF(szClassName), L""); + StringCchCopyW(szClassName, COUNTOF(szClassName), W("")); printf("%S::%S", szClassName, szFieldName); } @@ -175,7 +175,7 @@ void DisassembleToken(IMetaDataImport *i, case mdtMemberRef: { mdTypeRef cr = mdTypeRefNil; - LPWSTR pMemberName; + LPCWSTR pMemberName; WCHAR memberName[50]; ULONG memberNameLen; @@ -184,7 +184,7 @@ void DisassembleToken(IMetaDataImport *i, if (FAILED(hr)) { - pMemberName = L""; + pMemberName = W(""); } else pMemberName = memberName; @@ -196,7 +196,7 @@ void DisassembleToken(IMetaDataImport *i, { if (FAILED(i->GetTypeRefProps(cr, NULL, szName, 50, &cLen))) { - StringCchCopyW(szName, COUNTOF(szName), L""); + StringCchCopyW(szName, COUNTOF(szName), W("")); } } else if(TypeFromToken(cr) == mdtTypeDef) @@ -204,7 +204,7 @@ void DisassembleToken(IMetaDataImport *i, if (FAILED(i->GetTypeDefProps(cr, szName, 49, &cLen, NULL, NULL))) { - StringCchCopyW(szName, COUNTOF(szName), L""); + StringCchCopyW(szName, COUNTOF(szName), W("")); } } else if(TypeFromToken(cr) == mdtTypeSpec) @@ -217,7 +217,7 @@ void DisassembleToken(IMetaDataImport *i, PCCOR_SIGNATURE sig; if (FAILED(pIMDI->GetSigFromToken(cr, &cSig, &sig))) { - StringCchCopyW(szName, COUNTOF(szName), L""); + StringCchCopyW(szName, COUNTOF(szName), W("")); } else { @@ -229,12 +229,12 @@ void DisassembleToken(IMetaDataImport *i, } else { - StringCchCopyW(szName, COUNTOF(szName), L""); + StringCchCopyW(szName, COUNTOF(szName), W("")); } } else { - StringCchCopyW(szName, COUNTOF(szName), L""); + StringCchCopyW(szName, COUNTOF(szName), W("")); } printf("%S::%S ", szName, pMemberName); @@ -395,7 +395,7 @@ void DecodeIL(IMetaDataImport *pImport, BYTE *buffer, ULONG bufSize) { if (numChars < 80) str[numChars] = 0; - wcscpy_s(&str[79], 4, L"..."); + wcscpy_s(&str[79], 4, W("...")); WCHAR* ptr = str; while(*ptr != 0) { if (*ptr < 0x20 || * ptr >= 0x80) { @@ -475,7 +475,7 @@ void DisassembleToken(DacpObjectData& tokenArray, DWORD_PTR runtimeType = NULL; MOVE(runtimeType, runtimeTypeHandle + sizeof(DWORD_PTR)); - int offset = GetObjFieldOffset(runtimeType, L"m_handle"); + int offset = GetObjFieldOffset(runtimeType, W("m_handle")); DWORD_PTR methodTable = NULL; MOVE(methodTable, runtimeType + offset); @@ -507,12 +507,12 @@ void DisassembleToken(DacpObjectData& tokenArray, case mdtMethodDef: { CLRDATA_ADDRESS runtimeMethodHandle = GetObj(tokenArray, RidFromToken(token)); - int offset = GetObjFieldOffset(runtimeMethodHandle, L"m_value"); + int offset = GetObjFieldOffset(runtimeMethodHandle, W("m_value")); TADDR runtimeMethodInfo = NULL; MOVE(runtimeMethodInfo, runtimeMethodHandle+offset); - offset = GetObjFieldOffset(runtimeMethodInfo, L"m_handle"); + offset = GetObjFieldOffset(runtimeMethodInfo, W("m_handle")); TADDR methodDesc = NULL; MOVE(methodDesc, runtimeMethodInfo+offset); @@ -624,7 +624,7 @@ void DecodeDynamicIL(BYTE *data, ULONG Size, DacpObjectData& tokenArray) /******************************************************************************/ // CQuickBytes utilities -char* asString(CQuickBytes *out) { +static char* asString(CQuickBytes *out) { SIZE_T oldSize = out->Size(); out->ReSize(oldSize + 1); char* cur = &((char*) out->Ptr())[oldSize]; @@ -633,7 +633,7 @@ char* asString(CQuickBytes *out) { return((char*) out->Ptr()); } -void appendStr(CQuickBytes *out, const char* str, unsigned len=-1) { +static void appendStr(CQuickBytes *out, const char* str, unsigned len=-1) { if(len == (unsigned)(-1)) len = (unsigned)strlen(str); SIZE_T oldSize = out->Size(); out->ReSize(oldSize + len); @@ -642,14 +642,14 @@ void appendStr(CQuickBytes *out, const char* str, unsigned len=-1) { // Note no trailing null! } -void appendChar(CQuickBytes *out, char chr) { +static void appendChar(CQuickBytes *out, char chr) { SIZE_T oldSize = out->Size(); out->ReSize(oldSize + 1); ((char*) out->Ptr())[oldSize] = chr; // Note no trailing null! } -void insertStr(CQuickBytes *out, const char* str) { +static void insertStr(CQuickBytes *out, const char* str) { unsigned len = (unsigned)strlen(str); SIZE_T oldSize = out->Size(); out->ReSize(oldSize + len); @@ -924,7 +924,7 @@ const char* PrettyPrintClass( if (TypeFromToken(tk) == mdtTypeRef) { - if ((formatFlags & FormatAssembly) && FAILED(pIMDI->GetResolutionScopeOfTypeRef(tk, &tkEncloser)) || + if (((formatFlags & FormatAssembly) && FAILED(pIMDI->GetResolutionScopeOfTypeRef(tk, &tkEncloser))) || FAILED(pIMDI->GetNameOfTypeRef(tk, &nameSpace, &name))) { char str[1024]; @@ -1073,7 +1073,7 @@ void PrettyPrintClassFromToken( DWORD formatFlags /*= FormatCSharp*/) { // set the default value - swprintf_s(mdName, cbName, L"token_0x%8.8X", tok); + swprintf_s(mdName, cbName, W("token_0x%8.8X"), tok); DacpModuleData dmd; if (dmd.Request(g_sos, TO_CDADDR(moduleAddr)) != S_OK) diff --git a/src/ToolBox/SOS/Strike/strike.cpp b/src/ToolBox/SOS/Strike/strike.cpp index dd1dd805ba..bb7e027201 100644 --- a/src/ToolBox/SOS/Strike/strike.cpp +++ b/src/ToolBox/SOS/Strike/strike.cpp @@ -616,7 +616,6 @@ HRESULT DumpStackObjectsRaw(size_t nArg, __in_z LPSTR exprBottom, __in_z LPSTR e return E_FAIL; } -#ifndef FEATURE_PAL // We can use the gc snapshot to eliminate object addresses that are // not on the gc heap. if (!g_snapshot.Build()) @@ -624,7 +623,6 @@ HRESULT DumpStackObjectsRaw(size_t nArg, __in_z LPSTR exprBottom, __in_z LPSTR e ExtOut("Unable to determine bounds of gc heap\n"); return E_FAIL; } -#endif // !FEATURE_PAL // Print thread ID. ULONG id = 0; @@ -3186,8 +3184,6 @@ void DisplayInvalidStructuresMessage() ExtOut("consistency errors.\n"); } -#ifndef FEATURE_PAL - /**********************************************************************\ * Routine Description: * * * @@ -3399,6 +3395,8 @@ void PrintGCStat(HeapStat *inStat, const char* label=NULL) } } +#ifndef FEATURE_PAL + DECLARE_API(TraverseHeap) { INIT_API(); @@ -3476,6 +3474,8 @@ DECLARE_API(TraverseHeap) return Status; } +#endif // FEATURE_PAL + struct PrintRuntimeTypeArgs { DWORD_PTR mtOfRuntimeType; @@ -3599,8 +3599,6 @@ namespace sos }; } -#endif // FEATURE_PAL - class DumpHeapImpl { public: @@ -4324,8 +4322,6 @@ DECLARE_API(VerifyObj) INIT_API(); MINIDUMP_NOT_SUPPORTED(); -#ifndef FEATURE_PAL - TADDR taddrObj = 0; TADDR taddrMT; size_t objSize; @@ -4373,13 +4369,6 @@ Exit: } return Status; - -#else - - _ASSERTE(false); - return E_FAIL; - -#endif // FEATURE_PAL } void LNODisplayOutput(LPCWSTR tag, TADDR pMT, TADDR currentObj, size_t size) @@ -7656,6 +7645,8 @@ DECLARE_API(COMState) } #endif // FEATURE_COMINTEROP +#endif // FEATURE_PAL + BOOL traverseEh(UINT clauseIndex,UINT totalClauses,DACEHInfo *pEHInfo,LPVOID token) { size_t methodStart = (size_t) token; @@ -7733,7 +7724,6 @@ BOOL traverseEh(UINT clauseIndex,UINT totalClauses,DACEHInfo *pEHInfo,LPVOID tok return TRUE; } - DECLARE_API(EHInfo) { INIT_API(); @@ -7808,7 +7798,6 @@ DECLARE_API(EHInfo) return Status; } - /**********************************************************************\ * Routine Description: * * * @@ -8052,6 +8041,7 @@ BOOL gatherEh(UINT clauseIndex,UINT totalClauses,DACEHInfo *pEHInfo,LPVOID token return TRUE; } +#ifndef FEATURE_PAL /**********************************************************************\ * Routine Description: * diff --git a/src/ToolBox/SOS/Strike/util.cpp b/src/ToolBox/SOS/Strike/util.cpp index 8122f790f6..70e3688361 100644 --- a/src/ToolBox/SOS/Strike/util.cpp +++ b/src/ToolBox/SOS/Strike/util.cpp @@ -2451,11 +2451,9 @@ BOOL IsStringObject (size_t obj) void DumpStackObjectsOutput(const char *location, DWORD_PTR objAddr, BOOL verifyFields) { -#ifndef FEATURE_PAL // rule out pointers that are outside of the gc heap. if (g_snapshot.GetHeap(objAddr) == NULL) return; -#endif // FEATURE_PAL DacpObjectData objectData; if (objectData.Request(g_sos, TO_CDADDR(objAddr)) != S_OK) @@ -3535,9 +3533,6 @@ void ReloadSymbolWithLineInfo() #endif } - -#ifndef FEATURE_PAL - // Return 1 if the function is our stub // Return MethodDesc if the function is managed // Otherwise return 0 @@ -3587,6 +3582,7 @@ size_t FunctionType (size_t EIP) return (size_t) pMD; } +#ifndef FEATURE_PAL // // Gets version info for the CLR in the debuggee process. diff --git a/src/ToolBox/SOS/lldbplugin/soscommand.cpp b/src/ToolBox/SOS/lldbplugin/soscommand.cpp index 660295d456..e9a20565e6 100644 --- a/src/ToolBox/SOS/lldbplugin/soscommand.cpp +++ b/src/ToolBox/SOS/lldbplugin/soscommand.cpp @@ -10,11 +10,13 @@ class sosCommand : public lldb::SBCommandPluginInterface { + const char *m_command; void *m_sosHandle; public: - sosCommand() + sosCommand(const char *command) { + m_command = command; m_sosHandle = NULL; } @@ -24,37 +26,43 @@ public: lldb::SBCommandReturnObject &result) { DebugClient* client = new DebugClient(debugger, result); - if (arguments) - { - LoadSos(client); + LoadSos(client); - if (m_sosHandle) + if (m_sosHandle) + { + const char* sosCommand = m_command; + if (sosCommand == NULL) + { + if (arguments == NULL) { + goto exit; + } + sosCommand = *arguments++; + } + CommandFunc commandFunc = (CommandFunc)dlsym(m_sosHandle, sosCommand); + if (commandFunc) { - const char* sosCommand = *arguments++; - CommandFunc commandFunc = (CommandFunc)dlsym(m_sosHandle, sosCommand); - if (commandFunc) + std::string str; + if (arguments != NULL) { - std::string str; for (const char* arg = *arguments; arg; arg = *(++arguments)) { str.append(arg); str.append(" "); } - - const char* sosArgs = str.c_str(); - HRESULT hr = commandFunc(client, sosArgs); - if (hr != S_OK) - { - client->Output(DEBUG_OUTPUT_ERROR, "%s %s failed\n", sosCommand, sosArgs); - } } - else + const char* sosArgs = str.c_str(); + HRESULT hr = commandFunc(client, sosArgs); + if (hr != S_OK) { - client->Output(DEBUG_OUTPUT_ERROR, "SOS command '%s' not found %s\n", sosCommand, dlerror()); + client->Output(DEBUG_OUTPUT_ERROR, "%s %s failed\n", sosCommand, sosArgs); } } + else + { + client->Output(DEBUG_OUTPUT_ERROR, "SOS command '%s' not found %s\n", sosCommand, dlerror()); + } } - +exit: delete client; return result.Succeeded(); } @@ -112,6 +120,16 @@ bool sosCommandInitialize(lldb::SBDebugger debugger) { lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter(); - lldb::SBCommand command = interpreter.AddCommand("sos", new sosCommand(), "Various coreclr debugging commands. sos "); + interpreter.AddCommand("sos", new sosCommand(NULL), "Various coreclr debugging commands. sos "); + interpreter.AddCommand("bpmd", new sosCommand("bpmd"), "Creates a breakpoint at the specified managed method in the specified module."); + interpreter.AddCommand("clrstack", new sosCommand("ClrStack"), "Provides a stack trace of managed code only."); + interpreter.AddCommand("clrthreads", new sosCommand("Threads"), "List the managed threads running."); + interpreter.AddCommand("dumpheap", new sosCommand("DumpHeap"), "Displays info about the garbage-collected heap and collection statistics about objects."); + interpreter.AddCommand("dumpobj", new sosCommand("DumpObj"), "Displays info about an object at the specified address."); + interpreter.AddCommand("dso", new sosCommand("DumpStackObjects"), "Displays all managed objects found within the bounds of the current stack."); + interpreter.AddCommand("eeheap", new sosCommand("EEHeap"), "Displays info about process memory consumed by internal runtime data structures."); + interpreter.AddCommand("gcroot", new sosCommand("GCRoot"), "Displays info about references (or roots) to an object at the specified address."); + interpreter.AddCommand("ip2md", new sosCommand("IP2MD"), "Displays the MethodDesc structure at the specified address in code that has been JIT-compiled."); + interpreter.AddCommand("printexception", new sosCommand("PrintException"), "Displays and formats fields of any object derived from the Exception class at the specified address."); return true; } -- cgit v1.2.3