From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14130 invoked by alias); 5 Aug 2002 21:52:30 -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 14122 invoked from network); 5 Aug 2002 21:52:29 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 5 Aug 2002 21:52:29 -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 g75Ldcl09214 for ; Mon, 5 Aug 2002 17:39:38 -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 g75LqSu07125 for ; Mon, 5 Aug 2002 17:52:28 -0400 Received: from romulus.sfbay.redhat.com (remus.sfbay.redhat.com [172.16.27.252]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id g75LqRB25093 for ; Mon, 5 Aug 2002 14:52:27 -0700 Received: (from kev@localhost) by romulus.sfbay.redhat.com (8.11.6/8.11.6) id g75LqQ125935 for gdb-patches@sources.redhat.com; Mon, 5 Aug 2002 14:52:26 -0700 Date: Mon, 05 Aug 2002 14:52:00 -0000 From: Kevin Buettner Message-Id: <1020805215225.ZM25934@localhost.localdomain> To: gdb-patches@sources.redhat.com Subject: [RFA] find_saved_register(): Terminate loop when saved reg found MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-08/txt/msg00101.txt.bz2 As currently written, find_saved_register() scans from the callee (if any) of FRAME through to the innermost frame looking for the location at which a particular register was saved. The problem with the loop as currently written is that it doesn't terminate until the the very last (innermost) frame is reached. This is wrong. It should terminate as soon as the address of the saved register is found. Prior to April of this year, the loop in question worked quite differently. It would start at the innermost frame (which is the most recently pushed frame as viewed execution-wise from the inferior) and consider each caller in succession until the frame under consideration was reached. In April, 2002, the termination condition mentioned above was removed and the direction of frame traversal was reversed. I.e, instead of following the "caller" link, the loop now instead follows the "callee" link. I suspect that the addition of the appropriate termination condition for this new arrangement was merely an oversight. (This change fixes quite a few testsuite failures for the mips target that I'm working on.) Okay to commit? * frame.c (find_saved_register): Break out of loop once saved register address is found. Don't mention sparc in loop comment anymore. Index: frame.c =================================================================== RCS file: /cvs/src/src/gdb/frame.c,v retrieving revision 1.13 diff -u -p -r1.13 frame.c --- frame.c 10 Jun 2002 23:25:50 -0000 1.13 +++ frame.c 5 Aug 2002 20:54:46 -0000 @@ -94,10 +94,9 @@ find_saved_register (struct frame_info * if (frame == NULL) /* No regs saved if want current frame */ return 0; - /* Note that this next routine assumes that registers used in - frame x will be saved only in the frame that x calls and - frames interior to it. This is not true on the sparc, but the - above macro takes care of it, so we should be all right. */ + /* Note that the following loop assumes that registers used in + frame x will be saved only in the frame that x calls and frames + interior to it. */ while (1) { QUIT; @@ -107,7 +106,10 @@ find_saved_register (struct frame_info * frame = frame1; FRAME_INIT_SAVED_REGS (frame1); if (frame1->saved_regs[regnum]) - addr = frame1->saved_regs[regnum]; + { + addr = frame1->saved_regs[regnum]; + break; + } } return addr;