From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24427 invoked by alias); 9 Aug 2008 14:17:59 -0000 Received: (qmail 24416 invoked by uid 22791); 9 Aug 2008 14:17:58 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 09 Aug 2008 14:17:02 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CACE12A974B; Sat, 9 Aug 2008 10:17:00 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ES9mqTl91Gxe; Sat, 9 Aug 2008 10:17:00 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 5C3A72A9744; Sat, 9 Aug 2008 10:16:59 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id DFE76E7ACD; Sat, 9 Aug 2008 16:16:51 +0200 (CEST) Date: Sat, 09 Aug 2008 14:17:00 -0000 From: Joel Brobecker To: Aleksandar Ristovski Cc: gdb-patches@sources.redhat.com, Jerome Guitton Subject: Re: Powerpc skip prologue Message-ID: <20080809141651.GB4936@adacore.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="SUOF0GtieIMvvwua" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.2i 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: 2008-08/txt/msg00235.txt.bz2 --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1072 > GDB assumes the gpr registers will be saved starting from a rN register up > to r31. This assumption doesn't seem to be right. See this: > http://sourceware.org/ml/gdb-patches/2007-12/msg00111.html and this: > http://sourceware.org/ml/gdb/2008-07/msg00279.html > > So I devised a micro-patch for handling the saved gprs. I just realized that we faced the same problem and forgot to submit the patch to the FSF. The ABI doesn't say anything about requiring that a sequence of registers be saved, which is why we introduced the use of a map rather than just save the lowest/highest register number. I propose to commit the following in a week unless there are comments/ objections: 2008-08-09 Jerome Guitton * rs6000-tdep.c (rs6000_framedata): Add new field. (SET_REG_IN_MAP, GET_REG_IN_MAP): New macros. (skip_prologue): Update register map when a register is saved. (rs6000_frame_cache): Only set register address if the corresponding register has been saved. Tested on ppc-aix. Cheers, -- Joel --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rs6000-tdep.diff" Content-length: 2563 Index: 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 --- rs6000-tdep.c 15 Jul 2008 18:32:06 -0000 1.318 +++ rs6000-tdep.c 9 Aug 2008 14:12:58 -0000 @@ -117,6 +117,9 @@ struct rs6000_framedata by which we decrement sp to allocate the frame */ int saved_gpr; /* smallest # of saved gpr */ + unsigned int saved_gpr_map; /* saved gpr map; for any reg in gprs, + iff bit "# of reg" of saved_gprs_map is 1 + then reg is saved */ int saved_fpr; /* smallest # of saved fpr */ int saved_vr; /* smallest # of saved vr */ int saved_ev; /* smallest # of saved ev */ @@ -1042,6 +1045,9 @@ ppc_deal_with_atomic_sequence (struct fr #define GET_SRC_REG(x) (((x) >> 21) & 0x1f) +#define SET_REG_IN_MAP(map,x) ((map |= 1 << x)) +#define GET_REG_IN_MAP(map,x) ((map & (1 << x))) + /* Limit the number of skipped non-prologue instructions, as the examining of the prologue is expensive. */ static int max_skip_non_prologue_insns = 10; @@ -1155,6 +1161,7 @@ bl_to_blrl_insn_p (CORE_ADDR pc, int ins - offset is the initial size of this stack frame --- the amount by which we decrement the sp to allocate the frame. - saved_gpr is the number of the first saved gpr. + - saved_gpr_map is the map of saved gprs. - saved_fpr is the number of the first saved fpr. - saved_vr is the number of the first saved vr. - saved_ev is the number of the first saved ev. @@ -1197,6 +1204,7 @@ skip_prologue (struct gdbarch *gdbarch, memset (fdata, 0, sizeof (struct rs6000_framedata)); fdata->saved_gpr = -1; + fdata->saved_gpr_map = 0; fdata->saved_fpr = -1; fdata->saved_vr = -1; fdata->saved_ev = -1; @@ -1275,6 +1283,7 @@ skip_prologue (struct gdbarch *gdbarch, { reg = GET_SRC_REG (op); + SET_REG_IN_MAP (fdata->saved_gpr_map, reg); if (fdata->saved_gpr == -1 || fdata->saved_gpr > reg) { fdata->saved_gpr = reg; @@ -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 (GET_REG_IN_MAP (fdata.saved_gpr_map,i)) + cache->saved_regs[tdep->ppc_gp0_regnum + i].addr = gpr_addr; gpr_addr += wordsize; } } --SUOF0GtieIMvvwua--