This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Adding -file-list-exec-source-file command to GDB/MI


This change essentially adds the command -file-list-exec-source-file to
the mi commands.

* mi-cmd-file.c:    Added file to implement mi file commands.
* mi-cmds.c:        Added -file-list-exec-source-file command.
* mi-cmds.h:        Added -file-list-exec-source-file to proto list.
* doc/gdb.texinfo:  Document -file-list-exec-source-file.
* mi-file.exp:      Added testcase to test -file-list-exec-source-file.

Thanks,
Bob Rossi

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.351
diff -c -r1.351 Makefile.in
*** Makefile.in	26 Mar 2003 03:39:42 -0000	1.351
--- Makefile.in	29 Mar 2003 00:24:56 -0000
***************
*** 168,181 ****
  SUBDIR_MI_OBS = \
  	mi-out.o mi-console.o \
  	mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
! 	mi-cmd-disas.o \
  	mi-interp.o \
  	mi-main.o mi-parse.o mi-getopt.o
  SUBDIR_MI_SRCS = \
  	mi/mi-out.c mi/mi-console.c \
  	mi/mi-cmds.c mi/mi-cmd-env.c \
  	mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \
! 	mi/mi-cmd-disas.c \
  	mi/mi-interp.c \
  	mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
  SUBDIR_MI_DEPS =
--- 168,181 ----
  SUBDIR_MI_OBS = \
  	mi-out.o mi-console.o \
  	mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
! 	mi-cmd-file.o mi-cmd-disas.o \
  	mi-interp.o \
  	mi-main.o mi-parse.o mi-getopt.o
  SUBDIR_MI_SRCS = \
  	mi/mi-out.c mi/mi-console.c \
  	mi/mi-cmds.c mi/mi-cmd-env.c \
  	mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \
! 	mi/mi-cmd-file.c mi/mi-cmd-disas.c \
  	mi/mi-interp.c \
  	mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
  SUBDIR_MI_DEPS =
***************
*** 2538,2543 ****
--- 2538,2547 ----
  	$(ui_out_h) $(mi_out_h) $(breakpoint_h) $(gdb_string_h) \
  	$(mi_getopt_h) $(gdb_events_h) $(gdb_h)
  	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-break.c
+ mi-cmd-file.o: $(srcdir)/mi/mi-cmd-file.c $(defs_h) $(mi_cmds_h) \
+ 	$(ui_out_h) $(mi_out_h) $(breakpoint_h) $(gdb_string_h) \
+ 	$(mi_getopt_h) $(gdb_events_h) $(gdb_h)
+ 	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-file.c
  mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_h) \
  	$(mi_cmds_h) $(mi_getopt_h) $(ui_out_h) $(gdb_string_h) $(disasm_h)
  	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-disas.c
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.154
diff -c -r1.154 gdb.texinfo
*** doc/gdb.texinfo	27 Mar 2003 15:17:34 -0000	1.154
--- doc/gdb.texinfo	29 Mar 2003 00:25:22 -0000
***************
*** 16337,16342 ****
--- 16337,16353 ----
  N.A.
  
  
+ @subheading The @code{-file-list-exec-source-file} Command
+ @findex -file-list-exec-source-file
+ 
+ @subsubheading Synopsis
+ 
+ @smallexample
+  -file-list-exec-source-file
+ @end smallexample
+ 
+ List the current source file and line for the current executable.
+ 
  @subheading The @code{-file-list-exec-source-files} Command
  @findex -file-list-exec-source-files
  
Index: mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.10
diff -c -r1.10 mi-cmds.c
*** mi/mi-cmds.c	6 Feb 2003 01:19:12 -0000	1.10
--- mi/mi-cmds.c	29 Mar 2003 00:25:23 -0000
***************
*** 80,85 ****
--- 80,86 ----
    {"file-exec-and-symbols", "file %s", 0},
    {"file-exec-file", "exec-file %s", 0},
    {"file-list-exec-sections", 0, 0},
+   {"file-list-exec-source-file", 0, 0, mi_cmd_file_list_exec_source_file},
    {"file-list-exec-source-files", 0, 0},
    {"file-list-shared-libraries", 0, 0},
    {"file-list-symbol-files", 0, 0},
Index: mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.7
diff -c -r1.7 mi-cmds.h
*** mi/mi-cmds.h	6 Feb 2003 01:19:12 -0000	1.7
--- mi/mi-cmds.h	29 Mar 2003 00:25:23 -0000
***************
*** 80,85 ****
--- 80,86 ----
  extern mi_cmd_args_ftype mi_cmd_exec_step_instruction;
  extern mi_cmd_args_ftype mi_cmd_exec_until;
  extern mi_cmd_args_ftype mi_cmd_exec_interrupt;
+ extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file;
  extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
  extern mi_cmd_argv_ftype mi_cmd_interpreter_exec;
  extern mi_cmd_argv_ftype mi_cmd_stack_info_depth;
/* MI Command Set - breakpoint and watchpoint commands.
   Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
   Contributed by Cygnus Solutions (a Red Hat company).

   This file is part of GDB.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

#include "defs.h"
#include "mi-cmds.h"
#include "ui-out.h"
#include "symtab.h"
#include "source.h"

/* Return to the client the absolute path and line number of the 
   current file being executed. */

enum mi_cmd_result
mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc)
{
  struct symtab_and_line st;
  if (argc != 0)
    error ("mi_cmd_file_list_exec_source_file: Usage: No args");

  /* Set the default file and line, also get them */
  set_default_source_symtab_and_line();
  st = get_current_source_symtab_and_line();

  /* We should always get a symtab. */
  if (!st.symtab)
    error ("mi_cmd_file_list_exec_source_file: No symtab");

  /* Extract the fullname if it is not known yet */
  if (st.symtab->fullname == NULL)
    symtab_to_filename (st.symtab);

  /* We may not be able to open the file (not available). */
  if (st.symtab->fullname == NULL)
    error ("mi_cmd_file_list_exec_source_file: File not found");

  /* Print to the user the line and absolute file name */
  ui_out_field_int (uiout, "line", st.line);
  ui_out_field_string (uiout, "file", st.symtab->fullname);

  return MI_CMD_DONE;
}

Attachment: mi-file.exp
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]