[Lldb-commits] [PATCH] D152319: [lldb] Run crashlog inside lldb when invoked in interactive mode from the command line

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 7 16:21:29 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG7b4792159cb7: [lldb] Reinvoke crashlog under lldb when run with -i from the command line (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152319/new/

https://reviews.llvm.org/D152319

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -1271,7 +1271,7 @@
         pass
 
     def __call__(self, debugger, command, exe_ctx, result):
-        SymbolicateCrashLogs(debugger, shlex.split(command), result)
+        SymbolicateCrashLogs(debugger, shlex.split(command), result, True)
 
     def get_short_help(self):
         return "Symbolicate one or more darwin crash log files."
@@ -1596,7 +1596,7 @@
     return CreateSymbolicateCrashLogOptions("crashlog", description, True)
 
 
-def SymbolicateCrashLogs(debugger, command_args, result):
+def SymbolicateCrashLogs(debugger, command_args, result, is_command):
     option_parser = CrashLogOptionParser()
 
     if not len(command_args):
@@ -1608,6 +1608,26 @@
     except:
         return
 
+    # Interactive mode requires running the crashlog command from inside lldb.
+    if options.interactive and not is_command:
+        lldb_exec = (
+            subprocess.check_output(["/usr/bin/xcrun", "-f", "lldb"])
+            .decode("utf-8")
+            .strip()
+        )
+        sys.exit(
+            os.execv(
+                lldb_exec,
+                [
+                    lldb_exec,
+                    "-o",
+                    "command script import lldb.macosx",
+                    "-o",
+                    "crashlog {}".format(shlex.join(command_args)),
+                ],
+            )
+        )
+
     if options.version:
         print(debugger.GetVersionString())
         return
@@ -1659,7 +1679,7 @@
     # Create a new debugger instance
     debugger = lldb.SBDebugger.Create()
     result = lldb.SBCommandReturnObject()
-    SymbolicateCrashLogs(debugger, sys.argv[1:], result)
+    SymbolicateCrashLogs(debugger, sys.argv[1:], result, False)
     lldb.SBDebugger.Destroy(debugger)
 
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152319.529467.patch
Type: text/x-patch
Size: 1919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230607/437364e0/attachment-0001.bin>


More information about the lldb-commits mailing list