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