From owner-freebsd-bugs@FreeBSD.ORG Tue Dec 30 09:00:59 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5703B16A4CE for ; Tue, 30 Dec 2003 09:00:59 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 84C3843D49 for ; Tue, 30 Dec 2003 09:00:38 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) hBUH0cFR065610 for ; Tue, 30 Dec 2003 09:00:38 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id hBUH0cSN065609; Tue, 30 Dec 2003 09:00:38 -0800 (PST) (envelope-from gnats) Resent-Date: Tue, 30 Dec 2003 09:00:38 -0800 (PST) Resent-Message-Id: <200312301700.hBUH0cSN065609@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Peter Edwards Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 936AF16A4CE for ; Tue, 30 Dec 2003 08:55:56 -0800 (PST) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id AEF4843D48 for ; Tue, 30 Dec 2003 08:55:54 -0800 (PST) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.10/8.12.10) with ESMTP id hBUGtsdL096760 for ; Tue, 30 Dec 2003 08:55:54 -0800 (PST) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.10/8.12.10/Submit) id hBUGtsmg096759; Tue, 30 Dec 2003 08:55:54 -0800 (PST) (envelope-from nobody) Message-Id: <200312301655.hBUGtsmg096759@www.freebsd.org> Date: Tue, 30 Dec 2003 08:55:54 -0800 (PST) From: Peter Edwards To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.0 Subject: gnu/60732: [PATCH] unbreak kgdb backtraces through traps X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2003 17:00:59 -0000 >Number: 60732 >Category: gnu >Synopsis: [PATCH] unbreak kgdb backtraces through traps >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Dec 30 09:00:38 PST 2003 >Closed-Date: >Last-Modified: >Originator: Peter Edwards >Release: 5.2-CURRENT >Organization: >Environment: FreeBSD hippo 5.2-CURRENT FreeBSD 5.2-CURRENT #0: Mon Dec 29 21:20:38 GMT 2003 petere@hippo:/scratch/obj/scratch/src/sys/HIPPO i386 >Description: This has been bugging the hell out of me for ages: I finally cleaned up my local patch enough to consider submitting it. The usr/src/gnu/usr.bin/binutils/gdb directory contains some freebsd-specific code to enable kernel debugging, uthread manipulation etc. There's a set of files, fbsd-kgdb-${GDB_CPU}.h, that are supposed to provide hooks to the gdb base code. However, these are never included. For i386, the main loss is the definition of "FRAME_SAVED_PC", which is designed to aid gdb unwind through a stack frame. Without this definition, the topmost frame of a core from kernel panic under the actual trap() frame is lost: This is normally the most interesting frame >How-To-Repeat: Find a way to kill your machine with a page fault (some available on request :-)) As an example, here's a backtrace for a panic I can reproduce at will: (note "calltrap" appears in frame 5) #0 doadump () at /scratch/src/sys/kern/kern_shutdown.c:240 #1 0xc04c0489 in boot (howto=260) at /scratch/src/sys/kern/kern_shutdown.c:372 #2 0xc04c0868 in panic () at /scratch/src/sys/kern/kern_shutdown.c:550 #3 0xc05dc326 in trap_fatal (frame=0xd72e7c40, eva=0) at /scratch/src/sys/i386/i386/trap.c:821 #4 0xc05db903 in trap (frame= {tf_fs = 24, tf_es = -684851184, tf_ds = -1067712496, tf_edi = 0, tf_esi = -1067086800, tf_ebp = -684819296, tf_isp = -684819348, tf_ebx = -1000238144, tf_edx = -1050979712, tf_ecx = -1050979712, tf_eax = 20, tf_trapno = 12, tf_err = 0, tf_eip = -1068595426, tf_cs = 8, tf_eflags = 65683, tf_esp = -1050982468, tf_ss = 131}) at /scratch/src/sys/i386/i386/trap.c:250 #5 0xc05c9898 in calltrap () at {standard input}:94 #6 0xc04e8fa4 in turnstile_wait (ts=0x0, lock=0xc06560e0, owner=0x0) at /scratch/src/sys/kern/subr_turnstile.c:510 #7 0xc04b5af5 in _mtx_lock_sleep (m=0xc06560e0, opts=0, file=0x0, line=0) at /scratch/src/sys/kern/kern_mutex.c:476 #8 0xc04aa4a4 in ithread_loop (arg=0xc15aa600) at /scratch/src/sys/kern/kern_intr.c:543 #9 0xc04a9130 in fork_exit (callout=0xc04aa2e0 , arg=0x0, frame=0x0) at /scratch/src/sys/kern/kern_fork.c:793 With the fix in place, I get this stack trace: #0 doadump () at /scratch/src/sys/kern/kern_shutdown.c:240 #1 0xc04c0489 in boot (howto=260) at /scratch/src/sys/kern/kern_shutdown.c:372 #2 0xc04c0868 in panic () at /scratch/src/sys/kern/kern_shutdown.c:550 #3 0xc05dc326 in trap_fatal (frame=0xd72e7c40, eva=0) at /scratch/src/sys/i386/i386/trap.c:821 #4 0xc05db903 in trap (frame= {tf_fs = 24, tf_es = -684851184, tf_ds = -1067712496, tf_edi = 0, tf_esi = -1067086800, tf_ebp = -684819296, tf_isp = -684819348, tf_ebx = -1000238144, tf_edx = -1050979712, tf_ecx = -1050979712, tf_eax = 20, tf_trapno = 12, tf_err = 0, tf_eip = -1068595426, tf_cs = 8, tf_eflags = 65683, tf_esp = -1050982468, tf_ss = 131}) at /scratch/src/sys/i386/i386/trap.c:250 #5 0xc04e871e in propagate_priority (td=0xc46193c0) at /scratch/src/sys/kern/subr_turnstile.c:230 #6 0xc04e8fa4 in turnstile_wait (ts=0xc438a640, lock=0xc06560e0, owner=0x0) at /scratch/src/sys/kern/subr_turnstile.c:510 #7 0xc04b5af5 in _mtx_lock_sleep (m=0xc06560e0, opts=0, file=0x0, line=0) at /scratch/src/sys/kern/kern_mutex.c:476 #8 0xc04aa4a4 in ithread_loop (arg=0xc15aa600) at /scratch/src/sys/kern/kern_intr.c:543 #9 0xc04a9130 in fork_exit (callout=0xc04aa2e0 , arg=0x0, frame=0x0) at /scratch/src/sys/kern/kern_fork.c:793 (This time frame 5 actually shows me the faulting code.) >Fix: I rejigged the makefile to create a tm.h that included the stock gdb version, and the freebsd kgdb-specific code (the target for nm.h sets a precident for this). For i386, this just envolved ripping out the bits that were not used anyway, and leaving in a working definition of FRAME_SAVED_PC. For alpha, the existing version should work fine. The other platforms don't seem to have any support for FRAME_SAVED_PC yet anyway, so they shouldn't be affected. Here's the patch: begin 644 gdb-frame-patch.txt M26YD97@Z($UA:V5F:6QE"CT]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T] M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T*4D-3(&9I M;&4Z("]URY405)' M151]"B`*+2YF;W(@2"!I;B!T;2UF8G-D('AM+21[1T1"7T-057T*+21[2#I# M+RTN*B0O+WTN:#H**PHK=&TN:#H**PEE8VAO("RY405)'151]"BLN:68@97AIRY405)'151] M"BLN96YD:68**PHK"BLN9F]R($@@:6X@>&TM)'M'1$)?0U!5?0HK>&TN:#H* M(`EL;B`MRY#55)$25)]+RXN+RXN+RXN+RXN+V-O;G1R M:6(O9V1B+V=D8B]C;VYF:6TA]+F@@7`HK"2`@("`D M>T=$0D1)4GTO9V1B+V-O;F9I9R\D>T=$0E]#4%5]+WAM+21[1T1"7T-057TN M:"!<"B`)("`@("1[+E1!4D=%5'T*("YE;F1F;W(*(`I);F1E>#H@9F)S9"UK M9V1B+6DS.#8N:`H]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T] M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]"E)#4R!F:6QE.B`O M=7-R+V-VF4@ M,'@Q."!A;F0@:7,@:6UM961I871E;'D@8F5L;W<@=&AE"BT@("!P#$P(&%N9"!I'1E5]I;G1E9V5R("@H M1E)!344I+3YFRelease-Note: >Audit-Trail: >Unformatted: