next up previous contents index
Next: 10.8.7 trap_dump_panic: dump a Up: (X86) Base Environment: Trap Previous: 10.8.5 base_trap_default_handler: default trap

10.8.6 trap_dump: dump a saved trap state structure

   

SYNOPSIS

#include <oskit/x86/base_trap.h>

void trap_dump(const struct trap_state *state);

DESCRIPTION

This function dumps the contents of the specified trap state frame to the console using the printf function, in a simple human-readable form. The function is smart enough to determine whether the trap occurred from supervisor mode, user mode, or v86 mode, and interpret the saved state accordingly. For example, for traps from rings 1-3 or from v86 mode, the the original stack pointer is part of the saved state frame; however, for traps from ring 0, the original stack pointer is simply the end of the stack frame pushed by the processor, since no stack switch occurs in this case.

In addition, for traps from ring 0, this routine also provides a hex dump of the top of the kernel stack as it appeared when the trap occurred; this stack dump can aid in tracking down the cause of a kernel bug. trap_dump does not attempt to dump the stack for traps from user or v86 mode, because there seems to be no sufficiently generic way for it to access the appropriate user stack; in addition, in this case the trap might have been caused by a user-stack-related exception, in which case attempting to dump the user stack could lead to a recursive trap.

PARAMETERS

state
A pointer to the trap state structure to dump.

DEPENDENCIES

struct trap_state
10.8.1
printf
9.6



University of Utah Flux Research Group