2006-10-08 Paul Brook <paul@codesourcery.com>
[binutils-gdb.git] / gdb / dwarf2loc.c
index fea2c99a9d5e18af21f45a4d498f4ee9a0d8c822..76a99fa8560ade67824cb880b30c339d80b55da0 100644 (file)
@@ -1,6 +1,6 @@
 /* DWARF 2 location expression support for GDB.
 
-   Copyright 2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005 Free Software Foundation, Inc.
 
    Contributed by Daniel Jacobowitz, MontaVista Software, Inc.
 
@@ -18,8 +18,8 @@
 
    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.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "ui-out.h"
@@ -164,9 +164,11 @@ dwarf_expr_frame_base (void *baton, gdb_byte **start, size_t * length)
   if (SYMBOL_OPS (framefunc) == &dwarf2_loclist_funcs)
     {
       struct dwarf2_loclist_baton *symbaton;
+      struct frame_info *frame = debaton->frame;
+
       symbaton = SYMBOL_LOCATION_BATON (framefunc);
       *start = find_location_expression (symbaton, length,
-                                        get_frame_pc (debaton->frame));
+                                        get_frame_address_in_block (frame));
     }
   else
     {
@@ -475,13 +477,30 @@ dwarf2_tracepoint_var_ref (struct symbol *symbol, struct agent_expr *ax,
       ax_const_l (ax, frame_offset);
       ax_simple (ax, aop_add);
 
-      ax_const_l (ax, frame_offset);
+      value->kind = axs_lvalue_memory;
+    }
+  else if (data[0] >= DW_OP_breg0
+          && data[0] <= DW_OP_breg31)
+    {
+      unsigned int reg;
+      LONGEST offset;
+      gdb_byte *buf_end;
+
+      reg = data[0] - DW_OP_breg0;
+      buf_end = read_sleb128 (data + 1, data + size, &offset);
+      if (buf_end != data + size)
+       error (_("Unexpected opcode after DW_OP_breg%u for symbol \"%s\"."),
+              reg, SYMBOL_PRINT_NAME (symbol));
+
+      ax_reg (ax, reg);
+      ax_const_l (ax, offset);
       ax_simple (ax, aop_add);
+
       value->kind = axs_lvalue_memory;
     }
   else
-    error (_("Unsupported DWARF opcode in the location of \"%s\"."),
-          SYMBOL_PRINT_NAME (symbol));
+    error (_("Unsupported DWARF opcode 0x%x in the location of \"%s\"."),
+          data[0], SYMBOL_PRINT_NAME (symbol));
 }
 \f
 /* Return the value of SYMBOL in FRAME using the DWARF-2 expression
@@ -597,7 +616,8 @@ loclist_read_variable (struct symbol *symbol, struct frame_info *frame)
   size_t size;
 
   data = find_location_expression (dlbaton, &size,
-                                  frame ? get_frame_pc (frame) : 0);
+                                  frame ? get_frame_address_in_block (frame)
+                                  : 0);
   if (data == NULL)
     {
       val = allocate_value (SYMBOL_TYPE (symbol));