From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24366 invoked by alias); 9 Aug 2002 00:11:36 -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 24359 invoked from network); 9 Aug 2002 00:11:34 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 9 Aug 2002 00:11:34 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu.redhat.com [172.16.52.200] (may be forged)) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id g78NwLl21507 for ; Thu, 8 Aug 2002 19:58:22 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id g790BWu00728 for ; Thu, 8 Aug 2002 20:11:33 -0400 Received: from romulus.sfbay.redhat.com (IDENT:xOHNfNLVW0OIET+yPD4qmrC5MciaS9s0@romulus.sfbay.redhat.com [172.16.27.251]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id g790BWe12689 for ; Thu, 8 Aug 2002 17:11:32 -0700 Received: (from kev@localhost) by romulus.sfbay.redhat.com (8.11.6/8.11.6) id g790BUE26139 for gdb-patches@sources.redhat.com; Thu, 8 Aug 2002 17:11:30 -0700 Date: Thu, 08 Aug 2002 17:11:00 -0000 From: Kevin Buettner Message-Id: <1020809001129.ZM26138@localhost.localdomain> To: gdb-patches@sources.redhat.com Subject: [RFA] Call FRAME_INIT_SAVED_REGS instead of mips_find_saved_regs MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-08/txt/msg00195.txt.bz2 The patch below replaces calls to mips_find_saved_regs with calls to FRAME_INIT_SAVED_REGS. It should be noted that FRAME_INIT_SAVED_REGS invokes mips_find_saved_regs. FRAME_INIT_SAVED_REGS also makes sure that frame->saved_regs[SP_REGNUM] is set. (I don't know why the author of mips_find_saved_regs didn't do it there.) The fact that frame->saved_regs[SP_REGNUM] is setup in FRAME_INIT_SAVED_REGS has important implications for my rewrite of mips_get_saved_register(). In the rewrite, I've changed mips_get_saved_register() to call frame_register_unwind() instead of the soon-to-be-defunct find_saved_register(). Now find_saved_register() looped through frames calling FRAME_INIT_SAVED_REGS() unconditionally. This meant that frame->saved_regs[SP_REGNUM] would always be set up, regardless of the means by which frame->saved_regs had been initialized. frame_register_unwind() and company doesn't unconditionally call FRAME_INIT_SAVED_REGS(). Instead, it assumes if the saved_regs field has been allocated (i.e, it's non-zero), then nothing more needs to be done. I think this is a reasonable assumption. In order to make this assumption hold for mips, we need to visit all of the other code paths which might potentially initialize saved_regs and make sure that they also fill in the correct value for SP_REGNUM. If this is not done, then the SP value ends up being incorrect for many frames. There is still one more code path which needs to be fixed in this regard, but I'm submitting a patch for that separately. (Stay tuned.) In the course of multiarching FRAME_INIT_SAVED_REGS, I did consider adding the necessary bits of code for setting frame->saved_regs[SP_REGNUM] in mips_find_saved_regs, but decided it would be more obvious if I did a straightforward translation of the (now replaced) macro. The elimination of mips_find_saved_regs() can wait for another day. After this patch though, there'll only be one caller, so it'll be easier to merge mips_find_saved_regs into mips_frame_init_saved_regs(). Okay to commit? * mips-tdep.c (read_next_frame_reg): Call FRAME_INIT_SAVED_REGS instead of mips_find_saved_regs. * (mips_pop_frame): Likewise. Index: mips-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/mips-tdep.c,v retrieving revision 1.93 diff -u -p -r1.93 mips-tdep.c --- mips-tdep.c 8 Aug 2002 23:32:52 -0000 1.93 +++ mips-tdep.c 8 Aug 2002 23:42:57 -0000 @@ -1466,7 +1466,7 @@ read_next_frame_reg (struct frame_info * else { if (fi->saved_regs == NULL) - mips_find_saved_regs (fi); + FRAME_INIT_SAVED_REGS (fi); if (fi->saved_regs[regno]) return read_memory_integer (ADDR_BITS_REMOVE (fi->saved_regs[regno]), MIPS_SAVED_REGSIZE); } @@ -2890,7 +2890,7 @@ mips_pop_frame (void) write_register (PC_REGNUM, FRAME_SAVED_PC (frame)); if (frame->saved_regs == NULL) - mips_find_saved_regs (frame); + FRAME_INIT_SAVED_REGS (frame); for (regnum = 0; regnum < NUM_REGS; regnum++) { if (regnum != SP_REGNUM && regnum != PC_REGNUM