* dwarf2read.c (skip_one_die) <DW_FORM_ref_addr>: Use offset size
authorTom Tromey <tromey@redhat.com>
Thu, 4 Mar 2010 22:01:10 +0000 (22:01 +0000)
committerTom Tromey <tromey@redhat.com>
Thu, 4 Mar 2010 22:01:10 +0000 (22:01 +0000)
in DWARF 3 and later.
(read_attribute_value) <DW_FORM_ref_addr>: Likewise.

gdb/ChangeLog
gdb/dwarf2read.c

index a44b03afce6c4a92a16f80cba1a3b52c236dfdbb..ccb69032eec2f3b3fb51fbb8075424d926d9ee07 100644 (file)
@@ -1,3 +1,9 @@
+2010-03-04  Tom Tromey  <tromey@redhat.com>
+
+       * dwarf2read.c (skip_one_die) <DW_FORM_ref_addr>: Use offset size
+       in DWARF 3 and later.
+       (read_attribute_value) <DW_FORM_ref_addr>: Likewise.
+
 2010-03-04  Keith Seitz  <keiths@redhat.com>
 
        * linespec.c (decode_line_1): Update comments for is_quote_enclosed.
index 549d2c0add8239b313f0654eecb4c1d124b879c0..b144dc16d827fce2838c0ea88856c4728c32733d 100644 (file)
@@ -2882,8 +2882,15 @@ skip_one_die (gdb_byte *buffer, gdb_byte *info_ptr,
     skip_attribute:
       switch (form)
        {
-       case DW_FORM_addr:
        case DW_FORM_ref_addr:
+         /* In DWARF 2, DW_FORM_ref_addr is address sized; in DWARF 3
+            and later it is offset sized.  */
+         if (cu->header.version == 2)
+           info_ptr += cu->header.addr_size;
+         else
+           info_ptr += cu->header.offset_size;
+         break;
+       case DW_FORM_addr:
          info_ptr += cu->header.addr_size;
          break;
        case DW_FORM_data1:
@@ -7017,8 +7024,14 @@ read_attribute_value (struct attribute *attr, unsigned form,
   attr->form = form;
   switch (form)
     {
-    case DW_FORM_addr:
     case DW_FORM_ref_addr:
+      if (cu->header.version == 2)
+       DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read);
+      else
+       DW_ADDR (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read);
+      info_ptr += bytes_read;
+      break;
+    case DW_FORM_addr:
       DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read);
       info_ptr += bytes_read;
       break;