From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32752 invoked by alias); 29 Jul 2008 16:35:54 -0000 Received: (qmail 32744 invoked by uid 22791); 29 Jul 2008 16:35:53 -0000 X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 29 Jul 2008 16:35:28 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KNsAS-0005RT-UI for gdb@sources.redhat.com; Tue, 29 Jul 2008 16:35:20 +0000 Received: from enigma.qnx.com ([209.226.137.106]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 Jul 2008 16:35:20 +0000 Received: from aristovski by enigma.qnx.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 Jul 2008 16:35:20 +0000 To: gdb@sources.redhat.com From: Aleksandar Ristovski Subject: Re: PowerPC prologue analysis Date: Tue, 29 Jul 2008 16:52:00 -0000 Message-ID: References: <20080728201312.GA3911@caradoc.them.org> <20080728210800.GA7730@caradoc.them.org> <488F2040.8040202@qnx.com> <20080729154243.GA29510@caradoc.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070406020703010703000905" User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) In-Reply-To: <20080729154243.GA29510@caradoc.them.org> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00299.txt.bz2 This is a multi-part message in MIME format. --------------070406020703010703000905 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 737 Daniel Jacobowitz wrote: > On Tue, Jul 29, 2008 at 11:42:29AM -0400, Aleksandar Ristovski wrote: >> And for the reference: Daniel's patch ( >> http://sourceware.org/ml/gdb-patches/2007-12/msg00111.html ) does >> solve the problem with not all registers saved. >> >> Why is the patch not in HEAD gdb? > > There's a couple of questions in the posting and I never figured out > the answers to them. I'll be back to them at some point. > May I suggest that you break the patch in two patches: one dealing with not-all-registers-saved (i.e. gpr_mask) and the rest? I extracted the gpr_mask part here with the testsuite changes and I believe this part of the patch is safe to apply. Attached: Fragment extracted from Daniel's patch. --------------070406020703010703000905 Content-Type: text/plain; name="rs6000-tdep.c.Daniel-gpr_mask-part.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="rs6000-tdep.c.Daniel-gpr_mask-part.diff" Content-length: 2154 Index: gdb/rs6000-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v retrieving revision 1.318 diff -u -p -r1.318 rs6000-tdep.c --- gdb/rs6000-tdep.c 15 Jul 2008 18:32:06 -0000 1.318 +++ gdb/rs6000-tdep.c 29 Jul 2008 16:27:53 -0000 @@ -117,6 +117,7 @@ struct rs6000_framedata by which we decrement sp to allocate the frame */ int saved_gpr; /* smallest # of saved gpr */ + unsigned int gpr_mask; /* Each bit is an individual saved GPR. */ int saved_fpr; /* smallest # of saved fpr */ int saved_vr; /* smallest # of saved vr */ int saved_ev; /* smallest # of saved ev */ @@ -1275,6 +1276,10 @@ skip_prologue (struct gdbarch *gdbarch, { reg = GET_SRC_REG (op); + if ((op & 0xfc1f0000) == 0xbc010000) + fdata->gpr_mask |= ~((1U << reg) - 1); + else + fdata->gpr_mask |= 1U << reg; if (fdata->saved_gpr == -1 || fdata->saved_gpr > reg) { fdata->saved_gpr = reg; @@ -1678,11 +1683,15 @@ skip_prologue (struct gdbarch *gdbarch, else { + unsigned int all_mask = ~((1U << fdata->saved_gpr) - 1); + /* Not a recognized prologue instruction. Handle optimizer code motions into the prologue by continuing the search if we have no valid frame yet or if the return - address is not yet saved in the frame. */ - if (fdata->frameless == 0 && fdata->nosavedpc == 0) + address is not yet saved in the frame. Also skip instructions + if some of the GPRs expected to be saved are not yet saved. */ + if (fdata->frameless == 0 && fdata->nosavedpc == 0 + && (fdata->gpr_mask & all_mask) == all_mask) break; if (op == 0x4e800020 /* blr */ @@ -2573,7 +2582,8 @@ rs6000_frame_cache (struct frame_info *t CORE_ADDR gpr_addr = cache->base + fdata.gpr_offset; for (i = fdata.saved_gpr; i < ppc_num_gprs; i++) { - cache->saved_regs[tdep->ppc_gp0_regnum + i].addr = gpr_addr; + if (fdata.gpr_mask & (1U << i)) + cache->saved_regs[tdep->ppc_gp0_regnum + i].addr = gpr_addr; gpr_addr += wordsize; } } --------------070406020703010703000905 Content-Type: text/plain; name="gdb_arch_powerpc-prologue.exp.Daniel-gpr_mask-part.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="gdb_arch_powerpc-prologue.exp.Daniel-gpr_mask-part.diff" Content-length: 745 Index: gdb/testsuite/gdb.arch/powerpc-prologue.exp =================================================================== --- gdb/testsuite/gdb.arch/powerpc-prologue.exp (revision 197) +++ gdb/testsuite/gdb.arch/powerpc-prologue.exp (working copy) @@ -64,7 +64,7 @@ gdb_test "backtrace 10" \ "backtrace in PIC" gdb_test "info frame" \ - ".*Saved registers:.*r30 at.*r31 at.*pc at.*lr at.*" \ + ".*Saved registers:.*r30 at.*pc at.*lr at.*" \ "saved registers in PIC" # Testcase for scheduled prologue. @@ -84,5 +84,5 @@ gdb_test "backtrace 10" \ "backtrace in optimized" gdb_test "info frame" \ - ".*Saved registers:.*r30 at.*r31 at.*pc at.*lr at.*" \ + ".*Saved registers:.*r30 at.*pc at.*lr at.*" \ "saved registers in optimized" --------------070406020703010703000905--