[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
This commit is contained in:
Kuba Mracek
2018-11-28 22:01:52 +00:00
parent a3e7a167c4
commit e60bc53b46
12 changed files with 187 additions and 10 deletions

View File

@@ -1484,6 +1484,21 @@ uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() {
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)