diff options
author | Med Ismail Bennani <ismail@bennani.ma> | 2023-08-18 20:47:35 +0100 |
---|---|---|
committer | Med Ismail Bennani <ismail@bennani.ma> | 2023-08-18 20:50:39 +0100 |
commit | 4c4f0d81f47cf9ad785dc2ea323ec2f0aedb72df (patch) | |
tree | ed1f1c9974654bdb76ce86460013a92f0d71b65e /lldb/examples/python/crashlog.py | |
parent | 3054a0c4bc50856156f26b528895ddcfba4210fa (diff) | |
download | llvm-4c4f0d81f47cf9ad785dc2ea323ec2f0aedb72df.zip llvm-4c4f0d81f47cf9ad785dc2ea323ec2f0aedb72df.tar.gz llvm-4c4f0d81f47cf9ad785dc2ea323ec2f0aedb72df.tar.bz2 |
[lldb/crashlog] Add support for Last Exception Backtrace
This patch adds support to the "Last Exception Backtrace" to the
`crashlog` command.
This metadata is homologous to the "Application Specific Backtrace",
however the format is closer to a regular stack frame.
Since the thread that "contains" the "Last Exception Backtrace" doesn't
really exist, this information is displayed when requesting an extended
backtrace of the crashed thread, similarly to the "Application Specific
Backtrace".
To achieve that, this patch includes some refactors and fixes to the
existing "Application Specific Backtrace" handling.
rdar://113046509
Differential Revision: https://reviews.llvm.org/D157851
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Diffstat (limited to 'lldb/examples/python/crashlog.py')
-rwxr-xr-x | lldb/examples/python/crashlog.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py index 10e89b1..080062b 100755 --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -586,10 +586,15 @@ class JSONCrashLogParser(CrashLogParser): self.parse_threads(self.data["threads"]) if "asi" in self.data: self.crashlog.asi = self.data["asi"] + # FIXME: With the current design, we can either show the ASI or Last + # Exception Backtrace, not both. Is there a situation where we would + # like to show both ? if "asiBacktraces" in self.data: self.parse_app_specific_backtraces(self.data["asiBacktraces"]) if "lastExceptionBacktrace" in self.data: - self.crashlog.asb = self.data["lastExceptionBacktrace"] + self.parse_last_exception_backtraces( + self.data["lastExceptionBacktrace"] + ) self.parse_errors(self.data) thread = self.crashlog.threads[self.crashlog.crashed_thread_idx] reason = self.parse_crash_reason(self.data["exception"]) @@ -792,11 +797,22 @@ class JSONCrashLogParser(CrashLogParser): return True def parse_app_specific_backtraces(self, json_app_specific_bts): - for idx, backtrace in enumerate(json_app_specific_bts): - thread = self.crashlog.Thread(idx, True, self.crashlog.process_arch) - thread.queue = "Application Specific Backtrace" - if self.parse_asi_backtrace(thread, backtrace): - self.crashlog.threads.append(thread) + thread = self.crashlog.Thread( + len(self.crashlog.threads), True, self.crashlog.process_arch + ) + thread.queue = "Application Specific Backtrace" + if self.parse_asi_backtrace(thread, json_app_specific_bts[0]): + self.crashlog.threads.append(thread) + else: + print("error: Couldn't parse Application Specific Backtrace.") + + def parse_last_exception_backtraces(self, json_last_exc_bts): + thread = self.crashlog.Thread( + len(self.crashlog.threads), True, self.crashlog.process_arch + ) + thread.queue = "Last Exception Backtrace" + self.parse_frames(thread, json_last_exc_bts) + self.crashlog.threads.append(thread) def parse_thread_registers(self, json_thread_state, prefix=None): registers = dict() |