Do the dumpsys/dodumpsys thing on i386...

dumpsys() now mimics cpu_switchto() (pushes a switchframe onto the stack)
for postmortem debugging.

From simonb.
This commit is contained in:
skrll 2008-01-20 12:43:00 +00:00
parent 7660ca07d8
commit fb6e9dca10
2 changed files with 24 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dumpsys.c,v 1.1 2008/01/12 20:03:41 ad Exp $ */
/* $NetBSD: dumpsys.c,v 1.2 2008/01/20 12:43:00 skrll Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008 The NetBSD Foundation, Inc.
@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dumpsys.c,v 1.1 2008/01/12 20:03:41 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: dumpsys.c,v 1.2 2008/01/20 12:43:00 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -96,6 +96,7 @@ __KERNEL_RCSID(0, "$NetBSD: dumpsys.c,v 1.1 2008/01/12 20:03:41 ad Exp $");
* Exports, needed by savecore, the debugger or elsewhere in the kernel.
*/
void dodumpsys(void);
void dumpsys(void);
struct pcb dumppcb;
@ -155,15 +156,12 @@ extern phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
extern int mem_cluster_cnt;
void
dumpsys(void)
dodumpsys(void)
{
const struct bdevsw *bdev;
int dumpend, psize;
int error;
/* Save registers. */
savectx(&dumppcb);
if (dumpdev == NODEV)
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.S,v 1.63 2008/01/13 11:03:04 bouyer Exp $ */
/* $NetBSD: locore.S,v 1.64 2008/01/20 12:43:00 skrll Exp $ */
/*
* Copyright-o-rama!
@ -141,7 +141,7 @@
*/
#include <machine/asm.h>
__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.63 2008/01/13 11:03:04 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.64 2008/01/20 12:43:00 skrll Exp $");
#include "opt_compat_oldboot.h"
#include "opt_ddb.h"
@ -880,6 +880,24 @@ ENTRY(longjmp)
movl $1,%eax # return 1
ret
ENTRY(dumpsys)
# mimic cpu_switchto() for postmortem debugging.
# build a fake switch frame.
pushl %ebx
pushl %esi
pushl %edi
# save a context.
movl $dumppcb,%eax
movl %esp,PCB_ESP(%eax)
movl %ebp,PCB_EBP(%eax)
call _C_LABEL(dodumpsys)
addl $(3*4), %esp # sizeof(switchframe) - sizeof(%eip)
ret
/*
* struct lwp *cpu_switchto(struct lwp *oldlwp, struct newlwp,
* bool returning)