address size can be different from DW_OP_deref size
authorJoel Brobecker <brobecker@gnat.com>
Fri, 3 Jun 2011 17:42:24 +0000 (17:42 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Fri, 3 Jun 2011 17:42:24 +0000 (17:42 +0000)
gdb/ChangeLog:

        * dwarf2expr.c (execute_stack_op) [DW_OP_deref]: Handle
        the case where ADDR_SIZE is different from TYPE_LENGTH (type).

gdb/ChangeLog
gdb/dwarf2expr.c

index 50e7a98469b6c7417086560fc19f325f0e8e01f5..b0e7f91eca5b2819bdf8f4b0114f70214bf91b14 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-03  Joel Brobecker  <brobecker@adacore.com>
+
+       * dwarf2expr.c (execute_stack_op) [DW_OP_deref]: Handle
+       the case where ADDR_SIZE is different from TYPE_LENGTH (type).
+
 2011-06-03  Tom Tromey  <tromey@redhat.com>
 
        * python/py-inferior.c (python_inferior_exit): Use inferior's exit
index 3c60b6ab1b41b3383171b7e811304fd5aeb82be0..e1ddc963e8df29aeb8478794f6416b01f5981c13 100644 (file)
@@ -877,6 +877,19 @@ execute_stack_op (struct dwarf_expr_context *ctx,
              type = address_type;
 
            (ctx->read_mem) (ctx->baton, buf, addr, addr_size);
+
+           /* If the size of the object read from memory is different
+              from the type length, we need to zero-extend it.  */
+           if (TYPE_LENGTH (type) != addr_size)
+             {
+               ULONGEST result =
+                 extract_unsigned_integer (buf, addr_size, byte_order);
+
+               buf = alloca (TYPE_LENGTH (type));
+               store_unsigned_integer (buf, TYPE_LENGTH (type),
+                                       byte_order, result);
+             }
+
            result_val = value_from_contents_and_address (type, buf, addr);
            break;
          }