Re: [RFA] new GDB/MI command: -symbol-info-linetable

Elena Zannoni
2003-04-22T14:25:18Z

Thierry Schneider writes:
>
> Elena,
>
> Thank you for reviewing my changes and for the constructive feedback.
> I have incorporated all your suggestions, as well as the one from Bob
> Rossi who kindly informed me that the MI documentation had been merged
> gdb/doc/gdb.texinfo, and this is where I added my new documentation.
>

Ok, I just realized that you also need a gdb.mi/mi-symbol.exp file,
which will use set MIFLAGS "-i=mi" instead of set MIFLAGS "-i=mi1".
You may have to update some of the test output as well.
Post that new file as well.

the rest is ok.

elena

> Here is the updated ChangeLog:
>
> 2003-04-18 Thierry Schneider <tpschneider1@yahoo.com>
>
> * mi-cmds.h (mi_cmd_symbol_list_lines): Add declaration.
> * mi-cmds.c (mi_cmds): Add entry for new MI command.
> * mi-cmd-symbol.c (mi_cmd_symbol_list_lines): New source file
> for all symbol-related commands.
>
> 2003-04-18 Thierry Schneider <tpschneider1@yahoo.com>
>
> * gdb.texinfo (section GDB/MI Symbol Query): Add documentation
> for new MI command.
>
> 2003-04-18 Thierry Schneider <tpschneider1@yahoo.com>
>
> * mi1-symbol.exp (-symbol-list-lines): New test file to
> validate all symbol-related commands
>
> > > I unfortunately do not have a valid FSF assignement on file, yet.
> > > I have sent my application to the FSF, and I am waiting for the papers
> > > to arrive by mail.
> > >
> >
> > I think this has been sorted out now, right?
>
> Yes, I now have an FSF assignment on file.
>
> Thierry S.
> Index: Makefile.in
> ===================================================================
> RCS file: /cvs/src/src/gdb/Makefile.in,v
> retrieving revision 1.364
> diff -c -3 -p -r1.364 Makefile.in
> *** Makefile.in 15 Apr 2003 23:07:11 -0000 1.364
> --- Makefile.in 19 Apr 2003 02:18:04 -0000
> *************** SUBDIR_CLI_UNINSTALL=
> *** 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 =
> --- 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-cmd-symbol.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-cmd-symbol.c \
> mi/mi-interp.c \
> mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
> SUBDIR_MI_DEPS =
> *************** mi-cmd-env.o: $(srcdir)/mi/mi-cmd-env.c
> *** 2566,2571 ****
> --- 2566,2574 ----
> mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stack.c $(defs_h) $(target_h) $(frame_h) \
> $(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h) $(block_h)
> $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
> + mi-cmd-symbol.o: $(srcdir)/mi/mi-cmd-symbol.c $(defs_h) \
> + $(mi_cmds_h) $(ui_out_h) $(symtab_h)
> + $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-symbol.c
> mi-cmd-var.o: $(srcdir)/mi/mi-cmd-var.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
> $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h)
> $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-var.c
> Index: doc/gdb.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
> retrieving revision 1.156
> diff -c -3 -p -r1.156 gdb.texinfo
> *** doc/gdb.texinfo 14 Apr 2003 18:42:28 -0000 1.156
> --- doc/gdb.texinfo 19 Apr 2003 02:18:18 -0000
> *************** List the functions in the executable.
> *** 17117,17122 ****
> --- 17117,17148 ----
> N.A.
>
>
> + @subheading The @code{-symbol-list-lines} Command
> + @findex -symbol-list-lines
> +
> + @subsubheading Synopsis
> +
> + @smallexample
> + -symbol-list-lines @var{filename}
> + @end smallexample
> +
> + Print the list of lines that contain code and their associated program
> + addresses for the given source filename. The entries are sorted in
> + ascending PC order.
> +
> + @subsubheading @value{GDBN} Command
> +
> + There is no corresponding @value{GDBN} command.
> +
> + @subsubheading Example
> + @smallexample
> + (@value{GDBP})
> + -symbol-list-lines basics.c
> + ^done,lines=[{pc="0x08048554",line="7"},{pc="0x0804855a",line="8"}]
> + (@value{GDBP})
> + @end smallexample
> +
> +
> @subheading The @code{-symbol-list-types} Command
> @findex -symbol-list-types
>
> Index: mi/mi-cmds.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
> retrieving revision 1.11
> diff -c -3 -p -r1.11 mi-cmds.c
> *** mi/mi-cmds.c 2 Apr 2003 22:10:35 -0000 1.11
> --- mi/mi-cmds.c 19 Apr 2003 02:18:18 -0000
> *************** struct mi_cmd mi_cmds[] =
> *** 119,124 ****
> --- 119,125 ----
> {"symbol-info-line", 0, 0},
> {"symbol-info-symbol", 0, 0},
> {"symbol-list-functions", 0, 0},
> + {"symbol-list-lines", 0, 0, mi_cmd_symbol_list_lines},
> {"symbol-list-types", 0, 0},
> {"symbol-list-variables", 0, 0},
> {"symbol-locate", 0, 0},
> Index: mi/mi-cmds.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
> retrieving revision 1.8
> diff -c -3 -p -r1.8 mi-cmds.h
> *** mi/mi-cmds.h 2 Apr 2003 22:10:35 -0000 1.8
> --- mi/mi-cmds.h 19 Apr 2003 02:18:18 -0000
> *************** extern mi_cmd_argv_ftype mi_cmd_stack_li
> *** 88,93 ****
> --- 88,94 ----
> extern mi_cmd_argv_ftype mi_cmd_stack_list_frames;
> extern mi_cmd_argv_ftype mi_cmd_stack_list_locals;
> extern mi_cmd_argv_ftype mi_cmd_stack_select_frame;
> + extern mi_cmd_argv_ftype mi_cmd_symbol_list_lines;
> extern mi_cmd_args_ftype mi_cmd_target_download;
> extern mi_cmd_args_ftype mi_cmd_target_select;
> extern mi_cmd_argv_ftype mi_cmd_thread_list_ids;
> /* MI Command Set - symbol commands.
> Copyright 2003 Free Software Foundation, Inc.
>
> 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 "symtab.h"
> #include "ui-out.h"
>
> /* SYMBOL-LIST-LINES:
>
> Print the list of all pc addresses and lines of code for
> the provided (full or base) source file name. The entries
> are sorted in ascending PC order. */
>
> enum mi_cmd_result
> mi_cmd_symbol_list_lines (char *command, char **argv, int argc)
> {
> char *filename;
> struct symtab *s;
> int i;
> struct cleanup *cleanup_stack, *cleanup_tuple;
>
> if (argc != 1)
> error ("mi_cmd_symbol_list_lines: Usage: SOURCE_FILENAME");
>
> filename = argv[0];
> s = lookup_symtab (filename);
>
> if (s == NULL)
> error ("mi_cmd_symbol_list_lines: Unknown source file name.");
>
> /* Now, dump the associated line table. The pc addresses are already
> sorted by increasing values in the symbol table, so no need to
> perform any other sorting. */
>
> cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines");
>
> if (LINETABLE (s) != NULL && LINETABLE (s)->nitems > 0)
> for (i = 0; i < LINETABLE (s)->nitems; i++)
> {
> cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
> ui_out_field_core_addr (uiout, "pc", LINETABLE (s)->item[i].pc);
> ui_out_field_int (uiout, "line", LINETABLE (s)->item[i].line);
> do_cleanups (cleanup_tuple);
> }
>
> do_cleanups (cleanup_stack);
>
> return MI_CMD_DONE;
> }
> # Copyright 2003 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
>
> #
> # 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=mi1"
>
> 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_run_to_main
>
> proc test_list_lines {} {
> global mi_gdb_prompt
> global hex
> global decimal
> global srcfile
>
> # Test list-lines.
> # Tests:
> # -symbol-list-lines ${srcfile}
>
> mi_gdb_test "-symbol-list-lines ${srcfile}" \
> "\\^done,lines=\[\{pc=\"$hex\",line=\"$decimal\"\}.*\]" \
> "symbol-list-lines for source file ${srcfile}"
>
> }
>
> test_list_lines
>
> mi_gdb_exit
> return 0