From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32649 invoked by alias); 6 Mar 2004 23:17:44 -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 32642 invoked from network); 6 Mar 2004 23:17:43 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sources.redhat.com with SMTP; 6 Mar 2004 23:17:43 -0000 Received: from drow by nevyn.them.org with local (Exim 4.30 #1 (Debian)) id 1Azl39-0002T7-2e; Sat, 06 Mar 2004 18:17:43 -0500 Date: Sat, 06 Mar 2004 23:17:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sources.redhat.com Cc: cagney@gnu.org Subject: [rfa/mips] Stop backtraces when we've lost the PC Message-ID: <20040306231743.GA9379@nevyn.them.org> Mail-Followup-To: gdb-patches@sources.redhat.com, cagney@gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.1i X-SW-Source: 2004-03.o/txt/msg00128.txt Message-ID: <20040306231700.M3H1RYg0FRan_pYPNAYtFF-nUvrxvF_EyOIW_hZkk18@z> Here's an updated version of a little hack I've been using since GDB 6.0. If we are in a nested normal frame, i.e. something whose next frame is a function that it called in the normal way, and we didn't find a saved PC, we're going to be stuck in a loop. We might have been able to figure out the frame size, but not where the return address was stored; as the comment says, this happens in glibc's clone function. Of course the problem there is that it _doesn't_ save $ra in the normal fashion; it won't return. Without this patch schedlock.exp falls apart, because backtraces continue forever printing "clone()" on every line. OK? Or a better way to do this? -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer 2004-03-06 Daniel Jacobowitz * mips-tdep.c (mips_mdebug_frame_this_id): Terminate unwinding if we haven't found a saved PC. Index: mips-tdep.c =================================================================== RCS file: /big/fsf/rsync/src-cvs/src/gdb/mips-tdep.c,v retrieving revision 1.283 diff -u -p -r1.283 mips-tdep.c --- mips-tdep.c 17 Feb 2004 15:21:21 -0000 1.283 +++ mips-tdep.c 6 Mar 2004 22:52:29 -0000 @@ -1672,6 +1672,24 @@ mips_mdebug_frame_this_id (struct frame_ { struct mips_frame_cache *info = mips_mdebug_frame_cache (next_frame, this_cache); + + /* If the return address is not saved for two frames in a row, + then we are probably hosed. Not necessarily - it's possible to + write working assembly that violates this rule - but we can't + backtrace through that either. Eventually MIPS will support + DWARF2 unwind information, allowing assembly programmers to + avoid this problem. + + One place this check triggers is in the GNU/Linux clone syscall + wrapper. */ + if (frame_relative_level (next_frame) >= 0 + && get_frame_type (next_frame) == NORMAL_FRAME + && !trad_frame_addr_p (info->saved_regs, NUM_REGS + PC_REGNUM)) + { + (*this_id) = null_frame_id; + return; + } + (*this_id) = frame_id_build (info->base, frame_func_unwind (next_frame)); }