Push a switchframe in dumpsys and cpu_switchto, but as dumpsys calls

other funcs a switchframe needs to be a multiple of 8 bytes. Stash sp as
well in the switchframe to bump it to 24bytes.

Setup the switchframe appropriately in cpu_lwp_fork.

Remove savectx - nothing uses it.

All of this make gdb's life much easier when dealing with crash dumps and
live kernels.

Reviewd by chris.
This commit is contained in:
skrll 2008-01-12 20:50:23 +00:00
parent ee652e42b1
commit cf47b9b0c7
4 changed files with 18 additions and 41 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpuswitch.S,v 1.50 2007/10/17 19:53:30 garbled Exp $ */
/* $NetBSD: cpuswitch.S,v 1.51 2008/01/12 20:50:23 skrll Exp $ */
/*
* Copyright 2003 Wasabi Systems, Inc.
@ -171,7 +171,8 @@ _C_LABEL(curpcb):
* r1 'struct lwp *' of the LWP to switch to
*/
ENTRY(cpu_switchto)
stmfd sp!, {r4-r7, lr}
mov ip, sp
stmfd sp!, {r4-r7, ip, lr}
mov r6, r1 /* save new lwp */
mov r4, r0 /* save old lwp, it's the return value */
@ -347,10 +348,10 @@ ENTRY(cpu_switchto)
mov r1, r6
/*
* Pull the registers that got pushed when either savectx() or
* cpu_switchto() was called and return.
* Pull the registers that got pushed when cpu_switchto() was called,
* and return.
*/
ldmfd sp!, {r4-r7, pc}
ldmfd sp, {r4-r7, sp, pc}
.Lswitch_do_ras:
ldr r1, [r1, #(TF_PC)] /* second ras_lookup() arg */
@ -361,29 +362,6 @@ ENTRY(cpu_switchto)
strne r0, [r1, #(TF_PC)]
b .Lswitch_return
/* LINTSTUB: Func: void savectx(struct pcb *pcb) */
ENTRY(savectx)
/*
* r0 = pcb
*/
/* Push registers.*/
stmfd sp!, {r4-r7, lr}
/* Store all the registers in the process's pcb */
#ifndef __XSCALE__
add r2, r0, #(PCB_R8)
stmia r2, {r8-r13}
#else
strd r8, [r0, #(PCB_R8)]
strd r10, [r0, #(PCB_R10)]
strd r12, [r0, #(PCB_R12)]
#endif
/* Pull the regs of the stack */
ldmfd sp!, {r4-r7, pc}
ENTRY(lwp_trampoline)
bl _C_LABEL(lwp_startup)

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.S,v 1.19 2008/01/01 14:06:42 chris Exp $ */
/* $NetBSD: locore.S,v 1.20 2008/01/12 20:50:24 skrll Exp $ */
/*
* Copyright (C) 1994-1997 Mark Brinicombe
@ -218,11 +218,8 @@ ENTRY_NP(abort)
*/
ENTRY(dumpsys)
/* push registers onto stack */
stmfd sp!, {r0-r7, lr}
/* push the status bits onto the stack */
mrs r0, cpsr_all
stmfd sp!, {r0}
mov ip, sp
stmfd sp!, {r4-r7, ip, lr}
/* fill in dumppcb */
ldr r0, .Ldumppcb
@ -239,9 +236,7 @@ ENTRY(dumpsys)
bl _C_LABEL(dodumpsys)
/* unwind the stack */
ldmfd sp!, {r0}
nop
ldmfd sp!, {r0-r7, pc}
ldmfd sp, {r4-r7, sp, pc}
.Ldumppcb:
.word _C_LABEL(dumppcb)

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.40 2007/10/17 19:53:31 garbled Exp $ */
/* $NetBSD: vm_machdep.c,v 1.41 2008/01/12 20:50:24 skrll Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.40 2007/10/17 19:53:31 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.41 2008/01/12 20:50:24 skrll Exp $");
#include "opt_armfpe.h"
#include "opt_pmap_debug.h"
@ -190,6 +190,7 @@ cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize,
sf = (struct switchframe *)tf - 1;
sf->sf_r4 = (u_int)func;
sf->sf_r5 = (u_int)arg;
sf->sf_sp = (u_int)tf;
sf->sf_pc = (u_int)lwp_trampoline;
pcb->pcb_un.un_32.pcb32_sp = (u_int)sf;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: frame.h,v 1.15 2007/03/09 19:21:58 thorpej Exp $ */
/* $NetBSD: frame.h,v 1.16 2008/01/12 20:50:24 skrll Exp $ */
/*
* Copyright (c) 1994-1997 Mark Brinicombe.
@ -81,7 +81,9 @@ struct clockframe {
};
/*
* Switch frame
* Switch frame.
*
* Should be a multiple of 8 bytes for dumpsys.
*/
struct switchframe {
@ -89,6 +91,7 @@ struct switchframe {
u_int sf_r5;
u_int sf_r6;
u_int sf_r7;
u_int sf_sp;
u_int sf_pc;
};