mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-09 04:21:49 +08:00
de4f826b0f
* dictionary.h: New. * dictionary.c: New. * block.h: Add opaque declaration for struct dictionary. (struct block): Add 'dict' member; delete 'hashtable', 'nsyms', 'sym' members. (BLOCK_DICT): New macro. Delete macros BLOCK_HASHTABLE, BLOCK_NSYMS, BLOCK_SYM, BLOCK_BUCKETS, BLOCK_BUCKET, BLOCK_HASHTABLE_SIZE, BLOCK_SHOULD_SORT. (ALL_BLOCK_SYMBOLS): Update definition. * Makefile.in (SFILES): Add dictionary.c. (dictionary_h): New. (COMMON_OBS): Add dictionary.o. (dictionary.o): New. (ada-lang.o): Depend on dictionary_h. (buildsym.o, coffread.o, jv-lang.o, mdebugread.o, objfiles.o) (stack.o, symmisc.o, symtab.o, tracepoint.o, valops.o) (mi-cmd-stack.o): Ditto. (gdbtk-cmds.o): Update dependencies. (gdbtk-stack.o): Ditto. * ada-lang.c: Include dictionary.h. (symtab_for_sym): Update uses of ALL_BLOCK_SYMBOLS. (fill_in_ada_prototype, debug_print_block): Ditto. (ada_add_block_symbols): Update uses of ALL_BLOCK_SYMBOLS; replace explicit iteration by use of ALL_BLOCK_SYMBOLS. Delete variable 'is_sorted'. * mdebugread.c: Include dictionary.h. (struct parse_stack): Delete 'maxsyms' member. (parse_symbol): Update calls to new_block. Delete calls to shrink_block. Use dictionary methods. (psymtab_to_symtab_1): Delete calls to sort_symtab_syms. Update calls to new_symtab. Don't maintain maxsyms data. (mylookup_symbol): Update use of ALL_BLOCK_SYMBOLS. (add_symbol): Just call dict_add_symbol. (new_symtab): Delete 'maxsyms' argument. (new_symtab): Update calls to new_block. (new_block): Delete 'maxsyms' argument; add 'function' argument. (shrink_block): Delete function. (fixup_sigtramp): Update call to new_block. Add symbol via dict_add_symbol. * jv-lang.c: Include dictionary.h. (get_java_class_symtab): Set the BLOCK_DICT of the blocks appropriately. Set class_symtab->free_func. Make sure the blockvector is big enough to hold two blocks. (add_class_symtab_symbol): Use dictionary methods. (free_class_block): New function. (type_from_class): Replace explicit iteration by ALL_BLOCK_SYMBOLS. * symtab.h (struct symtab): Replace 'free_ptr' method by 'free_func'. * dwarf2read.c (psymtab_to_symtab_1): Delete call to sort_symtab_syms. * dwarfread.c (psymtab_to_symtab_1): Delete call to sort_symtab_syms. * coffread.c (coff_symfile_read): Delete call to sort_symtab_syms. Include dictionary.h. (patch_opaque_types): Update use of ALL_BLOCK_SYMBOLS. * dbxread.c (dbx_psymtab_to_symtab_1): Delete call to sort_symtab_syms. * objfiles.c: Include dictionary.h. (objfile_relocate): Update use of ALL_BLOCK_SYMBOLS. * buildsym.c: Include dictionary.h. (finish_block): Use dictionary methods. (end_symtab): Set free_func to NULL, not free_ptr. * tracepoint.c: Include dictionary.h. (add_local_symbols): Update use of ALL_BLOCK_SYMBOLS. (scope_info): Ditto. * stack.c: Include dictionary.h. (print_block_frame_locals): Update use of ALL_BLOCK_SYMBOLS. (print_block_frame_labels, print_frame_arg_vars) (print_frame_args): Ditto. * symmisc.c (free_symtab_block): Use dictionary methods. (dump_symtab): Ditto. (free_symtab): Replace use of 'free_ptr' by 'free_func'. Include dictionary.h. * symfile.h: Delete declarations of sort_block_syms, sort_symtab_syms. * symfile.c (sort_block_syms): Delete. (sort_symtab_syms): Delete. * symtab.c: Include dictionary.h. (lookup_block_symbol): Use dictionary iterators. (find_pc_sect_symtab): Update use of ALL_BLOCK_SYMBOLS. (search_symbols, make_symbol_completion_list): Ditto. (make_symbol_overload_list): Ditto. * valops.c (value_of_local): Use dict_empty. Include dictionary.h. 2003-06-11 David Carlton <carlton@bactrian.org> * generic/gdbtk-stack.c: Include dictionary.h. (gdb_block_vars): Update use of ALL_BLOCK_SYMBOLS. (gdb_get_blocks, gdb_get_vars_command): Ditto. * generic/gdbtk-cmds.c: Include dictionary.h. (gdb_listfuncs): Update use of ALL_BLOCK_SYMBOLS. 2003-06-11 David Carlton <carlton@bactrian.org> * mi-cmd-stack.c: Include dictionary.h. (list_args_or_locals): Update use of ALL_BLOCK_SYMBOLS.
317 lines
9.0 KiB
C
317 lines
9.0 KiB
C
/* MI Command Set - stack commands.
|
|
Copyright 2000, 2002, 2003 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 "target.h"
|
|
#include "frame.h"
|
|
#include "value.h"
|
|
#include "mi-cmds.h"
|
|
#include "ui-out.h"
|
|
#include "symtab.h"
|
|
#include "block.h"
|
|
#include "stack.h"
|
|
#include "dictionary.h"
|
|
|
|
static void list_args_or_locals (int locals, int values, struct frame_info *fi);
|
|
|
|
/* Print a list of the stack frames. Args can be none, in which case
|
|
we want to print the whole backtrace, or a pair of numbers
|
|
specifying the frame numbers at which to start and stop the
|
|
display. If the two numbers are equal, a single frame will be
|
|
displayed. */
|
|
enum mi_cmd_result
|
|
mi_cmd_stack_list_frames (char *command, char **argv, int argc)
|
|
{
|
|
int frame_low;
|
|
int frame_high;
|
|
int i;
|
|
struct cleanup *cleanup_stack;
|
|
struct frame_info *fi;
|
|
|
|
if (!target_has_stack)
|
|
error ("mi_cmd_stack_list_frames: No stack.");
|
|
|
|
if (argc > 2 || argc == 1)
|
|
error ("mi_cmd_stack_list_frames: Usage: [FRAME_LOW FRAME_HIGH]");
|
|
|
|
if (argc == 2)
|
|
{
|
|
frame_low = atoi (argv[0]);
|
|
frame_high = atoi (argv[1]);
|
|
}
|
|
else
|
|
{
|
|
/* Called with no arguments, it means we want the whole
|
|
backtrace. */
|
|
frame_low = -1;
|
|
frame_high = -1;
|
|
}
|
|
|
|
/* Let's position fi on the frame at which to start the
|
|
display. Could be the innermost frame if the whole stack needs
|
|
displaying, or if frame_low is 0. */
|
|
for (i = 0, fi = get_current_frame ();
|
|
fi && i < frame_low;
|
|
i++, fi = get_prev_frame (fi));
|
|
|
|
if (fi == NULL)
|
|
error ("mi_cmd_stack_list_frames: Not enough frames in stack.");
|
|
|
|
cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "stack");
|
|
|
|
/* Now let;s print the frames up to frame_high, or until there are
|
|
frames in the stack. */
|
|
for (;
|
|
fi && (i <= frame_high || frame_high == -1);
|
|
i++, fi = get_prev_frame (fi))
|
|
{
|
|
QUIT;
|
|
/* level == i: always print the level 'i'
|
|
source == LOC_AND_ADDRESS: print the location and the address
|
|
always, even for level 0.
|
|
args == 0: don't print the arguments. */
|
|
print_frame_info (fi /* frame info */ ,
|
|
i /* level */ ,
|
|
LOC_AND_ADDRESS /* source */ ,
|
|
0 /* args */ );
|
|
}
|
|
|
|
do_cleanups (cleanup_stack);
|
|
if (i < frame_high)
|
|
error ("mi_cmd_stack_list_frames: Not enough frames in stack.");
|
|
|
|
return MI_CMD_DONE;
|
|
}
|
|
|
|
enum mi_cmd_result
|
|
mi_cmd_stack_info_depth (char *command, char **argv, int argc)
|
|
{
|
|
int frame_high;
|
|
int i;
|
|
struct frame_info *fi;
|
|
|
|
if (!target_has_stack)
|
|
error ("mi_cmd_stack_info_depth: No stack.");
|
|
|
|
if (argc > 1)
|
|
error ("mi_cmd_stack_info_depth: Usage: [MAX_DEPTH]");
|
|
|
|
if (argc == 1)
|
|
frame_high = atoi (argv[0]);
|
|
else
|
|
/* Called with no arguments, it means we want the real depth of
|
|
the stack. */
|
|
frame_high = -1;
|
|
|
|
for (i = 0, fi = get_current_frame ();
|
|
fi && (i < frame_high || frame_high == -1);
|
|
i++, fi = get_prev_frame (fi))
|
|
QUIT;
|
|
|
|
ui_out_field_int (uiout, "depth", i);
|
|
|
|
return MI_CMD_DONE;
|
|
}
|
|
|
|
/* Print a list of the locals for the current frame. With argument of
|
|
0, print only the names, with argument of 1 print also the
|
|
values. */
|
|
enum mi_cmd_result
|
|
mi_cmd_stack_list_locals (char *command, char **argv, int argc)
|
|
{
|
|
if (argc != 1)
|
|
error ("mi_cmd_stack_list_locals: Usage: PRINT_VALUES");
|
|
|
|
list_args_or_locals (1, atoi (argv[0]), deprecated_selected_frame);
|
|
return MI_CMD_DONE;
|
|
}
|
|
|
|
/* Print a list of the arguments for the current frame. With argument
|
|
of 0, print only the names, with argument of 1 print also the
|
|
values. */
|
|
enum mi_cmd_result
|
|
mi_cmd_stack_list_args (char *command, char **argv, int argc)
|
|
{
|
|
int frame_low;
|
|
int frame_high;
|
|
int i;
|
|
struct frame_info *fi;
|
|
struct cleanup *cleanup_stack_args;
|
|
|
|
if (argc < 1 || argc > 3 || argc == 2)
|
|
error ("mi_cmd_stack_list_args: Usage: PRINT_VALUES [FRAME_LOW FRAME_HIGH]");
|
|
|
|
if (argc == 3)
|
|
{
|
|
frame_low = atoi (argv[1]);
|
|
frame_high = atoi (argv[2]);
|
|
}
|
|
else
|
|
{
|
|
/* Called with no arguments, it means we want args for the whole
|
|
backtrace. */
|
|
frame_low = -1;
|
|
frame_high = -1;
|
|
}
|
|
|
|
/* Let's position fi on the frame at which to start the
|
|
display. Could be the innermost frame if the whole stack needs
|
|
displaying, or if frame_low is 0. */
|
|
for (i = 0, fi = get_current_frame ();
|
|
fi && i < frame_low;
|
|
i++, fi = get_prev_frame (fi));
|
|
|
|
if (fi == NULL)
|
|
error ("mi_cmd_stack_list_args: Not enough frames in stack.");
|
|
|
|
cleanup_stack_args = make_cleanup_ui_out_list_begin_end (uiout, "stack-args");
|
|
|
|
/* Now let's print the frames up to frame_high, or until there are
|
|
frames in the stack. */
|
|
for (;
|
|
fi && (i <= frame_high || frame_high == -1);
|
|
i++, fi = get_prev_frame (fi))
|
|
{
|
|
struct cleanup *cleanup_frame;
|
|
QUIT;
|
|
cleanup_frame = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
|
|
ui_out_field_int (uiout, "level", i);
|
|
list_args_or_locals (0, atoi (argv[0]), fi);
|
|
do_cleanups (cleanup_frame);
|
|
}
|
|
|
|
do_cleanups (cleanup_stack_args);
|
|
if (i < frame_high)
|
|
error ("mi_cmd_stack_list_args: Not enough frames in stack.");
|
|
|
|
return MI_CMD_DONE;
|
|
}
|
|
|
|
/* Print a list of the locals or the arguments for the currently
|
|
selected frame. If the argument passed is 0, printonly the names
|
|
of the variables, if an argument of 1 is passed, print the values
|
|
as well. */
|
|
static void
|
|
list_args_or_locals (int locals, int values, struct frame_info *fi)
|
|
{
|
|
struct block *block;
|
|
struct symbol *sym;
|
|
struct dict_iterator iter;
|
|
int nsyms;
|
|
struct cleanup *cleanup_list;
|
|
static struct ui_stream *stb = NULL;
|
|
|
|
stb = ui_out_stream_new (uiout);
|
|
|
|
block = get_frame_block (fi, 0);
|
|
|
|
cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, locals ? "locals" : "args");
|
|
|
|
while (block != 0)
|
|
{
|
|
ALL_BLOCK_SYMBOLS (block, iter, sym)
|
|
{
|
|
int print_me = 0;
|
|
|
|
switch (SYMBOL_CLASS (sym))
|
|
{
|
|
default:
|
|
case LOC_UNDEF: /* catches errors */
|
|
case LOC_CONST: /* constant */
|
|
case LOC_TYPEDEF: /* local typedef */
|
|
case LOC_LABEL: /* local label */
|
|
case LOC_BLOCK: /* local function */
|
|
case LOC_CONST_BYTES: /* loc. byte seq. */
|
|
case LOC_UNRESOLVED: /* unresolved static */
|
|
case LOC_OPTIMIZED_OUT: /* optimized out */
|
|
print_me = 0;
|
|
break;
|
|
|
|
case LOC_ARG: /* argument */
|
|
case LOC_REF_ARG: /* reference arg */
|
|
case LOC_REGPARM: /* register arg */
|
|
case LOC_REGPARM_ADDR: /* indirect register arg */
|
|
case LOC_LOCAL_ARG: /* stack arg */
|
|
case LOC_BASEREG_ARG: /* basereg arg */
|
|
case LOC_COMPUTED_ARG: /* arg with computed location */
|
|
if (!locals)
|
|
print_me = 1;
|
|
break;
|
|
|
|
case LOC_LOCAL: /* stack local */
|
|
case LOC_BASEREG: /* basereg local */
|
|
case LOC_STATIC: /* static */
|
|
case LOC_REGISTER: /* register */
|
|
case LOC_COMPUTED: /* computed location */
|
|
if (locals)
|
|
print_me = 1;
|
|
break;
|
|
}
|
|
if (print_me)
|
|
{
|
|
struct cleanup *cleanup_tuple = NULL;
|
|
if (values)
|
|
cleanup_tuple =
|
|
make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
|
|
ui_out_field_string (uiout, "name", DEPRECATED_SYMBOL_NAME (sym));
|
|
|
|
if (values)
|
|
{
|
|
struct symbol *sym2;
|
|
if (!locals)
|
|
sym2 = lookup_symbol (DEPRECATED_SYMBOL_NAME (sym),
|
|
block, VAR_DOMAIN,
|
|
(int *) NULL,
|
|
(struct symtab **) NULL);
|
|
else
|
|
sym2 = sym;
|
|
print_variable_value (sym2, fi, stb->stream);
|
|
ui_out_field_stream (uiout, "value", stb);
|
|
do_cleanups (cleanup_tuple);
|
|
}
|
|
}
|
|
}
|
|
if (BLOCK_FUNCTION (block))
|
|
break;
|
|
else
|
|
block = BLOCK_SUPERBLOCK (block);
|
|
}
|
|
do_cleanups (cleanup_list);
|
|
ui_out_stream_delete (stb);
|
|
}
|
|
|
|
enum mi_cmd_result
|
|
mi_cmd_stack_select_frame (char *command, char **argv, int argc)
|
|
{
|
|
if (!target_has_stack)
|
|
error ("mi_cmd_stack_select_frame: No stack.");
|
|
|
|
if (argc > 1)
|
|
error ("mi_cmd_stack_select_frame: Usage: [FRAME_SPEC]");
|
|
|
|
/* with no args, don't change frame */
|
|
if (argc == 0)
|
|
select_frame_command (0, 1 /* not used */ );
|
|
else
|
|
select_frame_command (argv[0], 1 /* not used */ );
|
|
return MI_CMD_DONE;
|
|
}
|