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]

Re: [PATCH] mi-symbol-*


Hi,

Sorry for the long delay, I've been busy with other projects. I'll try 
providing the patch in smaller piece. 

Any comments on the current patch?

Jelmer
-- 
Jelmer Vernooij <jelmer at nl dot linux dot org> - http://nl.linux.org/~jelmer/
 21:10:41 up 1 day,  2:07, 10 users,  load average: 0.08, 0.04, 0.17
diff -r -u gdb+dejagnu-20020907/gdb/Makefile.in gdb-jelmer/gdb/Makefile.in
--- gdb+dejagnu-20020907/gdb/Makefile.in	2002-09-02 20:09:06.000000000 +0200
+++ gdb-jelmer/gdb/Makefile.in	2002-09-11 20:22:30.000000000 +0200
@@ -165,12 +165,12 @@
 	mi-out.o mi-console.o \
 	mi-cmds.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
 	mi-cmd-disas.o \
-	mi-main.o mi-parse.o mi-getopt.o
+	mi-main.o mi-parse.o mi-getopt.o mi-cmd-symbol.o
 SUBDIR_MI_SRCS = \
 	mi/mi-out.c mi/mi-console.c \
 	mi/mi-cmds.c \
 	mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \
-	mi/mi-cmd-disas.c \
+	mi/mi-cmd-disas.c mi/mi-cmd-symbol.c \
 	mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
 SUBDIR_MI_DEPS =
 SUBDIR_MI_INITS = \
@@ -2411,6 +2411,10 @@
 # Need to explicitly specify the compile rule as make will do nothing
 # or try to compile the object file into the mi directory.
 
+mi-cmd-symbol.o: $(srcdir)/mi/mi-cmd-symbol.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-symbol.c
 mi-cmd-break.o: $(srcdir)/mi/mi-cmd-break.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)
diff -r -u gdb+dejagnu-20020907/gdb/mi/gdbmi.texinfo gdb-jelmer/gdb/mi/gdbmi.texinfo
--- gdb+dejagnu-20020907/gdb/mi/gdbmi.texinfo	2002-06-17 19:30:57.000000000 +0200
+++ gdb-jelmer/gdb/mi/gdbmi.texinfo	2002-09-25 20:07:32.000000000 +0200
@@ -97,8 +97,8 @@
 
 @heading Acknowledgments
 
-In alphabetic order: Andrew Cagney, Fernando Nasser, Stan Shebs and
-Elena Zannoni.
+In alphabetic order: Andrew Cagney, Fernando Nasser, Stan Shebs, 
+Jelmer Vernooij and Elena Zannoni.
 
 @menu
 * GDB/MI Command Syntax::
@@ -2892,18 +2906,24 @@
 @subsubheading Synopsis
 
 @example
- -symbol-info-function
+ -symbol-info-function @var{symbol}
 @end example
 
-Show which function the symbol lives in.
+Show which function the @var{symbol} lives in.
+
 
 @subsubheading @value{GDBN} Command
 
 @samp{gdb_get_function} in @code{gdbtk}.
 
- at subsubheading Example
-N.A.
 
+ at subsubheading Example
+ at smallexample
+(@value{GDBP})
+-symbol-info-function *0x0804842d
+^done,function="main"
+(@value{GDBP})
+ at end smallexample
 
 @subheading The @code{-symbol-info-line} Command
 @findex -symbol-info-line
@@ -2911,19 +2931,25 @@
 @subsubheading Synopsis
 
 @example
- -symbol-info-line
+ -symbol-info-line @var{symbol}
 @end example
 
-Show the core addresses of the code for a source line.
+Show the line and file that contains @var{symbol}
+
 
 @subsubheading @value{GDBN} Command
 
 The corresponding @value{GDBN} comamnd is @samp{info line}.
 @code{gdbtk} has the @samp{gdb_get_line} and @samp{gdb_get_file} commands.
 
- at subsubheading Example
-N.A.
 
