diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -977,7 +977,7 @@ for error in crash_log.errors: print(error) -def load_crashlog_in_scripted_process(debugger, crash_log_file): +def load_crashlog_in_scripted_process(debugger, crash_log_file, options): result = lldb.SBCommandReturnObject() crashlog_path = os.path.expanduser(crash_log_file) @@ -1010,7 +1010,8 @@ return structured_data = lldb.SBStructuredData() - structured_data.SetFromJSON(json.dumps({ "crashlog_path" : crashlog_path })) + structured_data.SetFromJSON(json.dumps({ "crashlog_path" : crashlog_path, + "load_all_images": options.load_all_images })) launch_info = lldb.SBLaunchInfo(None) launch_info.SetProcessPluginName("ScriptedProcess") launch_info.SetScriptedProcessClassName("crashlog_scripted_process.CrashLogScriptedProcess") @@ -1069,7 +1070,9 @@ '-a', action='store_true', dest='load_all_images', - help='load all executable images, not just the images found in the crashed stack frames', + help='load all executable images, not just the images found in the ' + 'crashed stack frames, loads stackframes for all the threads in ' + 'interactive mode.', default=False) option_parser.add_option( '--images', @@ -1199,7 +1202,8 @@ if args: for crash_log_file in args: if should_run_in_interactive_mode(options, ci): - load_crashlog_in_scripted_process(debugger, crash_log_file) + load_crashlog_in_scripted_process(debugger, crash_log_file, + options) else: crash_log = CrashLogParser().parse(debugger, crash_log_file, options.verbose) SymbolicateCrashLog(crash_log, options) diff --git a/lldb/examples/python/scripted_process/crashlog_scripted_process.py b/lldb/examples/python/scripted_process/crashlog_scripted_process.py --- a/lldb/examples/python/scripted_process/crashlog_scripted_process.py +++ b/lldb/examples/python/scripted_process/crashlog_scripted_process.py @@ -19,18 +19,24 @@ self.crashed_thread_idx = crash_log.crashed_thread_idx self.loaded_images = [] + def load_images(self, images): + #TODO: Add to self.loaded_images and load images in lldb + if images: + for image in images: + if image not in self.loaded_images: + err = image.add_module(self.target) + if err: + print(err) + else: + self.loaded_images.append(image) + for thread in crash_log.threads: - if thread.did_crash(): + if self.load_all_images: + load_images(self, crash_log.images) + elif thread.did_crash(): for ident in thread.idents: - images = crash_log.find_images_with_identifier(ident) - if images: - for image in images: - #TODO: Add to self.loaded_images and load images in lldb - err = image.add_module(self.target) - if err: - print(err) - else: - self.loaded_images.append(image) + load_images(self, crash_log.find_images_with_identifier(ident)) + self.threads[thread.index] = CrashLogScriptedThread(self, None, thread) def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData): @@ -49,6 +55,14 @@ if not self.crashlog_path: return + load_all_images = args.GetValueForKey("load_all_images") + if load_all_images and load_all_images.IsValid(): + if load_all_images.GetType() == lldb.eStructuredDataTypeBoolean: + self.load_all_images = load_all_images.GetBooleanValue() + + if not self.load_all_images: + self.load_all_images = False + self.pid = super().get_process_id() self.crashed_thread_idx = 0 self.parse_crashlog() @@ -101,7 +115,7 @@ return self.register_ctx def create_stackframes(self): - if not self.has_crashed: + if not (self.scripted_process.load_all_images or self.has_crashed): return None if not self.backing_thread or not len(self.backing_thread.frames):