Subject: tracing through softintr in ddb
To: None <port-i386@netbsd.org>
From: Darrin B. Jewell <dbj@netbsd.org>
List: port-i386
Date: 03/09/2004 13:30:40
--=-=-=


I notice that ddb is having trouble tracing through soft interrupt
frames that are invoked from Xspllower from Xdoreti, largely because
the kludge in db_trace that tries to detect interrupt frames needs an
actual interrupt frame to do its work.

The following patch adds Xrecurse_soft{serial,net,clock} functions which
cons up fake interrupt frames for Xspllower and Xdoreti.  It allows
ddb to trace through soft interrupt frames for me, but it is pretty
much yet another kludge that adds a lot of extra overhead that isn't
really used by much.  Also, since intr.c is x86, but vector.S isn't,
the Xrecurse_soft{serial,net,clock} probably need to be defined
in the amd64 somehow as well, even if they don't do anything special.

This is kinda ugly, does anyone have anything better to suggest, or
does this look ok?

Darrin


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=ddb.diff
Content-Description: patch to ddb trace through softintr

Index: x86/include/intr.h
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/include/intr.h,v
retrieving revision 1.12
diff -u -u -p -r1.12 intr.h
--- x86/include/intr.h	4 Mar 2004 19:10:10 -0000	1.12
+++ x86/include/intr.h	9 Mar 2004 18:07:34 -0000
@@ -235,6 +235,9 @@ softintr(int sir)
 extern void Xsoftclock(void);
 extern void Xsoftnet(void);
 extern void Xsoftserial(void);
+extern void Xrecurse_softclock(void);
+extern void Xrecurse_softnet(void);
+extern void Xrecurse_softserial(void);
 
 extern struct intrstub i8259_stubs[];
 extern struct intrstub ioapic_edge_stubs[];
Index: x86/x86/intr.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/intr.c,v
retrieving revision 1.14
diff -u -u -p -r1.14 intr.c
--- x86/x86/intr.c	20 Feb 2004 18:04:06 -0000	1.14
+++ x86/x86/intr.c	9 Mar 2004 18:07:35 -0000
@@ -700,7 +700,7 @@ cpu_intr_init(struct cpu_info *ci)
 	    M_WAITOK|M_ZERO);
 	if (isp == NULL)
 		panic("can't allocate fixed interrupt source");
-	isp->is_recurse = Xsoftclock;
+	isp->is_recurse = Xrecurse_softclock;
 	isp->is_resume = Xsoftclock;
 	fake_softclock_intrhand.ih_level = IPL_SOFTCLOCK;
 	isp->is_handlers = &fake_softclock_intrhand;
@@ -713,7 +713,7 @@ cpu_intr_init(struct cpu_info *ci)
 	    M_WAITOK|M_ZERO);
 	if (isp == NULL)
 		panic("can't allocate fixed interrupt source");
-	isp->is_recurse = Xsoftnet;
+	isp->is_recurse = Xrecurse_softnet;
 	isp->is_resume = Xsoftnet;
 	fake_softnet_intrhand.ih_level = IPL_SOFTNET;
 	isp->is_handlers = &fake_softnet_intrhand;
@@ -726,7 +726,7 @@ cpu_intr_init(struct cpu_info *ci)
 	    M_WAITOK|M_ZERO);
 	if (isp == NULL)
 		panic("can't allocate fixed interrupt source");
-	isp->is_recurse = Xsoftserial;
+	isp->is_recurse = Xrecurse_softserial;
 	isp->is_resume = Xsoftserial;
 	fake_softserial_intrhand.ih_level = IPL_SOFTSERIAL;
 	isp->is_handlers = &fake_softserial_intrhand;
Index: i386/i386/vector.S
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/vector.S,v
retrieving revision 1.12
diff -u -u -p -r1.12 vector.S
--- i386/i386/vector.S	20 Feb 2004 17:35:01 -0000	1.12
+++ i386/i386/vector.S	9 Mar 2004 18:07:43 -0000
@@ -622,7 +622,22 @@ _C_LABEL(eintrcnt):
  * Soft interrupt handlers
  */
 
+#ifdef DDB
+IDTVEC(recurse_softserial)
+	pushfl
+	pushl	%cs
+	pushl	%esi
+	pushl	$0			/* dummy error code */
+	pushl	$T_ASTFLT		/* trap # for doing ASTs */
+	INTRENTRY
+	movl    $1f,%esi
+	jmp	_C_LABEL(Xsoftserial)
+1:	INTRFASTEXIT
+#endif
 IDTVEC(softserial)
+#ifdef DDB
+	pushl	$IPL_SOFTSERIAL
+#endif
 	movl	$IPL_SOFTSERIAL, CPUVAR(ILEVEL)
 	incl	CPUVAR(IDEPTH)
 #ifdef MULTIPROCESSOR
@@ -638,9 +653,27 @@ IDTVEC(softserial)
 	call	_C_LABEL(x86_softintunlock)
 #endif
 	decl	CPUVAR(IDEPTH)
+#ifdef DDB
+	addl	$4,%esp
+#endif
 	jmp	*%esi
 
+#ifdef DDB
+IDTVEC(recurse_softnet)
+	pushfl
+	pushl	%cs
+	pushl	%esi
+	pushl	$0			/* dummy error code */
+	pushl	$T_ASTFLT		/* trap # for doing ASTs */
+	INTRENTRY
+	movl    $1f,%esi
+	jmp	_C_LABEL(Xsoftnet)
+1:	INTRFASTEXIT
+#endif
 IDTVEC(softnet)
+#ifdef DDB
+	pushl	$IPL_SOFTNET
+#endif
 	movl	$IPL_SOFTNET, CPUVAR(ILEVEL)
 	incl	CPUVAR(IDEPTH)
 #ifdef MULTIPROCESSOR	
@@ -669,9 +702,27 @@ IDTVEC(softnet)
 	call	_C_LABEL(x86_softintunlock)	
 #endif
 	decl	CPUVAR(IDEPTH)
+#ifdef DDB
+	addl	$4,%esp
+#endif
 	jmp	*%esi
 
+#ifdef DDB
+IDTVEC(recurse_softclock)
+	pushfl
+	pushl	%cs
+	pushl	%esi
+	pushl	$0			/* dummy error code */
+	pushl	$T_ASTFLT		/* trap # for doing ASTs */
+	INTRENTRY
+	movl    $1f,%esi
+	jmp	_C_LABEL(Xsoftclock)
+1:	INTRFASTEXIT
+#endif
 IDTVEC(softclock)
+#ifdef DDB
+	pushl	$IPL_SOFTCLOCK
+#endif
 	movl	$IPL_SOFTCLOCK, CPUVAR(ILEVEL)
 	incl	CPUVAR(IDEPTH)
 #ifdef MULTIPROCESSOR	
@@ -688,6 +739,9 @@ IDTVEC(softclock)
 	call	_C_LABEL(x86_softintunlock)		
 #endif
 	decl	CPUVAR(IDEPTH)
+#ifdef DDB
+	addl	$4,%esp
+#endif
 	jmp	*%esi
 
 /*

--=-=-=--