krb5 commit: In k5test, look for lldb if gdb is not found

Greg Hudson ghudson at mit.edu
Wed Feb 23 01:42:43 EST 2022


https://github.com/krb5/krb5/commit/06e108a5eeb967361493ef1924ce7334f00cccc0
commit 06e108a5eeb967361493ef1924ce7334f00cccc0
Author: Greg Hudson <ghudson at mit.edu>
Date:   Thu Feb 10 15:02:14 2022 -0500

    In k5test, look for lldb if gdb is not found
    
    XCode for macOS provides lldb but not gdb.  For convenience, make
    k5test default to lldb if gdb is not found in the path.

 src/util/k5test.py |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/util/k5test.py b/src/util/k5test.py
index bd71a45..619f199 100644
--- a/src/util/k5test.py
+++ b/src/util/k5test.py
@@ -575,8 +575,7 @@ def _parse_args():
     parser.add_option('--debug', dest='debug', metavar='NUM',
                       help='Debug numbered command (or "all")')
     parser.add_option('--debugger', dest='debugger', metavar='COMMAND',
-                      help='Debugger command (default is gdb --args)',
-                      default='gdb --args')
+                      help='Debugger command (default is gdb --args)')
     parser.add_option('--stop-before', dest='stopb', metavar='NUM',
                       help='Stop before numbered command (or "all")')
     parser.add_option('--stop-after', dest='stopa', metavar='NUM',
@@ -589,12 +588,21 @@ def _parse_args():
     verbose = options.verbose
     testpass = options.testpass
     _debug = _parse_cmdnum('--debug', options.debug)
-    _debugger_command = shlex.split(options.debugger)
     _stop_before = _parse_cmdnum('--stop-before', options.stopb)
     _stop_after = _parse_cmdnum('--stop-after', options.stopa)
     _shell_before = _parse_cmdnum('--shell-before', options.shellb)
     _shell_after = _parse_cmdnum('--shell-after', options.shella)
 
+    if options.debugger is not None:
+        _debugger_command = shlex.split(options.debugger)
+    elif which('gdb') is not None:
+        _debugger_command = ['gdb', '--args']
+    elif which('lldb') is not None:
+        _debugger_command = ['lldb', '--']
+    elif options.debug is not None:
+        print('Cannot find a debugger; use --debugger=COMMAND')
+        sys.exit(1)
+
 
 # Translate a command number spec.  -1 means all, None means none.
 def _parse_cmdnum(optname, str):


More information about the cvs-krb5 mailing list