15796c8dcSSimon Schubert /* MI Command Set - symbol commands.
2*ef5ccd6cSJohn Marino Copyright (C) 2003-2013 Free Software Foundation, Inc.
35796c8dcSSimon Schubert
45796c8dcSSimon Schubert This file is part of GDB.
55796c8dcSSimon Schubert
65796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify
75796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by
85796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or
95796c8dcSSimon Schubert (at your option) any later version.
105796c8dcSSimon Schubert
115796c8dcSSimon Schubert This program is distributed in the hope that it will be useful,
125796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of
135796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
145796c8dcSSimon Schubert GNU General Public License for more details.
155796c8dcSSimon Schubert
165796c8dcSSimon Schubert You should have received a copy of the GNU General Public License
175796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */
185796c8dcSSimon Schubert
195796c8dcSSimon Schubert #include "defs.h"
205796c8dcSSimon Schubert #include "mi-cmds.h"
215796c8dcSSimon Schubert #include "symtab.h"
225796c8dcSSimon Schubert #include "objfiles.h"
235796c8dcSSimon Schubert #include "ui-out.h"
245796c8dcSSimon Schubert
25*ef5ccd6cSJohn Marino /* Print the list of all pc addresses and lines of code for the
26*ef5ccd6cSJohn Marino provided (full or base) source file name. The entries are sorted
27*ef5ccd6cSJohn Marino in ascending PC order. */
285796c8dcSSimon Schubert
295796c8dcSSimon Schubert void
mi_cmd_symbol_list_lines(char * command,char ** argv,int argc)305796c8dcSSimon Schubert mi_cmd_symbol_list_lines (char *command, char **argv, int argc)
315796c8dcSSimon Schubert {
325796c8dcSSimon Schubert struct gdbarch *gdbarch;
335796c8dcSSimon Schubert char *filename;
345796c8dcSSimon Schubert struct symtab *s;
355796c8dcSSimon Schubert int i;
365796c8dcSSimon Schubert struct cleanup *cleanup_stack, *cleanup_tuple;
37a45ae5f8SJohn Marino struct ui_out *uiout = current_uiout;
385796c8dcSSimon Schubert
395796c8dcSSimon Schubert if (argc != 1)
40c50c785cSJohn Marino error (_("-symbol-list-lines: Usage: SOURCE_FILENAME"));
415796c8dcSSimon Schubert
425796c8dcSSimon Schubert filename = argv[0];
435796c8dcSSimon Schubert s = lookup_symtab (filename);
445796c8dcSSimon Schubert
455796c8dcSSimon Schubert if (s == NULL)
46c50c785cSJohn Marino error (_("-symbol-list-lines: Unknown source file name."));
475796c8dcSSimon Schubert
48*ef5ccd6cSJohn Marino /* Now, dump the associated line table. The pc addresses are
49*ef5ccd6cSJohn Marino already sorted by increasing values in the symbol table, so no
50*ef5ccd6cSJohn Marino need to perform any other sorting. */
515796c8dcSSimon Schubert
525796c8dcSSimon Schubert gdbarch = get_objfile_arch (s->objfile);
535796c8dcSSimon Schubert cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines");
545796c8dcSSimon Schubert
555796c8dcSSimon Schubert if (LINETABLE (s) != NULL && LINETABLE (s)->nitems > 0)
565796c8dcSSimon Schubert for (i = 0; i < LINETABLE (s)->nitems; i++)
575796c8dcSSimon Schubert {
585796c8dcSSimon Schubert cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
595796c8dcSSimon Schubert ui_out_field_core_addr (uiout, "pc", gdbarch, LINETABLE (s)->item[i].pc);
605796c8dcSSimon Schubert ui_out_field_int (uiout, "line", LINETABLE (s)->item[i].line);
615796c8dcSSimon Schubert do_cleanups (cleanup_tuple);
625796c8dcSSimon Schubert }
635796c8dcSSimon Schubert
645796c8dcSSimon Schubert do_cleanups (cleanup_stack);
655796c8dcSSimon Schubert }
66