[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
Tue Jun 6 16:33:13 PDT 2023
JDevlieghere created this revision.
JDevlieghere added reviewers: mib, aprantl.
Herald added a project: All.
JDevlieghere requested review of this revision.
Run crashlog inside lldb when invoked in interactive mode from the command line. Currently, when passing -i to crashlog from the command line, we symbolicate in LLDB and immediately exit right after which pretty much defeats the purpose of interactive mode. On the other hand, we wouldn't want to reimplement the driver from the crashlog script. Re-invoking ourself from inside LLDB solves the issue.
rdar://97801509
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.529084.patch
Type: text/x-patch
Size: 1919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230606/34b741ba/attachment-0001.bin>
More information about the lldb-commits
mailing list