From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19755 invoked by alias); 21 Dec 2007 14:01:10 -0000 Received: (qmail 19742 invoked by uid 22791); 21 Dec 2007 14:01:08 -0000 X-Spam-Check-By: sourceware.org Received: from igw1.br.ibm.com (HELO igw1.br.ibm.com) (32.104.18.24) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 21 Dec 2007 14:00:25 +0000 Received: from mailhub1.br.ibm.com (mailhub1 [9.18.232.109]) by igw1.br.ibm.com (Postfix) with ESMTP id 168AE32C142 for ; Fri, 21 Dec 2007 11:40:40 -0200 (BRDT) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by mailhub1.br.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id lBLE0K0n1998940 for ; Fri, 21 Dec 2007 12:00:20 -0200 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id lBLE0JQ8025744 for ; Fri, 21 Dec 2007 12:00:19 -0200 Received: from [9.8.0.176] ([9.8.0.176]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id lBLE0I35023876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 21 Dec 2007 12:00:19 -0200 Subject: Re: [PATCH] Fix DW_CFA_restore_extended parsing From: Luis Machado Reply-To: luisgpm@linux.vnet.ibm.com To: Jim Blandy Cc: gdb-patches@sourceware.org In-Reply-To: <8f2776cb0712201403j593ffc0bg846b1a654a09d8bb@mail.gmail.com> References: <1198182171.9817.22.camel@gargoyle> <8f2776cb0712201403j593ffc0bg846b1a654a09d8bb@mail.gmail.com> Content-Type: multipart/mixed; boundary="=-Zd8HgkEh0l8LSAutG+37" Date: Fri, 21 Dec 2007 14:02:00 -0000 Message-Id: <1198245586.9817.29.camel@gargoyle> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-12/txt/msg00371.txt.bz2 --=-Zd8HgkEh0l8LSAutG+37 Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 574 On Thu, 2007-12-20 at 14:03 -0800, Jim Blandy wrote: > On Dec 20, 2007 12:22 PM, Luis Machado wrote: > > This simple patch fixes the issue. Any thoughts? Ok to commit? > > The only difference between those two opcodes is in their encoding --- > the action to be performed is identical. It seems silly to duplicate > the code. Could you pull the common code out into its own function, > and then have both cases simply parse their arguments and call the > function? Like so? -- Luis Machado Software Engineer IBM Linux Technology Center --=-Zd8HgkEh0l8LSAutG+37 Content-Disposition: attachment; filename=dwarf-fde-parse.diff Content-Type: text/x-patch; name=dwarf-fde-parse.diff; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 3088 2007-12-21 Luis Machado * dwarf2-frame.c (execute_cfa_program): Call dwarf2_restore_rule function to handle required actions for the DW_CFA_restore and DW_CFA_restore_extended instructions. (dwarf2_restore_rule): New function. Index: gdb/dwarf2-frame.c =================================================================== --- gdb.orig/dwarf2-frame.c 2007-10-21 12:33:37.000000000 -0700 +++ gdb/dwarf2-frame.c 2007-12-21 05:54:31.000000000 -0800 @@ -268,6 +268,36 @@ _("Support for DW_OP_GNU_push_tls_address is unimplemented")); } +/* Execute the required actions for both the DW_CFA_restore and +DW_CFA_restore_extended instructions. */ +static void +dwarf2_restore_rule (struct gdbarch *gdbarch, ULONGEST reg_num, + struct dwarf2_frame_state *fs, int eh_frame_p) +{ + ULONGEST reg; + + gdb_assert (fs->initial.reg); + reg = dwarf2_frame_adjust_regnum (gdbarch, reg_num, eh_frame_p); + dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1); + + /* 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; + + if (fs->regs.reg[reg].how == DWARF2_FRAME_REG_UNSPECIFIED) + complaint (&symfile_complaints, _("\ +incomplete CFI data; DW_CFA_restore unspecified\n\ +register %s (#%d) at 0x%s"), + gdbarch_register_name + (gdbarch, gdbarch_dwarf2_reg_to_regnum (gdbarch, reg)), + gdbarch_dwarf2_reg_to_regnum (gdbarch, reg), + paddr (fs->pc)); +} + static CORE_ADDR execute_stack_op (gdb_byte *exp, ULONGEST len, struct frame_info *next_frame, CORE_ADDR initial) @@ -324,23 +354,8 @@ } else if ((insn & 0xc0) == DW_CFA_restore) { - gdb_assert (fs->initial.reg); reg = insn & 0x3f; - reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p); - dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1); - if (reg < fs->initial.num_regs) - fs->regs.reg[reg] = fs->initial.reg[reg]; - else - fs->regs.reg[reg].how = DWARF2_FRAME_REG_UNSPECIFIED; - - if (fs->regs.reg[reg].how == DWARF2_FRAME_REG_UNSPECIFIED) - complaint (&symfile_complaints, _("\ -incomplete CFI data; DW_CFA_restore unspecified\n\ -register %s (#%d) at 0x%s"), - gdbarch_register_name - (gdbarch, gdbarch_dwarf2_reg_to_regnum (gdbarch, reg)), - gdbarch_dwarf2_reg_to_regnum (gdbarch, reg), - paddr (fs->pc)); + dwarf2_restore_rule (gdbarch, reg, fs, eh_frame_p); } else { @@ -378,11 +393,8 @@ break; case DW_CFA_restore_extended: - gdb_assert (fs->initial.reg); insn_ptr = read_uleb128 (insn_ptr, insn_end, ®); - 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]; + dwarf2_restore_rule (gdbarch, reg, fs, eh_frame_p); break; case DW_CFA_undefined: --=-Zd8HgkEh0l8LSAutG+37--