next up previous contents index
Next: 10.18.6 gdb_serial_puts: output a Up: 10.18 Serial-line Remote Debugging Previous: 10.18.4 gdb_serial_getchar: input a

10.18.5 gdb_serial_putchar: output a character to the remote debugger's console

   

SYNOPSIS

#include <oskit/gdb_serial.h>

void gdb_serial_putchar(int ch);

DESCRIPTION

If a remote debugging connection is currently active, this function sends the specified character to the remote debugger in a special ``output'' (`O') message which causes that character to be sent to the debugger's standard output. This allows the serial line used for remote debugging to double as a remote serial console, as described in Section 10.18.1.

Note that using gdb_serial_putchar by itself to print messages can be very inefficient, because a separate message is used for each character, and each of these messages must be acknowledged by the remote debugger before the next character can be sent. When possible, it is much faster to print strings of text using gdb_serial_puts (see Section 10.18.6). If you are using the implementation of printf in the OSKit's minimal C library (see Section 9.6), you can make this happen automatically by overriding puts with a version that calls gdb_serial_puts directly instead of calling putchar successively on each character.

If this function is called while no remote debugging connection is active, but the gdb_serial_send and gdb_serial_receive pointers are initialized to point to serial-line communication functions, then this function simply sends the specified character out the serial port using gdb_serial_send. This way, if the kernel attempts to print any messages before a connection has been established or after the connection has been dropped (e.g., by calling gdb_serial_exit), they won't confuse the debugger or cause the kernel to hang as they otherwise would, and they may be seen by the remote user if the serial port is being monitored at the time.

If the gdb_serial_send and gdb_serial_receive pointers are uninitialized (still NULL) when this function is called, it does nothing.

PARAMETERS

ch
The character to send to the remote debugger's console.

DEPENDENCIES

gdb_serial_send
10.18.8
gdb_serial_recv
10.18.7


next up previous contents index
Next: 10.18.6 gdb_serial_puts: output a Up: 10.18 Serial-line Remote Debugging Previous: 10.18.4 gdb_serial_getchar: input a

University of Utah Flux Research Group