Skip to content

Commit 2823c22

Browse files
fritzrChad Smith
authored and
Chad Smith
committed
Issue #194: Change --args to match 'gdb --args'. 'cmd' now only takes program name. (#198)
* Issue #194: Change --args to match 'gdb --args'. 'cmd' now only takes program name. * Use mutex group for --args|cmd and fix cmd to use a list type. * Update --args help text
1 parent ecf3a39 commit 2823c22

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

gdbgui/backend.py

+22-19
Original file line numberDiff line numberDiff line change
@@ -772,22 +772,11 @@ def main():
772772
parser = argparse.ArgumentParser(description=__doc__)
773773

774774
gdb_group = parser.add_argument_group(title="gdb commands")
775+
args_group = parser.add_mutually_exclusive_group()
775776
network = parser.add_argument_group(title="gdbgui network settings")
776777
security = parser.add_argument_group(title="security settings")
777778
other = parser.add_argument_group(title="other settings")
778779

779-
gdb_group.add_argument(
780-
"cmd",
781-
nargs="*",
782-
help="The binary and arguments to run in gdb. Example: './mybinary myarg -flag1 -flag2'",
783-
default=[],
784-
)
785-
gdb_group.add_argument(
786-
"--args",
787-
nargs="+",
788-
help='Alias for cmd argument above. Example: gdbgui --args "./mybinary myarg -flag1 -flag2"',
789-
default=[],
790-
)
791780
gdb_group.add_argument(
792781
"-x", "--gdb_cmd_file", help="Execute GDB commands from file."
793782
)
@@ -875,6 +864,26 @@ def main():
875864
"Pass this flag when debugging gdbgui itself to automatically reload the server when changes are detected",
876865
action="store_true",
877866
)
867+
868+
args_group.add_argument(
869+
"cmd",
870+
nargs='?',
871+
type=lambda prog : [prog],
872+
help='Name of the binary to run in gdb. To pass flags to the binary,'
873+
' use --args instead.'
874+
' Example: gdbgui ./mybinary [gdbgui-args...]',
875+
default=[],
876+
)
877+
args_group.add_argument(
878+
"--args",
879+
nargs=argparse.REMAINDER,
880+
help='Specify the executable file and any arguments. All arguments are'
881+
' taken literally, so if used, this must be the last argument'
882+
' passed to gdbgui.'
883+
' Example: gdbgui [...] --args ./mybinary myarg -flag1 -flag2',
884+
default=[],
885+
)
886+
878887
args = parser.parse_args()
879888

880889
initialize_preferences()
@@ -883,13 +892,7 @@ def main():
883892
print(__version__)
884893
return
885894

886-
if args.cmd and args.args:
887-
print("Cannot specify command and args. Must specify one or the other.")
888-
exit(1)
889-
if args.cmd:
890-
cmd = args.cmd
891-
else:
892-
cmd = args.args
895+
cmd = args.cmd or args.args
893896

894897
app.config["initial_binary_and_args"] = cmd
895898
app.config["rr"] = args.rr

0 commit comments

Comments
 (0)