kubamracek updated this revision to Diff 173603.
kubamracek added a comment.
Updating patch for the recently-landed StackFrameRecognizers.
https://reviews.llvm.org/D43886
Files:
include/lldb/API/SBThread.h
include/lldb/Target/StackFrameRecognizer.h
include/lldb/Target/Thread.h
source/API/SBThread.cpp
source/Commands/CommandObjectThread.cpp
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
source/Target/StackFrameRecognizer.cpp
source/Target/Thread.cpp
Index: source/Target/Thread.cpp
===
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -29,6 +29,7 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrameRecognizer.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/SystemRuntime.h"
#include "lldb/Target/Target.h"
@@ -2190,3 +2191,18 @@
}
return error;
}
+
+ValueObjectSP Thread::GetCurrentException() {
+ StackFrameSP frame_sp(GetStackFrameAtIndex(0));
+ if (!frame_sp) return ValueObjectSP();
+
+ RecognizedStackFrameSP recognized_frame(frame_sp->GetRecognizedFrame());
+ if (!recognized_frame) return ValueObjectSP();
+
+ return recognized_frame->GetExceptionObject();
+}
+
+ThreadSP Thread::GetCurrentExceptionBacktrace() {
+ // TODO
+ return ThreadSP();
+}
Index: source/Target/StackFrameRecognizer.cpp
===
--- source/Target/StackFrameRecognizer.cpp
+++ source/Target/StackFrameRecognizer.cpp
@@ -53,8 +53,8 @@
class StackFrameRecognizerManagerImpl {
public:
- void AddRecognizer(StackFrameRecognizerSP recognizer, ConstString &module,
- ConstString &symbol, bool first_instruction_only) {
+ void AddRecognizer(StackFrameRecognizerSP recognizer, const ConstString &module,
+ const ConstString &symbol, bool first_instruction_only) {
m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, false, module, RegularExpressionSP(),
symbol, RegularExpressionSP(),
first_instruction_only});
@@ -156,7 +156,7 @@
}
void StackFrameRecognizerManager::AddRecognizer(
-StackFrameRecognizerSP recognizer, ConstString &module, ConstString &symbol,
+StackFrameRecognizerSP recognizer, const ConstString &module, const ConstString &symbol,
bool first_instruction_only) {
GetStackFrameRecognizerManagerImpl().AddRecognizer(recognizer, module, symbol,
first_instruction_only);
Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -29,6 +29,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
+#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
@@ -43,10 +44,12 @@
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrameRecognizer.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/ConstString.h"
@@ -377,6 +380,8 @@
}
}
+static void RegisterObjCExceptionRecognizer();
+
AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process,
const ModuleSP &objc_module_sp)
: AppleObjCRuntime(process), m_get_class_info_code(),
@@ -397,6 +402,7 @@
static const ConstString g_gdb_object_getClass("gdb_object_getClass");
m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType(
g_gdb_object_getClass, eSymbolTypeCode) != NULL);
+ RegisterObjCExceptionRecognizer();
}
bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress(
@@ -2596,3 +2602,57 @@
} else
this->AppleObjCRuntime::GetValuesForGlobalCFBooleans(cf_true, cf_false);
}
+
+#pragma mark Frame recognizers
+
+class ObjCExceptionRecognizedStackFrame : public RecognizedStackFrame {
+ public:
+ ObjCExceptionRecognizedStackFrame(StackFrameSP frame_sp) {
+ThreadSP thread_sp = frame_sp->GetThread();
+ProcessSP process_sp = thread_sp->GetProcess();
+
+const lldb::ABISP &abi = process_sp->GetABI();
+if (!abi) return;
+
+CompilerType voidstar = process_sp->GetTarget()
+.GetScratchClangASTContext()
+