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 @@ -1111,12 +1111,17 @@ launch_info.SetProcessPluginName("ScriptedProcess") launch_info.SetScriptedProcessClassName("crashlog_scripted_process.CrashLogScriptedProcess") launch_info.SetScriptedProcessDictionary(structured_data) + launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry) + error = lldb.SBError() process = target.Launch(launch_info, error) if not process or error.Fail(): raise InteractiveCrashLogException("couldn't launch Scripted Process", error) + process.GetScriptedImplementation().set_crashlog(crashlog) + process.Continue() + if not options.skip_status: @contextlib.contextmanager def synchronous(debugger): 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 @@ -9,20 +9,18 @@ from lldb.macosx.crashlog import CrashLog,CrashLogParser class CrashLogScriptedProcess(ScriptedProcess): - def parse_crashlog(self): - crashlog_parser = CrashLogParser.create(self.dbg, self.crashlog_path, False) - crash_log = crashlog_parser.parse() - - self.pid = crash_log.process_id - self.addr_mask = crash_log.addr_mask - self.crashed_thread_idx = crash_log.crashed_thread_idx + def set_crashlog(self, crashlog): + self.crashlog = crashlog + self.pid = self.crashlog.process_id + self.addr_mask = self.crashlog.addr_mask + self.crashed_thread_idx = self.crashlog.crashed_thread_idx self.loaded_images = [] - self.exception = crash_log.exception + self.exception = self.crashlog.exception self.app_specific_thread = None - if hasattr(crash_log, 'asi'): - self.metadata['asi'] = crash_log.asi - if hasattr(crash_log, 'asb'): - self.extended_thread_info = crash_log.asb + if hasattr(self.crashlog, 'asi'): + self.metadata['asi'] = self.crashlog.asi + if hasattr(self.crashlog, 'asb'): + self.extended_thread_info = self.crashlog.asb def load_images(self, images): #TODO: Add to self.loaded_images and load images in lldb @@ -38,12 +36,12 @@ else: self.loaded_images.append(image) - for thread in crash_log.threads: + for thread in self.crashlog.threads: if self.load_all_images: - load_images(self, crash_log.images) + load_images(self, self.crashlog.images) elif thread.did_crash(): for ident in thread.idents: - load_images(self, crash_log.find_images_with_identifier(ident)) + load_images(self, self.crashlog.find_images_with_identifier(ident)) if hasattr(thread, 'app_specific_backtrace') and thread.app_specific_backtrace: # We don't want to include the Application Specific Backtrace @@ -92,7 +90,6 @@ self.crashed_thread_idx = 0 self.exception = None self.extended_thread_info = None - self.parse_crashlog() def read_memory_at_address(self, addr: int, size: int, error: lldb.SBError) -> lldb.SBData: # NOTE: CrashLogs don't contain any memory. diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h --- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h +++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h @@ -47,7 +47,7 @@ Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override; - void DidLaunch() override; + void DidResume() override; Status DoResume() override; diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp --- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp +++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp @@ -168,7 +168,7 @@ return {}; } -void ScriptedProcess::DidLaunch() { +void ScriptedProcess::DidResume() { m_pid = GetInterface().GetProcessID(); GetLoadedDynamicLibrariesInfos(); }