From f5a8abd159782e9fd63aa8974e4fb1ea66ac2ccb Mon Sep 17 00:00:00 2001 From: Fritz Reese Date: Mon, 21 May 2018 16:16:16 -0400 Subject: [PATCH 1/3] Issue #194: Change --args to match 'gdb --args'. 'cmd' now only takes program name. --- gdbgui/backend.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/gdbgui/backend.py b/gdbgui/backend.py index b0143209..c17d6e52 100755 --- a/gdbgui/backend.py +++ b/gdbgui/backend.py @@ -765,18 +765,6 @@ def main(): security = parser.add_argument_group(title="security settings") other = parser.add_argument_group(title="other settings") - gdb_group.add_argument( - "cmd", - nargs="*", - help="The binary and arguments to run in gdb. Example: './mybinary myarg -flag1 -flag2'", - default=[], - ) - gdb_group.add_argument( - "--args", - nargs="+", - help='Alias for cmd argument above. Example: gdbgui --args "./mybinary myarg -flag1 -flag2"', - default=[], - ) gdb_group.add_argument( "-x", "--gdb_cmd_file", help="Execute GDB commands from file." ) @@ -864,6 +852,24 @@ def main(): "Pass this flag when debugging gdbgui itself to automatically reload the server when changes are detected", action="store_true", ) + + gdb_group.add_argument( + "--args", + nargs=argparse.REMAINDER, + help='All remaining args are taken as the binary and arguments to run' + ' in gdb (as with gdb --args).' + ' Example: gdbgui [...] --args ./mybinary myarg -flag1 -flag2', + default=[], + ) + gdb_group.add_argument( + "cmd", + nargs='?', + help='Name of the binary to run in gdb. To pass flags to the binary,' + ' use --args.' + ' Example: gdbgui ./mybinary [gdbgui-args...]', + default=[], + ) + args = parser.parse_args() initialize_preferences() From caa69a466727b0c3bff568a4885af440eac7077f Mon Sep 17 00:00:00 2001 From: Fritz Reese Date: Mon, 28 May 2018 13:53:56 -0400 Subject: [PATCH 2/3] Use mutex group for --args|cmd and fix cmd to use a list type. --- gdbgui/backend.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/gdbgui/backend.py b/gdbgui/backend.py index c17d6e52..f55beb36 100755 --- a/gdbgui/backend.py +++ b/gdbgui/backend.py @@ -761,6 +761,7 @@ def main(): parser = argparse.ArgumentParser(description=__doc__) gdb_group = parser.add_argument_group(title="gdb commands") + args_group = parser.add_mutually_exclusive_group() network = parser.add_argument_group(title="gdbgui network settings") security = parser.add_argument_group(title="security settings") other = parser.add_argument_group(title="other settings") @@ -853,7 +854,16 @@ def main(): action="store_true", ) - gdb_group.add_argument( + args_group.add_argument( + "cmd", + nargs='?', + type=lambda prog : [prog], + help='Name of the binary to run in gdb. To pass flags to the binary,' + ' use --args instead.' + ' Example: gdbgui ./mybinary [gdbgui-args...]', + default=[], + ) + args_group.add_argument( "--args", nargs=argparse.REMAINDER, help='All remaining args are taken as the binary and arguments to run' @@ -861,14 +871,6 @@ def main(): ' Example: gdbgui [...] --args ./mybinary myarg -flag1 -flag2', default=[], ) - gdb_group.add_argument( - "cmd", - nargs='?', - help='Name of the binary to run in gdb. To pass flags to the binary,' - ' use --args.' - ' Example: gdbgui ./mybinary [gdbgui-args...]', - default=[], - ) args = parser.parse_args() @@ -878,13 +880,7 @@ def main(): print(__version__) return - if args.cmd and args.args: - print("Cannot specify command and args. Must specify one or the other.") - exit(1) - if args.cmd: - cmd = args.cmd - else: - cmd = args.args + cmd = args.cmd or args.args app.config["initial_binary_and_args"] = cmd app.config["rr"] = args.rr From d5d55b97076aa7c64fd368788849e970c64b6be2 Mon Sep 17 00:00:00 2001 From: Fritz Reese Date: Mon, 28 May 2018 13:53:19 -0400 Subject: [PATCH 3/3] Update --args help text --- gdbgui/backend.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gdbgui/backend.py b/gdbgui/backend.py index f55beb36..8830e227 100755 --- a/gdbgui/backend.py +++ b/gdbgui/backend.py @@ -866,9 +866,10 @@ def main(): args_group.add_argument( "--args", nargs=argparse.REMAINDER, - help='All remaining args are taken as the binary and arguments to run' - ' in gdb (as with gdb --args).' - ' Example: gdbgui [...] --args ./mybinary myarg -flag1 -flag2', + help='Specify the executable file and any arguments. All arguments are' + ' taken literally, so if used, this must be the last argument' + ' passed to gdbgui.' + ' Example: gdbgui [...] --args ./mybinary myarg -flag1 -flag2', default=[], )