+ at subsubheading Example
+ at smallexample
+(@value{GDBP})
+-symbol-info-line main
+^done,line="17",file="bla.c"
+(@value{GDBP})
+ at end smallexample
 
 @subheading The @code{-symbol-info-symbol} Command
 @findex -symbol-info-symbol
diff -r -u gdb+dejagnu-20020907/gdb/mi/mi-cmds.c gdb-jelmer/gdb/mi/mi-cmds.c
--- gdb+dejagnu-20020907/gdb/mi/mi-cmds.c	2001-03-06 09:21:45.000000000 +0100
+++ gdb-jelmer/gdb/mi/mi-cmds.c	2002-09-13 21:48:08.000000000 +0200
@@ -109,17 +109,17 @@
   {"stack-list-frames", 0, 0, mi_cmd_stack_list_frames},
   {"stack-list-locals", 0, 0, mi_cmd_stack_list_locals},
   {"stack-select-frame", 0, 0, mi_cmd_stack_select_frame},
-  {"symbol-info-address", 0, 0},
-  {"symbol-info-file", 0, 0},
-  {"symbol-info-function", 0, 0},
-  {"symbol-info-line", 0, 0},
-  {"symbol-info-symbol", 0, 0},
-  {"symbol-list-functions", 0, 0},
-  {"symbol-list-types", 0, 0},
-  {"symbol-list-variables", 0, 0},
-  {"symbol-locate", 0, 0},
+  {"symbol-info-file", 0, 0, mi_cmd_symbol_info_file},
+  {"symbol-info-function", 0, 0, mi_cmd_symbol_info_function},
+  {"symbol-info-line", 0, 0, mi_cmd_symbol_info_line},
   {"symbol-type", 0, 0},
   {"target-attach", 0, 0},
   {"target-compare-sections", 0, 0},
   {"target-detach", "detach", 0},
   {"target-download", 0, mi_cmd_target_download},
diff -r -u gdb+dejagnu-20020907/gdb/mi/mi-cmds.h gdb-jelmer/gdb/mi/mi-cmds.h
--- gdb+dejagnu-20020907/gdb/mi/mi-cmds.h	2001-03-06 09:21:45.000000000 +0100
+++ gdb-jelmer/gdb/mi/mi-cmds.h	2002-09-13 21:33:47.000000000 +0200
@@ -75,6 +75,12 @@
 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_gdb_exit;
+extern mi_cmd_argv_ftype mi_cmd_symbol_info_file;
+extern mi_cmd_argv_ftype mi_cmd_symbol_info_function;
+extern mi_cmd_argv_ftype mi_cmd_symbol_info_line;
 extern mi_cmd_argv_ftype mi_cmd_stack_info_depth;
 extern mi_cmd_argv_ftype mi_cmd_stack_list_args;
 extern mi_cmd_argv_ftype mi_cmd_stack_list_frames;
