This change essentially adds the command -file-list-exec-source-file to the mi commands. * mi-cmd-file.c: Added file to implement mi file commands. * mi-getopt.c: Added mi_valid_noargs to verify if a set of parameters passed to an MI function has no arguments * mi-getopt.h: Prototyped mi_valid_noargs * mi-cmds.c: Added -file-list-exec-source-file command. * mi-cmds.h: Added -file-list-exec-source-file to proto list. * doc/gdb.texinfo: Document -file-list-exec-source-file. * mi-file.exp: Added testcase to test -file-list-exec-source-file. Thanks, Bob Rossi Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.357 diff -w -u -r1.357 Makefile.in --- Makefile.in 2 Apr 2003 03:02:46 -0000 1.357 +++ Makefile.in 2 Apr 2003 19:30:31 -0000 @@ -168,14 +168,14 @@ SUBDIR_MI_OBS = \ mi-out.o mi-console.o \ mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \ - mi-cmd-disas.o \ + mi-cmd-file.o mi-cmd-disas.o \ mi-interp.o \ mi-main.o mi-parse.o mi-getopt.o SUBDIR_MI_SRCS = \ mi/mi-out.c mi/mi-console.c \ mi/mi-cmds.c mi/mi-cmd-env.c \ mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \ - mi/mi-cmd-disas.c \ + mi/mi-cmd-file.c mi/mi-cmd-disas.c \ mi/mi-interp.c \ mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c SUBDIR_MI_DEPS = @@ -2546,6 +2546,10 @@ $(ui_out_h) $(mi_out_h) $(breakpoint_h) $(gdb_string_h) \ $(mi_getopt_h) $(gdb_events_h) $(gdb_h) $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-break.c +mi-cmd-file.o: $(srcdir)/mi/mi-cmd-file.c $(defs_h) $(mi_cmds_h) \ + $(ui_out_h) $(mi_out_h) $(breakpoint_h) $(gdb_string_h) \ + $(mi_getopt_h) $(gdb_events_h) $(gdb_h) + $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-file.c mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_h) \ $(mi_cmds_h) $(mi_getopt_h) $(ui_out_h) $(gdb_string_h) $(disasm_h) $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-disas.c Index: doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.154 diff -w -u -r1.154 gdb.texinfo --- doc/gdb.texinfo 27 Mar 2003 15:17:34 -0000 1.154 +++ doc/gdb.texinfo 2 Apr 2003 19:30:57 -0000 @@ -16337,6 +16337,32 @@ N.A. +@subheading The @code{-file-list-exec-source-file} Command +@findex -file-list-exec-source-file + +@subsubheading Synopsis + +@smallexample + -file-list-exec-source-file +@end smallexample + +List the line number, the current source file, and the absolute path +to the current source file for the current executable. + +@subsubheading @value{GDBN} Command + +There's no @value{GDBN} command which directly corresponds to this one. + +@subsubheading Example + +@smallexample +(@value{GDBP}) +123-file-list-exec-source-file +123^done,line="1",file="foo.c",fullname="/home/bar/foo.c" +(@value{GDBP}) +@end smallexample + + @subheading The @code{-file-list-exec-source-files} Command @findex -file-list-exec-source-files Index: mi/mi-cmds.c =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v retrieving revision 1.10 diff -w -u -r1.10 mi-cmds.c --- mi/mi-cmds.c 6 Feb 2003 01:19:12 -0000 1.10 +++ mi/mi-cmds.c 2 Apr 2003 19:30:57 -0000 @@ -80,6 +80,7 @@ {"file-exec-and-symbols", "file %s", 0}, {"file-exec-file", "exec-file %s", 0}, {"file-list-exec-sections", 0, 0}, + {"file-list-exec-source-file", 0, 0, mi_cmd_file_list_exec_source_file}, {"file-list-exec-source-files", 0, 0}, {"file-list-shared-libraries", 0, 0}, {"file-list-symbol-files", 0, 0}, Index: mi/mi-cmds.h =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v retrieving revision 1.7 diff -w -u -r1.7 mi-cmds.h --- mi/mi-cmds.h 6 Feb 2003 01:19:12 -0000 1.7 +++ mi/mi-cmds.h 2 Apr 2003 19:30:58 -0000 @@ -80,6 +80,7 @@ extern mi_cmd_args_ftype mi_cmd_exec_step_instruction; extern mi_cmd_args_ftype mi_cmd_exec_until; extern mi_cmd_args_ftype mi_cmd_exec_interrupt; +extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file; extern mi_cmd_argv_ftype mi_cmd_gdb_exit; extern mi_cmd_argv_ftype mi_cmd_interpreter_exec; extern mi_cmd_argv_ftype mi_cmd_stack_info_depth; Index: mi/mi-getopt.c =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-getopt.c,v retrieving revision 1.6 diff -w -u -r1.6 mi-getopt.c --- mi/mi-getopt.c 6 Mar 2001 08:21:45 -0000 1.6 +++ mi/mi-getopt.c 2 Apr 2003 19:30:58 -0000 @@ -74,3 +74,19 @@ } error ("%s: Unknown option ``%s''", prefix, arg + 1); } + +int +mi_valid_noargs(const char *prefix, int argc, char **argv) +{ + int optind = 0; + char *optarg; + static struct mi_opt opts[] = + { + 0 + }; + + if ( mi_getopt(prefix, argc, argv, opts, &optind, &optarg) == -1 ) + return 1; + else + return 0; +} Index: mi/mi-getopt.h =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-getopt.h,v retrieving revision 1.4 diff -w -u -r1.4 mi-getopt.h --- mi/mi-getopt.h 6 Mar 2001 08:21:45 -0000 1.4 +++ mi/mi-getopt.h 2 Apr 2003 19:30:58 -0000 @@ -57,4 +57,24 @@ struct mi_opt; +/* mi_valid_noargs + + Determines if ARGC/ARGV are a valid set of parameters to satisfy + an MI function that is not supposed to recieve any arguments. + + An MI function that should not recieve arguments can still be + passed parameters after the special option '--' such as below. + + Example: The MI function -exec-run takes no args. + However, the client may pass '-exec-run -- -a ...' + See PR-783 + + PREFIX is passed to mi_getopt for an error message. + + This function Returns 1 if the parameter pair ARGC/ARGV are valid + for an MI function that takes no arguments. Otherwise, it returns 0 + and the appropriate error message is displayed by mi_getopt. */ + +extern int mi_valid_noargs (const char *prefix, int argc, char **argv); + #endif