[lldb] Add GetCurrentException APIs to SBThread, add frame recognizer for objc_exception_throw for Obj-C runtimes
This adds new APIs and a command to deal with exceptions (mostly Obj-C exceptions): SBThread and Thread get GetCurrentException API, which returns an SBValue/ValueObjectSP with the current exception for a thread. "Current" means an exception that is currently being thrown, caught or otherwise processed. In this patch, we only know about the exception when in objc_exception_throw, but subsequent patches will expand this (and add GetCurrentExceptionBacktrace, which will return an SBThread/ThreadSP containing a historical thread backtrace retrieved from the exception object. Currently unimplemented, subsequent patches will implement this).
Extracting the exception from objc_exception_throw is implemented by adding a frame recognizer.
This also add a new sub-command "thread exception", which prints the current exception.
Differential Revision: https://reviews.llvm.org/D43886
llvm-svn: 347813
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index a38b9f6..5771b37 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -1484,6 +1484,21 @@
return LLDB_INVALID_INDEX32;
}
+SBValue SBThread::GetCurrentException() {
+ ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+ if (!thread_sp) return SBValue();
+
+ return SBValue(thread_sp->GetCurrentException());
+}
+
+/* TODO(kubamracek)
+SBThread SBThread::GetCurrentExceptionBacktrace() {
+ ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+ if (!thread_sp) return SBThread();
+
+ return SBThread(thread_sp->GetCurrentExceptionBacktrace());
+}*/
+
bool SBThread::SafeToCallFunctions() {
ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
if (thread_sp)