[lldb/crashlog] Show help when the command is called without any argument
authorMed Ismail Bennani <medismail.bennani@gmail.com>
Wed, 8 Jun 2022 23:21:24 +0000 (16:21 -0700)
committerMed Ismail Bennani <medismail.bennani@gmail.com>
Fri, 10 Jun 2022 20:44:43 +0000 (13:44 -0700)
This patch changes the `crashlog` command behavior to print the help
message if no argument was provided with the command.

rdar://94576026

Differential Revision: https://reviews.llvm.org/D127362

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
lldb/examples/python/crashlog.py
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test [new file with mode: 0644]

index b214576..c30a0ec 100755 (executable)
@@ -1199,6 +1199,11 @@ be disassembled and lookups can be performed using the addresses found in the cr
 
 def SymbolicateCrashLogs(debugger, command_args):
     option_parser = CrashLogOptionParser()
+
+    if not len(command_args):
+        option_parser.print_help()
+        return
+
     try:
         (options, args) = option_parser.parse_args(command_args)
     except:
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test
new file mode 100644 (file)
index 0000000..d35e623
--- /dev/null
@@ -0,0 +1,9 @@
+# RUN: %lldb -o 'command script import lldb.macosx.crashlog' -o 'crashlog' 2>&1 | FileCheck %s
+
+# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
+
+# CHECK: Usage: crashlog [options] <FILE> [FILE ...]
+# CHECK: Symbolicate one or more darwin crash log files to provide source file and line
+# CHECK: Options:
+# CHECK:  -h, --help            show this help message and exit
+