2011-03-02 Michael Snyder <msnyder@vmware.com>
[deliverable/binutils-gdb.git] / gdb / mi / mi-cmd-file.c
CommitLineData
1abaf70c 1/* MI Command Set - breakpoint and watchpoint commands.
7b6bb8da 2 Copyright (C) 2000, 2001, 2002, 2007, 2008, 2009, 2010, 2011
0fb0cc75 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"
ccefe4c4 28#include "psymtab.h"
1abaf70c
BR
29
30/* Return to the client the absolute path and line number of the
31 current file being executed. */
32
ce8f13f8 33void
17784837 34mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc)
1abaf70c
BR
35{
36 struct symtab_and_line st;
1abaf70c 37
1b05df00
TT
38 if (!mi_valid_noargs ("-file-list-exec-source-file", argc, argv))
39 error (_("-file-list-exec-source-file: Usage: No args"));
1abaf70c 40
1abaf70c 41 /* Set the default file and line, also get them */
17784837
NR
42 set_default_source_symtab_and_line ();
43 st = get_current_source_symtab_and_line ();
1abaf70c
BR
44
45 /* We should always get a symtab.
46 Apparently, filename does not need to be tested for NULL.
47 The documentation in symtab.h suggests it will always be correct */
48 if (!st.symtab)
1b05df00 49 error (_("-file-list-exec-source-file: No symtab"));
1abaf70c
BR
50
51 /* Extract the fullname if it is not known yet */
57c22c6c 52 symtab_to_fullname (st.symtab);
1abaf70c
BR
53
54 /* Print to the user the line, filename and fullname */
55 ui_out_field_int (uiout, "line", st.line);
56 ui_out_field_string (uiout, "file", st.symtab->filename);
57c22c6c
BR
57
58 /* We may not be able to open the file (not available). */
59 if (st.symtab->fullname)
1abaf70c
BR
60 ui_out_field_string (uiout, "fullname", st.symtab->fullname);
61
17784837 62 ui_out_field_int (uiout, "macro-info", st.symtab->macro_table ? 1 : 0);
1abaf70c 63}
57c22c6c 64
ccefe4c4
TT
65/* A callback for map_partial_symbol_filenames. */
66static void
67print_partial_file_name (const char *filename, const char *fullname,
68 void *ignore)
69{
70 ui_out_begin (uiout, ui_out_type_tuple, NULL);
71
72 ui_out_field_string (uiout, "file", filename);
73
74 if (fullname)
75 ui_out_field_string (uiout, "fullname", fullname);
76
77 ui_out_end (uiout, ui_out_type_tuple);
78}
79
ce8f13f8 80void
57c22c6c
BR
81mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
82{
83 struct symtab *s;
57c22c6c
BR
84 struct objfile *objfile;
85
1b05df00
TT
86 if (!mi_valid_noargs ("-file-list-exec-source-files", argc, argv))
87 error (_("-file-list-exec-source-files: Usage: No args"));
57c22c6c
BR
88
89 /* Print the table header */
90 ui_out_begin (uiout, ui_out_type_list, "files");
91
92 /* Look at all of the symtabs */
93 ALL_SYMTABS (objfile, s)
94 {
95 ui_out_begin (uiout, ui_out_type_tuple, NULL);
96
97 ui_out_field_string (uiout, "file", s->filename);
98
99 /* Extract the fullname if it is not known yet */
100 symtab_to_fullname (s);
101
102 if (s->fullname)
103 ui_out_field_string (uiout, "fullname", s->fullname);
104
105 ui_out_end (uiout, ui_out_type_tuple);
106 }
107
ccefe4c4 108 map_partial_symbol_filenames (print_partial_file_name, NULL);
57c22c6c
BR
109
110 ui_out_end (uiout, ui_out_type_list);
57c22c6c 111}
This page took 0.608123 seconds and 4 git commands to generate.