Re: [RFC] Final(?) GDB/MI -symbol-*

Jelmer Vernooij
2002-09-24T13:53:26Z

> Here's another(the final?) update of my -symbol-* patch, changes:

> - Incorporated Keith's suggestions (use tuples,add cleanups,nicer error messages)
> - Added documentation
> - Added testsuite script

> Comments please ! :-)
I've (IRL) mailed the copyright assignment for the FSF back today -
anything else I need to do to get this patch in (who will review &
commit it or am I given CVS access?)

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/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-17 22:01:23.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::
> @@ -2863,8 +2863,12 @@
> The corresponding @value{GDBN} command is @samp{info address}.

> @subsubheading Example
> -N.A.
> -
> +@smallexample
> +(@value{GDBP})
> +-symbol-info-address main
> +^done,symbol=@{file="bla.c",line="16",name="main",address="0x0804842c"@}
> +(@value{GDBP})
> +@end smallexample

> @subheading The @code{-symbol-info-file} Command
> @findex -symbol-info-file
> @@ -2872,10 +2876,10 @@
> @subsubheading Synopsis

> @example
> - -symbol-info-file
> + -symbol-info-file @var{file}
> @end example

> -Show the file for the symbol.
> +Show the full path to the source file @var{file}.

> @subsubheading @value{GDBN} Command

> @@ -2883,8 +2887,12 @@
> @samp{gdb_find_file}.

> @subsubheading Example
> -N.A.
> -
> +@smallexample
> +(@value{GDBP})
> +-symbol-info-file bla.c
> +^done,file="/home/jelmer/bla.c"
> +(@value{GDBP})
> +@end smallexample

> @subheading The @code{-symbol-info-function} Command
> @findex -symbol-info-function
> @@ -2892,18 +2900,22 @@
> @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}.

> @subsubheading Example
> -N.A.
> -
> +@smallexample
> +(@value{GDBP})
> +-symbol-info-function *0x0804842d
> +^done,function="main"
> +(@value{GDBP})
> +@end smallexample

> @subheading The @code{-symbol-info-line} Command
> @findex -symbol-info-line
> @@ -2911,10 +2923,10 @@
> @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

> @@ -2922,8 +2934,12 @@
> @code{gdbtk} has the @samp{gdb_get_line} and @samp{gdb_get_file} commands.

> @subsubheading Example
> -N.A.
> -
> +@smallexample
> +(@value{GDBP})
> +-symbol-info-line main
> +^done,line="17",file="bla.c"
> +(@value{GDBP})
> +@end smallexample

> @subheading The @code{-symbol-info-symbol} Command
> @findex -symbol-info-symbol
> @@ -2931,18 +2947,22 @@
> @subsubheading Synopsis

> @example
> - -symbol-info-symbol @var{addr}
> + -symbol-info-symbol @var{symbol}
> @end example

> -Describe what symbol is at location @var{addr}.
> +Give details about @var{symbol}

> @subsubheading @value{GDBN} Command

> The corresponding @value{GDBN} command is @samp{info symbol}.

> @subsubheading Example
> -N.A.
> -
> +@smallexample
> +(@value{GDBP})
> +-symbol-info-symbol function_a
> +^done,symbol=@{file="bla.c",line="6",name="function_a",address="0x080483f0"@}
> +(@value{GDBP})
> +@end smallexample

> @subheading The @code{-symbol-list-functions} Command
> @findex -symbol-list-functions
> @@ -2950,10 +2970,12 @@
> @subsubheading Synopsis

> @example
> - -symbol-list-functions
> + -symbol-list-functions @var{pattern}
> @end example

> -List the functions in the executable.
> +List functions in the executable. If @var{pattern} is specified,
> +list all functions that match @var{pattern}; otherwise, list
> +all functions.

> @subsubheading @value{GDBN} Command

> @@ -2961,8 +2983,12 @@
> @samp{gdb_search} in @code{gdbtk}.

> @subsubheading Example
> -N.A.
> -
> +@smallexample
> +(@value{GDBP})
> +-symbol-list-functions funct.*
> +^done,symbols=[symbol=@{file="./gdb.mi/symbol.c",line="14",name="function_a",address="0x080483d0"@},symbol=@{file="./gdb.mi/symbol.c",line="19",name="function_b",address="0x080483dc"@}]
> +(@value{GDBP})
> +@end smallexample

> @subheading The @code{-symbol-list-types} Command
> @findex -symbol-list-types
> @@ -2970,10 +2996,12 @@
> @subsubheading Synopsis

> @example
> - -symbol-list-types
> + -symbol-list-types @var{pattern}
> @end example

