Skip to content

Commit 186d6d4

Browse files
JDevliegheremedismailben
authored andcommitted
[lldb] Reinvoke crashlog under lldb when run with -i from the command line
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. This pretty much defeats the purpose of interactive mode. That said, we wouldn't want to re-implement the driver from the crashlog script. Re-invoking the crashlog command from inside LLDB solves the issue. rdar://97801509 Differential revision: https://reviews.llvm.org/D152319
1 parent 8003e72 commit 186d6d4

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

lldb/examples/python/crashlog.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ def __init__(self, debugger, internal_dict):
13601360
pass
13611361

13621362
def __call__(self, debugger, command, exe_ctx, result):
1363-
SymbolicateCrashLogs(debugger, shlex.split(command), result)
1363+
SymbolicateCrashLogs(debugger, shlex.split(command), result, True)
13641364

13651365
def get_short_help(self):
13661366
return "Symbolicate one or more darwin crash log files."
@@ -1685,7 +1685,7 @@ def CrashLogOptionParser():
16851685
return CreateSymbolicateCrashLogOptions("crashlog", description, True)
16861686

16871687

1688-
def SymbolicateCrashLogs(debugger, command_args, result):
1688+
def SymbolicateCrashLogs(debugger, command_args, result, is_command):
16891689
option_parser = CrashLogOptionParser()
16901690

16911691
if not len(command_args):
@@ -1697,6 +1697,26 @@ def SymbolicateCrashLogs(debugger, command_args, result):
16971697
except:
16981698
return
16991699

1700+
# Interactive mode requires running the crashlog command from inside lldb.
1701+
if options.interactive and not is_command:
1702+
lldb_exec = (
1703+
subprocess.check_output(["/usr/bin/xcrun", "-f", "lldb"])
1704+
.decode("utf-8")
1705+
.strip()
1706+
)
1707+
sys.exit(
1708+
os.execv(
1709+
lldb_exec,
1710+
[
1711+
lldb_exec,
1712+
"-o",
1713+
"command script import lldb.macosx",
1714+
"-o",
1715+
"crashlog {}".format(shlex.join(command_args)),
1716+
],
1717+
)
1718+
)
1719+
17001720
if options.version:
17011721
print(debugger.GetVersionString())
17021722
return
@@ -1748,7 +1768,7 @@ def should_run_in_interactive_mode(options, ci):
17481768
# Create a new debugger instance
17491769
debugger = lldb.SBDebugger.Create()
17501770
result = lldb.SBCommandReturnObject()
1751-
SymbolicateCrashLogs(debugger, sys.argv[1:], result)
1771+
SymbolicateCrashLogs(debugger, sys.argv[1:], result, False)
17521772
lldb.SBDebugger.Destroy(debugger)
17531773

17541774

0 commit comments

Comments
 (0)