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