Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado <luisgpm@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Fix DW_CFA_restore_extended parsing
Date: Thu, 20 Dec 2007 20:25:00 -0000	[thread overview]
Message-ID: <1198182171.9817.22.camel@gargoyle> (raw)

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

Hi folks,

There appears to be a flaw during the execution of this instruction
(DW_CFA_restore_extended). Most of the time the registers are implicitly
defined to use an "unspecified" rule due to the lack of information (or
due to space optimization strategies) in the CIE's initial instructions.

Different from DW_CFA_restore, DW_CFA_restore_extended doesn't check if
the register rule in the current dwarf frame set's list of initialized
registers is valid prior to assigning the rule to it, so it might just
grab junk and fail eventually.

This is hard to reproduce as the extended restore instruction doesn't
show up very often, and you have to be lucky to grab the "wrong" kind of
junk for the rule, leading GDB to an internal error.

This simple patch fixes the issue. Any thoughts? Ok to commit?

Best regards,
-- 
Luis Machado
Software Engineer 
IBM Linux Technology Center

[-- Attachment #2: dwarf-fde-parse.diff --]
[-- Type: text/x-patch, Size: 1059 bytes --]

2007-12-20  Luis Machado  <luisgpm@br.ibm.com>

    * dwarf2-frame.c (execute_cfa_program): Check if a register's rule
    is explicitly defined in the CIE before assignment, else force the
    default rule.

Index: gdb/dwarf2-frame.c
===================================================================
--- gdb.orig/dwarf2-frame.c	2007-10-21 12:33:37.000000000 -0700
+++ gdb/dwarf2-frame.c	2007-12-20 11:19:56.000000000 -0800
@@ -382,7 +382,14 @@
 	      insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
 	      reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
 	      dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
-	      fs->regs.reg[reg] = fs->initial.reg[reg];
+
+              /* Check if this register was explicitly initialized in the
+	      CIE initial instructions.  If not, default the rule to
+	      UNSPECIFIED.  */
+	      if (reg < fs->initial.num_regs)
+	        fs->regs.reg[reg] = fs->initial.reg[reg];
+	      else
+		fs->regs.reg[reg].how = DWARF2_FRAME_REG_UNSPECIFIED;
 	      break;
 
 	    case DW_CFA_undefined:

             reply	other threads:[~2007-12-20 20:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-20 20:25 Luis Machado [this message]
2007-12-21  0:49 ` Jim Blandy
2007-12-21 14:02   ` Luis Machado
2007-12-21 19:16     ` Jim Blandy
2007-12-26 11:22       ` Luis Machado

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1198182171.9817.22.camel@gargoyle \
    --to=luisgpm@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox