[Lldb-commits] [PATCH] D126260: [lldb/crashlog] Add support for Application Specific Backtraces
Med Ismail Bennani via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon May 23 17:25:23 PDT 2022
mib created this revision.
mib added a reviewer: JDevlieghere.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.
For an exception crashlog, the thread backtracesaren't usually very helpful
and instead, developpers look at the "Application Specific Backtrace" that
was generated by `objc_exception_throw`.
LLDB could already parse and symbolicate these Application Specific Backtraces
for regular textual-based crashlog, so this patch adds support to parse them
in JSON crashlogs.
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126260
Files:
lldb/examples/python/crashlog.py
lldb/examples/python/scripted_process/crashlog_scripted_process.py
Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===================================================================
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -140,6 +140,8 @@
self.idx = self.backing_thread.index
self.tid = self.backing_thread.id
self.name = self.backing_thread.name
+ if self.backing_thread.app_specific_backtrace:
+ self.name = "Application Specific Backtrace - " + str(self.idx)
self.queue = self.backing_thread.queue
self.has_crashed = (self.scripted_process.crashed_thread_idx == self.idx)
self.create_stackframes()
Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -449,6 +449,8 @@
self.parse_images(self.data['usedImages'])
self.parse_main_image(self.data)
self.parse_threads(self.data['threads'])
+ if 'asiBacktraces' in self.data:
+ self.parse_app_specific_backtraces(self.data['asiBacktraces'])
self.parse_errors(self.data)
thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
reason = self.parse_crash_reason(self.data['exception'])
@@ -560,6 +562,37 @@
self.crashlog.threads.append(thread)
idx += 1
+ def parse_app_specific_backtraces(self, json_app_specific_bts):
+ def parse_asi_backtrace(self, thread, bt):
+ frame_regex = re.compile(r'^([0-9]+)' r'\s' # id
+ r'+(.+?)' r'\s+' # img_name
+ r'(0x[0-9a-fA-F]{7}[0-9a-fA-F]+)' # addr
+ r' +(.*)' # offs
+ )
+
+ for line in bt.split('\n'):
+ frame_match = frame_regex.search(line)
+ if not frame_match:
+ print("error: Couldn't parse Application Specific Backtrace.")
+ return False
+
+ (frame_id, frame_img_name,
+ frame_addr, frame_ofs) = frame_match.groups()
+
+ thread.add_ident(frame_img_name)
+ if frame_img_name not in self.crashlog.idents:
+ self.crashlog.idents.append(frame_img_name)
+ thread.frames.append(self.crashlog.Frame(int(frame_id), int(
+ frame_addr, 0), frame_ofs))
+
+ return True
+
+ for idx, backtrace in enumerate(json_app_specific_bts):
+ thread = self.crashlog.Thread(idx, True)
+ thread.queue = "Application Specific Backtraces"
+ if parse_asi_backtrace(self, thread, backtrace):
+ self.crashlog.threads.append(thread)
+
def parse_thread_registers(self, json_thread_state, prefix=None):
registers = dict()
for key, state in json_thread_state.items():
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126260.431536.patch
Type: text/x-patch
Size: 3102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220524/5c605607/attachment.bin>
More information about the lldb-commits
mailing list