| 1 | |
| 2 | = GDB Server for Soclib = |
| 3 | |
| 4 | The !GdbServer class implements the soclib software debugger. |
| 5 | |
| 6 | == Overview == |
| 7 | |
| 8 | The !GdbServer is able to manage all processors in a soclib platform. Once added to the platform netlist, it listens for TCP connection from [http://sourceware.org/gdb/ Gnu GDB] clients. Once connected, clients can be used to freeze, run, step every processor in the platform, add breakpoints, catch exceptions and dump registers and memory content. |
| 9 | |
| 10 | == Implementation == |
| 11 | |
| 12 | The !GdbServer contains no processor specific code and can be used to manage any Soclib processor model using the generic Iss interface. It is implemented as an Iss wrapper class. When the !GdbServer is in use, it intercepts all events between the processor Iss model and the Soclib platform. This enables the !GdbServer to access platform ressources as viewed from the processor without modifing platform components or procesor model source code. The !GdbServer is able to freeze the nested processor model while the platform is still running. |
| 13 | |
| 14 | == Usage == |
| 15 | |
| 16 | === Adding !GdbServer support to your platform === |
| 17 | |
| 18 | Adding the !GdbServer to your topcell is easy. First include the header: |
| 19 | |
| 20 | {{{ |
| 21 | #include "gdbserver.h" |
| 22 | }}} |
| 23 | |
| 24 | Then replace processor instantiation: |
| 25 | |
| 26 | {{{ |
| 27 | // Without GdbServer |
| 28 | // soclib::caba::IssWrapper<soclib::common::MipsElIss> cpu0("cpu0", 0); |
| 29 | // With GdbServer |
| 30 | soclib::caba::IssWrapper<soclib::common::GdbServer<soclib::common::MipsElIss> > cpu0("cpu0", 0); |
| 31 | }}} |
| 32 | |
| 33 | Do not forget to update the platform description file: |
| 34 | |
| 35 | {{{ |
| 36 | Uses('iss_wrapper', iss_t = 'common:gdb_iss', gdb_iss_t = 'common:mipsel'), |
| 37 | }}} |
| 38 | |
| 39 | === Connecting with a GDB client === |
| 40 | |
| 41 | When the simulation is running, the GDB Server listen for client connections on TCP port 2346. |
| 42 | |
| 43 | {{{ |
| 44 | $ ./system.x mutekh/kernel-soclib-mips.out |
| 45 | }}} |
| 46 | |
| 47 | Its easy to connect to the simulation with a suitable gdb client: |
| 48 | |
| 49 | {{{ |
| 50 | $ mipsel-unknown-elf-gdb mutekh/kernel-soclib-mips.out |
| 51 | GNU gdb 6.7 |
| 52 | Copyright (C) 2007 Free Software Foundation, Inc. |
| 53 | (gdb) target remote localhost:2346 |
| 54 | Remote debugging using localhost:2346 |
| 55 | 0xe010cef4 in cpu_atomic_bit_waitset (a=0x602002cc, n=<error type>) at /home/diaxen/projets/mutekh/cpu/mips/include/cpu/hexo/atomic.h:99 |
| 56 | 99 { |
| 57 | }}} |
| 58 | |
| 59 | The processors are now frozen. Each processor is seen as a thread by the GDB client: |
| 60 | |
| 61 | {{{ |
| 62 | (gdb) info threads |
| 63 | 4 Thread 4 (Processor mips_iss3) 0xe010ceec in cpu_atomic_bit_waitset (a=0x602002cc, n=<error type>) |
| 64 | at /home/diaxen/projets/mutekh/cpu/mips/include/cpu/hexo/atomic.h:99 |
| 65 | 3 Thread 3 (Processor mips_iss2) 0xe010ce64 in lock_spin (lock=0x602002cc) at /home/diaxen/projets/mutekh/arch/soclib/include/arch/hexo/lock.h:130 |
| 66 | 2 Thread 2 (Processor mips_iss1) 0xe010d110 in gpct_lock_HEXO_SPIN_unlock (lock=0x602061e8) at /home/diaxen/projets/mutekh/hexo/include/hexo/lock.h:134 |
| 67 | * 1 Thread 1 (Processor mips_iss0) 0xe010cef4 in cpu_atomic_bit_waitset (a=0x602002cc, n=<error type>) |
| 68 | at /home/diaxen/projets/mutekh/cpu/mips/include/cpu/hexo/atomic.h:99 |
| 69 | }}} |
| 70 | |
| 71 | Classical GDB debugging session takes place. Here is a register dump of the processor 0 (thread 1): |
| 72 | |
| 73 | {{{ |
| 74 | (gdb) info registers |
| 75 | zero at v0 v1 a0 a1 a2 a3 |
| 76 | R0 00000000 0000ff00 00000001 00000000 60200338 00000001 00000000 e010e74c |
| 77 | t0 t1 t2 t3 t4 t5 t6 t7 |
| 78 | R8 e010ef54 00000000 00000000 00000000 00000000 00000000 00000000 602021dc |
| 79 | s0 s1 s2 s3 s4 s5 s6 s7 |
| 80 | R16 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |
| 81 | t8 t9 k0 k1 gp sp s8 ra |
| 82 | R24 00000000 00000000 00000000 602007fc 60207ff0 60205ce8 60205ce8 e0101134 |
| 83 | sr lo hi bad cause pc |
| 84 | 0000ff00 00000000 00000000 00000000 00000000 e010117c |
| 85 | fsr fir |
| 86 | 00000000 00000000 |
| 87 | }}} |
| 88 | |
| 89 | More informations on using the GDB client can be found on the [http://sourceware.org/gdb/ The GNU Project Debugger] home page. |