next up previous contents index
Next: 10.17.7 gdb_copyout: safely write Up: 10.17 Remote Kernel Debugging Previous: 10.17.5 gdb_trap: default trap

10.17.6 gdb_copyin: safely read data from the subject's address space

   

SYNOPSIS

#include <oskit/gdb.h>

int gdb_copyin(oskit_addr_t src_va, void *dest_buf, oskit_size_t size);

DESCRIPTION

The protocol-specific local GDB stub calls this function in order to read data in the address space of the program being debugged. The default implementation of this function provided by libkern assumes that the kernel itself is the program being debugged; thus, it acts basically like an ordinary memcpy. However, the client can override this function with a version that accesses a different address space, such as a user process's address space, in order to support remote debugging of entities other than the kernel.

If a fault occurs while trying to read the specified data, this function catches the fault cleanly and returns an error code rather than allowing a recursive trap to be dispatched to the debugger. This way, if the user of the debugger accidentally attempts to follow an invalid pointer or display unmapped or nonexistent memory, it will merely cause the debugger to report an error rather than making everything go haywire.

PARAMETERS

src_va
The virtual address in the address space of the program being debugged (the kernel's address space, by default) from which to read data.
dest_buf
A pointer to the kernel buffer to copy data into. This buffer is provided by the caller, typically the local GDB stub,
size
The number of bytes of data to read into the destination buffer.

RETURNS

Returns zero if the transfer completed successfully, or nonzero if some or all of the source region is not accessible.

DEPENDENCIES

gdb_trap_recover
10.17.8



University of Utah Flux Research Group