1/* MI Command Set - breakpoint and watchpoint commands. 2 Copyright 2000, 2001, 2002 Free Software Foundation, Inc. 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 9 the Free Software Foundation; either version 2 of the License, or 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 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place - Suite 330, 20 Boston, MA 02111-1307, USA. */ 21 22#include "defs.h" 23#include "mi-cmds.h" 24#include "mi-getopt.h" 25#include "ui-out.h" 26#include "symtab.h" 27#include "source.h" 28 29/* Return to the client the absolute path and line number of the 30 current file being executed. */ 31 32enum mi_cmd_result 33mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc) 34{ 35 struct symtab_and_line st; 36 int optind = 0; 37 char *optarg; 38 39 if ( !mi_valid_noargs("mi_cmd_file_list_exec_source_file", argc, argv) ) 40 error ("mi_cmd_file_list_exec_source_file: Usage: No args"); 41 42 43 /* Set the default file and line, also get them */ 44 set_default_source_symtab_and_line(); 45 st = get_current_source_symtab_and_line(); 46 47 /* We should always get a symtab. 48 Apparently, filename does not need to be tested for NULL. 49 The documentation in symtab.h suggests it will always be correct */ 50 if (!st.symtab) 51 error ("mi_cmd_file_list_exec_source_file: No symtab"); 52 53 /* Extract the fullname if it is not known yet */ 54 if (st.symtab->fullname == NULL) 55 symtab_to_filename (st.symtab); 56 57 /* We may not be able to open the file (not available). */ 58 if (st.symtab->fullname == NULL) 59 error ("mi_cmd_file_list_exec_source_file: File not found"); 60 61 /* Print to the user the line, filename and fullname */ 62 ui_out_field_int (uiout, "line", st.line); 63 ui_out_field_string (uiout, "file", st.symtab->filename); 64 ui_out_field_string (uiout, "fullname", st.symtab->fullname); 65 66 return MI_CMD_DONE; 67} 68