next up previous contents index
Next: 10.17.8 gdb_trap_recover: recovery pointer Up: 10.17 Remote Kernel Debugging Previous: 10.17.6 gdb_copyin: safely read

10.17.7 gdb_copyout: safely write data into the subject's address space

   

SYNOPSIS

#include <oskit/gdb.h>

int gdb_copyout(const void *src_buf, oskit_addr_t dest_va, oskit_size_t size);

DESCRIPTION

The protocol-specific local GDB stub calls this function in order to write data into 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 write 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 write to unmapped or nonexistent memory, it will merely cause the debugger to report an error rather than making everything go haywire.

PARAMETERS

src_buf
A pointer to the kernel buffer containing the data to write.
dest_va
The virtual address in the address space of the program being debugged (the kernel's address space, by default) at which to write the data.
size
The number of bytes of data to transfer.

RETURNS

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

DEPENDENCIES

gdb_trap_recover
10.17.8



University of Utah Flux Research Group