Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

GDB Debug Interface


Files

file  debug.c

Functions

void set_mem_fault_trap ()
void debuglog (int level, char *msg)
 print debug messages. More...

int hex2digit (int digit)
 converts an ascii hex digit to a number. More...

char digit2hex (int digit)
 convert number NIB to a hex digit. More...

unsigned char * mem2hex (unsigned char *mem, unsigned char *buf, int count, int may_fault)
 converts a memory block to hex and stores it in buf. More...

unsigned char * hex2mem (unsigned char *buf, unsigned char *mem, int count, int may_fault)
 Convert the hex array pointed to by buf into binary to be placed in mem. More...

int hex2int (char **ptr, int *intValue)
 while we find nice hex chars, build an int. More...

void getpacket (unsigned char *buffer)
 Scan for the sequence $<data>#<checksum>. More...

void putpacket (unsigned char *buffer)
 Send the packet in buffer. More...

void gdb_event_loop (int sigval, unsigned long *registers)
 This is the gdb event loop waiting for GDB commands. More...

char * make_return_packet (int val)
 make a return packet. More...

char * gdb_read_registers ()
 g - read registers. More...

char * gdb_write_registers (char *regs)
 G - write registers. More...

char * gdb_read_memory (long addr, int nbytes)
 m - read memory. More...

char * gdb_write_memory (long addr, int nbytes, char *mem)
 M write memory. More...

char * gdb_continue (int sig, long addr)
 c - continue at address. More...

char * gdb_step (int sig, long addr)
 s - step instruction(s). More...

char * gdb_kill ()
 k - kill program. More...

char * gdb_last_signal (int val)
 ? - last signal. More...

char * gdb_baudrate (int baud)
 b - change baud rate. More...

char * gdb_dump_state ()
 T - dump state. More...

char * gdb_detach ()
 D - host requests a detach. More...

char * gdb_set_thread (int cmd, int tid)
 H - set thread. More...

char * gdb_read_reg (int reg)
 p - read one register. More...

char * gdb_write_reg (int reg, long val)
 P - write one register. More...

char * gdb_exited ()
 W - process exited. More...

char * gdb_terminated ()
 X - process terminated. More...

char * gdb_hex (char *str, int nbytes)
 O - hex encoding. More...

char * gdb_thread_alive (int tid)
 A - tread alive request. More...

char * gdb_extended ()
 ! - extended protocol. More...

char * gdb_debug ()
 d - toggle gdb stub diagnostics. More...

char * gdb_toggle ()
 d - toggle gdb stub. More...

char * gdb_reset ()
 r - reset target. More...

char * gdb_search (long addr, long pat, long mask)
 t - search backwards. More...

char * gdb_get_query (char *query)
 q - general get query. More...

char * gdb_set (char *query)
 Q - general set query. More...


Variables

volatile int mem_err = 0
int remote_debug = 0
int initialized = 0
trap_info hard_trap_info []

Detailed Description

This is something that came with the newlib and looks like a good idea.

Function Documentation

void debuglog int    level,
char *    msg
 

print debug messages.

This uses print, rather than one of the stdio routines, cause if there are stack or memory problems, the stdio routines don't work.

Parameters:
level  is the debug level
msg  is the string to print

Definition at line 121 of file debug.c.

References BUFMAX, print, and remote_debug.

char digit2hex int    digit
 

convert number NIB to a hex digit.

Parameters:
digit  is a decimal digit.
returns a hex digit.

Definition at line 211 of file debug.c.

Referenced by putpacket.

char* gdb_baudrate int    baud
 

b - change baud rate.

Parameters:
baud  is the new baudrate
returns the baud rate.

Definition at line 702 of file debug.c.

References make_return_packet.

char* gdb_continue int    sig,
long    addr
 

c - continue at address.

Parameters:
addr  is the address to start at
sig  is an optional signal. If sig is zero, then ignore it.
returns an OK or an error number.

Definition at line 644 of file debug.c.

char* gdb_debug  
 

d - toggle gdb stub diagnostics.

returns an OK or an error number.

Definition at line 862 of file debug.c.

References make_return_packet, and remote_debug.

char* gdb_detach  
 

D - host requests a detach.

returns either a S, T, W, or X command. returns an OK or an error number.

Definition at line 738 of file debug.c.

char* gdb_dump_state  
 

T - dump state.

