Skip to content

Conversation

medismailben
Copy link
Member

In 88f4091, we changed the way the crashlog scripted process was
launched since the previous approach required to parse the file twice,
by stopping at entry, setting the crashlog object in the middle of the
scripted process launch and resuming it.

Since then, we've introduced SBScriptObject which allows to pass any
arbitrary python object accross the SBAPI boundary to another scripted
affordance.

This patch make sure of that to include the parse crashlog object into
the scripted process launch info dictionary, which eliviates the need to
stop at entry.

Signed-off-by: Med Ismail Bennani [email protected]

@medismailben medismailben force-pushed the crashlog-stop-at-entry branch from 45a0d7a to 5bd7522 Compare August 22, 2025 00:48
@medismailben medismailben marked this pull request as ready for review August 22, 2025 00:48
@llvmbot llvmbot added the lldb label Aug 22, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 22, 2025

@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)

Changes

In 88f4091, we changed the way the crashlog scripted process was
launched since the previous approach required to parse the file twice,
by stopping at entry, setting the crashlog object in the middle of the
scripted process launch and resuming it.

Since then, we've introduced SBScriptObject which allows to pass any
arbitrary python object accross the SBAPI boundary to another scripted
affordance.

This patch make sure of that to include the parse crashlog object into
the scripted process launch info dictionary, which eliviates the need to
stop at entry.

Signed-off-by: Med Ismail Bennani <[email protected]>


Full diff: https://github.com/llvm/llvm-project/pull/154651.diff

2 Files Affected:

  • (modified) lldb/examples/python/crashlog.py (+7-4)
  • (modified) lldb/examples/python/crashlog_scripted_process.py (+8-3)
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index bb20f3a25c1c1..b466be6a62428 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1540,13 +1540,19 @@ def load_crashlog_in_scripted_process(debugger, crashlog_path, options, result):
             }
         )
     )
+
+    crashlog_sd = lldb.SBStructuredData()
+    crashlog_sd.SetGenericValue(
+        lldb.SBScriptObject(crashlog, lldb.eScriptLanguagePython)
+    )
+    structured_data.SetValueForKey("crashlog", crashlog_sd)
+
     launch_info = lldb.SBLaunchInfo(None)
     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)
@@ -1554,9 +1560,6 @@ def load_crashlog_in_scripted_process(debugger, crashlog_path, options, result):
     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
diff --git a/lldb/examples/python/crashlog_scripted_process.py b/lldb/examples/python/crashlog_scripted_process.py
index f54a8df0479e7..f8a727a1e393a 100644
--- a/lldb/examples/python/crashlog_scripted_process.py
+++ b/lldb/examples/python/crashlog_scripted_process.py
@@ -10,8 +10,7 @@
 
 
 class CrashLogScriptedProcess(ScriptedProcess):
-    def set_crashlog(self, crashlog):
-        self.crashlog = crashlog
+    def parse_crashlog(self):
         if self.crashlog.process_id:
             if type(self.crashlog.process_id) is int:
                 self.pid = self.crashlog.process_id
@@ -29,7 +28,7 @@ def set_crashlog(self, crashlog):
         if hasattr(self.crashlog, "asb"):
             self.extended_thread_info = self.crashlog.asb
 
-        crashlog.load_images(self.options, self.loaded_images)
+        self.crashlog.load_images(self.options, self.loaded_images)
 
         for thread in self.crashlog.threads:
             if (
@@ -92,10 +91,16 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args: lldb.SBStructuredData
                     no_parallel_image_loading.GetBooleanValue()
                 )
 
+        crashlog = args.GetValueForKey("crashlog")
+        if crashlog and crashlog.IsValid():
+            if crashlog.GetType() == lldb.eStructuredDataTypeGeneric:
+                self.crashlog = crashlog.GetGenericValue()
+
         self.pid = super().get_process_id()
         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

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup!

… mode

In 88f4091, we changed the way the crashlog scripted process was
launched since the previous approach required to parse the file twice,
by stopping at entry, setting the crashlog object in the middle of the
scripted process launch and resuming it.

Since then, we've introduced SBScriptObject which allows to pass any
arbitrary python object accross the SBAPI boundary to another scripted
affordance.

This patch make sure of that to include the parse crashlog object into
the scripted process launch info dictionary, which eliviates the need to
stop at entry.

Signed-off-by: Med Ismail Bennani <[email protected]>
@medismailben medismailben force-pushed the crashlog-stop-at-entry branch from 5bd7522 to 04db318 Compare August 22, 2025 05:56
@medismailben medismailben merged commit 595148a into llvm:main Aug 22, 2025
9 checks passed
medismailben added a commit to medismailben/llvm-project that referenced this pull request Aug 22, 2025
… mode (llvm#154651)

In 88f4091, we changed the way the crashlog scripted process was
launched since the previous approach required to parse the file twice,
by stopping at entry, setting the crashlog object in the middle of the
scripted process launch and resuming it.

Since then, we've introduced SBScriptObject which allows to pass any
arbitrary python object accross the SBAPI boundary to another scripted
affordance.

This patch make sure of that to include the parse crashlog object into
the scripted process launch info dictionary, which eliviates the need to
stop at entry.

Signed-off-by: Med Ismail Bennani <[email protected]>

Signed-off-by: Med Ismail Bennani <[email protected]>
(cherry picked from commit 595148a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants