summaryrefslogtreecommitdiff
path: root/src/ToolBox/SOS
diff options
context:
space:
mode:
authorMike McLaughlin <mikem@microsoft.com>2015-11-03 19:55:35 -0800
committerMike McLaughlin <mikem@microsoft.com>2015-11-03 19:55:35 -0800
commit810b1162fff85075feb6cd5dd47b30e9f668ad38 (patch)
tree1c899d0af21b7aeef7ae512879e49f18d302c32f /src/ToolBox/SOS
parentb5f4ac87fc16188a0436aa1244d747f81a88cfa5 (diff)
parenta5bcc44a468fab8699633d70a2394d6e565ece23 (diff)
downloadcoreclr-810b1162fff85075feb6cd5dd47b30e9f668ad38.tar.gz
coreclr-810b1162fff85075feb6cd5dd47b30e9f668ad38.tar.bz2
coreclr-810b1162fff85075feb6cd5dd47b30e9f668ad38.zip
Merge pull request #1946 from mikem8361/unwindi
Fix sos clrstack unwinding for the special HelperMethodFrame.
Diffstat (limited to 'src/ToolBox/SOS')
-rw-r--r--src/ToolBox/SOS/Strike/datatarget.cpp12
-rw-r--r--src/ToolBox/SOS/Strike/datatarget.h6
-rw-r--r--src/ToolBox/SOS/Strike/strike.cpp5
-rw-r--r--src/ToolBox/SOS/lldbplugin/debugclient.cpp100
-rw-r--r--src/ToolBox/SOS/lldbplugin/debugclient.h12
-rw-r--r--src/ToolBox/SOS/lldbplugin/inc/dbgeng.h5
-rw-r--r--src/ToolBox/SOS/lldbplugin/sosplugin.h1
7 files changed, 116 insertions, 25 deletions
diff --git a/src/ToolBox/SOS/Strike/datatarget.cpp b/src/ToolBox/SOS/Strike/datatarget.cpp
index 6da8f7100f..08436f7548 100644
--- a/src/ToolBox/SOS/Strike/datatarget.cpp
+++ b/src/ToolBox/SOS/Strike/datatarget.cpp
@@ -196,8 +196,14 @@ DataTarget::Request(
}
HRESULT STDMETHODCALLTYPE
-DataTarget::GetPid(
- /* [out] */ DWORD *pdwProcessId)
+DataTarget::VirtualUnwind(
+ /* [in] */ DWORD threadId,
+ /* [in] */ ULONG32 contextSize,
+ /* [in, out, size_is(contextSize)] */ PBYTE context)
{
- return g_ExtSystem->GetCurrentProcessId(pdwProcessId);
+ if (g_ExtClient == NULL)
+ {
+ return E_UNEXPECTED;
+ }
+ return g_ExtClient->VirtualUnwind(threadId, contextSize, context);
} \ No newline at end of file
diff --git a/src/ToolBox/SOS/Strike/datatarget.h b/src/ToolBox/SOS/Strike/datatarget.h
index 407ddc00d9..49137af216 100644
--- a/src/ToolBox/SOS/Strike/datatarget.h
+++ b/src/ToolBox/SOS/Strike/datatarget.h
@@ -85,6 +85,8 @@ public:
// ICorDebugDataTarget4
- virtual HRESULT STDMETHODCALLTYPE GetPid(
- /* [out] */ DWORD *pdwProcessId);
+ virtual HRESULT STDMETHODCALLTYPE VirtualUnwind(
+ /* [in] */ DWORD threadId,
+ /* [in] */ ULONG32 contextSize,
+ /* [in, out, size_is(contextSize)] */ PBYTE context);
}; \ No newline at end of file
diff --git a/src/ToolBox/SOS/Strike/strike.cpp b/src/ToolBox/SOS/Strike/strike.cpp
index 13449eb95d..eb71163d1a 100644
--- a/src/ToolBox/SOS/Strike/strike.cpp
+++ b/src/ToolBox/SOS/Strike/strike.cpp
@@ -6892,8 +6892,13 @@ HRESULT HandleCLRNotificationEvent()
if (!CheckCLRNotificationEvent(&dle))
{
+#ifndef FEATURE_PAL
ExtOut("Expecting first chance CLRN exception\n");
return E_FAIL;
+#else
+ g_ExtControl->Execute(DEBUG_EXECUTE_NOT_LOGGED, "process continue", 0);
+ return S_OK;
+#endif
}
// Notification only needs to live for the lifetime of the call below, so it's a non-static
diff --git a/src/ToolBox/SOS/lldbplugin/debugclient.cpp b/src/ToolBox/SOS/lldbplugin/debugclient.cpp
index ebb4504bf5..fad404a820 100644
--- a/src/ToolBox/SOS/lldbplugin/debugclient.cpp
+++ b/src/ToolBox/SOS/lldbplugin/debugclient.cpp
@@ -7,7 +7,6 @@
#include <cstdlib>
#include "sosplugin.h"
#include <string.h>
-#include <dbgtargetcontext.h>
#include <string>
ULONG g_currentThreadIndex = -1;
@@ -708,8 +707,8 @@ DebugClient::GetModuleDirectory(
// Internal function
ULONG64
DebugClient::GetModuleBase(
- lldb::SBTarget target,
- lldb::SBModule module)
+ /* const */ lldb::SBTarget& target,
+ /* const */ lldb::SBModule& module)
{
// Find the first section with an valid base address
int numSections = module.GetNumSections();
@@ -922,6 +921,19 @@ DebugClient::GetThreadContextById(
dtcontext = (DT_CONTEXT*)context;
dtcontext->ContextFlags = contextFlags;
+ GetContextFromFrame(frame, dtcontext);
+ hr = S_OK;
+
+exit:
+ return hr;
+}
+
+// Internal function
+void
+DebugClient::GetContextFromFrame(
+ /* const */ lldb::SBFrame& frame,
+ DT_CONTEXT *dtcontext)
+{
#ifdef DBG_TARGET_AMD64
dtcontext->Rip = frame.GetPC();
dtcontext->Rsp = frame.GetSP();
@@ -969,29 +981,19 @@ DebugClient::GetThreadContextById(
dtcontext->R11 = GetRegister(frame, "r11");
dtcontext->R12 = GetRegister(frame, "r12");
#endif
-
- hr = S_OK;
-
-exit:
- return hr;
}
// Internal function
DWORD_PTR
-DebugClient::GetRegister(lldb::SBFrame frame, const char *name)
+DebugClient::GetRegister(
+ /* const */ lldb::SBFrame& frame,
+ const char *name)
{
lldb::SBValue regValue = frame.FindRegister(name);
lldb::SBError error;
DWORD_PTR result = regValue.GetValueAsUnsigned(error);
-#ifdef _DEBUG
- if (!regValue.IsValid() || error.Fail())
- {
- Output(DEBUG_OUTPUT_ERROR, "Invalid register name '%s'\n", name);
- }
-#endif
-
return result;
}
@@ -1115,7 +1117,7 @@ DebugClient::GetExpression(
// Internal function
DWORD_PTR
DebugClient::GetExpression(
- lldb::SBFrame frame,
+ /* const */ lldb::SBFrame& frame,
lldb::SBError& error,
PCSTR exp)
{
@@ -1130,6 +1132,70 @@ DebugClient::GetExpression(
return result;
}
+HRESULT
+DebugClient::VirtualUnwind(
+ DWORD threadID,
+ ULONG32 contextSize,
+ PBYTE context)
+{
+ lldb::SBProcess process;
+ lldb::SBThread thread;
+
+ if (context == NULL || contextSize < sizeof(DT_CONTEXT))
+ {
+ return E_FAIL;
+ }
+
+ process = GetCurrentProcess();
+ if (!process.IsValid())
+ {
+ return E_FAIL;
+ }
+
+ thread = process.GetThreadByID(threadID);
+ if (!thread.IsValid())
+ {
+ return E_FAIL;
+ }
+
+ DT_CONTEXT *dtcontext = (DT_CONTEXT*)context;
+ lldb::SBFrame frameFound;
+
+#ifdef DBG_TARGET_AMD64
+ DWORD64 spToFind = dtcontext->Rsp;
+#elif DBG_TARGET_ARM
+ DWORD spToFind = dtcontext->Sp;
+#endif
+
+ int numFrames = thread.GetNumFrames();
+ for (int i = 0; i < numFrames; i++)
+ {
+ lldb::SBFrame frame = thread.GetFrameAtIndex(i);
+ if (!frame.IsValid())
+ {
+ break;
+ }
+
+ lldb::addr_t sp = frame.GetSP();
+
+ if (sp == spToFind && (i + 1) < numFrames)
+ {
+ // Get next frame after finding the match
+ frameFound = thread.GetFrameAtIndex(i + 1);
+ break;
+ }
+ }
+
+ if (!frameFound.IsValid())
+ {
+ return E_FAIL;
+ }
+
+ GetContextFromFrame(frameFound, dtcontext);
+
+ return S_OK;
+}
+
//----------------------------------------------------------------------------
// Helper functions
//----------------------------------------------------------------------------
diff --git a/src/ToolBox/SOS/lldbplugin/debugclient.h b/src/ToolBox/SOS/lldbplugin/debugclient.h
index c3978f21dd..036c17360f 100644
--- a/src/ToolBox/SOS/lldbplugin/debugclient.h
+++ b/src/ToolBox/SOS/lldbplugin/debugclient.h
@@ -13,9 +13,10 @@ private:
lldb::SBProcess GetCurrentProcess();
lldb::SBThread GetCurrentThread();
lldb::SBFrame GetCurrentFrame();
- ULONG64 GetModuleBase(lldb::SBTarget target, lldb::SBModule module);
- DWORD_PTR GetExpression(lldb::SBFrame frame, lldb::SBError& error, PCSTR exp);
- DWORD_PTR GetRegister(lldb::SBFrame frame, const char *name);
+ ULONG64 GetModuleBase(lldb::SBTarget& target, lldb::SBModule& module);
+ DWORD_PTR GetExpression(lldb::SBFrame& frame, lldb::SBError& error, PCSTR exp);
+ void GetContextFromFrame(lldb::SBFrame& frame, DT_CONTEXT *dtcontext);
+ DWORD_PTR GetRegister(lldb::SBFrame& frame, const char *name);
public:
DebugClient(lldb::SBDebugger &debugger, lldb::SBCommandReturnObject &returnObject);
@@ -192,4 +193,9 @@ public:
DWORD_PTR GetExpression(
PCSTR exp);
+
+ HRESULT VirtualUnwind(
+ DWORD threadID,
+ ULONG32 contextSize,
+ PBYTE context);
};
diff --git a/src/ToolBox/SOS/lldbplugin/inc/dbgeng.h b/src/ToolBox/SOS/lldbplugin/inc/dbgeng.h
index 36c1c83073..04b27fbf8e 100644
--- a/src/ToolBox/SOS/lldbplugin/inc/dbgeng.h
+++ b/src/ToolBox/SOS/lldbplugin/inc/dbgeng.h
@@ -457,6 +457,11 @@ public:
// Evaluates a lldb expression into a value.
virtual DWORD_PTR GetExpression(
/* [in] */ PCSTR exp) = 0;
+
+ virtual HRESULT VirtualUnwind(
+ /* [in] */ DWORD threadID,
+ /* [in] */ ULONG32 contextSize,
+ /* [in, out, size_is(contextSize)] */ PBYTE context) = 0;
};
typedef class IDebugClient* PDEBUG_CLIENT;
diff --git a/src/ToolBox/SOS/lldbplugin/sosplugin.h b/src/ToolBox/SOS/lldbplugin/sosplugin.h
index 54a7aee491..4b44589fe7 100644
--- a/src/ToolBox/SOS/lldbplugin/sosplugin.h
+++ b/src/ToolBox/SOS/lldbplugin/sosplugin.h
@@ -7,6 +7,7 @@
#include "mstypes.h"
#define DEFINE_EXCEPTION_RECORD
#include <dbgeng.h>
+#include <dbgtargetcontext.h>
#include "debugclient.h"
typedef HRESULT (*CommandFunc)(PDEBUG_CLIENT client, const char *args);