GDB (xrefs)
mi-cmd-file.c
Go to the documentation of this file.
1 /* MI Command Set - file commands.
2  Copyright (C) 2000-2015 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 3 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, see <http://www.gnu.org/licenses/>. */
19 
20 #include "defs.h"
21 #include "mi-cmds.h"
22 #include "mi-getopt.h"
23 #include "ui-out.h"
24 #include "symtab.h"
25 #include "source.h"
26 #include "objfiles.h"
27 #include "psymtab.h"
28 
29 /* Return to the client the absolute path and line number of the
30  current file being executed. */
31 
32 void
33 mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc)
34 {
35  struct symtab_and_line st;
36  struct ui_out *uiout = current_uiout;
37 
38  if (!mi_valid_noargs ("-file-list-exec-source-file", argc, argv))
39  error (_("-file-list-exec-source-file: Usage: No args"));
40 
41  /* Set the default file and line, also get them. */
44 
45  /* We should always get a symtab. Apparently, filename does not
46  need to be tested for NULL. The documentation in symtab.h
47  suggests it will always be correct. */
48  if (!st.symtab)
49  error (_("-file-list-exec-source-file: No symtab"));
50 
51  /* Print to the user the line, filename and fullname. */
52  ui_out_field_int (uiout, "line", st.line);
53  ui_out_field_string (uiout, "file",
55 
56  ui_out_field_string (uiout, "fullname", symtab_to_fullname (st.symtab));
57 
58  ui_out_field_int (uiout, "macro-info",
60  (SYMTAB_COMPUNIT (st.symtab)) != NULL);
61 }
62 
63 /* A callback for map_partial_symbol_filenames. */
64 
65 static void
66 print_partial_file_name (const char *filename, const char *fullname,
67  void *ignore)
68 {
69  struct ui_out *uiout = current_uiout;
70 
71  ui_out_begin (uiout, ui_out_type_tuple, NULL);
72 
73  ui_out_field_string (uiout, "file", filename);
74 
75  if (fullname)
76  ui_out_field_string (uiout, "fullname", fullname);
77 
79 }
80 
81 void
82 mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
83 {
84  struct ui_out *uiout = current_uiout;
85  struct compunit_symtab *cu;
86  struct symtab *s;
87  struct objfile *objfile;
88 
89  if (!mi_valid_noargs ("-file-list-exec-source-files", argc, argv))
90  error (_("-file-list-exec-source-files: Usage: No args"));
91 
92  /* Print the table header. */
93  ui_out_begin (uiout, ui_out_type_list, "files");
94 
95  /* Look at all of the file symtabs. */
96  ALL_FILETABS (objfile, cu, s)
97  {
98  ui_out_begin (uiout, ui_out_type_tuple, NULL);
99 
101  ui_out_field_string (uiout, "fullname", symtab_to_fullname (s));
102 
103  ui_out_end (uiout, ui_out_type_tuple);
104  }
105 
107  1 /*need_fullname*/);
108 
109  ui_out_end (uiout, ui_out_type_list);
110 }
const char * symtab_to_filename_for_display(struct symtab *symtab)
Definition: source.c:1171
#define SYMTAB_COMPUNIT(symtab)
Definition: symtab.h:965
void ui_out_field_int(struct ui_out *uiout, const char *fldname, int value)
Definition: ui-out.c:467
void ui_out_end(struct ui_out *uiout, enum ui_out_type type)
Definition: ui-out.c:415
void set_default_source_symtab_and_line(void)
Definition: source.c:203
void map_symbol_filenames(symbol_filename_ftype *fun, void *data, int need_fullname)
Definition: symfile.c:3940
struct symtab_and_line get_current_source_symtab_and_line(void)
Definition: source.c:181
#define COMPUNIT_MACRO_TABLE(cust)
Definition: symtab.h:1104
#define _(String)
Definition: gdb_locale.h:40
Definition: ui-out.c:99
const char * symtab_to_fullname(struct symtab *s)
Definition: source.c:1131
int mi_valid_noargs(const char *prefix, int argc, char **argv)
Definition: mi-getopt.c:99
Definition: symtab.h:925
struct symtab * symtab
Definition: symtab.h:1369
static void print_partial_file_name(const char *filename, const char *fullname, void *ignore)
Definition: mi-cmd-file.c:66
#define ALL_FILETABS(objfile, ps, s)
Definition: objfiles.h:610
void ui_out_begin(struct ui_out *uiout, enum ui_out_type type, const char *id)
Definition: ui-out.c:377
void mi_cmd_file_list_exec_source_files(char *command, char **argv, int argc)
Definition: mi-cmd-file.c:82
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
Definition: corelow.c:917
void ui_out_field_string(struct ui_out *uiout, const char *fldname, const char *string)
Definition: ui-out.c:541
struct ui_out * current_uiout
Definition: ui-out.c:233
void mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc)
Definition: mi-cmd-file.c:33
void error(const char *fmt,...)
Definition: errors.c:38