]>
Commit | Line | Data |
---|---|---|
1abaf70c BR |
1 | /* MI Command Set - breakpoint and watchpoint commands. |
2 | Copyright 2000, 2001, 2002 Free Software Foundation, Inc. | |
3 | Contributed by Cygnus Solutions (a Red Hat company). | |
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 | |
9 | the Free Software Foundation; either version 2 of the License, or | |
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 | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #include "defs.h" | |
23 | #include "mi-cmds.h" | |
24 | #include "mi-getopt.h" | |
25 | #include "ui-out.h" | |
26 | #include "symtab.h" | |
27 | #include "source.h" | |
57c22c6c | 28 | #include "objfiles.h" |
1abaf70c BR |
29 | |
30 | /* Return to the client the absolute path and line number of the | |
31 | current file being executed. */ | |
32 | ||
33 | enum mi_cmd_result | |
34 | mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc) | |
35 | { | |
36 | struct symtab_and_line st; | |
37 | int optind = 0; | |
38 | char *optarg; | |
39 | ||
40 | if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) ) | |
41 | error ("mi_cmd_file_list_exec_source_file: Usage: No args"); | |
42 | ||
1abaf70c BR |
43 | /* Set the default file and line, also get them */ |
44 | set_default_source_symtab_and_line(); | |
45 | st = get_current_source_symtab_and_line(); | |
46 | ||
47 | /* We should always get a symtab. | |
48 | Apparently, filename does not need to be tested for NULL. | |
49 | The documentation in symtab.h suggests it will always be correct */ | |
50 | if (!st.symtab) | |
51 | error ("mi_cmd_file_list_exec_source_file: No symtab"); | |
52 | ||
53 | /* Extract the fullname if it is not known yet */ | |
57c22c6c | 54 | symtab_to_fullname (st.symtab); |
1abaf70c BR |
55 | |
56 | /* Print to the user the line, filename and fullname */ | |
57 | ui_out_field_int (uiout, "line", st.line); | |
58 | ui_out_field_string (uiout, "file", st.symtab->filename); | |
57c22c6c BR |
59 | |
60 | /* We may not be able to open the file (not available). */ | |
61 | if (st.symtab->fullname) | |
1abaf70c BR |
62 | ui_out_field_string (uiout, "fullname", st.symtab->fullname); |
63 | ||
64 | return MI_CMD_DONE; | |
65 | } | |
57c22c6c BR |
66 | |
67 | enum mi_cmd_result | |
68 | mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc) | |
69 | { | |
70 | struct symtab *s; | |
71 | struct partial_symtab *ps; | |
72 | struct objfile *objfile; | |
73 | ||
74 | if (!mi_valid_noargs ("mi_cmd_file_list_exec_source_files", argc, argv)) | |
75 | error ("mi_cmd_file_list_exec_source_files: Usage: No args"); | |
76 | ||
77 | /* Print the table header */ | |
78 | ui_out_begin (uiout, ui_out_type_list, "files"); | |
79 | ||
80 | /* Look at all of the symtabs */ | |
81 | ALL_SYMTABS (objfile, s) | |
82 | { | |
83 | ui_out_begin (uiout, ui_out_type_tuple, NULL); | |
84 | ||
85 | ui_out_field_string (uiout, "file", s->filename); | |
86 | ||
87 | /* Extract the fullname if it is not known yet */ | |
88 | symtab_to_fullname (s); | |
89 | ||
90 | if (s->fullname) | |
91 | ui_out_field_string (uiout, "fullname", s->fullname); | |
92 | ||
93 | ui_out_end (uiout, ui_out_type_tuple); | |
94 | } | |
95 | ||
96 | /* Look at all of the psymtabs */ | |
97 | ALL_PSYMTABS (objfile, ps) | |
98 | { | |
99 | if (!ps->readin) | |
100 | { | |
101 | ui_out_begin (uiout, ui_out_type_tuple, NULL); | |
102 | ||
103 | ui_out_field_string (uiout, "file", ps->filename); | |
104 | ||
105 | /* Extract the fullname if it is not known yet */ | |
106 | psymtab_to_fullname (ps); | |
107 | ||
108 | if (ps->fullname) | |
109 | ui_out_field_string (uiout, "fullname", ps->fullname); | |
110 | ||
111 | ui_out_end (uiout, ui_out_type_tuple); | |
112 | } | |
113 | } | |
114 | ||
115 | ui_out_end (uiout, ui_out_type_list); | |
116 | ||
117 | return MI_CMD_DONE; | |
118 | } |