[Lldb-commits] [lldb] 88f4091 - [lldb] Parse the crashlog only once
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 11 17:05:21 PDT 2023
Author: Jonas Devlieghere
Date: 2023-04-11T17:05:15-07:00
New Revision: 88f409194d5ac84eb19ee91260a17c6c8b992eda
URL: https://github.com/llvm/llvm-project/commit/88f409194d5ac84eb19ee91260a17c6c8b992eda
DIFF: https://github.com/llvm/llvm-project/commit/88f409194d5ac84eb19ee91260a17c6c8b992eda.diff
LOG: [lldb] Parse the crashlog only once
Now that we can pass Python objects to the scripted process instance, we
don't need to parse the crashlog twice anymore.
Differential revision: https://reviews.llvm.org/D148063
Added:
Modified:
lldb/examples/python/crashlog.py
lldb/examples/python/scripted_process/crashlog_scripted_process.py
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
Removed:
################################################################################
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index b09c03a50bb7..68ead43ce869 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1111,12 +1111,17 @@ def load_crashlog_in_scripted_process(debugger, crash_log_file, options, result)
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
index 8c32b40d8c8a..b8c05717bb3a 100644
--- 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 @@ def load_images(self, images):
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 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args : lldb.SBStructuredDat
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.cpp b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index 5e7f88cc2d86..999edd8f8db7 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -168,7 +168,7 @@ Status ScriptedProcess::DoLaunch(Module *exe_module,
return {};
}
-void ScriptedProcess::DidLaunch() {
+void ScriptedProcess::DidResume() {
m_pid = GetInterface().GetProcessID();
GetLoadedDynamicLibrariesInfos();
}
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
index 368c54b1b461..856e05c901ed 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -47,7 +47,7 @@ class ScriptedProcess : public Process {
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
- void DidLaunch() override;
+ void DidResume() override;
Status DoResume() override;
More information about the lldb-commits
mailing list