KDB updates

linas at austin.ibm.com linas at austin.ibm.com
Fri Mar 19 08:35:41 EST 2004


On Thu, Mar 18, 2004 at 07:16:47PM +0500, Ananth N Mavinakayanahalli wrote:
> Hello Linas,
>
> We are working with your patch (now in ameslab) and found an issue with
> stack backtrace for the "current" process. Inlined is a patch that fixes
> it (uses a method similar to the i386 code) and it also contains a few
> other checks. Please comment....
>
> (Oh, I had to define irq_affinity[NR_IRQS] as extern in xics.c for a
> successful UNI build)
>
> We have been working on a Power3 box all this while and KDB works fine.
> We are now trying it on a p630 but the machine locks up solid immediately
> upon entry; we have to reset it through the hmc console.
>
> Just curious if you had the patch working on SMP? Are there any other
> issues to take care of in this case? Any pointers would be helpful.
>
>
> Thanks,
> Ananth
> --
> Ananth Narayan
> Linux Technology Center,
> IBM Software Lab, INDIA
>
>
> 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;
>  }
> 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)
>  {
> --- 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