Skip to content

Commit 1373f7c

Browse files
authored
Revert "[lldb/crashlog] Make interactive mode the new default" (#96263)
Reverts #94575 since introduces test failure: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6166/
1 parent 03921b9 commit 1373f7c

File tree

6 files changed

+55
-83
lines changed

6 files changed

+55
-83
lines changed

lldb/examples/python/crashlog.py

Lines changed: 48 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import concurrent.futures
3232
import contextlib
3333
import datetime
34-
import enum
3534
import json
3635
import os
3736
import platform
@@ -46,6 +45,7 @@
4645
import time
4746
import uuid
4847

48+
4949
print_lock = threading.RLock()
5050

5151
try:
@@ -1582,12 +1582,9 @@ def synchronous(debugger):
15821582
debugger.RunCommandInterpreter(True, False, run_options, 0, False, True)
15831583

15841584

1585-
class CrashLogLoadingMode(str, enum.Enum):
1586-
batch = "batch"
1587-
interactive = "interactive"
1588-
1589-
1590-
def CreateSymbolicateCrashLogOptions(command_name, description):
1585+
def CreateSymbolicateCrashLogOptions(
1586+
command_name, description, add_interactive_options
1587+
):
15911588
usage = "crashlog [options] <FILE> [FILE ...]"
15921589
arg_parser = argparse.ArgumentParser(
15931590
description=description,
@@ -1603,12 +1600,6 @@ def CreateSymbolicateCrashLogOptions(command_name, description):
16031600
help="crash report(s) to symbolicate",
16041601
)
16051602

1606-
arg_parser.add_argument(
1607-
"-m",
1608-
"--mode",
1609-
choices=[mode.value for mode in CrashLogLoadingMode],
1610-
help="change how the symbolicated process and threads are displayed to the user (default: interactive)",
1611-
)
16121603
arg_parser.add_argument(
16131604
"--version",
16141605
"-V",
@@ -1745,35 +1736,36 @@ def CreateSymbolicateCrashLogOptions(command_name, description):
17451736
help=argparse.SUPPRESS,
17461737
default=False,
17471738
)
1748-
arg_parser.add_argument(
1749-
"--target",
1750-
"-t",
1751-
dest="target_path",
1752-
help="the target binary path that should be used for interactive crashlog (optional)",
1753-
default=None,
1754-
)
1755-
arg_parser.add_argument(
1756-
"--skip-status",
1757-
"-s",
1758-
dest="skip_status",
1759-
action="store_true",
1760-
help="prevent the interactive crashlog to dump the process status and thread backtrace at launch",
1761-
default=False,
1762-
)
1763-
legacy_group = arg_parser.add_mutually_exclusive_group()
1764-
legacy_group.add_argument(
1765-
"-i",
1766-
"--interactive",
1767-
action="store_true",
1768-
help=argparse.SUPPRESS,
1769-
)
1770-
legacy_group.add_argument(
1771-
"-b",
1772-
"--batch",
1773-
action="store_true",
1774-
help=argparse.SUPPRESS,
1775-
)
1776-
1739+
if add_interactive_options:
1740+
arg_parser.add_argument(
1741+
"-i",
1742+
"--interactive",
1743+
action="store_true",
1744+
help="parse a crash log and load it in a ScriptedProcess",
1745+
default=False,
1746+
)
1747+
arg_parser.add_argument(
1748+
"-b",
1749+
"--batch",
1750+
action="store_true",
1751+
help="dump symbolicated stackframes without creating a debug session",
1752+
default=True,
1753+
)
1754+
arg_parser.add_argument(
1755+
"--target",
1756+
"-t",
1757+
dest="target_path",
1758+
help="the target binary path that should be used for interactive crashlog (optional)",
1759+
default=None,
1760+
)
1761+
arg_parser.add_argument(
1762+
"--skip-status",
1763+
"-s",
1764+
dest="skip_status",
1765+
action="store_true",
1766+
help="prevent the interactive crashlog to dump the process status and thread backtrace at launch",
1767+
default=False,
1768+
)
17771769
return arg_parser
17781770

17791771

@@ -1786,7 +1778,7 @@ def CrashLogOptionParser():
17861778
created that has all of the shared libraries loaded at the load addresses found in the crash log file. This allows
17871779
you to explore the program as if it were stopped at the locations described in the crash log and functions can
17881780
be disassembled and lookups can be performed using the addresses found in the crash log."""
1789-
return CreateSymbolicateCrashLogOptions("crashlog", description)
1781+
return CreateSymbolicateCrashLogOptions("crashlog", description, True)
17901782

17911783

17921784
def SymbolicateCrashLogs(debugger, command_args, result, is_command):
@@ -1802,35 +1794,8 @@ def SymbolicateCrashLogs(debugger, command_args, result, is_command):
18021794
result.SetError(str(e))
18031795
return
18041796

1805-
# To avoid breaking existing users, we should keep supporting legacy flags
1806-
# even if we don't use them / advertise them anymore.
1807-
if not options.mode:
1808-
if options.batch:
1809-
options.mode = CrashLogLoadingMode.batch
1810-
else:
1811-
options.mode = CrashLogLoadingMode.interactive
1812-
1813-
if options.mode != CrashLogLoadingMode.interactive and (
1814-
options.target_path or options.skip_status
1815-
):
1816-
print(
1817-
"Target path (-t) and skipping process status (-s) options can only used in interactive mode (-m=interactive)."
1818-
)
1819-
print("Aborting symbolication.")
1820-
arg_parser.print_help()
1821-
return
1822-
1823-
if options.version:
1824-
print(debugger.GetVersionString())
1825-
return
1826-
1827-
if options.debug:
1828-
print("command_args = %s" % command_args)
1829-
print("options", options)
1830-
print("args", options.reports)
1831-
18321797
# Interactive mode requires running the crashlog command from inside lldb.
1833-
if options.mode == CrashLogLoadingMode.interactive and not is_command:
1798+
if options.interactive and not is_command:
18341799
lldb_exec = (
18351800
subprocess.check_output(["/usr/bin/xcrun", "-f", "lldb"])
18361801
.decode("utf-8")
@@ -1856,24 +1821,31 @@ def SymbolicateCrashLogs(debugger, command_args, result, is_command):
18561821
print(debugger.GetVersionString())
18571822
return
18581823

1824+
if options.debug:
1825+
print("command_args = %s" % command_args)
1826+
print("options", options)
1827+
print("args", options.reports)
1828+
18591829
if options.debug_delay > 0:
18601830
print("Waiting %u seconds for debugger to attach..." % options.debug_delay)
18611831
time.sleep(options.debug_delay)
18621832
error = lldb.SBError()
18631833

18641834
def should_run_in_interactive_mode(options, ci):
1865-
if options.mode == CrashLogLoadingMode.batch:
1866-
return False
1867-
elif ci and ci.IsInteractive():
1835+
if options.interactive:
18681836
return True
1837+
elif options.batch:
1838+
return False
1839+
# elif ci and ci.IsInteractive():
1840+
# return True
18691841
else:
1870-
return sys.stdout.isatty()
1842+
return False
18711843

18721844
ci = debugger.GetCommandInterpreter()
18731845

18741846
if options.reports:
18751847
for crashlog_file in options.reports:
1876-
crashlog_path = os.path.normpath(os.path.expanduser(crashlog_file))
1848+
crashlog_path = os.path.expanduser(crashlog_file)
18771849
if not os.path.exists(crashlog_path):
18781850
raise FileNotFoundError(
18791851
"crashlog file %s does not exist" % crashlog_path

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/altered_threadState.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RUN: %clang_host -g %S/Inputs/test.c -o %t.out
22
# RUN: cp %S/Inputs/altered_threadState.crash %t.crash
33
# RUN: %python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}'
4-
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog -b %t.crash' 2>&1 | FileCheck %s
4+
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
55

66
# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
77

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
# RUN: cp %S/Inputs/a.out.ips %t.crash
44
# RUN: %python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}' --json
5-
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog --mode batch %t.crash' 2>&1 | FileCheck %s
6-
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog --mode batch -c %t.crash' 2>&1 | FileCheck %s
5+
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
6+
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog -c %t.crash' 2>&1 | FileCheck %s
77

88
# RUN: cp %S/Inputs/a.out.ips %t.nometadata.crash
99
# RUN: %python %S/patch-crashlog.py --binary %t.out --crashlog %t.nometadata.crash --offsets '{"main":20, "bar":9, "foo":16}' --json --no-metadata
10-
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog --mode batch %t.nometadata.crash' 2>&1 | FileCheck %s
10+
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.nometadata.crash' 2>&1 | FileCheck %s
1111

1212
# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
1313

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# RUN: cp %S/Inputs/no_threadState.ips %t.crash
44
# RUN: %python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}' --json
5-
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog --mode batch %t.crash' 2>&1 | FileCheck %s
5+
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
66

77
# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
88

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# RUN: mkdir -p %t.dir
44
# RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > %t.dir/multithread-test
55
# RUN: %lldb -b -o 'command script import lldb.macosx.crashlog' \
6-
# RUN: -o 'crashlog -a -s -t %t.dir/multithread-test %S/Inputs/interactive_crashlog/multithread-test.ips' \
6+
# RUN: -o 'crashlog -a -i -s -t %t.dir/multithread-test %S/Inputs/interactive_crashlog/multithread-test.ips' \
77
# RUN: -o 'command source -s 0 %s' 2>&1 | FileCheck %s
88

99
# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RUN: %clang_host -g %S/Inputs/test.c -o %t.out
22
# RUN: cp %S/Inputs/a.out.crash %t.crash
33
# RUN: %python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}'
4-
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog -b %t.crash' 2>&1 | FileCheck %s
4+
# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
55

66
# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
77

0 commit comments

Comments
 (0)