GDB (API)
/home/stan/gdb/src/gdb/mi/mi-symbol-cmds.c
Go to the documentation of this file.
00001 /* MI Command Set - symbol commands.
00002    Copyright (C) 2003-2013 Free Software Foundation, Inc.
00003 
00004    This file is part of GDB.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00018 
00019 #include "defs.h"
00020 #include "mi-cmds.h"
00021 #include "symtab.h"
00022 #include "objfiles.h"
00023 #include "ui-out.h"
00024 
00025 /* Print the list of all pc addresses and lines of code for the
00026    provided (full or base) source file name.  The entries are sorted
00027    in ascending PC order.  */
00028 
00029 void
00030 mi_cmd_symbol_list_lines (char *command, char **argv, int argc)
00031 {
00032   struct gdbarch *gdbarch;
00033   char *filename;
00034   struct symtab *s;
00035   int i;
00036   struct cleanup *cleanup_stack, *cleanup_tuple;
00037   struct ui_out *uiout = current_uiout;
00038 
00039   if (argc != 1)
00040     error (_("-symbol-list-lines: Usage: SOURCE_FILENAME"));
00041 
00042   filename = argv[0];
00043   s = lookup_symtab (filename);
00044 
00045   if (s == NULL)
00046     error (_("-symbol-list-lines: Unknown source file name."));
00047 
00048   /* Now, dump the associated line table.  The pc addresses are
00049      already sorted by increasing values in the symbol table, so no
00050      need to perform any other sorting.  */
00051 
00052   gdbarch = get_objfile_arch (s->objfile);
00053   cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines");
00054 
00055   if (LINETABLE (s) != NULL && LINETABLE (s)->nitems > 0)
00056     for (i = 0; i < LINETABLE (s)->nitems; i++)
00057     {
00058       cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
00059       ui_out_field_core_addr (uiout, "pc", gdbarch, LINETABLE (s)->item[i].pc);
00060       ui_out_field_int (uiout, "line", LINETABLE (s)->item[i].line);
00061       do_cleanups (cleanup_tuple);
00062     }
00063 
00064   do_cleanups (cleanup_stack);
00065 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines