[PATCH]: Re: KDB updates

Ananth N Mavinakayanahalli ananth at in.ibm.com
Fri Mar 19 20:12:11 EST 2004


On Fri, Mar 19, 2004 at 01:05:11PM +1100, Paul Mackerras wrote:
> Linas,
>
> > I don't have bk push authority to ameslab, can you commit the attached
> > patch from Ananth?  (unless Ananth writes back and says 'stop don't do it')
> > I tested it on power3, it handles user-space stacks much better, and also
> > fixes my '10 seconds to enter kdb' complaint.
>
> -ENOPATCH :)

Inlined is the patch..


Anton,

I needed to declare

extern cpumask_t irq_affinity[NR_IRQS];

in xics.c for a successful "uni" build with ameslab on a Power3 system.
The inlined patch contains this addition too.

--
Ananth Narayan
Linux Technology Center,
IBM Software Lab, INDIA


diff -Naur --exclude=BitKeeper --exclude=SCCS temp/ameslab/arch/ppc64/kernel/xics.c ameslab/arch/ppc64/kernel/xics.c
--- temp/ameslab/arch/ppc64/kernel/xics.c	2004-03-15 10:03:58.000000000 +0530
+++ ameslab/arch/ppc64/kernel/xics.c	2004-03-16 09:40:21.000000000 +0530
@@ -238,6 +238,7 @@

 /* XXX Fix this when we clean up large irq support */
 extern cpumask_t get_irq_affinity(unsigned int irq);
+extern cpumask_t irq_affinity[NR_IRQS];

 static int get_irq_server(unsigned int irq)
 {
diff -Naur --exclude=BitKeeper --exclude=SCCS temp/ameslab/arch/ppc64/kdb/kdba_bp.c ameslab/arch/ppc64/kdb/kdba_bp.c
--- temp/ameslab/arch/ppc64/kdb/kdba_bp.c	2004-03-15 10:03:56.000000000 +0530
+++ ameslab/arch/ppc64/kdb/kdba_bp.c	2004-03-16 14:46:47.000000000 +0530
@@ -92,6 +92,9 @@
 	unsigned long primary;
 	unsigned long extended;

+	if (KDB_NULL_REGS(ef))
+		return KDB_DB_NOBPT;
+
 	msr = get_msr();
 	trap = ef->trap;
 	if (KDB_DEBUG(BP))
@@ -187,9 +190,6 @@
 	if (rv > 0)
 		goto handled;

-	goto handle;
-
-
 handle:

 	/*
@@ -271,6 +271,8 @@
 	kdb_dbtrap_t rv;
 	kdb_bp_t *bp;

+	if (KDB_NULL_REGS(ef))
+		return KDB_DB_NOBPT;
 	/*
 	 * Determine which breakpoint was encountered.
 	 */
@@ -294,6 +296,13 @@
 			kdb_id1(ef->nip);
 			rv = KDB_DB_BPT;
 			bp->bp_delay = 1;
+			/* SSBPT is set when the kernel debugger must single
+			 * step a task in order to re-establish an instruction
+			 * breakpoint which uses the instruction replacement
+			 * mechanism. It is cleared by any action that removes
+			 * the need to single-step the breakpoint
+			 */
+			KDB_STATE_SET(SSBPT);
 			break;
 		}
 	}