> -List all the type names.
> +List type names. If @var{pattern} is specified,
> +list all types that match @var{pattern}; otherwise, list
> +all types.

> @subsubheading @value{GDBN} Command

> @@ -2981,7 +3009,12 @@
> @samp{gdb_search} in @code{gdbtk}.

> @subsubheading Example
> -N.A.
> +@smallexample
> +(@value{GDBP})
> +-symbol-list-types .*int$
> +^done,symbols=[symbol=@{file="./gdb.mi/symbol.c",line="0",name="complex int"@},symbol=@{file="./gdb.mi/symbol.c",line="0",name="int"@},symbol=@{file="./gdb.mi/symbol.c",line="0",name="long int"@},symbol=@{file="./gdb.mi/symbol.c",line="0",name="long long int"@},symbol=@{file="./gdb.mi/symbol.c",line="0",name="long long unsigned int"@},symbol=@{file="./gdb.mi/symbol.c",line="0",name="long unsigned int"@},symbol=@{file="./gdb.mi/symbol.c",line="0",name="short int"@},symbol=@{file="./gdb.mi/symbol.c",line="0",name="short unsigned int"@},symbol=@{file="./gdb.mi/symbol.c",line="0",name="unsigned int"@}]
> +(@value{GDBP})
> +@end smallexample

> @subheading The @code{-symbol-list-variables} Command
> @@ -2990,18 +3023,24 @@
> @subsubheading Synopsis

> @example
> - -symbol-list-variables
> + -symbol-list-variables @var{pattern}
> @end example

> -List all the global and static variable names.
> +List global and static variable names. If @var{pattern} is specified,
> +list all variables that match @var{pattern}; otherwise, list
> +all variables.

> @subsubheading @value{GDBN} Command

> @samp{info variables} in @value{GDBN}, @samp{gdb_search} in @code{gdbtk}.

> @subsubheading Example
> -N.A.
> -
> +@smallexample
> +(@value{GDBP})
> +-symbol-list-variables glob
> +^done,symbols=[symbol=@{file="./gdb.mi/symbol.c",line="23",name="global_a"@},symbol=@{file="./gdb.mi/symbol.c",line="23",name="global_b"@},symbol=@{file="./gdb.mi/symbol.c",line="24",name="global_c"@},symbol=@{file="./gdb.mi/symbol.c",line="25",name="global_d"@}]
> +(@value{GDBP})
> +@end smallexample

> @subheading The @code{-symbol-locate} Command
> @findex -symbol-locate
> @@ -3009,16 +3048,22 @@
> @subsubheading Synopsis

> @example
> - -symbol-locate
> + -symbol-locate @var{symbol}
> @end example

> +Show details for @var{symbol}
> +
> @subsubheading @value{GDBN} Command

> @samp{gdb_loc} in @code{gdbtk}.

> @subsubheading Example
> -N.A.
> -
> +@smallexample
> +(@value{GDBP})
> +-symbol-locate function_b
> +^done,symbol=@{file="./gdb.mi/symbol.c",line="19",name="function_b",address="0x080483dc"@}
> +(@value{GDBP})
> +@end smallexample

> @subheading The @code{-symbol-type} Command
> @findex -symbol-type
> @@ -3061,8 +3106,12 @@
> The corresponding @value{GDBN} command is @samp{attach}.

> @subsubheading Example
> -N.A.
> -
> +@smallexample
> +(@value{GDBP})
> +-target-attach 20666
> +^done,thread-id="0",frame=@{addr="0x400bc991",func="nanosleep",args=[],from="/lib/libc.so.6"@}
> +(@value{GDBP})
> +@end smallexample

