summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
diff options
context:
space:
mode:
authorMed Ismail Bennani <medismail.bennani@gmail.com>2022-08-11 22:26:36 -0700
committerMed Ismail Bennani <medismail.bennani@gmail.com>2022-08-11 22:29:06 -0700
commitedc77353daa707712fc92a31edb5b27ad103ba30 (patch)
treef697b5f0e4e225c4cfad9e72fe2366c6efacb912 /lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
parent603f44acc6ec31a274c554f0647630c10a114a6b (diff)
[lldb/crashlog] Improve exception reporting for interactive mode
This patch improve exception reporting when loading a crash report in a scripted process. Now, we parse the `exception` dictionary from the crash report use it the create a higher fidelity `MachException` stop info. This patch also updates the test to reflect that change. rdar://97096486 Differential Revision: https://reviews.llvm.org/D131086 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Diffstat (limited to 'lldb/source/Plugins/Process/scripted/ScriptedThread.cpp')
-rw-r--r--lldb/source/Plugins/Process/scripted/ScriptedThread.cpp44
1 files changed, 40 insertions, 4 deletions
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
index e28f66015dd5..5c49caedcfcc 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -9,6 +9,7 @@
#include "ScriptedThread.h"
#include "Plugins/Process/Utility/RegisterContextThreadMemory.h"
+#include "Plugins/Process/Utility/StopInfoMachException.h"
#include "lldb/Target/OperatingSystem.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
@@ -259,11 +260,46 @@ bool ScriptedThread::CalculateStopInfo() {
StopInfo::CreateStopReasonWithSignal(*this, signal, description.data());
} break;
case lldb::eStopReasonException: {
- llvm::StringRef description;
- data_dict->GetValueForKeyAsString("desc", description);
-
+#if defined(__APPLE__)
+ StructuredData::Dictionary *mach_exception;
+ if (data_dict->GetValueForKeyAsDictionary("mach_exception",
+ mach_exception)) {
+ llvm::StringRef value;
+ mach_exception->GetValueForKeyAsString("type", value);
+ auto exc_type =
+ StopInfoMachException::MachException::ExceptionCode(value.data());
+
+ if (!exc_type)
+ return false;
+
+ uint32_t exc_data_size = 0;
+ llvm::SmallVector<uint64_t, 3> raw_codes;
+
+ StructuredData::Array *exc_rawcodes;
+ mach_exception->GetValueForKeyAsArray("rawCodes", exc_rawcodes);
+ if (exc_rawcodes) {
+ auto fetch_data = [&raw_codes](StructuredData::Object *obj) {
+ if (!obj)
+ return false;
+ raw_codes.push_back(obj->GetIntegerValue());
+ return true;
+ };
+
+ exc_rawcodes->ForEach(fetch_data);
+ exc_data_size = raw_codes.size();
+ }
+
+ stop_info_sp = StopInfoMachException::CreateStopReasonWithMachException(
+ *this, *exc_type, exc_data_size,
+ exc_data_size >= 1 ? raw_codes[0] : 0,
+ exc_data_size >= 2 ? raw_codes[1] : 0,
+ exc_data_size >= 3 ? raw_codes[2] : 0);
+
+ break;
+ }
+#endif
stop_info_sp =
- StopInfo::CreateStopReasonWithException(*this, description.data());
+ StopInfo::CreateStopReasonWithException(*this, "EXC_BAD_ACCESS");
} break;
default:
return ScriptedInterface::ErrorWithMessage<bool>(