+2002-03-29 Jim Blandy <jimb@redhat.com>
+
+ * stack.c (get_selected_block): Add new argument `addr_in_block',
+ used to return the exact code address we used to select the block,
+ not just the block.
+ * blockframe.c (get_frame_block, get_current_block): Same.
+ * frame.h (get_frame_block, get_current_block,
+ get_selected_block): Update declarations.
+ * linespec.c, stack.c, blockframe.c, breakpoint.c, findvar.c,
+ linespec.c, varobj.c, printcmd.c, symtab.c: Callers changed.
+
2002-04-05 Michael Snyder <msnyder@redhat.com>
* breakpoint.c (insert_breakpoints): Change 'hw' to 'hardware in
#endif
/* Return the innermost lexical block in execution
- in a specified stack frame. The frame address is assumed valid. */
+ in a specified stack frame. The frame address is assumed valid.
+
+ If ADDR_IN_BLOCK is non-zero, set *ADDR_IN_BLOCK to the exact code
+ address we used to choose the block. We use this to find a source
+ line, to decide which macro definitions are in scope.
+
+ The value returned in *ADDR_IN_BLOCK isn't necessarily the frame's
+ PC, and may not really be a valid PC at all. For example, in the
+ caller of a function declared to never return, the code at the
+ return address will never be reached, so the call instruction may
+ be the very last instruction in the block. So the address we use
+ to choose the block is actually one byte before the return address
+ --- hopefully pointing us at the call instruction, or its delay
+ slot instruction. */
struct block *
-get_frame_block (struct frame_info *frame)
+get_frame_block (struct frame_info *frame, CORE_ADDR *addr_in_block)
{
CORE_ADDR pc;
after the call insn, we probably want to make frame->pc point after
the call insn anyway. */
--pc;
+
+ if (addr_in_block)
+ *addr_in_block = pc;
+
return block_for_pc (pc);
}
struct block *
-get_current_block (void)
+get_current_block (CORE_ADDR *addr_in_block)
{
- return block_for_pc (read_pc ());
+ CORE_ADDR pc = read_pc ();
+
+ if (addr_in_block)
+ *addr_in_block = pc;
+
+ return block_for_pc (pc);
}
CORE_ADDR
struct symbol *
get_frame_function (struct frame_info *frame)
{
- register struct block *bl = get_frame_block (frame);
+ register struct block *bl = get_frame_block (frame, 0);
if (bl == 0)
return 0;
return block_function (bl);
but it's better than a core dump. */
if (selected_frame == NULL)
error ("No selected frame.");
- block = get_frame_block (selected_frame);
+ block = get_frame_block (selected_frame, 0);
pc = selected_frame->pc;
sals.nelts = 0;
if (frame == NULL)
return 0;
- b = get_frame_block (frame);
+ b = get_frame_block (frame, 0);
if (SYMBOL_CLASS (var) == LOC_REGPARM_ADDR)
{
extern struct frame_info *get_next_frame (struct frame_info *);
-extern struct block *get_frame_block (struct frame_info *);
+extern struct block *get_frame_block (struct frame_info *,
+ CORE_ADDR *addr_in_block);
-extern struct block *get_current_block (void);
+extern struct block *get_current_block (CORE_ADDR *addr_in_block);
-extern struct block *get_selected_block (void);
+extern struct block *get_selected_block (CORE_ADDR *addr_in_block);
extern struct symbol *get_frame_function (struct frame_info *);
sym = lookup_symbol (copy,
(s ? BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)
- : get_selected_block ()),
+ : get_selected_block (0)),
VAR_NAMESPACE, 0, &sym_symtab);
symbol_found: /* We also jump here from inside the C++ class/namespace
+2002-04-05 Jim Blandy <jimb@redhat.com>
+
+ * mi-cmd-stack.c (list_args_or_locals): Pass new arg to
+ get_frame_block. (See entry in gdb/ChangeLog.)
+
2002-04-05 Elena Zannoni <ezannoni@redhat.com>
* mi-cmd-disas.c (mi_cmd_disassemble): Use TARGET_PRINT_INSN
stb = ui_out_stream_new (uiout);
- block = get_frame_block (fi);
+ block = get_frame_block (fi, 0);
ui_out_list_begin (uiout, locals ? "locals" : "args");
old_chain = make_cleanup (free_funcalls, 0 /*ignore*/);
funcall_chain = 0;
- expression_context_block = block ? block : get_selected_block ();
+ expression_context_block = block ? block : get_selected_block (0);
namecopy = (char *) alloca (strlen (lexptr) + 1);
expout_size = 10;
if (exp == 0)
error ("Argument required.");
- sym = lookup_symbol (exp, get_selected_block (), VAR_NAMESPACE,
+ sym = lookup_symbol (exp, get_selected_block (0), VAR_NAMESPACE,
&is_a_field_of_this, (struct symtab **) NULL);
if (sym == NULL)
{
return;
if (d->block)
- within_current_scope = contained_in (get_selected_block (), d->block);
+ within_current_scope = contained_in (get_selected_block (0), d->block);
else
within_current_scope = 1;
if (!within_current_scope)
else if (d->format.format)
printf_filtered ("/%c ", d->format.format);
print_expression (d->exp, gdb_stdout);
- if (d->block && !contained_in (get_selected_block (), d->block))
+ if (d->block && !contained_in (get_selected_block (0), d->block))
printf_filtered (" (cannot be evaluated in the current context)");
printf_filtered ("\n");
gdb_flush (gdb_stdout);
print_frame_local_vars (register struct frame_info *fi, register int num_tabs,
register struct ui_file *stream)
{
- register struct block *block = get_frame_block (fi);
+ register struct block *block = get_frame_block (fi, 0);
register int values_printed = 0;
if (block == 0)
register struct ui_file *stream)
{
register struct blockvector *bl;
- register struct block *block = get_frame_block (fi);
+ register struct block *block = get_frame_block (fi, 0);
register int values_printed = 0;
int index, have_default = 0;
char *blocks_printed;
}
/* Return the symbol-block in which the selected frame is executing.
- Can return zero under various legitimate circumstances. */
+ Can return zero under various legitimate circumstances.
+
+ If ADDR_IN_BLOCK is non-zero, set *ADDR_IN_BLOCK to the relevant
+ code address within the block returned. We use this to decide
+ which macros are in scope. */
struct block *
-get_selected_block (void)
+get_selected_block (CORE_ADDR *addr_in_block)
{
if (!target_has_stack)
return 0;
if (!selected_frame)
- return get_current_block ();
- return get_frame_block (selected_frame);
+ return get_current_block (addr_in_block);
+ return get_frame_block (selected_frame, addr_in_block);
}
/* Find a frame a certain number of levels away from FRAME.
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
- for (b = get_selected_block (); b != NULL; b = BLOCK_SUPERBLOCK (b))
+ for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
{
if (!BLOCK_SUPERBLOCK (b))
{
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
- for (b = get_selected_block (); b != NULL; b = BLOCK_SUPERBLOCK (b))
+ for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
{
if (!BLOCK_SUPERBLOCK (b))
{
block = NULL;
if (fi != NULL)
- block = get_frame_block (fi);
+ block = get_frame_block (fi, 0);
p = expression;
innermost_block = NULL;