OSDN Git Service

gdb/ChangeLog:
authorjimb <jimb>
Fri, 5 Apr 2002 22:04:39 +0000 (22:04 +0000)
committerjimb <jimb>
Fri, 5 Apr 2002 22:04:39 +0000 (22:04 +0000)
* 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.)

13 files changed:
gdb/ChangeLog
gdb/blockframe.c
gdb/breakpoint.c
gdb/findvar.c
gdb/frame.h
gdb/linespec.c
gdb/mi/ChangeLog
gdb/mi/mi-cmd-stack.c
gdb/parse.c
gdb/printcmd.c
gdb/stack.c
gdb/symtab.c
gdb/varobj.c

index 325794c..ad19293 100644 (file)
@@ -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
index 1f10381..8626ede 100644 (file)
@@ -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);
index a55b428..772ee88 100644 (file)
@@ -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;
index 5d54117..e94c150 100644 (file)
@@ -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)
          {
index b5f535a..5f952c5 100644 (file)
@@ -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 *);
 
index 15ccab0..cbfafcf 100644 (file)
@@ -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 
index 1c47618..b810a57 100644 (file)
@@ -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
index 0e4bdf4..b4bae47 100644 (file)
@@ -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");
 
index b3fbe19..40491cf 100644 (file)
@@ -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;
index fd51c2b..b74f558 100644 (file)
@@ -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);
index 2fe6e42..bedb6ee 100644 (file)
@@ -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.
index e32dcf7..05f777b 100644 (file)
@@ -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))
        {
index f56b7aa..3f13894 100644 (file)
@@ -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;