Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] -symbol-info-symbol and -symbol-list-functions
@ 2002-09-11 12:12 Jelmer Vernooij
  2002-09-11 12:30 ` Keith Seitz
  2002-09-11 13:45 ` Elena Zannoni
  0 siblings, 2 replies; 4+ messages in thread
From: Jelmer Vernooij @ 2002-09-11 12:12 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 499 bytes --]

Hi all!

This is my first attempt to implement -symbol-info-symbol and
-symbol-list-functions. 

It's not meant to be committed already, but I'm just wondering whether
I'm using the correct functions, coding style and output. Should I
really use search_symbols for these kinds of things? It seems a little
inefficient to use a function that does regex matching when supplying 
a 'normal' symbol name (and it might have some issues as well with 
names that contain special regex characters).

Jelmer

[-- Attachment #2: gdb-mi-symbol.diff --]
[-- Type: text/plain, Size: 5087 bytes --]

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/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-11 20:46:06.000000000 +0200
@@ -113,8 +113,8 @@
   {"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-info-symbol", 0, 0, mi_cmd_symbol_info_symbol},
+  {"symbol-list-functions", 0, 0, mi_cmd_symbol_list_functions},
   {"symbol-list-types", 0, 0},
   {"symbol-list-variables", 0, 0},
   {"symbol-locate", 0, 0},
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-11 20:45:15.000000000 +0200
@@ -75,6 +75,8 @@
 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_symbol;
+extern mi_cmd_argv_ftype mi_cmd_symbol_list_functions;
 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-11 21:02:02.000000000 +0200
@@ -0,0 +1,83 @@
+/* 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"
+
+static void
+print_symbol_search_info (struct symbol_search *matches)
+{
+  struct symbol_search *p;
+
+  ui_out_list_begin (uiout, "symbols");
+
+  for (p = matches; p; p = p->next)
+    {
+      ui_out_list_begin (uiout, "symbol");
+      if (p->msymbol == NULL)
+        {
+          ui_out_field_string (uiout, "file", p->symtab->filename);
+          ui_out_field_int (uiout, "line", p->symbol->line);
+          ui_out_field_string (uiout, "name", p->symbol->ginfo.name);
+        }
+      else
+        {
+          ui_out_field_string (uiout, "name", p->msymbol->ginfo.name);
+        }
+      ui_out_list_end (uiout);
+    }
+
+  ui_out_list_end (uiout);
+}
+
+enum mi_cmd_result
+mi_cmd_symbol_info_symbol (char *command, char **argv, int argc)
+{
+  struct symbol_search *matches;
+  if (argc != 1)
+    error ("mi_cmd_symbol_info_line: Usage: SYMBOL");
+
+  search_symbols (argv[0], FUNCTIONS_NAMESPACE, 0, NULL, &matches);
+
+  print_symbol_search_info (matches);
+
+  return MI_CMD_DONE;
+}
+
+
+enum mi_cmd_result
+mi_cmd_symbol_list_functions (char *command, char **argv, int argc)
+{
+  struct symbol_search *matches;
+  if (argc != 0)
+    error ("mi_cmd_symbol_list_functions doesn't require any arguments");
+
+  search_symbols (NULL, FUNCTIONS_NAMESPACE, 0, NULL, &matches);
+
+  print_symbol_search_info (matches);
+
+  return MI_CMD_DONE;
+}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] -symbol-info-symbol and -symbol-list-functions
  2002-09-11 12:12 [RFC] -symbol-info-symbol and -symbol-list-functions Jelmer Vernooij
@ 2002-09-11 12:30 ` Keith Seitz
  2002-09-11 13:45 ` Elena Zannoni
  1 sibling, 0 replies; 4+ messages in thread
From: Keith Seitz @ 2002-09-11 12:30 UTC (permalink / raw)
  To: Jelmer Vernooij; +Cc: gdb-patches

Just a quick comment or two...

On Wed, 11 Sep 2002, Jelmer Vernooij wrote:

> It's not meant to be committed already, but I'm just wondering whether
> I'm using the correct functions, coding style and output. Should I
> really use search_symbols for these kinds of things? It seems a little
> inefficient to use a function that does regex matching when supplying 
> a 'normal' symbol name (and it might have some issues as well with 
> names that contain special regex characters).

Why not allow regexp matching? It is much more useful than looking for an 
exact string. If the UI really wants an exact string match, it's easy 
enough for it to construct a regexp which will do this.

+      if (p->msymbol == NULL)
+        {
+          ui_out_field_string (uiout, "file", p->symtab->filename);
+          ui_out_field_int (uiout, "line", p->symbol->line);
+          ui_out_field_string (uiout, "name", p->symbol->ginfo.name);
+        }
+      else
+        {
+          ui_out_field_string (uiout, "name", p->msymbol->ginfo.name);
+        }

Does this work on an executable with no debug info? With Insight, this 
code is a lot more complicated... (In other words, couldn't any of these 
strings be NULL?)

Also, as I recall there are accessors for at least ginfo.name 
(SYMBOL_SOURCE_NAME). Also as I recall, this macro wasn't enough for C++. 
We modified it a little in insight, too, since SYMBOL_SOURCE_NAME could 
output mangled names, depending on user setting. We chose to override 
this:

/* A convenience macro for getting the demangled source names,
   regardless of the user's mangling style. */
#define GDBTK_SYMBOL_SOURCE_NAME(symbol) \
      (SYMBOL_DEMANGLED_NAME (symbol) != NULL \
       ? SYMBOL_DEMANGLED_NAME (symbol)       \
       : SYMBOL_NAME (symbol))

+enum mi_cmd_result
+mi_cmd_symbol_list_functions (char *command, char **argv, int argc)
+{
+  struct symbol_search *matches;
+  if (argc != 0)
+    error ("mi_cmd_symbol_list_functions doesn't require any arguments");

Why not allow an optional regexp argument to search for, just like the 
command line? (It could be "" by default, thus listing all functions.)

+  search_symbols (NULL, FUNCTIONS_NAMESPACE, 0, NULL, &matches);

The results of this function need to be deallocated. Suggest adding 
make_cleanup_free_search_symbols and do_cleanups whenever search_symbols 
is called.

For a working reference of a generic use of search_symbols, see 
gdb/gdbtk/generic/gdbtk-cmds.c (gdb_search) in the insight module. (You 
can get this by checking out the file 'src/gdb/gdbtk/generic/gdbtk-cmds.c' 
from sources.redhat.com.)

Keith


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] -symbol-info-symbol and -symbol-list-functions
  2002-09-11 12:12 [RFC] -symbol-info-symbol and -symbol-list-functions Jelmer Vernooij
  2002-09-11 12:30 ` Keith Seitz
@ 2002-09-11 13:45 ` Elena Zannoni
  2002-09-11 13:54   ` Michael Snyder
  1 sibling, 1 reply; 4+ messages in thread
From: Elena Zannoni @ 2002-09-11 13:45 UTC (permalink / raw)
  To: Jelmer Vernooij; +Cc: gdb-patches

Jelmer Vernooij writes:
 > Hi all!
 > 
 > This is my first attempt to implement -symbol-info-symbol and
 > -symbol-list-functions. 
 > 
 > It's not meant to be committed already, but I'm just wondering whether
 > I'm using the correct functions, coding style and output. Should I
 > really use search_symbols for these kinds of things? It seems a little
 > inefficient to use a function that does regex matching when supplying 
 > a 'normal' symbol name (and it might have some issues as well with 
 > names that contain special regex characters).
 > 

Thanks for your work. 
I agree with Keith's comments, his suggestions are good ones.

There is another thing I have noticed. The symbol-info-symbol command
is supposed to take an address as argument and return a symbol that is
located at the given address. Look at the implementation in
printcmd.c:sym_info(), and at the documentation in gdbmi.texinfo.  I
think here you are just doing a search within functions only for a
symbol of a given name, if I read your code correctly.

Other than that, you are on the right track. As Keith points out, a
lot of these MI commands were 'inspired' by gdbtk, so it is generally
useful to look at how gdbtk solved the problem and what complications
it ran into.

Elena



 > Jelmer
 > 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/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-11 20:46:06.000000000 +0200
 > @@ -113,8 +113,8 @@
 >    {"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-info-symbol", 0, 0, mi_cmd_symbol_info_symbol},
 > +  {"symbol-list-functions", 0, 0, mi_cmd_symbol_list_functions},
 >    {"symbol-list-types", 0, 0},
 >    {"symbol-list-variables", 0, 0},
 >    {"symbol-locate", 0, 0},
 > 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-11 20:45:15.000000000 +0200
 > @@ -75,6 +75,8 @@
 >  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_symbol;
 > +extern mi_cmd_argv_ftype mi_cmd_symbol_list_functions;
 >  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-11 21:02:02.000000000 +0200
 > @@ -0,0 +1,83 @@
 > +/* 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"
 > +
 > +static void
 > +print_symbol_search_info (struct symbol_search *matches)
 > +{
 > +  struct symbol_search *p;
 > +
 > +  ui_out_list_begin (uiout, "symbols");
 > +
 > +  for (p = matches; p; p = p->next)
 > +    {
 > +      ui_out_list_begin (uiout, "symbol");
 > +      if (p->msymbol == NULL)
 > +        {
 > +          ui_out_field_string (uiout, "file", p->symtab->filename);
 > +          ui_out_field_int (uiout, "line", p->symbol->line);
 > +          ui_out_field_string (uiout, "name", p->symbol->ginfo.name);
 > +        }
 > +      else
 > +        {
 > +          ui_out_field_string (uiout, "name", p->msymbol->ginfo.name);
 > +        }
 > +      ui_out_list_end (uiout);
 > +    }
 > +
 > +  ui_out_list_end (uiout);
 > +}
 > +
 > +enum mi_cmd_result
 > +mi_cmd_symbol_info_symbol (char *command, char **argv, int argc)
 > +{
 > +  struct symbol_search *matches;
 > +  if (argc != 1)
 > +    error ("mi_cmd_symbol_info_line: Usage: SYMBOL");
 > +
 > +  search_symbols (argv[0], FUNCTIONS_NAMESPACE, 0, NULL, &matches);
 > +
 > +  print_symbol_search_info (matches);
 > +
 > +  return MI_CMD_DONE;
 > +}
 > +
 > +
 > +enum mi_cmd_result
 > +mi_cmd_symbol_list_functions (char *command, char **argv, int argc)
 > +{
 > +  struct symbol_search *matches;
 > +  if (argc != 0)
 > +    error ("mi_cmd_symbol_list_functions doesn't require any arguments");
 > +
 > +  search_symbols (NULL, FUNCTIONS_NAMESPACE, 0, NULL, &matches);
 > +
 > +  print_symbol_search_info (matches);
 > +
 > +  return MI_CMD_DONE;
 > +}


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] -symbol-info-symbol and -symbol-list-functions
  2002-09-11 13:45 ` Elena Zannoni
@ 2002-09-11 13:54   ` Michael Snyder
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Snyder @ 2002-09-11 13:54 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: Jelmer Vernooij, gdb-patches

Elena Zannoni wrote:
> 
> Jelmer Vernooij writes:
>  > Hi all!
>  >
>  > This is my first attempt to implement -symbol-info-symbol and
>  > -symbol-list-functions.
>  >
>  > It's not meant to be committed already, but I'm just wondering whether
>  > I'm using the correct functions, coding style and output. Should I
>  > really use search_symbols for these kinds of things? It seems a little
>  > inefficient to use a function that does regex matching when supplying
>  > a 'normal' symbol name (and it might have some issues as well with
>  > names that contain special regex characters).
>  >
> 
> Thanks for your work.
> I agree with Keith's comments, his suggestions are good ones.
> 
> There is another thing I have noticed. The symbol-info-symbol command
> is supposed to take an address as argument and return a symbol that is
> located at the given address. Look at the implementation in
> printcmd.c:sym_info(), and at the documentation in gdbmi.texinfo.  I
> think here you are just doing a search within functions only for a
> symbol of a given name, if I read your code correctly.

Hmmm, yeah -- "info symbol" already does that.

> 
> Other than that, you are on the right track. As Keith points out, a
> lot of these MI commands were 'inspired' by gdbtk, so it is generally
> useful to look at how gdbtk solved the problem and what complications
> it ran into.
> 
> Elena
> 
>  > Jelmer
>  > 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/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-11 20:46:06.000000000 +0200
>  > @@ -113,8 +113,8 @@
>  >    {"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-info-symbol", 0, 0, mi_cmd_symbol_info_symbol},
>  > +  {"symbol-list-functions", 0, 0, mi_cmd_symbol_list_functions},
>  >    {"symbol-list-types", 0, 0},
>  >    {"symbol-list-variables", 0, 0},
>  >    {"symbol-locate", 0, 0},
>  > 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-11 20:45:15.000000000 +0200
>  > @@ -75,6 +75,8 @@
>  >  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_symbol;
>  > +extern mi_cmd_argv_ftype mi_cmd_symbol_list_functions;
>  >  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-11 21:02:02.000000000 +0200
>  > @@ -0,0 +1,83 @@
>  > +/* 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"
>  > +
>  > +static void
>  > +print_symbol_search_info (struct symbol_search *matches)
>  > +{
>  > +  struct symbol_search *p;
>  > +
>  > +  ui_out_list_begin (uiout, "symbols");
>  > +
>  > +  for (p = matches; p; p = p->next)
>  > +    {
>  > +      ui_out_list_begin (uiout, "symbol");
>  > +      if (p->msymbol == NULL)
>  > +        {
>  > +          ui_out_field_string (uiout, "file", p->symtab->filename);
>  > +          ui_out_field_int (uiout, "line", p->symbol->line);
>  > +          ui_out_field_string (uiout, "name", p->symbol->ginfo.name);
>  > +        }
>  > +      else
>  > +        {
>  > +          ui_out_field_string (uiout, "name", p->msymbol->ginfo.name);
>  > +        }
>  > +      ui_out_list_end (uiout);
>  > +    }
>  > +
>  > +  ui_out_list_end (uiout);
>  > +}
>  > +
>  > +enum mi_cmd_result
>  > +mi_cmd_symbol_info_symbol (char *command, char **argv, int argc)
>  > +{
>  > +  struct symbol_search *matches;
>  > +  if (argc != 1)
>  > +    error ("mi_cmd_symbol_info_line: Usage: SYMBOL");
>  > +
>  > +  search_symbols (argv[0], FUNCTIONS_NAMESPACE, 0, NULL, &matches);
>  > +
>  > +  print_symbol_search_info (matches);
>  > +
>  > +  return MI_CMD_DONE;
>  > +}
>  > +
>  > +
>  > +enum mi_cmd_result
>  > +mi_cmd_symbol_list_functions (char *command, char **argv, int argc)
>  > +{
>  > +  struct symbol_search *matches;
>  > +  if (argc != 0)
>  > +    error ("mi_cmd_symbol_list_functions doesn't require any arguments");
>  > +
>  > +  search_symbols (NULL, FUNCTIONS_NAMESPACE, 0, NULL, &matches);
>  > +
>  > +  print_symbol_search_info (matches);
>  > +
>  > +  return MI_CMD_DONE;
>  > +}


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-09-11 20:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-11 12:12 [RFC] -symbol-info-symbol and -symbol-list-functions Jelmer Vernooij
2002-09-11 12:30 ` Keith Seitz
2002-09-11 13:45 ` Elena Zannoni
2002-09-11 13:54   ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox