Developer should implement methods to interface architecture and GDB, mapping registers and memory to desired GDB format. These methods, explained in detail below, should be implemented in a file named after your processor: <PROCESSOR_NAME>_gdb_funcs.cpp, given your processor is implemented in <PROCESSOR_NAME>.ac. Then "make distclean" your simulator, run acsim with -gdb, and make it again. Acsim with -gdb will make your simulator class inherit from AC_GDB_Interface and include your <PROCESSOR_NAME>_gdb_funcs.cpp, so using those functions.
When built, the simulator will handle the --gdb, waiting for the GDB to connect at port 5000 (port defined in compile time, changeable with -DPORT_NUM=<YOUR_PORT>
, or defined in run time, using --gdb=<YOUR_PORT>).
reg_read()
and reg_write()
, then define the number of registers GDB expect to receive/send in nRegs()
. The order is defined in REGISTER_RAW_SIZE
and REGISTER_NAME
macros. Please read "info gdb", section "Remote Protocol", nodes "Packets" and "Register Packet Format" before continue.RB_GP
), one with floating point registers (RB_FP
) and one with status register (RB_S
). If GDB expect the packets in order: 32 general purpose registers, 32 floating point registers and 8 status register and PC
, your functions should be like:int YOUR_CLASS::nRegs( void ) { return 73; } ac_word YOUR_CLASS::reg_read( int reg ) { // General Purpose if ( ( reg >= 0 ) && ( reg < 32 ) ) return RB_GP.read( reg ); // Floating Point else if ( ( reg >= 32 ) && ( reg < 64 ) ) return RB_FP.read( reg - 32 ); // Status else if ( ( reg >= 64 ) && ( reg < 72 ) ) return RB_SR.read( reg - 64 ); // Program Counter else if ( reg == 72 ) return ac_resources::ac_pc; return 0; // unmaped register? return 0 } void YOUR_CLASS::reg_write( int reg, ac_word value ) { // General Purpose if ( ( reg >= 0 ) && ( reg < 32 ) ) RB_GP.write( reg, value ); // Floating Point else if ( ( reg >= 32 ) && ( reg < 64 ) ) RB_FP.write( reg - 32, value ); // Status else if ( ( reg >= 64 ) && ( reg < 72 ) ) RB_SR.write( reg - 64, value ); // Program Counter else if ( reg == 72 ) ac_resources::ac_pc = value; }
unsigned char YOUR_CLASS::mem_read( unsigned int address ) { return ac_resources::IM->read_byte( address ); } void YOUR_CLASS::mem_write( unsigned int address, unsigned char byte) { ac_resources::IM->write_byte( address, byte ); }
Gdb info page, section "Remote Protocol", node "Register Packet Format".
Gdb source package, file gdb/remote-mips.c, mips_map_regno(). (http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/src/gdb/remote-mips.c?&cvsroot=src)
Gdb source package, file gdb/sparc-stub.c, regnames enumerate. (http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/src/gdb/sparc-stub.c?&cvsroot=src)