> @subheading The @code{-target-compare-sections} Command
> @findex -target-compare-sections
> 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-address", 0, 0, mi_cmd_symbol_locate},
> + {"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-info-symbol", 0, 0, mi_cmd_symbol_locate},
> + {"symbol-list-functions", 0, 0, mi_cmd_symbol_list_symbols},
> + {"symbol-list-types", 0, 0, mi_cmd_symbol_list_symbols},
> + {"symbol-list-variables", 0, 0, mi_cmd_symbol_list_symbols},
> + {"symbol-locate", 0, 0, mi_cmd_symbol_locate},
> {"symbol-type", 0, 0},
> - {"target-attach", 0, 0},
> + {"target-attach", "attach %s", 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_symbol_info_symbol;
> +extern mi_cmd_argv_ftype mi_cmd_symbol_list_symbols;
> +extern mi_cmd_argv_ftype mi_cmd_symbol_locate;
> 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_locate (char *command, char **argv, int argc)
> +{
> + struct symtabs_and_lines sals;
> + struct symbol *sym;
> + struct minimal_symbol *msym;
> + struct cleanup *old_chain;
> +
> + if (argc != 1)
> + error ("mi_cmd_symbol_locate: Usage: SYMBOL");
> +
> + sals = decode_line_spec (argv[0], 1);
> + old_chain = make_cleanup( xfree, sals.sals);
> +
> + if (sals.nelts != 1)
> + error ("mi_cmd_symbol_locate: No such symbol");
> +
> + resolve_sal_pc (&sals.sals[0]);
> +
> + sym = find_pc_function (sals.sals[0].pc);
> + msym = lookup_minimal_symbol_by_pc (sals.sals[0].pc);
> +
> + print_symbol_info (sals.sals[0].symtab, sym, msym);
> +
> + do_cleanups(old_chain);
> +
> + 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;
> +}
> +
> +enum mi_cmd_result
> +mi_cmd_symbol_list_symbols (char *command, char **argv, int argc)
> +{
> + struct symbol_search *matches;
> + struct symbol_search *p;
> + struct cleanup *old_chain = NULL;
> + namespace_enum space = 0;
> + char *function_name;
> + if (argc > 1)
> + error ("%s: Usage: [FUNCTION]", command);
> +
> + if (strcmp (command, "symbol-list-functions") == 0)
> + space = FUNCTIONS_NAMESPACE;
> + else if (strcmp (command, "symbol-list-types") == 0)
> + space = TYPES_NAMESPACE;
> + else if (strcmp (command, "symbol-list-variables") == 0)
> + space = VARIABLES_NAMESPACE;
> + else
> + error ("mi_cmd_symbol_list_symbols: Called for illegal command %s!",
> + command);
> +
> + search_symbols (argv[0], space, 0, NULL, &matches);
> +
> + if (matches != NULL)
> + old_chain = make_cleanup_free_search_symbols (matches);
> +
> + ui_out_list_begin (uiout, "symbols");
> +
> + for (p = matches; p; p = p->next)
> + {
> + print_symbol_info (p->symtab, p->symbol, p->msymbol);
> + }
> +
> + ui_out_list_end (uiout);
> +
> + if (matches)
> + do_cleanups (old_chain);
> +
> + return MI_CMD_DONE;
> +}
> --- /dev/null 2002-08-29 13:57:56.000000000 +0200
> +++ gdb-jelmer/gdb/testsuite/gdb.mi/mi-symbol.exp 2002-09-17 21:28:15.000000000 +0200
> @@ -0,0 +1,123 @@
> +# Copyright 1999 Free Software Foundation, Inc.
> +
> +# 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.
> +
> +# Please email any bugs, comments, and/or additions to this file to:
> +# bug-gdb@prep.ai.mit.edu
> +
> +#
> +# Test essential Machine interface (MI) operations
> +#
> +# test the -symbol-locate, -symbol-list-functions,
> +# -symbol-list-variables, -symbol-list-types, -symbol-show-file,
> +# -symbol-info-line
> +
> +load_lib mi-support.exp
> +set MIFLAGS "-i=mi"
> +
> +gdb_exit
> +if [mi_gdb_start] {
> + continue
> +}
> +
> +set testfile "symbol"
> +set srcfile ${testfile}.c
> +set binfile ${objdir}/${subdir}/${testfile}
> +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
> + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
> +}
> +
> +mi_delete_breakpoints
> +mi_gdb_reinitialize_dir $srcdir/$subdir
> +mi_gdb_load ${binfile}
> +
> +proc test_list_functions {} {
> + global mi_gdb_prompt
> + global srcfile
> + global hex
> +
> + mi_gdb_test "223-symbol-list-functions function_.*" \
> + "223\\^done,symbols=\\\[symbol=\{file=\"./gdb.mi/symbol.c\",line=\"14\",name=\"function_a\",address=\"$hex\"\},symbol=\{file=\"./gdb.mi/symbol.c\",line=\"19\",name=\"function_b\",address=\"$hex\"\}\\\]" \
> + "Function list based on regex failed"
> +}
> +
> +proc test_list_variables {} {
> + global mi_gdb_prompt
> + global srcfile
> + global hex
> +
> + mi_gdb_test "226-symbol-list-variables global_.*" \
> + "226\\^done,symbols=\\\[symbol=\{file=\"./gdb.mi/symbol.c\",line=\"23\",name=\"global_a\"\},symbol=\{file=\"./gdb.mi/symbol.c\",line=\"23\",name=\"global_b\"\},symbol=\{file=\"./gdb.mi/symbol.c\",line=\"24\",name=\"global_c\"\},symbol=\{file=\"./gdb.mi/symbol.c\",line=\"25\",name=\"global_d\"\}\]" \
> + "Variable list based on regex failed"
> +}
> +
> +proc test_list_types {} {
> + global mi_gdb_prompt
> + global srcfile
> + global hex
> +
> + mi_gdb_test "225-symbol-list-types type_.*" \
> + "225\\^done,symbols=\\\[symbol=\{file=\"./gdb.mi/symbol.c\",line=\"0\",name=\"struct_type_a\"\},symbol=\{file=\"./gdb.mi/symbol.c\",line=\"0\",name=\"struct_type_b\"\},symbol=\{file=\"./gdb.mi/symbol.c\",line=\"5\",name=\"type_a\"\},symbol=\{file=\"./gdb.mi/symbol.c\",line=\"11\",name=\"type_b\"\}\\\]" \
> + "Types name list based on regex failed"
> +}
> +
> +proc test_locate_symbol {} {
> + global mi_gdb_prompt
> + global srcfile
> + global hex
> +
> + mi_gdb_test "226-symbol-locate main" \
> + "226\\^done,symbol=\{file=\"./gdb.mi/symbol.c\",line=\"29\",name=\"main\",address=\"$hex\"\}" \
> + "Retrieving symbol info for function main"
> +
> + mi_gdb_test "228-symbol-locate function_a" \
> + "228\\^done,symbol=\{file=\"./gdb.mi/symbol.c\",line=\"14\",name=\"function_a\",address=\"$hex\"\}" \
> + "Retrieving symbol info for function function_a"
> +}
> +
> +proc test_info_file {} {
> + global mi_gdb_prompt
> + global srcfile
> + global hex
> +
> + mi_gdb_test "227-symbol-info-file symbol.c" \
> + "227\\^done,file=\"/home/jelmer/cgdb/gdb-jelmer/gdb/testsuite/gdb.mi/symbol.c\"" \
> + "Retrieving full path for symbol.c"
> +
> +}
> +
> +proc test_info_line {} {
> + global mi_gdb_prompt
> + global srcfile
> + global hex
> +
> + mi_gdb_test "228-symbol-info-line main" \
> + "228\\^done,line=\"31\",file=\"./gdb.mi/symbol.c\"" \
> + "Looking up line number for function main"
> +
> + mi_gdb_test "229-symbol-info-line function_b" \
> + "229\\^done,line=\"20\",file=\"./gdb.mi/symbol.c\"" \
> + "Looking up line number for function function_b"
> +}
> +
> +test_list_functions
> +test_list_variables
> +test_list_types
> +test_locate_symbol
> +test_info_file
> +test_info_line
> +
> +mi_gdb_exit
> +return 0
> --- /dev/null 2002-08-29 13:57:56.000000000 +0200
> +++ gdb-jelmer/gdb/testsuite/gdb.mi/symbol.c 2002-09-17 20:54:42.000000000 +0200
> @@ -0,0 +1,31 @@
> +typedef struct struct_type_a {
> + int a;
> + char b[210];
> + char *c;
> +}type_a;
> +
> +typedef struct struct_type_b {
> + long a;
> + char *b;
> + char c[2][10];
> +}type_b;
> +
> +int function_a(int arg1, int arg2, int arg3)
> +{
> + return 0;
> +}
> +
> +char function_b(char arg1, char arg2, char arg3)
> +{
> + return 1;
> +}
> +
> +int global_a, global_b;
> +char global_c;
> +char global_d[100];
> +
> +
> +int main(int argc, char **argv)
> +{
> + int local_a,local_b,local_c;
> +}
> --- gdb+dejagnu-20020907/gdb/testsuite/gdb.mi/Makefile.in 2000-04-18 10:03:40.000000000 +0200
> +++ gdb-jelmer/gdb/testsuite/gdb.mi/Makefile.in 2002-09-17 20:53:25.000000000 +0200
> @@ -1,7 +1,7 @@
> VPATH = @srcdir@
> srcdir = @srcdir@

> -PROGS = basics c_variable cpp_variable var-cmd
> +PROGS = basics c_variable cpp_variable var-cmd symbol

> MISCELLANEOUS = testcmds

--
Jelmer Vernooij <jelmer@nl.linux.org> - http://nl.linux.org/~jelmer/
Development And Underdevelopment: http://library.thinkquest.org/C0110231/
Listening to
15:51:50 up 5 min, 3 users, load average: 0.11, 0.09, 0.04