From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30563 invoked by alias); 12 Oct 2004 21:26:40 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 30553 invoked from network); 12 Oct 2004 21:26:39 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 12 Oct 2004 21:26:39 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.10) with ESMTP id i9CLQYfh009197 for ; Tue, 12 Oct 2004 17:26:34 -0400 Received: from localhost.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i9CLQXr09989; Tue, 12 Oct 2004 17:26:33 -0400 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 99D6628CF; Tue, 12 Oct 2004 17:26:13 -0400 (EDT) Message-ID: <416C4BF5.7000900@gnu.org> Date: Tue, 12 Oct 2004 21:26:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20041009 MIME-Version: 1.0 To: Joel Brobecker Cc: gdb-patches@sources.redhat.com Subject: Re: [RFC] Calling mips-tdep.c:read_next_frame_reg with null frame? References: <20041011040934.GD26446@gnat.com> In-Reply-To: <20041011040934.GD26446@gnat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-10/txt/msg00219.txt.bz2 > I am wondering what would happen if we were to call mips32_scan_prologue > with a NULL frame, which I think is something that we are doing on a > regular basis. See for instance how after_prologue that calls > heuristic_proc_desc with a NULL frame, which gets passed to scan_prologue. > > There is some code in that function that does: > > frame_addr = read_next_frame_reg (next_frame, NUM_REGS + 30); > > Looking at read_next_frame_reg(): > > static CORE_ADDR > read_next_frame_reg (struct frame_info *fi, int regno) > { > /* Always a pseudo. */ > gdb_assert (regno >= NUM_REGS); > if (fi == NULL) > { > LONGEST val; > regcache_cooked_read_signed (current_regcache, regno, &val); > return val; > } > else > return frame_unwind_register_signed (fi, regno); > > So when the frame is null, we fetch some value from the regcache. > But what if we don't have any inferior? Looks like we have to be > a bit careful with the following code: > > else if (frame_reg == MIPS_SP_REGNUM) > { > unsigned alloca_adjust; > > frame_reg = 30; > frame_addr = read_next_frame_reg (next_frame, NUM_REGS + 30); > alloca_adjust = (unsigned) (frame_addr - (sp + low_word)); > if (alloca_adjust > 0) > { > /* FP > SP + frame_size. This may be because of > an alloca or somethings similar. Fix sp to > "pre-alloca" value, and try again. */ > sp += alloca_adjust; > /* Need to reset the status of all registers. Otherwise, > we will hit a guard that prevents the new address > for each register to be recomputed during the second > pass. */ > reset_saved_regs (this_cache); > goto restart; > } > } > Same for > > /* move $30,$sp. With different versions of gas this will be either > `addu $30,$sp,$zero' or `or $30,$sp,$zero' or `daddu 30,sp,$0'. > Accept any one of these. */ > else if (inst == 0x03A0F021 || inst == 0x03a0f025 || inst == 0x03a0f02d) > { > /* New gcc frame, virtual frame pointer is at r30 + frame_size. */ > if (frame_reg == MIPS_SP_REGNUM) > { > unsigned alloca_adjust; > > frame_reg = 30; > frame_addr = read_next_frame_reg (next_frame, NUM_REGS + 30); > (etc...) > > I suggest modifying the (frame_reg == SP_REGNUM) check into > > (frame_reg == SP_REGNUM && next_frame != NULL) > > with a comment saying that if NEXT_FRAME is null, then we're probably > not analyzing a live frame, but just scanning the prologue. So we don't > need to do anything special for this instruction. Yes (it's definitly not a live frame so the information extracted from the instructions doesn't need to be saved). Btw, if you replace: reset_saved_regs (this_cache); goto restart; with reset_saved_regs (this_cache); frame_offset = 0; I believe that you can blow away the GOTO. Andrew