@@ -324,7 +333,7 @@
 static void
 kdba_handle_bp(kdb_eframe_t ef, kdb_bp_t *bp)
 {
-	if (!ef) {
+	if (KDB_NULL_REGS(ef)) {
 		kdb_printf("kdba_handle_bp: ef == NULL\n");
 		return;
 	}
@@ -337,12 +346,6 @@
 	 */
 	kdba_setsinglestep(ef);

-	/* KDB_STATE_SSBPT is set when the kernel debugger must single step
-	 * a task in order to re-establish an instruction breakpoint which
-	 * uses the instruction replacement mechanism.
-	 */
-	KDB_STATE_SET(SSBPT);
-
 	/*
 	 * Reset delay attribute
 	 */
@@ -665,7 +668,9 @@
  *
  *	For instruction replacement breakpoints, we must single-step
  *	over the replaced instruction at this point so we can re-install
- *	the breakpoint instruction after the single-step.
+ *	the breakpoint instruction after the single-step. SSBPT is set
+ *	when the breakpoint is initially hit and is cleared by any action
+ *	that removes the need for single-step over the breakpoint.
  */

 int
@@ -679,6 +684,8 @@
 	if (KDB_DEBUG(BP)) {
 		kdb_printf("kdba_installbp bp_installed %d\n", bp->bp_installed);
 	}
+	if (!KDB_STATE(SSBPT))
+		bp->bp_delay = 0;
 	if (!bp->bp_installed) {
 		if (bp->bp_hardtype) {
 			kdba_installdbreg(bp);
@@ -695,14 +702,15 @@
 		    if (KDB_DEBUG(BP))
 			kdb_printf("0x%lx 0x%lx 0x%lx\n",bp->bp_inst,bp->bp_addr,sizeof(bp->bp_addr));
 		    rc = kdb_getword(&bp->bp_inst, bp->bp_addr,sizeof(bp->bp_addr));
-		    kdb_putword(bp->bp_addr, PPC64_BREAKPOINT_INSTRUCTION,sizeof(PPC64_BREAKPOINT_INSTRUCTION));
+		    if (kdb_putword(bp->bp_addr, PPC64_BREAKPOINT_INSTRUCTION,sizeof(PPC64_BREAKPOINT_INSTRUCTION)))
+			return (1);
 		    if (KDB_DEBUG(BP))
 			kdb_printf("kdba_installbp instruction 0x%x at " kdb_bfd_vma_fmt "\n",
 				   PPC64_BREAKPOINT_INSTRUCTION, bp->bp_addr);
 		    bp->bp_installed = 1;
 		}
 	}
-return 0;
+	return 0;
 }

 /*
diff -Naur --exclude=BitKeeper --exclude=SCCS temp/ameslab/arch/ppc64/kdb/kdba_id.c ameslab/arch/ppc64/kdb/kdba_id.c
--- temp/ameslab/arch/ppc64/kdb/kdba_id.c	2004-03-15 10:03:56.000000000 +0530
+++ ameslab/arch/ppc64/kdb/kdba_id.c	2004-03-16 14:33:30.000000000 +0530
@@ -194,8 +194,6 @@
 int
 kdba_id_parsemode(const char *mode, disassemble_info *dip)
 {
-
-
 	return 0;
 }

diff -Naur --exclude=BitKeeper --exclude=SCCS temp/ameslab/arch/ppc64/kdb/kdbasupport.c ameslab/arch/ppc64/kdb/kdbasupport.c
--- temp/ameslab/arch/ppc64/kdb/kdbasupport.c	2004-03-15 10:03:56.000000000 +0530
+++ ameslab/arch/ppc64/kdb/kdbasupport.c	2004-03-16 10:17:26.000000000 +0530
@@ -516,7 +516,9 @@
 		ef = &regs;
 	}
 	cpus_in_kdb++;
+	kdb_save_running(ef);
 	rv = kdb_main_loop(reason, reason2, error, db_result, ef);
+	kdb_unsave_running(ef);
 	cpus_in_kdb--;
 	return rv;
 }
--- temp/ameslab/arch/ppc64/kdb/kdba_bt.c	2004-03-15 10:03:56.000000000 +0530
+++ ameslab/arch/ppc64/kdb/kdba_bt.c	2004-03-17 13:39:53.000000000 +0530
@@ -113,12 +113,6 @@
 	unsigned long symsize,symoffset;
 	char *symmodname;

-	if (!regs && !addr)
-	{
-		kdb_printf(" invalid regs pointer \n");
-		return 0;
-	}
-
 	/*
 	 * The caller may have supplied an address at which the
 	 * stack traceback operation should begin.  This address
@@ -129,12 +123,29 @@
 	 * entitled '<unknown>' was called from the function which
 	 * contains return-address.
 	 */
-	if (addr) {
+	if (!addr)
+		addr = (kdb_machreg_t *)p->thread.ksp;
+
+	if (addr && !task_curr(p)) {
 		eip = 0;
 		esp = *addr;
-		ebp=0;
+		ebp = 0;
 	} else {
-		ebp=regs->link;
+		if (task_curr(p)) {
+			struct kdb_running_process *krp = kdb_running_process + task_cpu(p);
+			if (!krp->seqno) {
+				kdb_printf("Process did not save state, cannot backtrace \n");
+				kdb_ps1(p);
+				return 0;
+			}
+			regs = krp->regs;
+		} else {
+			if (!regs)
+				regs = p->thread.regs;
+		}
+		if (KDB_NULL_REGS(regs))
+			return KDB_BADREG;
+		ebp = regs->link;
 		eip = regs->nip;
 		if (regs_esp)
 			esp = regs->gpr[1];
@@ -318,5 +329,5 @@
 int
 kdba_bt_process(struct task_struct *p, int argcount)
 {
-	return (kdba_bt_stack_ppc(p->thread.regs, (kdb_machreg_t *) p->thread.ksp, argcount, p, 0));
+	return (kdba_bt_stack_ppc(NULL, NULL, argcount, p, 0));
 }

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list