From: Joel Brobecker Date: Sun, 4 May 2003 03:50:13 +0000 (+0000) Subject: From Thierry Schneider : X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0d18235fb6cefd77bcb3645f3d334802452e693f;p=binutils-gdb.git From Thierry Schneider : * 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. --- diff --git a/gdb/mi/ChangeLog b/gdb/mi/ChangeLog index 73b4975534c..765143d80ce 100644 --- a/gdb/mi/ChangeLog +++ b/gdb/mi/ChangeLog @@ -1,3 +1,11 @@ +2003-05-03 J. Brobecker + + From Thierry Schneider : + * 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-02 Bob Rossi * mi-cmd-file.c: New file to implement mi file commands. diff --git a/gdb/mi/mi-cmd-symbol.c b/gdb/mi/mi-cmd-symbol.c new file mode 100644 index 00000000000..1d86d21d517 --- /dev/null +++ b/gdb/mi/mi-cmd-symbol.c @@ -0,0 +1,67 @@ +/* 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; +} diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index d6778421339..9ec174fd854 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -119,6 +119,7 @@ struct mi_cmd mi_cmds[] = {"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}, diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index 47e1bbf17a7..b0c8cb8db1f 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -88,6 +88,7 @@ extern mi_cmd_argv_ftype mi_cmd_stack_list_args; 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;