diff options
author | Jim Blandy <jimb@codesourcery.com> | 2002-04-05 22:04:43 +0000 |
---|---|---|
committer | Jim Blandy <jimb@codesourcery.com> | 2002-04-05 22:04:43 +0000 |
commit | ae767bfb78e53e5586a10e6d7144dc3199e5aa36 (patch) | |
tree | 89d180b4aad315ea33face14267ddd1b5d639609 | |
parent | 84d2ac95e4f51faedabd0219bbf0fd1c2ef5f530 (diff) | |
download | gdb-ae767bfb78e53e5586a10e6d7144dc3199e5aa36.zip gdb-ae767bfb78e53e5586a10e6d7144dc3199e5aa36.tar.gz gdb-ae767bfb78e53e5586a10e6d7144dc3199e5aa36.tar.bz2 |
gdb/ChangeLog:
* 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.
gdb/mi/ChangeLog:
* mi-cmd-stack.c (list_args_or_locals): Pass new arg to
get_frame_block. (See entry in gdb/ChangeLog.)
-rw-r--r-- | gdb/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/blockframe.c | 32 | ||||
-rw-r--r-- | gdb/breakpoint.c | 2 | ||||
-rw-r--r-- | gdb/findvar.c | 2 | ||||
-rw-r--r-- | gdb/frame.h | 7 | ||||
-rw-r--r-- | gdb/linespec.c | 2 | ||||
-rw-r--r-- | gdb/mi/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/mi/mi-cmd-stack.c | 2 | ||||
-rw-r--r-- | gdb/parse.c | 2 | ||||
-rw-r--r-- | gdb/printcmd.c | 6 | ||||
-rw-r--r-- | gdb/stack.c | 16 | ||||
-rw-r--r-- | gdb/symtab.c | 4 | ||||
-rw-r--r-- | gdb/varobj.c | 2 |
13 files changed, 68 insertions, 25 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 325794c..ad19293 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +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 diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 1f10381..8626ede 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -504,10 +504,23 @@ get_frame_saved_regs (struct frame_info *frame, #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; @@ -520,13 +533,22 @@ get_frame_block (struct frame_info *frame) 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 @@ -559,7 +581,7 @@ get_pc_function_start (CORE_ADDR pc) 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); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index a55b428..772ee88 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5699,7 +5699,7 @@ get_catch_sals (int this_level_only) 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; diff --git a/gdb/findvar.c b/gdb/findvar.c index 5d54117..e94c150 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -551,7 +551,7 @@ addresses have not been bound by the dynamic loader. Try again when executable i if (frame == NULL) return 0; - b = get_frame_block (frame); + b = get_frame_block (frame, 0); if (SYMBOL_CLASS (var) == LOC_REGPARM_ADDR) { diff --git a/gdb/frame.h b/gdb/frame.h index b5f535a..5f952c5 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -196,11 +196,12 @@ extern struct frame_info *get_current_frame (void); 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 *); diff --git a/gdb/linespec.c b/gdb/linespec.c index 15ccab0..cbfafcf 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1187,7 +1187,7 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, 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 diff --git a/gdb/mi/ChangeLog b/gdb/mi/ChangeLog index 1c47618..b810a57 100644 --- a/gdb/mi/ChangeLog +++ b/gdb/mi/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 0e4bdf4..b4bae47 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -218,7 +218,7 @@ list_args_or_locals (int locals, int values, struct frame_info *fi) 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"); diff --git a/gdb/parse.c b/gdb/parse.c index b3fbe19..40491cf 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -1134,7 +1134,7 @@ parse_exp_1 (char **stringptr, struct block *block, int comma) 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; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index fd51c2b..b74f558 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1113,7 +1113,7 @@ address_info (char *exp, int from_tty) 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) { @@ -1549,7 +1549,7 @@ do_one_display (struct display *d) 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) @@ -1683,7 +1683,7 @@ Num Enb Expression\n"); 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); diff --git a/gdb/stack.c b/gdb/stack.c index 2fe6e42..bedb6ee 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1238,7 +1238,7 @@ static void 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) @@ -1272,7 +1272,7 @@ print_frame_label_vars (register struct frame_info *fi, int this_level_only, 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; @@ -1501,17 +1501,21 @@ record_selected_frame (CORE_ADDR *frameaddrp, int *levelp) } /* 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. diff --git a/gdb/symtab.c b/gdb/symtab.c index e32dcf7..05f777b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -3312,7 +3312,7 @@ make_symbol_completion_list (char *text, char *word) /* 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)) { @@ -3845,7 +3845,7 @@ make_symbol_overload_list (struct symbol *fsym) /* 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)) { diff --git a/gdb/varobj.c b/gdb/varobj.c index f56b7aa..3f13894 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -426,7 +426,7 @@ varobj_create (char *objname, block = NULL; if (fi != NULL) - block = get_frame_block (fi); + block = get_frame_block (fi, 0); p = expression; innermost_block = NULL; |