returns the signal number, the registers, the thread ID, and possible extensions in a vector that looks like: TAAn...:r...;n...:r...;n...:r...; where:

AA = signal number n... = register number (hex) r... = register contents n... = `thread' r... = thread process ID. This is a hex integer. n... = other string not starting with valid hex digit. gdb should ignore this n,r pair and go on to the next. This way we can extend the protocol.

Definition at line 726 of file debug.c.

void gdb_event_loop int    sigval,
unsigned long *    registers
 

This is the gdb event loop waiting for GDB commands.

Definition at line 418 of file debug.c.

References DEBUG, gdb_kill, gdb_last_signal, gdb_read_memory, gdb_toggle, gdb_write_memory, getpacket, hex2int, make_return_packet, packet_in_buf, packet_out_buf, and putpacket.

char* gdb_exited  
 

W - process exited.

returns the exit status.

Definition at line 798 of file debug.c.

References make_return_packet.

char* gdb_extended  
 

! - extended protocol.

returns an OK or an error number.

Definition at line 849 of file debug.c.

References make_return_packet.

char* gdb_get_query char *    query
 

q - general get query.

Parameters:
query  is a string, that's the query to be executed.
FIXME: not entirely sure what this is supposed to return.

Definition at line 930 of file debug.c.

References make_return_packet.

char* gdb_hex char *    str,
int    nbytes
 

O - hex encoding.

Parameters:
str  is a pointer to a vector of bytes
nbytes  is the number of bytes to encode
returns a vector of ASCII encoded hex numbers.

Definition at line 824 of file debug.c.

char* gdb_kill  
 

k - kill program.

returns an OK or an error number.

Definition at line 668 of file debug.c.

References make_return_packet.

Referenced by gdb_event_loop.

char* gdb_last_signal int    val
 

? - last signal.

returns the last signal number.

Definition at line 681 of file debug.c.

References DEBUG, digit2hex, and packet_out_buf.

char* gdb_read_memory long    addr,
int    nbytes
 

m - read memory.

Parameters:
addr  is the address to start the read at
nbytes  is the number of bytes to read.
returns a vector of nbytes or an error number. Can be fewer bytes than requested if able to read only part of thedata.

Definition at line 607 of file debug.c.

References make_return_packet, MAY_FAULT, mem2hex, and packet_out_buf.

char* gdb_read_reg int    reg
 

p - read one register.

Parameters:
reg  is the register number.
returns the register value or ENN.

Definition at line 769 of file debug.c.

References make_return_packet.

char* gdb_read_registers  
 

g - read registers.

returns a vector of words, size is NUM_REGS.

Definition at line 581 of file debug.c.

char* gdb_reset  
 

r - reset target.

returns an OK or an error number.

Definition at line 900 of file debug.c.

References make_return_packet.

char* gdb_search long    addr,
long    pat,
long    mask
 

t - search backwards.

Parameters:
addr  is the address to start searching from
pat  is a pattern to match
mask  is the mask to use.
FIXME: not entirely sure what this is supposed to return.

Definition at line 916 of file debug.c.

References make_return_packet.

char* gdb_set char *    query
 

Q - general set query.

Parameters:
query  is a string, that's the query to be executed.
FIXME: not entirely sure what this means. returns an OK or an error number.

Definition at line 945 of file debug.c.

References make_return_packet.

char* gdb_set_thread int    cmd,
int    tid
 

H - set thread.

Parameters:
cmd  is the command to execute
tid  is the thread ID
cmd = 'c' for thread used in step and continue; cmd = 'g' for thread used in other operations. tid = -1 for all threads. tid = zero, pick a thread,any thread. returns an OK or an error number.

Definition at line 755 of file debug.c.

References make_return_packet.

char* gdb_step int    sig,
long    addr
 

s - step instruction(s).

Parameters:
addr  is the address to start at
sig  is an optional signal. If sig is zero, then ignore it.
returns an OK or an error number.

Definition at line 657 of file debug.c.

char* gdb_terminated  
 

X - process terminated.

returns the last signal.

Definition at line 811 of file debug.c.

char* gdb_thread_alive int    tid
 

A - tread alive request.

Parameters:
tid  is the thread ID.
returns an OK or an error number.

Definition at line 836 of file debug.c.

References make_return_packet.

char* gdb_toggle  
 

d - toggle gdb stub.

returns an OK or an error number.

Definition at line 879 of file debug.c.

References make_return_packet, and remote_debug.

Referenced by gdb_event_loop.

char* gdb_write_memory long    addr,
int    nbytes,
char *    mem
 

M write memory.

Parameters:
addr  is the address to start writing to
nbytes  is the number of bytes to write
mem  is the new values of the bytes.
returns an OK or an error number.

Definition at line 626 of file debug.c.

References hex2mem, make_return_packet, and MAY_FAULT.

char* gdb_write_reg int    reg,
long    val
 

P - write one register.

Parameters:
reg  is the register number
val  is the new value
returns the register value or ENN.

Definition at line 784 of file debug.c.

References make_return_packet.

char* gdb_write_registers char *    regs
 

G - write registers.

Parameters:
regs  is a vector of words, size is NUM_REGS.
returns an OK or an error number.

Definition at line 593 of file debug.c.

void getpacket unsigned char *    buffer
 

Scan for the sequence $<data>#<checksum>.

Parameters:
buffer  is the buffer to be scanned

Definition at line 323 of file debug.c.

References _LIBC_inbyte, _LIBC_outbyte, BUFMAX, and hex2digit.

int hex2digit int    digit
 

converts an ascii hex digit to a number.

Parameters:
digit  is hex digit.
returns a decimal digit.

Definition at line 188 of file debug.c.

References ERROR.

int hex2int char **    ptr,
int *    intValue
 

while we find nice hex chars, build an int.

Parameters:
ptr  is a pointer to a pointer the string to parse
intValue  is a pointer to the output integer
returns the int in the param field, and the number of chars processed.

Definition at line 299 of file debug.c.

References hex2digit.

unsigned char* hex2mem unsigned char *    buf,
unsigned char *    mem,
int    count,
int    may_fault
 

Convert the hex array pointed to by buf into binary to be placed in mem.

Parameters:
mem  is a pointer to the output memory block
buf  is a pointer to the input buffer
count  is the number of bytes
may_fault  is a flag. If may_fault is non-zero, then we will handle memory faults by returning a 0, else treat a fault like any other fault in the stub.
return a pointer to the character AFTER the last byte written

Definition at line 269 of file debug.c.

References DEBUG, hex2digit, and set_mem_fault_trap.

char* make_return_packet int    val
 

make a return packet.

Parameters:
val  is the value to return, 0 = OK, any other value is converted to a two digit hex number.
returns a string or "OK" or "ENN", where NN is the error number. Each N is an ASCII encoded hex digit.

Definition at line 559 of file debug.c.

References digit2hex, and packet_out_buf.

unsigned char* mem2hex unsigned char *    mem,
unsigned char *    buf,
int    count,
int    may_fault
 

converts a memory block to hex and stores it in buf.

Parameters:
mem  is a pointer to the memory block
buf  is a pointer to the output buffer
count  is the number of bytes
may_fault  is a flag. If may_fault is non-zero, then we will handle memory faults by returning a 0, else treat a fault like any other fault in the stub.
Return a pointer to the last char put in buf (null), in case of mem fault, return 0.

Definition at line 231 of file debug.c.

References DEBUG, digit2hex, MAY_FAULT, and set_mem_fault_trap.

void putpacket unsigned char *    buffer
 

Send the packet in buffer.

Parameters:
buffer  is the buffer to be sent

Definition at line 387 of file debug.c.

References _LIBC_inbyte, _LIBC_outbyte, and digit2hex.

void set_mem_fault_trap  
 

this is a memory fault exception handler, used by mem2hex & hex2mem

Referenced by hex2mem, and mem2hex.


Variable Documentation

struct trap_info hard_trap_info[]
 

this is a list of signal to exception mappings.

Definition at line 103 of file debug.c.

int initialized = 0
 

indicate whether the debug vectors ahave been initialized 0 means not yet, 1 means yep, it's ready.

Definition at line 93 of file debug.c.

Referenced by set_debug_traps.

volatile int mem_err = 0
 

indicate to caller of mem2hex or hex2mem that there has been an error. 0 means ok, 1 means error

Definition at line 77 of file debug.c.

int remote_debug = 0
 

1 means print debugging messages from the target, 0 means be quiet. This is changed by gdb_debug().

Definition at line 85 of file debug.c.

Referenced by debuglog, gdb_debug, and gdb_toggle.


Generated on Thu Feb 20 15:39:03 2003 for cubeOS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002