GDB (xrefs)

mi-symbol-cmds.c
Go to the documentation of this file.
1 /* MI Command Set - symbol commands.
2 Copyright (C) 2003-2018 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #include "defs.h"
20 #include "mi-cmds.h"
21 #include "symtab.h"
22 #include "objfiles.h"
23 #include "ui-out.h"
24
25 /* Print the list of all pc addresses and lines of code for the
26 provided (full or base) source file name. The entries are sorted
27 in ascending PC order. */
28
29 void
30 mi_cmd_symbol_list_lines (const char *command, char **argv, int argc)
31 {
32 struct gdbarch *gdbarch;
33 char *filename;
34 struct symtab *s;
35 int i;
36 struct ui_out *uiout = current_uiout;
37
38 if (argc != 1)
39 error (_("-symbol-list-lines: Usage: SOURCE_FILENAME"));
40
41 filename = argv[0];
42 s = lookup_symtab (filename);
43
44 if (s == NULL)
45 error (_("-symbol-list-lines: Unknown source file name."));
46
47 /* Now, dump the associated line table. The pc addresses are
48 already sorted by increasing values in the symbol table, so no
49 need to perform any other sorting. */
50
51 gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s));
52
53 ui_out_emit_list list_emitter (uiout, "lines");
54 if (SYMTAB_LINETABLE (s) != NULL && SYMTAB_LINETABLE (s)->nitems > 0)
55 for (i = 0; i < SYMTAB_LINETABLE (s)->nitems; i++)
56 {
57 ui_out_emit_tuple tuple_emitter (uiout, NULL);
58 uiout->field_core_addr ("pc", gdbarch, SYMTAB_LINETABLE (s)->item[i].pc);
59 uiout->field_int ("line", SYMTAB_LINETABLE (s)->item[i].line);
60 }
61 }
gdbarch
Definition: gdbarch.c:127
ui_out::field_core_addr
void field_core_addr(const char *fldname, struct gdbarch *gdbarch, CORE_ADDR address)
Definition: ui-out.c:513
ui_out_emit_type
Definition: ui-out.h:192
mi-cmds.h
lookup_symtab
struct symtab * lookup_symtab(const char *name)
Definition: symtab.c:502
_
#define _(String)
Definition: gdb_locale.h:35
defs.h
objfiles.h
symtab.h
SYMTAB_OBJFILE
#define SYMTAB_OBJFILE(symtab)
Definition: symtab.h:1336
current_uiout
#define current_uiout
Definition: ui-out.h:39
get_objfile_arch
struct gdbarch * get_objfile_arch(const struct objfile *objfile)
Definition: objfiles.c:445
symtab
Definition: symtab.h:1291
ui_out
Definition: ui-out.h:77
ui_out::field_int
void field_int(const char *fldname, int value)
Definition: ui-out.c:486
gdb.argv
argv
Definition: __init__.py:63
SYMTAB_LINETABLE
#define SYMTAB_LINETABLE(symtab)
Definition: symtab.h:1332
error
void error(const char *fmt,...)
Definition: errors.c:38
mi_cmd_symbol_list_lines
void mi_cmd_symbol_list_lines(const char *command, char **argv, int argc)
Definition: mi-symbol-cmds.c:30
ui-out.h