[Lldb-commits] [lldb] 3f3db13 - [lldb/crashlog] Add `-V|--version` option

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 10 16:18:56 PDT 2022


Author: Med Ismail Bennani
Date: 2022-08-10T16:18:46-07:00
New Revision: 3f3db135251c85503fde681dd34e8ced0606aee2

URL: https://github.com/llvm/llvm-project/commit/3f3db135251c85503fde681dd34e8ced0606aee2
DIFF: https://github.com/llvm/llvm-project/commit/3f3db135251c85503fde681dd34e8ced0606aee2.diff

LOG: [lldb/crashlog] Add `-V|--version` option

This patch introduces a new option to the crashlog command to get the
the script version.

Since `crashlog.py` is not actually versioned, this returns lldb's
version instead.

rdar://98392669

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

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>

Added: 
    

Modified: 
    lldb/examples/python/crashlog.py
    lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test

Removed: 
    


################################################################################
diff  --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 4773a136bfae0..33f4c4f3b3680 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1089,6 +1089,13 @@ def CreateSymbolicateCrashLogOptions(
     usage = "usage: %prog [options] <FILE> [FILE ...]"
     option_parser = optparse.OptionParser(
         description=description, prog='crashlog', usage=usage)
+    option_parser.add_option(
+        '--version',
+        '-V',
+        dest='version',
+        action='store_true',
+        help='Show crashlog version',
+        default=False)
     option_parser.add_option(
         '--verbose',
         '-v',
@@ -1233,6 +1240,10 @@ def SymbolicateCrashLogs(debugger, command_args, result):
     except:
         return
 
+    if options.version:
+        print(debugger.GetVersionString())
+        return
+
     if options.debug:
         print('command_args = %s' % command_args)
         print('options', options)

diff  --git a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
index 51b1221fc2ab0..abd1e7c3da53d 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
@@ -1,8 +1,11 @@
 # REQUIRES: python, native && target-aarch64 && system-darwin
 
 # RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
+# RUN: -o 'crashlog -V' \
 # RUN: -o 'crashlog -a -i -t /this_file_does_not_exist %S/Inputs/interactive_crashlog/multithread-test.ips' 2>&1 | FileCheck %s
 
 # CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
 
+# CHECK: lldb{{.*}}version
+
 # CHECK: error: couldn't create target provided by the user (/this_file_does_not_exist)


        


More information about the lldb-commits mailing list