--- /dev/null	2002-08-29 13:57:56.000000000 +0200
+++ gdb-jelmer/gdb/mi/mi-cmd-symbol.c	2002-09-17 18:29:39.000000000 +0200
@@ -0,0 +1,222 @@
+/* MI Command Set - symbol query commands.
+   Copyright 2000, 2002 Free Software Foundation, Inc.
+   Contributed by Jelmer Vernooij
+
+   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 "target.h"
+#include "frame.h"
+#include "value.h"
+#include "mi-cmds.h"
+#include "ui-out.h"
+#include "symtab.h"
+#include "linespec.h"
+
+static void
+print_symbol_info (struct symtab *symtab, struct symbol *sym,
+                   struct minimal_symbol *msym)
+{
+  /* Strip off some C++ special symbols, like RTTI and global
+   *          constructors/destructors. */
+  if ((sym != NULL && !STREQN (SYMBOL_NAME (sym), "__tf", 4)
+       && !STREQN (SYMBOL_NAME (sym), "_GLOBAL_", 8)) || msym != NULL)
+    {
+
+      ui_out_tuple_begin (uiout, "symbol");
+      if (sym)
+        {
+          if (symtab->filename)
+            ui_out_field_string (uiout, "file", symtab->filename);
+          ui_out_field_int (uiout, "line", SYMBOL_LINE (sym));
+          ui_out_field_string (uiout, "name", SYMBOL_SOURCE_NAME (sym));
+          if (SYMBOL_CLASS (sym) == LOC_BLOCK)
+            ui_out_field_core_addr (uiout, "address",
+                                    SYMBOL_BLOCK_VALUE (sym)->startaddr);
+        }
+      else if (msym)
+        {
+          ui_out_field_string (uiout, "name", SYMBOL_SOURCE_NAME (msym));
+          ui_out_field_core_addr (uiout, "address",
+                                  SYMBOL_VALUE_ADDRESS (msym));
+        }
+      ui_out_tuple_end (uiout);
+    }
+}
+
+enum mi_cmd_result
+mi_cmd_symbol_info_line (char *command, char **argv, int argc)
+{
+  struct symtabs_and_lines sals;
+  struct cleanup *old_chain;
+  char *args, **canonical;
+
+  if (argc != 1)
+    error ("mi_cmd_symbol_info_line: Usage: SYMBOL");
+
+  args = argv[0];
+
+  sals = decode_line_1 (&args, 1, NULL, 0, &canonical);
+
+  old_chain = make_cleanup (xfree, sals.sals);
+
+  if (sals.nelts == 1)
+    {
+      ui_out_field_int (uiout, "line", sals.sals[0].line);
+      ui_out_field_string (uiout, "file", sals.sals[0].symtab->filename);
+      return MI_CMD_DONE;
+    }
+
+  do_cleanups(old_chain);
+
+  error ("mi_cmd_symbol_info_line: No such symbol");
+
+  return MI_CMD_DONE;
+}
+
+enum mi_cmd_result
+mi_cmd_symbol_info_file (char *command, char **argv, int argc)
+{
+  struct symtab *st;
+  char *fullname;
+
+  if (argc != 1)
+    error ("mi_cmd_symbol_info_file: Usage: FILE");
+
+  st = lookup_symtab (argv[0]);
+
+  if (!st)
+    error ("mi_cmd_symbol_info_file: No such source file");
+
+  if (st->fullname)
+    ui_out_field_string (uiout, "file", st->fullname);
+  else
+    ui_out_field_string (uiout, "file", symtab_to_filename (st));
+
+  return MI_CMD_DONE;
+}
+
+enum mi_cmd_result
+mi_cmd_symbol_info_function (char *command, char **argv, int argc)
+{
+  char *function = "";
+  struct symtabs_and_lines sals;
+  struct symbol *sym;
+  struct minimal_symbol *msym;
+  struct cleanup *old_chain;
+  char *args, **canonical;
+
+  if (argc != 1)
+    error ("mi_cmd_symbol_info_function: Usage: SYMBOL");
+
+  args = argv[0];
+
+  sals = decode_line_1 (&args, 1, NULL, 0, &canonical);
+  old_chain = make_cleanup( xfree, sals.sals);
+
+  if (sals.nelts == 1)
+    {
+      resolve_sal_pc (&sals.sals[0]);
+      /* Try 'normal' symbol first */
+      if ((sym = find_pc_function (sals.sals[0].pc)))
+        {
+          function = SYMBOL_SOURCE_NAME (sym);
+        }
+      else if ((msym = lookup_minimal_symbol_by_pc (sals.sals[0].pc)))
+        {
+          function = SYMBOL_SOURCE_NAME (msym);
+        }
+
+      ui_out_field_string (uiout, "function", function);
+      return MI_CMD_DONE;
+    }
+  do_cleanups(old_chain);
+
+  error ("mi_cmd_symbol_info_function: No such symbol");
+  return MI_CMD_DONE;
+}

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