* Adding -file-list-exec-source-file command to GDB/MI
@ 2003-03-10 0:31 Bob Rossi
2003-03-10 4:28 ` Eli Zaretskii
0 siblings, 1 reply; 36+ messages in thread
From: Bob Rossi @ 2003-03-10 0:31 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 4870 bytes --]
Hi,
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-cmds.c: Added -file-list-exec-source-file command.
* mi-cmds.h: Added -file-list-exec-source-file to proto list.
* gdbmi.texinfo: Document -file-list-exec-source-file.
* mi-file.exp: Added testcase to test -file-list-exec-source-file.
Also, do you think it would be good if the function
-file-list-exec-source-file optionally took an argument ( a filename ).
If it reiceived an argument, it would return the absolute path to that
file.
I think the normal way a front end gets the absolute path to a file now
is,
1. list filename.c
2. info source
3. parse the output looking for 'Located in '
This optional argument would solve that problem.
Thanks,
Bob Rossi
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.328
diff -c -r1.328 Makefile.in
*** gdb/Makefile.in 7 Feb 2003 05:33:44 -0000 1.328
--- gdb/Makefile.in 10 Feb 2003 20:51:47 -0000
***************
*** 168,181 ****
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-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-interp.c \
mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
SUBDIR_MI_DEPS =
--- 168,181 ----
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-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-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 =
***************
*** 2494,2499 ****
--- 2494,2503 ----
$(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: gdb/mi/gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.33
diff -c -r1.33 gdbmi.texinfo
*** gdb/mi/gdbmi.texinfo 4 Feb 2003 18:41:29 -0000 1.33
--- gdb/mi/gdbmi.texinfo 10 Feb 2003 20:51:55 -0000
***************
*** 2340,2345 ****
--- 2340,2355 ----
@subsubheading Example
N.A.
+ @subheading The @code{-file-list-exec-source-file} Command
+ @findex -file-list-exec-source-file
+
+ @subsubheading Synopsis
+
+ @example
+ -file-list-exec-source-file
+ @end example
+
+ List the current source file and line for the current executable.
@subheading The @code{-file-list-exec-source-files} Command
@findex -file-list-exec-source-files
Index: gdb/mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.10
diff -c -r1.10 mi-cmds.c
*** gdb/mi/mi-cmds.c 6 Feb 2003 01:19:12 -0000 1.10
--- gdb/mi/mi-cmds.c 10 Feb 2003 20:51:55 -0000
***************
*** 80,85 ****
--- 80,86 ----
{"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: gdb/mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.7
diff -c -r1.7 mi-cmds.h
*** gdb/mi/mi-cmds.h 6 Feb 2003 01:19:12 -0000 1.7
--- gdb/mi/mi-cmds.h 10 Feb 2003 20:51:55 -0000
***************
*** 80,85 ****
--- 80,86 ----
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;
[-- Attachment #2: mi-file.exp --]
[-- Type: text/plain, Size: 2145 bytes --]
# Copyright 1999 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
#
# Test essential Machine interface (MI) operations
#
# Verify that, using the MI, we can run a simple program and perform basic
# debugging activities like: insert breakpoints, run the program,
# step, next, continue until it ends and, last but not least, quit.
#
# The goal is not to test gdb functionality, which is done by other tests,
# but to verify the correct output response to MI operations.
#
load_lib mi-support.exp
set MIFLAGS "-i=mi"
gdb_exit
if [mi_gdb_start] {
continue
}
set testfile "basics"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
proc test_tbreak_creation_and_listing {} {
global binfile
set abs_srcfile ${binfile}.c
# get the absolute path to the current file
mi_gdb_test "111-file-list-exec-source-file" \
"111\\\^done,line=\"23\",file=\"${abs_srcfile}\"" \
"request absolute path of current source file"
}
test_tbreak_creation_and_listing
mi_gdb_exit
return 0
[-- Attachment #3: mi-cmd-file.c --]
[-- Type: text/x-csrc, Size: 2060 bytes --]
/* MI Command Set - breakpoint and watchpoint commands.
Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Cygnus Solutions (a Red Hat company).
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "mi-cmds.h"
#include "ui-out.h"
#include "symtab.h"
#include "source.h"
/* Return to the client the absolute path and line number of the
current file being executed. */
enum mi_cmd_result
mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc)
{
struct symtab_and_line st;
if (argc != 0)
error ("mi_cmd_file_list_exec_source_file: Usage: No args");
/* Set the default file and line, also get them */
set_default_source_symtab_and_line();
st = get_current_source_symtab_and_line();
/* We should always get a symtab. */
if (!st.symtab)
error ("mi_cmd_file_list_exec_source_file: No symtab");
/* Extract the fullname if it is not known yet */
if (st.symtab->fullname == NULL)
symtab_to_filename (st.symtab);
/* We may not be able to open the file (not available). */
if (st.symtab->fullname == NULL)
error ("mi_cmd_file_list_exec_source_file: File not found");
/* Print to the user the line and absolute file name */
ui_out_field_int (uiout, "line", st.line);
ui_out_field_string (uiout, "file", st.symtab->fullname);
return MI_CMD_DONE;
}
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-10 0:31 Adding -file-list-exec-source-file command to GDB/MI Bob Rossi
@ 2003-03-10 4:28 ` Eli Zaretskii
2003-03-18 2:10 ` Bob Rossi
0 siblings, 1 reply; 36+ messages in thread
From: Eli Zaretskii @ 2003-03-10 4:28 UTC (permalink / raw)
To: bob_rossi; +Cc: gdb-patches
> Date: Sun, 9 Mar 2003 19:31:17 -0500
> From: Bob Rossi <bob_rossi@cox.net>
>
> 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-cmds.c: Added -file-list-exec-source-file command.
> * mi-cmds.h: Added -file-list-exec-source-file to proto list.
> * gdbmi.texinfo: Document -file-list-exec-source-file.
> * mi-file.exp: Added testcase to test -file-list-exec-source-file.
The doco patch is approved.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-10 4:28 ` Eli Zaretskii
@ 2003-03-18 2:10 ` Bob Rossi
2003-03-18 5:46 ` Eli Zaretskii
0 siblings, 1 reply; 36+ messages in thread
From: Bob Rossi @ 2003-03-18 2:10 UTC (permalink / raw)
To: gdb-patches
On Mon, Mar 10, 2003 at 06:23:05AM +0200, Eli Zaretskii wrote:
> > Date: Sun, 9 Mar 2003 19:31:17 -0500
> > From: Bob Rossi <bob_rossi@cox.net>
> >
> > 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-cmds.c: Added -file-list-exec-source-file command.
> > * mi-cmds.h: Added -file-list-exec-source-file to proto list.
> > * gdbmi.texinfo: Document -file-list-exec-source-file.
> > * mi-file.exp: Added testcase to test -file-list-exec-source-file.
>
> The doco patch is approved.
This is my first patch. I was wondering, how long does it take to get
approved/rejected?
I am assuming that the 'doco' patch was for the documentation.
Is that correct?
I was hoping this patch would go into the next release of gdb.
Thanks,
Bob Rossi
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-18 2:10 ` Bob Rossi
@ 2003-03-18 5:46 ` Eli Zaretskii
0 siblings, 0 replies; 36+ messages in thread
From: Eli Zaretskii @ 2003-03-18 5:46 UTC (permalink / raw)
To: bob_rossi; +Cc: gdb-patches
> Date: Mon, 17 Mar 2003 21:10:31 -0500
> From: Bob Rossi <bob_rossi@cox.net>
> >
> > The doco patch is approved.
>
> This is my first patch. I was wondering, how long does it take to get
> approved/rejected?
It depends. If/when you feel you were waiting for too long, please
don't hesitate to send a reminder.
> I am assuming that the 'doco' patch was for the documentation.
> Is that correct?
Yes.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-04-02 20:24 Bob Rossi
2003-04-02 21:59 ` Andrew Cagney
@ 2003-04-03 2:54 ` Eli Zaretskii
1 sibling, 0 replies; 36+ messages in thread
From: Eli Zaretskii @ 2003-04-03 2:54 UTC (permalink / raw)
To: bob_rossi; +Cc: gdb-patches
> Date: Wed, 2 Apr 2003 14:46:26 -0500
> From: Bob Rossi <bob_rossi@cox.net>
>
> 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.
Okay for the manual patch.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-04-02 20:24 Bob Rossi
@ 2003-04-02 21:59 ` Andrew Cagney
2003-04-03 2:54 ` Eli Zaretskii
1 sibling, 0 replies; 36+ messages in thread
From: Andrew Cagney @ 2003-04-02 21:59 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
> 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.
Yes, ok. Just tweak the below GNU coding probs before committing.
> +int
> +mi_valid_noargs(const char *prefix, int argc, char **argv)
mi_valid_noargs (
> +{
> + int optind = 0;
> + char *optarg;
> + static struct mi_opt opts[] =
> + {
> + 0
> + };
> +
> + if ( mi_getopt(prefix, argc, argv, opts, &optind, &optarg) == -1 )
if (mi_getopt (prefix, ...., &optarg) == -1)
> + return 1;
> + else
> + return 0;
> +}
Andrew
^ permalink raw reply [flat|nested] 36+ messages in thread
* Adding -file-list-exec-source-file command to GDB/MI
@ 2003-04-02 20:24 Bob Rossi
0 siblings, 0 replies; 36+ messages in thread
From: Bob Rossi @ 2003-04-02 20:24 UTC (permalink / raw)
To: gdb-patches
Seems like this didn't go through the first time. Sorry if posted twice.
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
# Copyright 1999 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
#
# Test essential Machine interface (MI) operations
#
# Verify that, using the MI, we can run a simple program and perform basic
# debugging activities like: insert breakpoints, run the program,
# step, next, continue until it ends and, last but not least, quit.
#
# The goal is not to test gdb functionality, which is done by other tests,
# but to verify the correct output response to MI operations.
#
load_lib mi-support.exp
set MIFLAGS "-i=mi"
gdb_exit
if [mi_gdb_start] {
continue
}
set testfile "basics"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
proc test_tbreak_creation_and_listing {} {
global srcfile
global srcdir
global subdir
set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
# get the path and absolute path to the current executable
mi_gdb_test "111-file-list-exec-source-file" \
"111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
"request path info of current source file (${srcfile})"
}
test_tbreak_creation_and_listing
mi_gdb_exit
return 0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Adding -file-list-exec-source-file command to GDB/MI
@ 2003-04-02 20:24 Bob Rossi
2003-04-02 21:59 ` Andrew Cagney
2003-04-03 2:54 ` Eli Zaretskii
0 siblings, 2 replies; 36+ messages in thread
From: Bob Rossi @ 2003-04-02 20:24 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 6090 bytes --]
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
[-- Attachment #2: mi-cmd-file.c --]
[-- Type: text/x-csrc, Size: 2379 bytes --]
/* MI Command Set - breakpoint and watchpoint commands.
Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Cygnus Solutions (a Red Hat company).
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "mi-cmds.h"
#include "mi-getopt.h"
#include "ui-out.h"
#include "symtab.h"
#include "source.h"
/* Return to the client the absolute path and line number of the
current file being executed. */
enum mi_cmd_result
mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc)
{
struct symtab_and_line st;
int optind = 0;
char *optarg;
if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) )
error ("mi_cmd_file_list_exec_source_file: Usage: No args");
/* Set the default file and line, also get them */
set_default_source_symtab_and_line();
st = get_current_source_symtab_and_line();
/* We should always get a symtab.
Apparently, filename does not need to be tested for NULL.
The documentation in symtab.h suggests it will always be correct */
if (!st.symtab)
error ("mi_cmd_file_list_exec_source_file: No symtab");
/* Extract the fullname if it is not known yet */
if (st.symtab->fullname == NULL)
symtab_to_filename (st.symtab);
/* We may not be able to open the file (not available). */
if (st.symtab->fullname == NULL)
error ("mi_cmd_file_list_exec_source_file: File not found");
/* Print to the user the line, filename and fullname */
ui_out_field_int (uiout, "line", st.line);
ui_out_field_string (uiout, "file", st.symtab->filename);
ui_out_field_string (uiout, "fullname", st.symtab->fullname);
return MI_CMD_DONE;
}
[-- Attachment #3: mi-file.exp --]
[-- Type: text/plain, Size: 2258 bytes --]
# Copyright 1999 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
#
# Test essential Machine interface (MI) operations
#
# Verify that, using the MI, we can run a simple program and perform basic
# debugging activities like: insert breakpoints, run the program,
# step, next, continue until it ends and, last but not least, quit.
#
# The goal is not to test gdb functionality, which is done by other tests,
# but to verify the correct output response to MI operations.
#
load_lib mi-support.exp
set MIFLAGS "-i=mi"
gdb_exit
if [mi_gdb_start] {
continue
}
set testfile "basics"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
proc test_tbreak_creation_and_listing {} {
global srcfile
global srcdir
global subdir
set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
# get the path and absolute path to the current executable
mi_gdb_test "111-file-list-exec-source-file" \
"111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
"request path info of current source file (${srcfile})"
}
test_tbreak_creation_and_listing
mi_gdb_exit
return 0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-04-02 16:15 ` Bob Rossi
@ 2003-04-02 16:27 ` Andrew Cagney
0 siblings, 0 replies; 36+ messages in thread
From: Andrew Cagney @ 2003-04-02 16:27 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
>> >enum mi_cmd_result
>> >mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc)
>> >{
>> > struct symtab_and_line st;
>
>>
>> See:
>> http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=783
>>
>> Even though there are no arguments it will want to discard any "--". A
>> mi_getopt() call to strip off any leading "--". I think you'll want to
>> tweak that function so that calling it is easier - allow NULL OPT and
>> OPTARG?
>
>
> Ok, I've got all the changes down but this one.
>
> Instead of changing mi_getopt, I wrote a wrapper function called
> extern int mi_valid_noargs (const char *prefix, int argc, char **argv);
> and put it in mi_getopt.[ch].
>
> This function basically returns 1 if the arguments are valid for a
> function that takes no arguments, and 0 otherwise.
>
> What do you think?
>
> The reason I like this solution is because the caller doesn't need to concern
> itself with mi_getopt. So if the interface ever changes to mi_getopt,
> there will be less spots to fix. Also, It keeps the client smaller and
> less confusing.
>
> Bob Rossi
>
> The body looks something like this.
Ah, yes and yep. You'll need to GNUtify the coding style :-)
> extern int mi_valid_noargs(const char *prefix, int argc, char **argv) {
> int optind = 0;
> char *optarg;
> static struct mi_opt opts[] =
> {
> 0
> };
>
> int opt = mi_getopt(prefix, argc, argv, opts, &optind, &optarg);
>
> /* The end of the list was reached first try */
> if ( opt == -1 )
> return 1;
> else
> return 0;
> }
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-31 5:38 ` Andrew Cagney
2003-03-31 18:46 ` Bob Rossi
@ 2003-04-02 16:15 ` Bob Rossi
2003-04-02 16:27 ` Andrew Cagney
1 sibling, 1 reply; 36+ messages in thread
From: Bob Rossi @ 2003-04-02 16:15 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
> >enum mi_cmd_result
> >mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc)
> >{
> > struct symtab_and_line st;
>
> See:
> http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=783
>
> Even though there are no arguments it will want to discard any "--". A
> mi_getopt() call to strip off any leading "--". I think you'll want to
> tweak that function so that calling it is easier - allow NULL OPT and
> OPTARG?
Ok, I've got all the changes down but this one.
Instead of changing mi_getopt, I wrote a wrapper function called
extern int mi_valid_noargs (const char *prefix, int argc, char **argv);
and put it in mi_getopt.[ch].
This function basically returns 1 if the arguments are valid for a
function that takes no arguments, and 0 otherwise.
What do you think?
The reason I like this solution is because the caller doesn't need to concern
itself with mi_getopt. So if the interface ever changes to mi_getopt,
there will be less spots to fix. Also, It keeps the client smaller and
less confusing.
Bob Rossi
The body looks something like this.
extern int mi_valid_noargs(const char *prefix, int argc, char **argv) {
int optind = 0;
char *optarg;
static struct mi_opt opts[] =
{
0
};
int opt = mi_getopt(prefix, argc, argv, opts, &optind, &optarg);
/* The end of the list was reached first try */
if ( opt == -1 )
return 1;
else
return 0;
}
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-31 19:20 ` Jason Molenda
@ 2003-03-31 20:12 ` Andrew Cagney
0 siblings, 0 replies; 36+ messages in thread
From: Andrew Cagney @ 2003-03-31 20:12 UTC (permalink / raw)
To: Jason Molenda; +Cc: gdb-patches
> Ah, now I see. You didn't mean "That doesn't work", you meant "That
> doesn't work generally".
"Generally" isn't the issue. GDB needs changes that work. As you note
with #2
> #1 doesn't apply to us at Apple. #2 is a real problem - although
> the failure mode is that the UI re-fetches the stack, so it's not
> too traumatic. And because it only needs to re-fetch the 0th frame,
> it is fast. And you'll have the same problem with varobj's being
> deleted when your FP moves IIRC.
even for Apple, this doesn't work.
Per my original comment, and many previous posts, MI (varobj) needs to
switch to frame IDs.
> As for #3, I don't understand why the PC won't remain constant for
> a frame other than the 0th, but you're familiar with far more
> architectures than me. Obviously the currently executing frame
> will have a changing PC, but the frames higher up on the stack
> should stay constant unless they've executed some more.
The function address is needed when trying to correctly re-identify a
frame that has executed.
Andrew
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-31 18:52 ` Andrew Cagney
@ 2003-03-31 19:20 ` Jason Molenda
2003-03-31 20:12 ` Andrew Cagney
0 siblings, 1 reply; 36+ messages in thread
From: Jason Molenda @ 2003-03-31 19:20 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Mon, Mar 31, 2003 at 01:52:35PM -0500, Andrew Cagney wrote:
> >> > The other difference is the addition of FP here -- our UI uses the
> >> > PC and FP to uniquely identify stack frames
> >
> >>
> >> That doesn't work. The MI needs to be updated so that it uses frame
> >> ID's when identifying frames.
> >
> >
> > Uh, we have a bit of an existance proof that it does--in the form
> > of a PB+GDB that have been shipping like this for over a year.
>
> Unfortunatly, that doesn't mean that it works:
>
> - it doesn't handle architectures with multiple stacks (ia64)
> - it relies on $fp being constant through out the lifetime of the frame
> (including the prologue) and that is definitly not true
> - I suspect it is also making similar assumptions about $pc, it should
> be using func.
Ah, now I see. You didn't mean "That doesn't work", you meant "That
doesn't work generally".
#1 doesn't apply to us at Apple. #2 is a real problem - although
the failure mode is that the UI re-fetches the stack, so it's not
too traumatic. And because it only needs to re-fetch the 0th frame,
it is fast. And you'll have the same problem with varobj's being
deleted when your FP moves IIRC.
As for #3, I don't understand why the PC won't remain constant for
a frame other than the 0th, but you're familiar with far more
architectures than me. Obviously the currently executing frame
will have a changing PC, but the frames higher up on the stack
should stay constant unless they've executed some more.
Jason
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-31 18:46 ` Bob Rossi
@ 2003-03-31 18:56 ` Andrew Cagney
0 siblings, 0 replies; 36+ messages in thread
From: Andrew Cagney @ 2003-03-31 18:56 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
> On Mon, Mar 31, 2003 at 12:38:13AM -0500, Andrew Cagney wrote:
>
>> >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-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.
>
>>
>> I've attached a slightly tweaked version. It was checking for the path
>> to the executable instead of the source file (separate build / config
>> directories is the norm) (I'm also not sure what would happen if the
>> configure contained a relative path but worry about that when someone
>> notices :-)
>
>
> I am noticing this now. The variable
> set abs_srcfile [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
> has the value ("\./gdb\.mi/basics\.c") when I run the testcase.
> This is why I made it check for the path to the executable in the first
> place.
>
> What do you think we should do here? I have no idea.
Unfortunatly ditto. A pattern like:
"/.*/${srcfile}"
would at least check that it has gained a leading slash.
Expect/Dejagnu must have a realpath equivalent. Unfortunatly, I don't
know what it is.
> I like fullname because it is used already in symtab.h
>
> /* Full name of file as found by searching the source path.
> NULL if not yet known. */
>
> char *fullname;
sold.
Andrew
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-31 17:16 ` Jason Molenda
@ 2003-03-31 18:52 ` Andrew Cagney
2003-03-31 19:20 ` Jason Molenda
0 siblings, 1 reply; 36+ messages in thread
From: Andrew Cagney @ 2003-03-31 18:52 UTC (permalink / raw)
To: Jason Molenda; +Cc: gdb-patches
> On Mon, Mar 31, 2003 at 09:31:36AM -0500, Andrew Cagney wrote:
>
>>
>
>> > -stack-list-frames
>> > ^done,stack=[frame={level="0",addr="0x00001dc8",fp="0xbffffca0",func="foo",file="f/a.c",line="3",dir="/tmp/e/"}, [...]
>
>>
>> [...]
>>
>
>> > The other difference is the addition of FP here -- our UI uses the
>> > PC and FP to uniquely identify stack frames
>
>>
>> That doesn't work. The MI needs to be updated so that it uses frame
>> ID's when identifying frames.
>
>
> Uh, we have a bit of an existance proof that it does--in the form
> of a PB+GDB that have been shipping like this for over a year.
Unfortunatly, that doesn't mean that it works:
- it doesn't handle architectures with multiple stacks (ia64)
- it relies on $fp being constant through out the lifetime of the frame
(including the prologue) and that is definitly not true
- I suspect it is also making similar assumptions about $pc, it should
be using func.
Andrew
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-31 5:38 ` Andrew Cagney
@ 2003-03-31 18:46 ` Bob Rossi
2003-03-31 18:56 ` Andrew Cagney
2003-04-02 16:15 ` Bob Rossi
1 sibling, 1 reply; 36+ messages in thread
From: Bob Rossi @ 2003-03-31 18:46 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Mon, Mar 31, 2003 at 12:38:13AM -0500, Andrew Cagney wrote:
> >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-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.
>
> I've attached a slightly tweaked version. It was checking for the path
> to the executable instead of the source file (separate build / config
> directories is the norm) (I'm also not sure what would happen if the
> configure contained a relative path but worry about that when someone
> notices :-)
I am noticing this now. The variable
set abs_srcfile [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
has the value ("\./gdb\.mi/basics\.c") when I run the testcase.
This is why I made it check for the path to the executable in the first
place.
What do you think we should do here? I have no idea.
> Rather than file=..., should the field be called something like
> fullname=...., realpath= or fullpath=? That way, the same term can be
> used consistently through out MI.
I like fullname because it is used already in symtab.h
/* Full name of file as found by searching the source path.
NULL if not yet known. */
char *fullname;
>
> >enum mi_cmd_result
> >mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc)
> >{
> > struct symtab_and_line st;
>
> See:
> http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=783
>
> Even though there are no arguments it will want to discard any "--". A
> mi_getopt() call to strip off any leading "--". I think you'll want to
> tweak that function so that calling it is easier - allow NULL OPT and
> OPTARG?
>
> > /* Print to the user the line and absolute file name */
> > ui_out_field_int (uiout, "line", st.line);
> > ui_out_field_string (uiout, "file", st.symtab->fullname);
>
> Following on from above, should it print both "file" and "fullname"?
Yes, defiantly.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-31 14:31 ` Andrew Cagney
@ 2003-03-31 17:16 ` Jason Molenda
2003-03-31 18:52 ` Andrew Cagney
0 siblings, 1 reply; 36+ messages in thread
From: Jason Molenda @ 2003-03-31 17:16 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Mon, Mar 31, 2003 at 09:31:36AM -0500, Andrew Cagney wrote:
>
> > -stack-list-frames
> > ^done,stack=[frame={level="0",addr="0x00001dc8",fp="0xbffffca0",func="foo",file="f/a.c",line="3",dir="/tmp/e/"}, [...]
>
> [...]
>
> > The other difference is the addition of FP here -- our UI uses the
> > PC and FP to uniquely identify stack frames
>
> That doesn't work. The MI needs to be updated so that it uses frame
> ID's when identifying frames.
Uh, we have a bit of an existance proof that it does--in the form
of a PB+GDB that have been shipping like this for over a year.
I don't mean to indicate that this is the only thing the UI does,
but after an exec-next I think the sequence is something like -
retrieve frame #0 and #1, get the depth of the stack, send a
stack-list-frames-lite command (which returns just the PC and FP
for the frames - filling out the stack frame cache is really
expensive for a big application with a deep stack.) I don't remember
the exact sequence offhand, but that's basically it.
Our last source merge was early in your frame cache reworkings,
and we won't have another merge until we branch off for our next
release, so we can't look at using it for this release.
(the stack-list-frames-lite is recognized as a hack that is not
relevant in the face of all your frame code reworkings; I expect
we'll be switching over first thing after this release branches.)
Jason
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-31 8:13 ` Jason Molenda
@ 2003-03-31 14:31 ` Andrew Cagney
2003-03-31 17:16 ` Jason Molenda
0 siblings, 1 reply; 36+ messages in thread
From: Andrew Cagney @ 2003-03-31 14:31 UTC (permalink / raw)
To: Jason Molenda; +Cc: Bob Rossi, gdb-patches
> -stack-list-frames
> ^done,stack=[frame={level="0",addr="0x00001dc8",fp="0xbffffca0",func="foo",file="f/a.c",line="3",dir="/tmp/e/"}, [...]
[...]
> The other difference is the addition of FP here -- our UI uses the
> PC and FP to uniquely identify stack frames
That doesn't work. The MI needs to be updated so that it uses frame
ID's when identifying frames.
Andrew
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-31 4:22 ` Andrew Cagney
@ 2003-03-31 8:13 ` Jason Molenda
2003-03-31 14:31 ` Andrew Cagney
0 siblings, 1 reply; 36+ messages in thread
From: Jason Molenda @ 2003-03-31 8:13 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Bob Rossi, gdb-patches
On Sun, Mar 30, 2003 at 11:22:03PM -0500, Andrew Cagney wrote:
> >
> > Sure, I'll look into that. I would also like to add the extra field to
> > -break-list. Does that make sense to everyone else?
>
> Does to me.
Ah, I see why this has never been an issue at Apple. We control
the compiler, and -gstabs+ is the default debug output. This means
that we have the compilation directory at the start of each file,
e.g. (the file /tmp/e/f/a.c compiled from /tmp/e)
.stabs "/tmp/e/",100,0,0,.Ltext0
.stabs "f/a.c",100,0,0,.Ltext0
And we have a modification to MI in our gdb which includes that
directory in things like stack-list-frames. Here's the Apple gdb
output when stopped:
-stack-list-frames
^done,stack=[frame={level="0",addr="0x00001dc8",fp="0xbffffca0",func="foo",file="f/a.c",line="3",dir="/tmp/e/"}, [...]
And here's the FSF gdb:
-stack-list-frames
^done,stack=[frame={level="0 ",addr="0x0804830f",func="foo",file="f/a.c",line="3"}, [...]
The other difference is the addition of FP here -- our UI uses the
PC and FP to uniquely identify stack frames so it won't re-fetch
things unnecessarily while keeping its stack frame display current.
I send this as an aside, not as an argument against the change Bob
is proposing. The gdb developer community doesn't control gcc as
handily as we can at Apple, so this particular solution isn't
relevant. Although I see gcc 3.2's DWARF-2 output includes the
compilation directory.
J
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-29 0:41 Bob Rossi
@ 2003-03-31 5:38 ` Andrew Cagney
2003-03-31 18:46 ` Bob Rossi
2003-04-02 16:15 ` Bob Rossi
0 siblings, 2 replies; 36+ messages in thread
From: Andrew Cagney @ 2003-03-31 5:38 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1999 bytes --]
> 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-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.
I've attached a slightly tweaked version. It was checking for the path
to the executable instead of the source file (separate build / config
directories is the norm) (I'm also not sure what would happen if the
configure contained a relative path but worry about that when someone
notices :-)
> + @subheading The @code{-file-list-exec-source-file} Command
> + @findex -file-list-exec-source-file
> +
> + @subsubheading Synopsis
> +
> + @smallexample
> + -file-list-exec-source-file
Can you please expand this to include sample output vis:
(gdb)
111-file-list-exec-source-file
111^done,line="23",file="/home/scratch/GDB/src/gdb/testsuite/gdb.mi/basics.c"
(gdb)
Rather than file=..., should the field be called something like
fullname=...., realpath= or fullpath=? That way, the same term can be
used consistently through out MI.
> enum mi_cmd_result
> mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc)
> {
> struct symtab_and_line st;
See:
http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=783
Even though there are no arguments it will want to discard any "--". A
mi_getopt() call to strip off any leading "--". I think you'll want to
tweak that function so that calling it is easier - allow NULL OPT and
OPTARG?
> /* Print to the user the line and absolute file name */
> ui_out_field_int (uiout, "line", st.line);
> ui_out_field_string (uiout, "file", st.symtab->fullname);
Following on from above, should it print both "file" and "fullname"?
> return MI_CMD_DONE;
> }
[-- Attachment #2: mi-file.exp --]
[-- Type: text/plain, Size: 2224 bytes --]
# Copyright 1999 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
#
# Test essential Machine interface (MI) operations
#
# Verify that, using the MI, we can run a simple program and perform basic
# debugging activities like: insert breakpoints, run the program,
# step, next, continue until it ends and, last but not least, quit.
#
# The goal is not to test gdb functionality, which is done by other tests,
# but to verify the correct output response to MI operations.
#
load_lib mi-support.exp
set MIFLAGS "-i=mi"
gdb_exit
if [mi_gdb_start] {
continue
}
set testfile "basics"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
proc test_tbreak_creation_and_listing {} {
global srcfile
global srcdir
global subdir
set abs_srcfile [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
# get the absolute path to the current file
mi_gdb_test "111-file-list-exec-source-file" \
"111\\\^done,line=\"23\",file=\"${abs_srcfile}\"" \
"request absolute path of current source file (${abs_srcfile})"
}
test_tbreak_creation_and_listing
mi_gdb_exit
return 0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-30 4:06 ` Bob Rossi
@ 2003-03-31 4:22 ` Andrew Cagney
2003-03-31 8:13 ` Jason Molenda
0 siblings, 1 reply; 36+ messages in thread
From: Andrew Cagney @ 2003-03-31 4:22 UTC (permalink / raw)
To: Bob Rossi; +Cc: Jason Molenda, gdb-patches
>
> Sure, I'll look into that. I would also like to add the extra field to
> -break-list. Does that make sense to everyone else?
Does to me.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-28 15:26 ` Andrew Cagney
@ 2003-03-30 4:06 ` Bob Rossi
2003-03-31 4:22 ` Andrew Cagney
0 siblings, 1 reply; 36+ messages in thread
From: Bob Rossi @ 2003-03-30 4:06 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Jason Molenda, gdb-patches
On Fri, Mar 28, 2003 at 10:26:12AM -0500, Andrew Cagney wrote:
> >On Fri, Mar 21, 2003 at 01:55:32AM -0800, Jason Molenda wrote:
> >
> >>Hello Bob,
> >>
> >>My approval isn't needed for these patches or anything, I'm just
> >>an interested observer making comments.
> >>
> >>On Thu, Mar 20, 2003 at 05:44:54PM -0500, Bob Rossi wrote:
> >>
> >
> >>> This change essentially adds the command -file-list-exec-source-file to
> >>> the mi commands.
> >
> >>
> >>I don't understand why this command is useful.
> >>
> >>A UI can get the filename of the currently-executing source file
> >>easily enough with "stack-list-frames 0 1". The pathname is returned
> >>as it was recorded in the debug info from the compiler - it might
> >>be an absolute path or it might be a relative path.
> >
> >
> >At a minumum, it is a strong convienence function for the front end to
> >gdb. It guarentees that the front end is thinking about the same file
> >that gdb is. The front end needs to know about absolute paths. It cares
> >nothing about relative paths.
> >
> >
> >>
> >>If the path is relative, gdb will interpret that pathname based on
> >>the directory gdb was invoked--which presumably the UI did itself.
> >>Or it will be interpreted relative to any paths added with the
> >>"dir" (CLI) / "environment-directory" (MI) command, which the UI
> >>would have added as well. (or it can get the list of paths with
> >>the environment-directory command without any arguments)
> >>
> >>Why does this information have to be provided by gdb?
> >
> >
> >The best answer probably is, because its been provided for the last
> >decade ( with annotation 1 and 2 ). I strongly believe that just because
> >gdb is switching its interface to front ends, doesn't mean it should
> >take away functionality that was provided before.
> >
> >However, in my opinion, It doesn't really make sense that each front
> >that implements an interface to gdb figure out how to do each of the
> >steps provided above. Especially since gdb is already doing all that
> >work.
> >
> >Why repeat the functionality in all of the front ends to gdb?
> >
> >It would seem that the best solution would be if this command could be
> >automatically run ( on the front end's request ) every time the source
> >file or line number changed. Just like annotation 1 or 2.
>
> Sounds like the MI interface should provide both (hey if the client
> wants a choice of 14 different salad dressings, then who is gdb to argue).
>
> Someone want to add an extra field, containing that absolute path, to
> the stack-list-frames command?
>
> Andrew
>
>
Sure, I'll look into that. I would also like to add the extra field to
-break-list. Does that make sense to everyone else?
Bob Rossi
^ permalink raw reply [flat|nested] 36+ messages in thread
* Adding -file-list-exec-source-file command to GDB/MI
@ 2003-03-29 0:41 Bob Rossi
2003-03-31 5:38 ` Andrew Cagney
0 siblings, 1 reply; 36+ messages in thread
From: Bob Rossi @ 2003-03-29 0:41 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 4394 bytes --]
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-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.351
diff -c -r1.351 Makefile.in
*** Makefile.in 26 Mar 2003 03:39:42 -0000 1.351
--- Makefile.in 29 Mar 2003 00:24:56 -0000
***************
*** 168,181 ****
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-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-interp.c \
mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
SUBDIR_MI_DEPS =
--- 168,181 ----
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-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-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 =
***************
*** 2538,2543 ****
--- 2538,2547 ----
$(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 -c -r1.154 gdb.texinfo
*** doc/gdb.texinfo 27 Mar 2003 15:17:34 -0000 1.154
--- doc/gdb.texinfo 29 Mar 2003 00:25:22 -0000
***************
*** 16337,16342 ****
--- 16337,16353 ----
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 current source file and line for the current executable.
+
@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 -c -r1.10 mi-cmds.c
*** mi/mi-cmds.c 6 Feb 2003 01:19:12 -0000 1.10
--- mi/mi-cmds.c 29 Mar 2003 00:25:23 -0000
***************
*** 80,85 ****
--- 80,86 ----
{"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 -c -r1.7 mi-cmds.h
*** mi/mi-cmds.h 6 Feb 2003 01:19:12 -0000 1.7
--- mi/mi-cmds.h 29 Mar 2003 00:25:23 -0000
***************
*** 80,85 ****
--- 80,86 ----
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;
[-- Attachment #2: mi-cmd-file.c --]
[-- Type: text/x-csrc, Size: 2060 bytes --]
/* MI Command Set - breakpoint and watchpoint commands.
Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Cygnus Solutions (a Red Hat company).
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "mi-cmds.h"
#include "ui-out.h"
#include "symtab.h"
#include "source.h"
/* Return to the client the absolute path and line number of the
current file being executed. */
enum mi_cmd_result
mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc)
{
struct symtab_and_line st;
if (argc != 0)
error ("mi_cmd_file_list_exec_source_file: Usage: No args");
/* Set the default file and line, also get them */
set_default_source_symtab_and_line();
st = get_current_source_symtab_and_line();
/* We should always get a symtab. */
if (!st.symtab)
error ("mi_cmd_file_list_exec_source_file: No symtab");
/* Extract the fullname if it is not known yet */
if (st.symtab->fullname == NULL)
symtab_to_filename (st.symtab);
/* We may not be able to open the file (not available). */
if (st.symtab->fullname == NULL)
error ("mi_cmd_file_list_exec_source_file: File not found");
/* Print to the user the line and absolute file name */
ui_out_field_int (uiout, "line", st.line);
ui_out_field_string (uiout, "file", st.symtab->fullname);
return MI_CMD_DONE;
}
[-- Attachment #3: mi-file.exp --]
[-- Type: text/plain, Size: 2145 bytes --]
# Copyright 1999 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
#
# Test essential Machine interface (MI) operations
#
# Verify that, using the MI, we can run a simple program and perform basic
# debugging activities like: insert breakpoints, run the program,
# step, next, continue until it ends and, last but not least, quit.
#
# The goal is not to test gdb functionality, which is done by other tests,
# but to verify the correct output response to MI operations.
#
load_lib mi-support.exp
set MIFLAGS "-i=mi"
gdb_exit
if [mi_gdb_start] {
continue
}
set testfile "basics"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
proc test_tbreak_creation_and_listing {} {
global binfile
set abs_srcfile ${binfile}.c
# get the absolute path to the current file
mi_gdb_test "111-file-list-exec-source-file" \
"111\\\^done,line=\"23\",file=\"${abs_srcfile}\"" \
"request absolute path of current source file"
}
test_tbreak_creation_and_listing
mi_gdb_exit
return 0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-28 16:05 ` Bob Rossi
@ 2003-03-28 16:10 ` Daniel Jacobowitz
0 siblings, 0 replies; 36+ messages in thread
From: Daniel Jacobowitz @ 2003-03-28 16:10 UTC (permalink / raw)
To: Andrew Cagney, gdb-patches
The whole thing, please.
On Fri, Mar 28, 2003 at 11:05:09AM -0500, Bob Rossi wrote:
> In the situation were a multi file patch needs correcting.
> Should only the file that needs correcting be reposted?
> Or should the entire multi file patch be reposted when a part of it is corrected?
>
> Bobby
>
>
> On Fri, Mar 28, 2003 at 10:30:18AM -0500, Andrew Cagney wrote:
> >
> > > * mi-cmd-file.c: Added file to implement mi file commands.
> >
> > I think that file was lost?
> >
> > > @subsubheading Example
> > > N.A.
> > >
> > >+ @subheading The @code{-file-list-exec-source-file} Command
> > >+ @findex -file-list-exec-source-file
> > >+
> > >+ @subsubheading Synopsis
> > >+
> > >+ @example
> > >+ -file-list-exec-source-file
> > >+ @end example
> > >+
> > >+ List the current source file and line for the current executable.
> >
> > FYI, I just fixed/merged that file. It now uses @smallexample which is
> > consistent with the rest of the manual.
> >
> > Can you please extend this so that it includes example output.
> >
> > Andrew
> >
>
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-28 15:30 ` Andrew Cagney
@ 2003-03-28 16:05 ` Bob Rossi
2003-03-28 16:10 ` Daniel Jacobowitz
0 siblings, 1 reply; 36+ messages in thread
From: Bob Rossi @ 2003-03-28 16:05 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
In the situation were a multi file patch needs correcting.
Should only the file that needs correcting be reposted?
Or should the entire multi file patch be reposted when a part of it is corrected?
Bobby
On Fri, Mar 28, 2003 at 10:30:18AM -0500, Andrew Cagney wrote:
>
> > * mi-cmd-file.c: Added file to implement mi file commands.
>
> I think that file was lost?
>
> > @subsubheading Example
> > N.A.
> >
> >+ @subheading The @code{-file-list-exec-source-file} Command
> >+ @findex -file-list-exec-source-file
> >+
> >+ @subsubheading Synopsis
> >+
> >+ @example
> >+ -file-list-exec-source-file
> >+ @end example
> >+
> >+ List the current source file and line for the current executable.
>
> FYI, I just fixed/merged that file. It now uses @smallexample which is
> consistent with the rest of the manual.
>
> Can you please extend this so that it includes example output.
>
> Andrew
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-20 22:44 Bob Rossi
` (2 preceding siblings ...)
2003-03-26 22:48 ` Andrew Cagney
@ 2003-03-28 15:30 ` Andrew Cagney
2003-03-28 16:05 ` Bob Rossi
3 siblings, 1 reply; 36+ messages in thread
From: Andrew Cagney @ 2003-03-28 15:30 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
> * mi-cmd-file.c: Added file to implement mi file commands.
I think that file was lost?
> @subsubheading Example
> N.A.
>
> + @subheading The @code{-file-list-exec-source-file} Command
> + @findex -file-list-exec-source-file
> +
> + @subsubheading Synopsis
> +
> + @example
> + -file-list-exec-source-file
> + @end example
> +
> + List the current source file and line for the current executable.
FYI, I just fixed/merged that file. It now uses @smallexample which is
consistent with the rest of the manual.
Can you please extend this so that it includes example output.
Andrew
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-21 13:16 ` Bob Rossi
@ 2003-03-28 15:26 ` Andrew Cagney
2003-03-30 4:06 ` Bob Rossi
0 siblings, 1 reply; 36+ messages in thread
From: Andrew Cagney @ 2003-03-28 15:26 UTC (permalink / raw)
To: Bob Rossi; +Cc: Jason Molenda, gdb-patches
> On Fri, Mar 21, 2003 at 01:55:32AM -0800, Jason Molenda wrote:
>
>> Hello Bob,
>>
>> My approval isn't needed for these patches or anything, I'm just
>> an interested observer making comments.
>>
>> On Thu, Mar 20, 2003 at 05:44:54PM -0500, Bob Rossi wrote:
>>
>
>> > This change essentially adds the command -file-list-exec-source-file to
>> > the mi commands.
>
>>
>> I don't understand why this command is useful.
>>
>> A UI can get the filename of the currently-executing source file
>> easily enough with "stack-list-frames 0 1". The pathname is returned
>> as it was recorded in the debug info from the compiler - it might
>> be an absolute path or it might be a relative path.
>
>
> At a minumum, it is a strong convienence function for the front end to
> gdb. It guarentees that the front end is thinking about the same file
> that gdb is. The front end needs to know about absolute paths. It cares
> nothing about relative paths.
>
>
>>
>> If the path is relative, gdb will interpret that pathname based on
>> the directory gdb was invoked--which presumably the UI did itself.
>> Or it will be interpreted relative to any paths added with the
>> "dir" (CLI) / "environment-directory" (MI) command, which the UI
>> would have added as well. (or it can get the list of paths with
>> the environment-directory command without any arguments)
>>
>> Why does this information have to be provided by gdb?
>
>
> The best answer probably is, because its been provided for the last
> decade ( with annotation 1 and 2 ). I strongly believe that just because
> gdb is switching its interface to front ends, doesn't mean it should
> take away functionality that was provided before.
>
> However, in my opinion, It doesn't really make sense that each front
> that implements an interface to gdb figure out how to do each of the
> steps provided above. Especially since gdb is already doing all that
> work.
>
> Why repeat the functionality in all of the front ends to gdb?
>
> It would seem that the best solution would be if this command could be
> automatically run ( on the front end's request ) every time the source
> file or line number changed. Just like annotation 1 or 2.
Sounds like the MI interface should provide both (hey if the client
wants a choice of 14 different salad dressings, then who is gdb to argue).
Someone want to add an extra field, containing that absolute path, to
the stack-list-frames command?
Andrew
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-26 22:48 ` Andrew Cagney
@ 2003-03-28 14:35 ` Bob Rossi
0 siblings, 0 replies; 36+ messages in thread
From: Bob Rossi @ 2003-03-28 14:35 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Wed, Mar 26, 2003 at 05:48:23PM -0500, Andrew Cagney wrote:
> Bob, you should by now have an account. Can you please check that it
> works by adding your self to the write after approval list as an
> `obvious-fix' (remember to post patch and changelog).
>
> Andrew
2003-03-28 Bob Rossi <bob_rossi@cox.net>
* MAINTAINERS (write after approval): Add myself.
===================================================================
RCS file: /cvs/src/src/gdb/MAINTAINERS,v
retrieving revision 1.232
diff -w -u -r1.232 MAINTAINERS
--- MAINTAINERS 21 Mar 2003 20:00:20 -0000 1.232
+++ MAINTAINERS 28 Mar 2003 14:32:09 -0000
@@ -367,6 +367,7 @@
David O'Brien obrien@freebsd.org
Alexandre Oliva aoliva@redhat.com
Tom Rix trix@redhat.com
+Bob Rossi bob_rossi@cox.net
Theodore A. Roth troth@verinet.com
Ian Roxborough irox@redhat.com
Grace Sainsbury graces@redhat.com
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-20 22:44 Bob Rossi
2003-03-21 4:34 ` Eli Zaretskii
2003-03-21 9:53 ` Jason Molenda
@ 2003-03-26 22:48 ` Andrew Cagney
2003-03-28 14:35 ` Bob Rossi
2003-03-28 15:30 ` Andrew Cagney
3 siblings, 1 reply; 36+ messages in thread
From: Andrew Cagney @ 2003-03-26 22:48 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
Bob, you should by now have an account. Can you please check that it
works by adding your self to the write after approval list as an
`obvious-fix' (remember to post patch and changelog).
Andrew
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-21 9:53 ` Jason Molenda
@ 2003-03-21 13:16 ` Bob Rossi
2003-03-28 15:26 ` Andrew Cagney
0 siblings, 1 reply; 36+ messages in thread
From: Bob Rossi @ 2003-03-21 13:16 UTC (permalink / raw)
To: Jason Molenda; +Cc: gdb-patches
On Fri, Mar 21, 2003 at 01:55:32AM -0800, Jason Molenda wrote:
> Hello Bob,
>
> My approval isn't needed for these patches or anything, I'm just
> an interested observer making comments.
>
> On Thu, Mar 20, 2003 at 05:44:54PM -0500, Bob Rossi wrote:
>
> > This change essentially adds the command -file-list-exec-source-file to
> > the mi commands.
>
> I don't understand why this command is useful.
>
> A UI can get the filename of the currently-executing source file
> easily enough with "stack-list-frames 0 1". The pathname is returned
> as it was recorded in the debug info from the compiler - it might
> be an absolute path or it might be a relative path.
At a minumum, it is a strong convienence function for the front end to
gdb. It guarentees that the front end is thinking about the same file
that gdb is. The front end needs to know about absolute paths. It cares
nothing about relative paths.
>
> If the path is relative, gdb will interpret that pathname based on
> the directory gdb was invoked--which presumably the UI did itself.
> Or it will be interpreted relative to any paths added with the
> "dir" (CLI) / "environment-directory" (MI) command, which the UI
> would have added as well. (or it can get the list of paths with
> the environment-directory command without any arguments)
>
> Why does this information have to be provided by gdb?
The best answer probably is, because its been provided for the last
decade ( with annotation 1 and 2 ). I strongly believe that just because
gdb is switching its interface to front ends, doesn't mean it should
take away functionality that was provided before.
However, in my opinion, It doesn't really make sense that each front
that implements an interface to gdb figure out how to do each of the
steps provided above. Especially since gdb is already doing all that
work.
Why repeat the functionality in all of the front ends to gdb?
It would seem that the best solution would be if this command could be
automatically run ( on the front end's request ) every time the source
file or line number changed. Just like annotation 1 or 2.
Bobby
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-20 22:44 Bob Rossi
2003-03-21 4:34 ` Eli Zaretskii
@ 2003-03-21 9:53 ` Jason Molenda
2003-03-21 13:16 ` Bob Rossi
2003-03-26 22:48 ` Andrew Cagney
2003-03-28 15:30 ` Andrew Cagney
3 siblings, 1 reply; 36+ messages in thread
From: Jason Molenda @ 2003-03-21 9:53 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
Hello Bob,
My approval isn't needed for these patches or anything, I'm just
an interested observer making comments.
On Thu, Mar 20, 2003 at 05:44:54PM -0500, Bob Rossi wrote:
> This change essentially adds the command -file-list-exec-source-file to
> the mi commands.
I don't understand why this command is useful.
A UI can get the filename of the currently-executing source file
easily enough with "stack-list-frames 0 1". The pathname is returned
as it was recorded in the debug info from the compiler - it might
be an absolute path or it might be a relative path.
If the path is relative, gdb will interpret that pathname based on
the directory gdb was invoked--which presumably the UI did itself.
Or it will be interpreted relative to any paths added with the
"dir" (CLI) / "environment-directory" (MI) command, which the UI
would have added as well. (or it can get the list of paths with
the environment-directory command without any arguments)
Why does this information have to be provided by gdb?
Jason
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-03-20 22:44 Bob Rossi
@ 2003-03-21 4:34 ` Eli Zaretskii
2003-03-21 9:53 ` Jason Molenda
` (2 subsequent siblings)
3 siblings, 0 replies; 36+ messages in thread
From: Eli Zaretskii @ 2003-03-21 4:34 UTC (permalink / raw)
To: bob_rossi; +Cc: gdb-patches
> Date: Thu, 20 Mar 2003 17:44:54 -0500
> From: Bob Rossi <bob_rossi@cox.net>
>
> 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-cmds.c: Added -file-list-exec-source-file command.
> * mi-cmds.h: Added -file-list-exec-source-file to proto list.
> * gdbmi.texinfo: Document -file-list-exec-source-file.
> * mi-file.exp: Added testcase to test -file-list-exec-source-file.
The patch for gdbmi.texinfo is approved.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Adding -file-list-exec-source-file command to GDB/MI
@ 2003-03-20 22:44 Bob Rossi
2003-03-21 4:34 ` Eli Zaretskii
` (3 more replies)
0 siblings, 4 replies; 36+ messages in thread
From: Bob Rossi @ 2003-03-20 22:44 UTC (permalink / raw)
To: gdb-patches
----- Forwarded message from Bob Rossi <bob_rossi@cox.net> -----
Date: Thu, 20 Mar 2003 17:29:35 -0500
From: Bob Rossi <bob_rossi@cox.net>
To: gdb@sources.redhat.com
Subject: Adding -file-list-exec-source-file command to GDB/MI
----- Forwarded message from Bob Rossi <bob_rossi@cox.net> -----
Date: Sun, 9 Mar 2003 19:31:17 -0500
From: Bob Rossi <bob_rossi@cox.net>
To: gdb-patches@sources.redhat.com
Subject: Adding -file-list-exec-source-file command to GDB/MI
Hi,
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-cmds.c: Added -file-list-exec-source-file command.
* mi-cmds.h: Added -file-list-exec-source-file to proto list.
* gdbmi.texinfo: Document -file-list-exec-source-file.
* mi-file.exp: Added testcase to test -file-list-exec-source-file.
Also, do you think it would be good if the function
-file-list-exec-source-file optionally took an argument ( a filename ).
If it reiceived an argument, it would return the absolute path to that
file.
I think the normal way a front end gets the absolute path to a file now
is,
1. list filename.c
2. info source
3. parse the output looking for 'Located in '
This optional argument would solve that problem.
Thanks,
Bob Rossi
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.328
diff -c -r1.328 Makefile.in
*** gdb/Makefile.in 7 Feb 2003 05:33:44 -0000 1.328
--- gdb/Makefile.in 10 Feb 2003 20:51:47 -0000
***************
*** 168,181 ****
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-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-interp.c \
mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
SUBDIR_MI_DEPS =
--- 168,181 ----
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-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-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 =
***************
*** 2494,2499 ****
--- 2494,2503 ----
$(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: gdb/mi/gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.33
diff -c -r1.33 gdbmi.texinfo
*** gdb/mi/gdbmi.texinfo 4 Feb 2003 18:41:29 -0000 1.33
--- gdb/mi/gdbmi.texinfo 10 Feb 2003 20:51:55 -0000
***************
*** 2340,2345 ****
--- 2340,2355 ----
@subsubheading Example
N.A.
+ @subheading The @code{-file-list-exec-source-file} Command
+ @findex -file-list-exec-source-file
+
+ @subsubheading Synopsis
+
+ @example
+ -file-list-exec-source-file
+ @end example
+
+ List the current source file and line for the current executable.
@subheading The @code{-file-list-exec-source-files} Command
@findex -file-list-exec-source-files
Index: gdb/mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.10
diff -c -r1.10 mi-cmds.c
*** gdb/mi/mi-cmds.c 6 Feb 2003 01:19:12 -0000 1.10
--- gdb/mi/mi-cmds.c 10 Feb 2003 20:51:55 -0000
***************
*** 80,85 ****
--- 80,86 ----
{"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: gdb/mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.7
diff -c -r1.7 mi-cmds.h
*** gdb/mi/mi-cmds.h 6 Feb 2003 01:19:12 -0000 1.7
--- gdb/mi/mi-cmds.h 10 Feb 2003 20:51:55 -0000
***************
*** 80,85 ****
--- 80,86 ----
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;
# Copyright 1999 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
#
# Test essential Machine interface (MI) operations
#
# Verify that, using the MI, we can run a simple program and perform basic
# debugging activities like: insert breakpoints, run the program,
# step, next, continue until it ends and, last but not least, quit.
#
# The goal is not to test gdb functionality, which is done by other tests,
# but to verify the correct output response to MI operations.
#
load_lib mi-support.exp
set MIFLAGS "-i=mi"
gdb_exit
if [mi_gdb_start] {
continue
}
set testfile "basics"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
proc test_tbreak_creation_and_listing {} {
global binfile
set abs_srcfile ${binfile}.c
# get the absolute path to the current file
mi_gdb_test "111-file-list-exec-source-file" \
"111\\\^done,line=\"23\",file=\"${abs_srcfile}\"" \
"request absolute path of current source file"
}
test_tbreak_creation_and_listing
mi_gdb_exit
return 0
----- End forwarded message -----
----- End forwarded message -----
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-02-11 6:39 ` Eli Zaretskii
@ 2003-02-13 3:00 ` Bob Rossi
0 siblings, 0 replies; 36+ messages in thread
From: Bob Rossi @ 2003-02-13 3:00 UTC (permalink / raw)
To: gdb-patches
On Tue, Feb 11, 2003 at 08:38:56AM +0200, Eli Zaretskii wrote:
>
> On Mon, 10 Feb 2003, Bob Rossi wrote:
>
> > This is a patch to add -file-list-exec-source-file to GDB. The command
> > returns to the client the absolute path and line number of the current
> > executable.
>
> Thanks.
>
> But what happens if the debug format doesn't support full file names?
> COFF debug info is one such case; what does the command do in that case?
I think it should act the way annotate 1 acts. Since this is the
de-facto standard for getting the current file that gdb is on.
How could I test this case? Can you give me a simple way to create an
executable that has the COFF debug format in it?
Thanks,
Bobby
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
2003-02-10 22:15 Bob Rossi
@ 2003-02-11 6:39 ` Eli Zaretskii
2003-02-13 3:00 ` Bob Rossi
0 siblings, 1 reply; 36+ messages in thread
From: Eli Zaretskii @ 2003-02-11 6:39 UTC (permalink / raw)
To: Bob Rossi; +Cc: gdb-patches
On Mon, 10 Feb 2003, Bob Rossi wrote:
> This is a patch to add -file-list-exec-source-file to GDB. The command
> returns to the client the absolute path and line number of the current
> executable.
Thanks.
But what happens if the debug format doesn't support full file names?
COFF debug info is one such case; what does the command do in that case?
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Adding -file-list-exec-source-file command to GDB/MI
@ 2003-02-10 22:28 Michael Elizabeth Chastain
0 siblings, 0 replies; 36+ messages in thread
From: Michael Elizabeth Chastain @ 2003-02-10 22:28 UTC (permalink / raw)
To: bob_rossi, gdb-patches
Hi Bob,
I am not an MI maintainer, but I noticed a couple of things?
(1) Your patch is missing mi-cmd-file.c -- you need to include it as
an attachment. Or you can run 'diff -N' and pick it up inside the diff.
(2) Normally people don't submit the ChangeLog entries as diffs because
'patch' is always out of sync. We just list them as text at the
start of the file.
(3) The most painful -- do you and/or your company have a copyright
assignment for gdb on file with the Free Software Foundation?
Michael C
^ permalink raw reply [flat|nested] 36+ messages in thread
* Adding -file-list-exec-source-file command to GDB/MI
@ 2003-02-10 22:15 Bob Rossi
2003-02-11 6:39 ` Eli Zaretskii
0 siblings, 1 reply; 36+ messages in thread
From: Bob Rossi @ 2003-02-10 22:15 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 5771 bytes --]
Hi,
This is a patch to add -file-list-exec-source-file to GDB. The command
returns to the client the absolute path and line number of the current
executable. It is a replacement for the old way of getting the line
and file using annotations 1 or 2. It is nice because the client doesn't
have to call the -interpreter-exec command and parse the output of the CLI.
I ran the testsuite and there were no errors. I tested the feature from
GDB when there was not an program being debugged and when GDB had to
find the main file ( before running the exe ).
Both of these cases worked properly.
I tested it on:
uname -a='Linux 2.4.18 #2 Mon Nov 4 18:23:35 EST 2002 i686 unknown'
gdb -v|tail -n1='This GDB was configured as "i386-linux".'
This patch can be applied from src/gdb using patch -p1.
I added a file called mi-cmd-file.c. I was following the pattern created
by the designers of GDB/MI. I was imagining that all of the
unimplemented function -file will go in it when they are ready.
The file is attached.
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.328
diff -c -r1.328 Makefile.in
*** gdb/Makefile.in 7 Feb 2003 05:33:44 -0000 1.328
--- gdb/Makefile.in 10 Feb 2003 20:51:47 -0000
***************
*** 168,181 ****
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-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-interp.c \
mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
SUBDIR_MI_DEPS =
--- 168,181 ----
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-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-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 =
***************
*** 2494,2499 ****
--- 2494,2503 ----
$(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: gdb/mi/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/mi/ChangeLog,v
retrieving revision 1.92
diff -c -r1.92 ChangeLog
*** gdb/mi/ChangeLog 9 Feb 2003 10:47:37 -0000 1.92
--- gdb/mi/ChangeLog 10 Feb 2003 20:51:51 -0000
***************
*** 1,3 ****
--- 1,10 ----
+ 2003-02-10 Bob Rossi <bob_rossi@cox.net>
+
+ * mi-cmd-file.c: added file to implement mi file commands.
+ * mi-cmds.c: Add -file-list-exec-source-file command.
+ * mi-cmds.h: Add -file-list-exec-source-file to proto list.
+ * gdbmi.texinfo: Document -file-list-exec-source-file.
+
2003-02-09 Andrew Cagney <ac131313@redhat.com>
* mi-interp.c (mi_remove_notify_hooks): Convert function
Index: gdb/mi/gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.33
diff -c -r1.33 gdbmi.texinfo
*** gdb/mi/gdbmi.texinfo 4 Feb 2003 18:41:29 -0000 1.33
--- gdb/mi/gdbmi.texinfo 10 Feb 2003 20:51:55 -0000
***************
*** 2340,2345 ****
--- 2340,2355 ----
@subsubheading Example
N.A.
+ @subheading The @code{-file-list-exec-source-file} Command
+ @findex -file-list-exec-source-file
+
+ @subsubheading Synopsis
+
+ @example
+ -file-list-exec-source-file
+ @end example
+
+ List the current source file and line for the current executable.
@subheading The @code{-file-list-exec-source-files} Command
@findex -file-list-exec-source-files
Index: gdb/mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.10
diff -c -r1.10 mi-cmds.c
*** gdb/mi/mi-cmds.c 6 Feb 2003 01:19:12 -0000 1.10
--- gdb/mi/mi-cmds.c 10 Feb 2003 20:51:55 -0000
***************
*** 80,85 ****
--- 80,86 ----
{"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: gdb/mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.7
diff -c -r1.7 mi-cmds.h
*** gdb/mi/mi-cmds.h 6 Feb 2003 01:19:12 -0000 1.7
--- gdb/mi/mi-cmds.h 10 Feb 2003 20:51:55 -0000
***************
*** 80,85 ****
--- 80,86 ----
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;
[-- Attachment #2: mi-cmd-file.c --]
[-- Type: text/x-csrc, Size: 1138 bytes --]
#include "defs.h"
#include "mi-cmds.h"
#include "ui-out.h"
#include "symtab.h"
#include "source.h"
/* Return to the client the absolute path and line number of the
current file being executed. */
enum mi_cmd_result
mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc)
{
struct symtab_and_line st;
if (argc != 0)
error ("mi_cmd_file_list_exec_source_file: Usage: No args");
/* Set the default file and line, also get them */
set_default_source_symtab_and_line();
st = get_current_source_symtab_and_line();
/* We should always get a symtab. */
if (!st.symtab)
error ("mi_cmd_file_list_exec_source_file: No symtab");
/* Extract the fullname if it is not known yet */
if (st.symtab->fullname == NULL)
symtab_to_filename (st.symtab);
/* We may not be able to open the file (not available). */
if (st.symtab->fullname == NULL)
error ("mi_cmd_file_list_exec_source_file: File not found");
/* Print to the user the line and absolute file name */
ui_out_field_int (uiout, "line", st.line);
ui_out_field_string (uiout, "file", st.symtab->fullname);
return MI_CMD_DONE;
}
^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2003-04-03 2:54 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-10 0:31 Adding -file-list-exec-source-file command to GDB/MI Bob Rossi
2003-03-10 4:28 ` Eli Zaretskii
2003-03-18 2:10 ` Bob Rossi
2003-03-18 5:46 ` Eli Zaretskii
-- strict thread matches above, loose matches on Subject: below --
2003-04-02 20:24 Bob Rossi
2003-04-02 21:59 ` Andrew Cagney
2003-04-03 2:54 ` Eli Zaretskii
2003-04-02 20:24 Bob Rossi
2003-03-29 0:41 Bob Rossi
2003-03-31 5:38 ` Andrew Cagney
2003-03-31 18:46 ` Bob Rossi
2003-03-31 18:56 ` Andrew Cagney
2003-04-02 16:15 ` Bob Rossi
2003-04-02 16:27 ` Andrew Cagney
2003-03-20 22:44 Bob Rossi
2003-03-21 4:34 ` Eli Zaretskii
2003-03-21 9:53 ` Jason Molenda
2003-03-21 13:16 ` Bob Rossi
2003-03-28 15:26 ` Andrew Cagney
2003-03-30 4:06 ` Bob Rossi
2003-03-31 4:22 ` Andrew Cagney
2003-03-31 8:13 ` Jason Molenda
2003-03-31 14:31 ` Andrew Cagney
2003-03-31 17:16 ` Jason Molenda
2003-03-31 18:52 ` Andrew Cagney
2003-03-31 19:20 ` Jason Molenda
2003-03-31 20:12 ` Andrew Cagney
2003-03-26 22:48 ` Andrew Cagney
2003-03-28 14:35 ` Bob Rossi
2003-03-28 15:30 ` Andrew Cagney
2003-03-28 16:05 ` Bob Rossi
2003-03-28 16:10 ` Daniel Jacobowitz
2003-02-10 22:28 Michael Elizabeth Chastain
2003-02-10 22:15 Bob Rossi
2003-02-11 6:39 ` Eli Zaretskii
2003-02-13 3:00 ` Bob Rossi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox