From owner-freebsd-current@FreeBSD.ORG Sun May 18 14:27:24 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 55B0137B401; Sun, 18 May 2003 14:27:24 -0700 (PDT) Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by mx1.FreeBSD.org (Postfix) with SMTP id EDBB843F3F; Sun, 18 May 2003 14:27:22 -0700 (PDT) (envelope-from iedowse@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 18 May 2003 22:27:22 +0100 (BST) To: obrien@freebsd.org, mp@freebsd.org Date: Sun, 18 May 2003 22:27:22 +0100 From: Ian Dowse Message-ID: <200305182227.aa40061@salmon.maths.tcd.ie> cc: current@freebsd.org Subject: kgdb missing stack frames X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 May 2003 21:27:24 -0000 Support for decoding i386 trap frames in kgdb appears to have been lost by revision 1.3 of contrib/gdb/gdb/config/i386/tm-fbsd.h, since FRAME_SAVED_PC() is defined there in terms of i386bsd_frame_saved_pc(), so fbsd_kern_frame_saved_pc() in gnu/usr.bin/binutils/gdb/kvm-fbsd.c never gets called. A simple way to see this is to run gdb -k kernel.debug /dev/mem and get a backtrace from the idle process: (kgdb) proc 11 (kgdb) bt #0 mi_switch () at ../../../kern/kern_synch.c:530 #1 0xc01edb92 in ithread_schedule (ithread=0xc1898280, do_switch=1) at ../../../kern/kern_intr.c:402 #2 0xc034ad43 in sched_ithd (cookie=0xc1894d80) at ../../../i386/isa/ithread.c:77 #3 0xc03380cc in Xintr14 () at {standard input}:382 #4 0xc01ed16c in idle_proc (dummy=0x0) at ../../../kern/kern_idle.c:114 #5 0xc01ecea0 in fork_exit (callout=0xc01ed130 , arg=0x0, frame=0x0) at ../../../kern/kern_fork.c:792 This is what it should look like: (kgdb) proc 11 (kgdb) bt #0 mi_switch () at ../../../kern/kern_synch.c:530 #1 0xc01edb92 in ithread_schedule (ithread=0xc1898280, do_switch=1) at ../../../kern/kern_intr.c:402 #2 0xc034ad43 in sched_ithd (cookie=0xc1898280) at ../../../i386/isa/ithread.c:77 #3 0xc033e242 in cpu_idle () at ../../../i386/i386/machdep.c:1074 #4 0xc01ed16c in idle_proc (dummy=0x0) at ../../../kern/kern_idle.c:114 #5 0xc01ecea0 in fork_exit (callout=0xc01ed130 , arg=0x0, frame=0x0) at ../../../kern/kern_fork.c:792 i.e, the cpu_idle() frame now appears instead of Xintr14(). The following patch appears to fix this on the i386 (I haven't looked at whether the problem affects other architectures). I also haven't looked in detail to see what else could be stripped from fbsd-kgdb-i386.h. Ian Index: contrib/gdb/gdb/config/i386/tm-fbsd.h =================================================================== RCS file: /dump/FreeBSD-CVS/src/contrib/gdb/gdb/config/i386/tm-fbsd.h,v retrieving revision 1.4 diff -u -r1.4 tm-fbsd.h --- contrib/gdb/gdb/config/i386/tm-fbsd.h 12 Oct 2002 17:56:56 -0000 1.4 +++ contrib/gdb/gdb/config/i386/tm-fbsd.h 18 May 2003 21:12:05 -0000 @@ -77,7 +77,11 @@ /* Override FRAME_SAVED_PC to enable the recognition of signal handlers. */ #undef FRAME_SAVED_PC -#define FRAME_SAVED_PC(frame) i386bsd_frame_saved_pc (frame) +#define FRAME_SAVED_PC(frame) \ + (kernel_debugging ? fbsd_kern_frame_saved_pc (frame) : \ + i386bsd_frame_saved_pc (frame)) + +extern CORE_ADDR fbsd_kern_frame_saved_pc(struct frame_info *fr); extern CORE_ADDR i386bsd_frame_saved_pc (struct frame_info *frame); Index: gnu/usr.bin/binutils/gdb/fbsd-kgdb-i386.h =================================================================== RCS file: /dump/FreeBSD-CVS/src/gnu/usr.bin/binutils/gdb/fbsd-kgdb-i386.h,v retrieving revision 1.3 diff -u -r1.3 fbsd-kgdb-i386.h --- gnu/usr.bin/binutils/gdb/fbsd-kgdb-i386.h 18 Sep 2002 16:20:49 -0000 1.3 +++ gnu/usr.bin/binutils/gdb/fbsd-kgdb-i386.h 18 May 2003 21:05:35 -0000 @@ -12,19 +12,6 @@ #undef SIGTRAMP_END #define SIGTRAMP_END(pc) 0xbfbfdff0 - -/* Override FRAME_SAVED_PC to enable the recognition of signal handlers. */ - -extern CORE_ADDR fbsd_kern_frame_saved_pc(struct frame_info *fr); - -#undef FRAME_SAVED_PC -#define FRAME_SAVED_PC(FRAME) \ - (kernel_debugging \ - ? fbsd_kern_frame_saved_pc (FRAME) : \ - (FRAME)->signal_handler_caller \ - ? sigtramp_saved_pc (FRAME) \ - : read_memory_integer ((FRAME)->frame + 4, 4)) - /* Offset to saved PC in sigcontext, from . */ #define SIGCONTEXT_PC_OFFSET 20