Commit | Line | Data |
---|---|---|
1abaf70c | 1 | /* MI Command Set - breakpoint and watchpoint commands. |
0fb0cc75 JB |
2 | Copyright (C) 2000, 2001, 2002, 2007, 2008, 2009 |
3 | Free Software Foundation, Inc. | |
1abaf70c BR |
4 | Contributed by Cygnus Solutions (a Red Hat company). |
5 | ||
6 | This file is part of GDB. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 10 | the Free Software Foundation; either version 3 of the License, or |
1abaf70c BR |
11 | (at your option) any later version. |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
1abaf70c BR |
20 | |
21 | #include "defs.h" | |
22 | #include "mi-cmds.h" | |
23 | #include "mi-getopt.h" | |
24 | #include "ui-out.h" | |
25 | #include "symtab.h" | |
26 | #include "source.h" | |
57c22c6c | 27 | #include "objfiles.h" |
1abaf70c BR |
28 | |
29 | /* Return to the client the absolute path and line number of the | |
30 | current file being executed. */ | |
31 | ||
ce8f13f8 | 32 | void |
17784837 | 33 | mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc) |
1abaf70c BR |
34 | { |
35 | struct symtab_and_line st; | |
36 | int optind = 0; | |
37 | char *optarg; | |
38 | ||
17784837 | 39 | if (!mi_valid_noargs ("mi_cmd_file_list_exec_source_file", argc, argv)) |
8a3fe4f8 | 40 | error (_("mi_cmd_file_list_exec_source_file: Usage: No args")); |
1abaf70c | 41 | |
1abaf70c | 42 | /* Set the default file and line, also get them */ |
17784837 NR |
43 | set_default_source_symtab_and_line (); |
44 | st = get_current_source_symtab_and_line (); | |
1abaf70c BR |
45 | |
46 | /* We should always get a symtab. | |
47 | Apparently, filename does not need to be tested for NULL. | |
48 | The documentation in symtab.h suggests it will always be correct */ | |
49 | if (!st.symtab) | |
8a3fe4f8 | 50 | error (_("mi_cmd_file_list_exec_source_file: No symtab")); |
1abaf70c BR |
51 | |
52 | /* Extract the fullname if it is not known yet */ | |
57c22c6c | 53 | symtab_to_fullname (st.symtab); |
1abaf70c BR |
54 | |
55 | /* Print to the user the line, filename and fullname */ | |
56 | ui_out_field_int (uiout, "line", st.line); | |
57 | ui_out_field_string (uiout, "file", st.symtab->filename); | |
57c22c6c BR |
58 | |
59 | /* We may not be able to open the file (not available). */ | |
60 | if (st.symtab->fullname) | |
1abaf70c BR |
61 | ui_out_field_string (uiout, "fullname", st.symtab->fullname); |
62 | ||
17784837 | 63 | ui_out_field_int (uiout, "macro-info", st.symtab->macro_table ? 1 : 0); |
1abaf70c | 64 | } |
57c22c6c | 65 | |
ce8f13f8 | 66 | void |
57c22c6c BR |
67 | mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc) |
68 | { | |
69 | struct symtab *s; | |
70 | struct partial_symtab *ps; | |
71 | struct objfile *objfile; | |
72 | ||
73 | if (!mi_valid_noargs ("mi_cmd_file_list_exec_source_files", argc, argv)) | |
8a3fe4f8 | 74 | error (_("mi_cmd_file_list_exec_source_files: Usage: No args")); |
57c22c6c BR |
75 | |
76 | /* Print the table header */ | |
77 | ui_out_begin (uiout, ui_out_type_list, "files"); | |
78 | ||
79 | /* Look at all of the symtabs */ | |
80 | ALL_SYMTABS (objfile, s) | |
81 | { | |
82 | ui_out_begin (uiout, ui_out_type_tuple, NULL); | |
83 | ||
84 | ui_out_field_string (uiout, "file", s->filename); | |
85 | ||
86 | /* Extract the fullname if it is not known yet */ | |
87 | symtab_to_fullname (s); | |
88 | ||
89 | if (s->fullname) | |
90 | ui_out_field_string (uiout, "fullname", s->fullname); | |
91 | ||
92 | ui_out_end (uiout, ui_out_type_tuple); | |
93 | } | |
94 | ||
95 | /* Look at all of the psymtabs */ | |
96 | ALL_PSYMTABS (objfile, ps) | |
97 | { | |
98 | if (!ps->readin) | |
99 | { | |
100 | ui_out_begin (uiout, ui_out_type_tuple, NULL); | |
101 | ||
102 | ui_out_field_string (uiout, "file", ps->filename); | |
103 | ||
104 | /* Extract the fullname if it is not known yet */ | |
105 | psymtab_to_fullname (ps); | |
106 | ||
107 | if (ps->fullname) | |
108 | ui_out_field_string (uiout, "fullname", ps->fullname); | |
109 | ||
110 | ui_out_end (uiout, ui_out_type_tuple); | |
111 | } | |
112 | } | |
113 | ||
114 | ui_out_end (uiout, ui_out_type_list); | |
57c22c6c | 115 | } |