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