1130803Smarcel/* MI Command Set - symbol commands. 2130803Smarcel Copyright 2003 Free Software Foundation, Inc. 3130803Smarcel 4130803Smarcel This file is part of GDB. 5130803Smarcel 6130803Smarcel This program is free software; you can redistribute it and/or modify 7130803Smarcel it under the terms of the GNU General Public License as published by 8130803Smarcel the Free Software Foundation; either version 2 of the License, or 9130803Smarcel (at your option) any later version. 10130803Smarcel 11130803Smarcel This program is distributed in the hope that it will be useful, 12130803Smarcel but WITHOUT ANY WARRANTY; without even the implied warranty of 13130803Smarcel MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14130803Smarcel GNU General Public License for more details. 15130803Smarcel 16130803Smarcel You should have received a copy of the GNU General Public License 17130803Smarcel along with this program; if not, write to the Free Software 18130803Smarcel Foundation, Inc., 59 Temple Place - Suite 330, 19130803Smarcel Boston, MA 02111-1307, USA. */ 20130803Smarcel 21130803Smarcel#include "defs.h" 22130803Smarcel#include "mi-cmds.h" 23130803Smarcel#include "symtab.h" 24130803Smarcel#include "ui-out.h" 25130803Smarcel 26130803Smarcel/* SYMBOL-LIST-LINES: 27130803Smarcel 28130803Smarcel Print the list of all pc addresses and lines of code for 29130803Smarcel the provided (full or base) source file name. The entries 30130803Smarcel are sorted in ascending PC order. */ 31130803Smarcel 32130803Smarcelenum mi_cmd_result 33130803Smarcelmi_cmd_symbol_list_lines (char *command, char **argv, int argc) 34130803Smarcel{ 35130803Smarcel char *filename; 36130803Smarcel struct symtab *s; 37130803Smarcel int i; 38130803Smarcel struct cleanup *cleanup_stack, *cleanup_tuple; 39130803Smarcel 40130803Smarcel if (argc != 1) 41130803Smarcel error ("mi_cmd_symbol_list_lines: Usage: SOURCE_FILENAME"); 42130803Smarcel 43130803Smarcel filename = argv[0]; 44130803Smarcel s = lookup_symtab (filename); 45130803Smarcel 46130803Smarcel if (s == NULL) 47130803Smarcel error ("mi_cmd_symbol_list_lines: Unknown source file name."); 48130803Smarcel 49130803Smarcel /* Now, dump the associated line table. The pc addresses are already 50130803Smarcel sorted by increasing values in the symbol table, so no need to 51130803Smarcel perform any other sorting. */ 52130803Smarcel 53130803Smarcel cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines"); 54130803Smarcel 55130803Smarcel if (LINETABLE (s) != NULL && LINETABLE (s)->nitems > 0) 56130803Smarcel for (i = 0; i < LINETABLE (s)->nitems; i++) 57130803Smarcel { 58130803Smarcel cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); 59130803Smarcel ui_out_field_core_addr (uiout, "pc", LINETABLE (s)->item[i].pc); 60130803Smarcel ui_out_field_int (uiout, "line", LINETABLE (s)->item[i].line); 61130803Smarcel do_cleanups (cleanup_tuple); 62130803Smarcel } 63130803Smarcel 64130803Smarcel do_cleanups (cleanup_stack); 65130803Smarcel 66130803Smarcel return MI_CMD_DONE; 67130803Smarcel} 68