Commit | Line | Data |
---|---|---|
0d18235f | 1 | /* MI Command Set - symbol commands. |
0b302171 | 2 | Copyright (C) 2003, 2007-2012 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 | |
a9762ec7 | 8 | the Free Software Foundation; either version 3 of the License, or |
0d18235f JB |
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 | |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
0d18235f JB |
18 | |
19 | #include "defs.h" | |
20 | #include "mi-cmds.h" | |
21 | #include "symtab.h" | |
5af949e3 | 22 | #include "objfiles.h" |
0d18235f JB |
23 | #include "ui-out.h" |
24 | ||
2b03b41d SS |
25 | /* Print the list of all pc addresses and lines of code for the |
26 | provided (full or base) source file name. The entries are sorted | |
27 | in ascending PC order. */ | |
0d18235f | 28 | |
ce8f13f8 | 29 | void |
0d18235f JB |
30 | mi_cmd_symbol_list_lines (char *command, char **argv, int argc) |
31 | { | |
5af949e3 | 32 | struct gdbarch *gdbarch; |
0d18235f JB |
33 | char *filename; |
34 | struct symtab *s; | |
35 | int i; | |
36 | struct cleanup *cleanup_stack, *cleanup_tuple; | |
79a45e25 | 37 | struct ui_out *uiout = current_uiout; |
0d18235f JB |
38 | |
39 | if (argc != 1) | |
1b05df00 | 40 | error (_("-symbol-list-lines: Usage: SOURCE_FILENAME")); |
0d18235f JB |
41 | |
42 | filename = argv[0]; | |
43 | s = lookup_symtab (filename); | |
44 | ||
45 | if (s == NULL) | |
1b05df00 | 46 | error (_("-symbol-list-lines: Unknown source file name.")); |
0d18235f | 47 | |
2b03b41d SS |
48 | /* Now, dump the associated line table. The pc addresses are |
49 | already sorted by increasing values in the symbol table, so no | |
50 | need to perform any other sorting. */ | |
0d18235f | 51 | |
5af949e3 | 52 | gdbarch = get_objfile_arch (s->objfile); |
0d18235f JB |
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); | |
5af949e3 | 59 | ui_out_field_core_addr (uiout, "pc", gdbarch, LINETABLE (s)->item[i].pc); |
0d18235f JB |
60 | ui_out_field_int (uiout, "line", LINETABLE (s)->item[i].line); |
61 | do_cleanups (cleanup_tuple); | |
62 | } | |
63 | ||
64 | do_cleanups (cleanup_stack); | |
0d18235f | 65 | } |