Implement =thread-selected notification.
[deliverable/binutils-gdb.git] / gdb / mi / mi-cmd-file.c
CommitLineData
1abaf70c 1/* MI Command Set - breakpoint and watchpoint commands.
9b254dd1 2 Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
1abaf70c
BR
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
1abaf70c
BR
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
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
1abaf70c
BR
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"
57c22c6c 26#include "objfiles.h"
1abaf70c
BR
27
28/* Return to the client the absolute path and line number of the
29 current file being executed. */
30
ce8f13f8 31void
17784837 32mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc)
1abaf70c
BR
33{
34 struct symtab_and_line st;
35 int optind = 0;
36 char *optarg;
37
17784837 38 if (!mi_valid_noargs ("mi_cmd_file_list_exec_source_file", argc, argv))
8a3fe4f8 39 error (_("mi_cmd_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)
8a3fe4f8 49 error (_("mi_cmd_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
ce8f13f8 65void
57c22c6c
BR
66mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
67{
68 struct symtab *s;
69 struct partial_symtab *ps;
70 struct objfile *objfile;
71
72 if (!mi_valid_noargs ("mi_cmd_file_list_exec_source_files", argc, argv))
8a3fe4f8 73 error (_("mi_cmd_file_list_exec_source_files: Usage: No args"));
57c22c6c
BR
74
75 /* Print the table header */
76 ui_out_begin (uiout, ui_out_type_list, "files");
77
78 /* Look at all of the symtabs */
79 ALL_SYMTABS (objfile, s)
80 {
81 ui_out_begin (uiout, ui_out_type_tuple, NULL);
82
83 ui_out_field_string (uiout, "file", s->filename);
84
85 /* Extract the fullname if it is not known yet */
86 symtab_to_fullname (s);
87
88 if (s->fullname)
89 ui_out_field_string (uiout, "fullname", s->fullname);
90
91 ui_out_end (uiout, ui_out_type_tuple);
92 }
93
94 /* Look at all of the psymtabs */
95 ALL_PSYMTABS (objfile, ps)
96 {
97 if (!ps->readin)
98 {
99 ui_out_begin (uiout, ui_out_type_tuple, NULL);
100
101 ui_out_field_string (uiout, "file", ps->filename);
102
103 /* Extract the fullname if it is not known yet */
104 psymtab_to_fullname (ps);
105
106 if (ps->fullname)
107 ui_out_field_string (uiout, "fullname", ps->fullname);
108
109 ui_out_end (uiout, ui_out_type_tuple);
110 }
111 }
112
113 ui_out_end (uiout, ui_out_type_list);
57c22c6c 114}
This page took 0.990659 seconds and 4 git commands to generate.