From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30954 invoked by alias); 1 Dec 2004 02:42:28 -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 30920 invoked from network); 1 Dec 2004 02:42:21 -0000 Received: from unknown (HELO priv-edtnes51.telusplanet.net) (199.185.220.223) by sourceware.org with SMTP; 1 Dec 2004 02:42:21 -0000 Received: from takamaka.act-europe.fr ([142.179.108.108]) by priv-edtnes51.telusplanet.net (InterMail vM.6.01.03.02 201-2131-111-104-20040324) with ESMTP id <20041201024220.TVNY26235.priv-edtnes51.telusplanet.net@takamaka.act-europe.fr> for ; Tue, 30 Nov 2004 19:42:20 -0700 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 4ECAD47DA6; Tue, 30 Nov 2004 18:42:20 -0800 (PST) Date: Wed, 01 Dec 2004 02:42:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: [RFA/alpha] Fetch register from the right frame Message-ID: <20041201024220.GD1204@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Nq2Wo0NMKNjxTN9z" Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2004-12/txt/msg00000.txt.bz2 --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2332 Hello, Trying to switch to gdb-6.3 on alpha-tru64, we noticed the following problem: (gdb) bt #0 0x000003ff8057d43c in __hstTransferRegistersPC () from /usr/shlib/libpthread.so #1 0x000003ff8056e8e4 in __osTransferContext () from /usr/shlib/libpthread.so #2 0x000003ff80560c30 in __dspDispatch () from /usr/shlib/libpthread.so #3 0x000003ff80560178 in __cvWaitPrim () from /usr/shlib/libpthread.so #4 0x000003ff8055da9c in __pthread_cond_wait () from /usr/shlib/libpthread.so #5 0x000000012002cf50 in system.tasking.rendezvous.wait_for_call () at s-tasren.adb:6 #6 0x00000001200296ec in system.tasking.rendezvous.accept_trivial () at s-tasren.adb:6 #7 0x000000012001e204 in task_switch.callee (<_task>=Cannot access memory at address 0x28 ) at task_switch.adb:29 warning: Previous frame inner to this frame (corrupt stack?) The two symptoms of the same problem are: . "<_task>=Cannot access memory at address 0x28" at frame #7 . warning: Previous frame inner to this frame (corrupt stack?) The callstack is missing the following two frames: #8 0x0000000120027cfc in system.tasking.stages.task_wrapper () at s-tassta.adb:6 #9 0x000003ff8058a47c in __thdBase () from /usr/shlib/libpthread.so I tracked the problem to alpha_heuristic_frame_prev_register(): Basically, after having verified that the register we'd like to fetch has not been saved in by the next frame, we try to fetch the value of the register inside the next frame. But instead, what we do, is that we actually fetch the value of the register for the frame *following* the next frame. Oups! In our case above, instead of fetching the value of FP in __pthread_cond_wait(), we end up fetching its value from __cvWaitPrim, which contains the following instruction: 0x000003ff8055fc58 <__cvWaitPrim+72>: clr fp So the value of FP becomes incorrect, and causes the backtrace screwup later down the road when we try to read RA using an offset from FP. 2004-11-30 Joel Brobecker * alpha-tdep.c (alpha_heuristic_frame_prev_register): Fetch the register value from the correct frame. Tested on alpha-tru64 5.1, fixes the problem above, no regression in the testsuite. OK to apply? Thanks, -- Joel --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="reg.diff" Content-length: 714 Index: alpha-tdep.c =================================================================== RCS file: /nile.c/cvs/Dev/gdb/gdb-6.3/gdb/alpha-tdep.c,v retrieving revision 1.1 diff -u -p -r1.1 alpha-tdep.c --- alpha-tdep.c 20 Oct 2004 23:11:33 -0000 1.1 +++ alpha-tdep.c 30 Nov 2004 18:09:39 -0000 @@ -1190,8 +1190,8 @@ alpha_heuristic_frame_prev_register (str } /* Otherwise assume the next frame has the same register value. */ - frame_register (next_frame, regnum, optimizedp, lvalp, addrp, - realnump, bufferp); + frame_register_unwind (next_frame, regnum, optimizedp, lvalp, addrp, + realnump, bufferp); } static const struct frame_unwind alpha_heuristic_frame_unwind = { --Nq2Wo0NMKNjxTN9z--