]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/mi/mi-symbol-cmds.c
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / mi / mi-symbol-cmds.c
CommitLineData
0d18235f 1/* MI Command Set - symbol commands.
6aba47ca 2 Copyright (C) 2003, 2007 Free Software Foundation, Inc.
0d18235f
JB
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
1caae165
EZ
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
0d18235f
JB
20
21#include "defs.h"
22#include "mi-cmds.h"
23#include "symtab.h"
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
32enum mi_cmd_result
33mi_cmd_symbol_list_lines (char *command, char **argv, int argc)
34{
35 char *filename;
36 struct symtab *s;
37 int i;
38 struct cleanup *cleanup_stack, *cleanup_tuple;
39
40 if (argc != 1)
8a3fe4f8 41 error (_("mi_cmd_symbol_list_lines: Usage: SOURCE_FILENAME"));
0d18235f
JB
42
43 filename = argv[0];
44 s = lookup_symtab (filename);
45
46 if (s == NULL)
8a3fe4f8 47 error (_("mi_cmd_symbol_list_lines: Unknown source file name."));
0d18235f
JB
48
49 /* Now, dump the associated line table. The pc addresses are already
50 sorted by increasing values in the symbol table, so no need to
51 perform any other sorting. */
52
53 cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines");
54
55 if (LINETABLE (s) != NULL && LINETABLE (s)->nitems > 0)
56 for (i = 0; i < LINETABLE (s)->nitems; i++)
57 {
58 cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
59 ui_out_field_core_addr (uiout, "pc", LINETABLE (s)->item[i].pc);
60 ui_out_field_int (uiout, "line", LINETABLE (s)->item[i].line);
61 do_cleanups (cleanup_tuple);
62 }
63
64 do_cleanups (cleanup_stack);
65
66 return MI_CMD_DONE;
67}