From: Konstantin Baladurin Date: Tue, 3 Oct 2017 18:28:06 +0000 (+0300) Subject: [SOS] Use addresses without sign extension in lldb plugin (dotnet/coreclr#14009) X-Git-Tag: submit/tizen/20210909.063632~11030^2~6844 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d90ad00f87870984f9d3c66e60e90a335ad57287;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [SOS] Use addresses without sign extension in lldb plugin (dotnet/coreclr#14009) lldb doesn't expect sign-extended addresses so we need to convert them before using with lldb API. This patch allows to use SOS plugin for core files in lldb on 32-bit platforms and also fixes output of the 'clrstack -f' command. Commit migrated from https://github.com/dotnet/coreclr/commit/4ad0b6a18fe24864ff11760e9b313a0d6dbe9d3b --- diff --git a/src/coreclr/src/ToolBox/SOS/lldbplugin/services.cpp b/src/coreclr/src/ToolBox/SOS/lldbplugin/services.cpp index e3eee4f..d0ea7bc 100644 --- a/src/coreclr/src/ToolBox/SOS/lldbplugin/services.cpp +++ b/src/coreclr/src/ToolBox/SOS/lldbplugin/services.cpp @@ -8,6 +8,8 @@ #include #include +#define CONVERT_FROM_SIGN_EXTENDED(offset) ((ULONG_PTR)(offset)) + ULONG g_currentThreadIndex = -1; ULONG g_currentThreadSystemId = -1; char *g_coreclrDirectory; @@ -545,6 +547,9 @@ LLDBServices::Disassemble( uint8_t byte; int cch; + // lldb doesn't expect sign-extended address + offset = CONVERT_FROM_SIGN_EXTENDED(offset); + if (buffer == NULL) { hr = E_INVALIDARG; @@ -750,6 +755,9 @@ LLDBServices::ReadVirtual( lldb::SBError error; size_t read = 0; + // lldb doesn't expect sign-extended address + offset = CONVERT_FROM_SIGN_EXTENDED(offset); + lldb::SBProcess process = GetCurrentProcess(); if (!process.IsValid()) { @@ -776,6 +784,9 @@ LLDBServices::WriteVirtual( lldb::SBError error; size_t written = 0; + // lldb doesn't expect sign-extended address + offset = CONVERT_FROM_SIGN_EXTENDED(offset); + lldb::SBProcess process = GetCurrentProcess(); if (!process.IsValid()) { @@ -822,6 +833,9 @@ LLDBServices::GetNameByOffset( lldb::SBSymbol symbol; std::string str; + // lldb doesn't expect sign-extended address + offset = CONVERT_FROM_SIGN_EXTENDED(offset); + target = m_debugger.GetSelectedTarget(); if (!target.IsValid()) { @@ -1012,6 +1026,9 @@ LLDBServices::GetModuleByOffset( lldb::SBTarget target; int numModules; + // lldb doesn't expect sign-extended address + offset = CONVERT_FROM_SIGN_EXTENDED(offset); + target = m_debugger.GetSelectedTarget(); if (!target.IsValid()) { @@ -1076,6 +1093,9 @@ LLDBServices::GetModuleNames( lldb::SBFileSpec fileSpec; HRESULT hr = S_OK; + // lldb doesn't expect sign-extended address + base = CONVERT_FROM_SIGN_EXTENDED(base); + target = m_debugger.GetSelectedTarget(); if (!target.IsValid()) { @@ -1167,6 +1187,9 @@ LLDBServices::GetLineByOffset( lldb::SBLineEntry lineEntry; std::string str; + // lldb doesn't expect sign-extended address + offset = CONVERT_FROM_SIGN_EXTENDED(offset); + target = m_debugger.GetSelectedTarget(); if (!target.IsValid()) {