GDB (API)
|
00001 /* MI Command Set - file commands. 00002 Copyright (C) 2000-2013 Free Software Foundation, Inc. 00003 Contributed by Cygnus Solutions (a Red Hat company). 00004 00005 This file is part of GDB. 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00019 00020 #include "defs.h" 00021 #include "mi-cmds.h" 00022 #include "mi-getopt.h" 00023 #include "ui-out.h" 00024 #include "symtab.h" 00025 #include "source.h" 00026 #include "objfiles.h" 00027 #include "psymtab.h" 00028 00029 /* Return to the client the absolute path and line number of the 00030 current file being executed. */ 00031 00032 void 00033 mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc) 00034 { 00035 struct symtab_and_line st; 00036 struct ui_out *uiout = current_uiout; 00037 00038 if (!mi_valid_noargs ("-file-list-exec-source-file", argc, argv)) 00039 error (_("-file-list-exec-source-file: Usage: No args")); 00040 00041 /* Set the default file and line, also get them. */ 00042 set_default_source_symtab_and_line (); 00043 st = get_current_source_symtab_and_line (); 00044 00045 /* We should always get a symtab. Apparently, filename does not 00046 need to be tested for NULL. The documentation in symtab.h 00047 suggests it will always be correct. */ 00048 if (!st.symtab) 00049 error (_("-file-list-exec-source-file: No symtab")); 00050 00051 /* Print to the user the line, filename and fullname. */ 00052 ui_out_field_int (uiout, "line", st.line); 00053 ui_out_field_string (uiout, "file", 00054 symtab_to_filename_for_display (st.symtab)); 00055 00056 ui_out_field_string (uiout, "fullname", symtab_to_fullname (st.symtab)); 00057 00058 ui_out_field_int (uiout, "macro-info", st.symtab->macro_table ? 1 : 0); 00059 } 00060 00061 /* A callback for map_partial_symbol_filenames. */ 00062 00063 static void 00064 print_partial_file_name (const char *filename, const char *fullname, 00065 void *ignore) 00066 { 00067 struct ui_out *uiout = current_uiout; 00068 00069 ui_out_begin (uiout, ui_out_type_tuple, NULL); 00070 00071 ui_out_field_string (uiout, "file", filename); 00072 00073 if (fullname) 00074 ui_out_field_string (uiout, "fullname", fullname); 00075 00076 ui_out_end (uiout, ui_out_type_tuple); 00077 } 00078 00079 void 00080 mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc) 00081 { 00082 struct ui_out *uiout = current_uiout; 00083 struct symtab *s; 00084 struct objfile *objfile; 00085 00086 if (!mi_valid_noargs ("-file-list-exec-source-files", argc, argv)) 00087 error (_("-file-list-exec-source-files: Usage: No args")); 00088 00089 /* Print the table header. */ 00090 ui_out_begin (uiout, ui_out_type_list, "files"); 00091 00092 /* Look at all of the symtabs. */ 00093 ALL_SYMTABS (objfile, s) 00094 { 00095 ui_out_begin (uiout, ui_out_type_tuple, NULL); 00096 00097 ui_out_field_string (uiout, "file", symtab_to_filename_for_display (s)); 00098 ui_out_field_string (uiout, "fullname", symtab_to_fullname (s)); 00099 00100 ui_out_end (uiout, ui_out_type_tuple); 00101 } 00102 00103 map_partial_symbol_filenames (print_partial_file_name, NULL, 00104 1 /*need_fullname*/); 00105 00106 ui_out_end (uiout, ui_out_type_list); 00107 }