1*b725ae77Skettenis /* MI Command Set - symbol commands.
2*b725ae77Skettenis Copyright 2003 Free Software Foundation, Inc.
3*b725ae77Skettenis
4*b725ae77Skettenis This file is part of GDB.
5*b725ae77Skettenis
6*b725ae77Skettenis This program is free software; you can redistribute it and/or modify
7*b725ae77Skettenis it under the terms of the GNU General Public License as published by
8*b725ae77Skettenis the Free Software Foundation; either version 2 of the License, or
9*b725ae77Skettenis (at your option) any later version.
10*b725ae77Skettenis
11*b725ae77Skettenis This program is distributed in the hope that it will be useful,
12*b725ae77Skettenis but WITHOUT ANY WARRANTY; without even the implied warranty of
13*b725ae77Skettenis MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14*b725ae77Skettenis GNU General Public License for more details.
15*b725ae77Skettenis
16*b725ae77Skettenis You should have received a copy of the GNU General Public License
17*b725ae77Skettenis along with this program; if not, write to the Free Software
18*b725ae77Skettenis Foundation, Inc., 59 Temple Place - Suite 330,
19*b725ae77Skettenis Boston, MA 02111-1307, USA. */
20*b725ae77Skettenis
21*b725ae77Skettenis #include "defs.h"
22*b725ae77Skettenis #include "mi-cmds.h"
23*b725ae77Skettenis #include "symtab.h"
24*b725ae77Skettenis #include "ui-out.h"
25*b725ae77Skettenis
26*b725ae77Skettenis /* SYMBOL-LIST-LINES:
27*b725ae77Skettenis
28*b725ae77Skettenis Print the list of all pc addresses and lines of code for
29*b725ae77Skettenis the provided (full or base) source file name. The entries
30*b725ae77Skettenis are sorted in ascending PC order. */
31*b725ae77Skettenis
32*b725ae77Skettenis enum mi_cmd_result
mi_cmd_symbol_list_lines(char * command,char ** argv,int argc)33*b725ae77Skettenis mi_cmd_symbol_list_lines (char *command, char **argv, int argc)
34*b725ae77Skettenis {
35*b725ae77Skettenis char *filename;
36*b725ae77Skettenis struct symtab *s;
37*b725ae77Skettenis int i;
38*b725ae77Skettenis struct cleanup *cleanup_stack, *cleanup_tuple;
39*b725ae77Skettenis
40*b725ae77Skettenis if (argc != 1)
41*b725ae77Skettenis error ("mi_cmd_symbol_list_lines: Usage: SOURCE_FILENAME");
42*b725ae77Skettenis
43*b725ae77Skettenis filename = argv[0];
44*b725ae77Skettenis s = lookup_symtab (filename);
45*b725ae77Skettenis
46*b725ae77Skettenis if (s == NULL)
47*b725ae77Skettenis error ("mi_cmd_symbol_list_lines: Unknown source file name.");
48*b725ae77Skettenis
49*b725ae77Skettenis /* Now, dump the associated line table. The pc addresses are already
50*b725ae77Skettenis sorted by increasing values in the symbol table, so no need to
51*b725ae77Skettenis perform any other sorting. */
52*b725ae77Skettenis
53*b725ae77Skettenis cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines");
54*b725ae77Skettenis
55*b725ae77Skettenis if (LINETABLE (s) != NULL && LINETABLE (s)->nitems > 0)
56*b725ae77Skettenis for (i = 0; i < LINETABLE (s)->nitems; i++)
57*b725ae77Skettenis {
58*b725ae77Skettenis cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
59*b725ae77Skettenis ui_out_field_core_addr (uiout, "pc", LINETABLE (s)->item[i].pc);
60*b725ae77Skettenis ui_out_field_int (uiout, "line", LINETABLE (s)->item[i].line);
61*b725ae77Skettenis do_cleanups (cleanup_tuple);
62*b725ae77Skettenis }
63*b725ae77Skettenis
64*b725ae77Skettenis do_cleanups (cleanup_stack);
65*b725ae77Skettenis
66*b725ae77Skettenis return MI_CMD_DONE;
67*b725ae77Skettenis }
68