kgdb missing stack frames

From: Ian Dowse <iedowse_at_maths.tcd.ie>
Date: Sun, 18 May 2003 22:27:22 +0100
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 <idle_proc>, 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 <idle_proc>, 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
_at__at_ -77,7 +77,11 _at__at_
 /* 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
_at__at_ -12,19 +12,6 _at__at_
 #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 <sys/signal.h>.  */
 #define SIGCONTEXT_PC_OFFSET 20
 
Received on Sun May 18 2003 - 12:27:24 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:08 UTC