@@ -772,22 +772,11 @@ def main():
772
772
parser = argparse .ArgumentParser (description = __doc__ )
773
773
774
774
gdb_group = parser .add_argument_group (title = "gdb commands" )
775
+ args_group = parser .add_mutually_exclusive_group ()
775
776
network = parser .add_argument_group (title = "gdbgui network settings" )
776
777
security = parser .add_argument_group (title = "security settings" )
777
778
other = parser .add_argument_group (title = "other settings" )
778
779
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
- )
791
780
gdb_group .add_argument (
792
781
"-x" , "--gdb_cmd_file" , help = "Execute GDB commands from file."
793
782
)
@@ -875,6 +864,26 @@ def main():
875
864
"Pass this flag when debugging gdbgui itself to automatically reload the server when changes are detected" ,
876
865
action = "store_true" ,
877
866
)
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
+
878
887
args = parser .parse_args ()
879
888
880
889
initialize_preferences ()
@@ -883,13 +892,7 @@ def main():
883
892
print (__version__ )
884
893
return
885
894
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
893
896
894
897
app .config ["initial_binary_and_args" ] = cmd
895
898
app .config ["rr" ] = args .rr
0 commit comments