2003-06-01 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / dwarf2-frame.c
index 7694218b9048e70fb7544b0a39511c505d95cd68..7dbd0dbf753faac7cda5c41bc9c102bea6e24061 100644 (file)
@@ -65,6 +65,9 @@ struct dwarf2_cie
   /* Encoding of addresses.  */
   unsigned char encoding;
 
+  /* True if a 'z' augmentation existed.  */
+  unsigned char saw_z_augmentation;
+
   struct dwarf2_cie *next;
 };
 
@@ -550,9 +553,21 @@ dwarf2_frame_cache (struct frame_info *next_frame, void **this_cache)
        cache->reg[regnum] = fs->regs.reg[reg];
     }
 
-  /* Stored the location of the return addess.  */
-  if (fs->retaddr_column < fs->regs.num_regs)
+  /* Store the location of the return addess.  If the return address
+     column (adjusted) is not the same as gdb's PC_REGNUM, then this
+     implies a copy from the ra column register.  */
+  if (fs->retaddr_column < fs->regs.num_regs
+      && fs->regs.reg[fs->retaddr_column].how != REG_UNSAVED)
     cache->reg[PC_REGNUM] = fs->regs.reg[fs->retaddr_column];
+  else
+    {
+      reg = DWARF2_REG_TO_REGNUM (fs->retaddr_column);
+      if (reg != PC_REGNUM)
+       {
+         cache->reg[PC_REGNUM].loc.reg = reg;
+         cache->reg[PC_REGNUM].how = REG_SAVED_REG;
+       }
+    }
 
   do_cleanups (old_chain);
 
@@ -1099,7 +1114,8 @@ decode_frame_entry (struct comp_unit *unit, char *buf, int eh_frame_p)
       cie->return_address_register = read_1_byte (unit->abfd, buf);
       buf += 1;
 
-      if (*augmentation == 'z')
+      cie->saw_z_augmentation = (*augmentation == 'z');
+      if (cie->saw_z_augmentation)
        {
          ULONGEST length;
 
@@ -1188,6 +1204,18 @@ decode_frame_entry (struct comp_unit *unit, char *buf, int eh_frame_p)
        read_encoded_value (unit, fde->cie->encoding & 0x0f, buf, &bytes_read);
       buf += bytes_read;
 
+      /* A 'z' augmentation in the CIE implies the presence of an
+        augmentation field in the FDE as well.  The only thing known
+        to be in here at present is the LSDA entry for EH.  So we
+        can skip the whole thing.  */
+      if (fde->cie->saw_z_augmentation)
+       {
+         ULONGEST length;
+
+         length = read_unsigned_leb128 (unit->abfd, buf, &bytes_read);
+         buf += bytes_read + length;
+       }
+
       fde->instructions = buf;
       fde->end = end;
 
This page took 0.023488 seconds and 4 git commands to generate.