Hi, This is a new task, but is an intersting and challenging task.
A *simple* implementation of debugging support is finished, but it needs improvement. Now I only test it on sparc/sis with rap format file. In the following steps, I'll test it on other archs, improve it and *may* refactor the current implementation. The following is the details of the work. Because I am new to gdb internals, there maybe errors and hope you can correct them. 1. The work with the gdb part. added files. solib-rtems.c, spart-rtems-tdep.c, solib-rtems.h to gdb. I used solib-target.c and solib-svr4.c as the templates to code solib-rtems.c. 1.1 how gdb dynamically loaded files on the target? There is an interface to let gdb get the information of the loaded files on the target. In solib-rtems.c, a solib event breakpoint is set at '_rtld_debug_state'. _rtld_debug_state is an empty function in RTL, and dlopen should invoke _rtld_debug_state. When the target stops at _rtld_debug_state, sparc-rtems4.11-gdb will execute update_solib_list(solib.c) and then call rtems_current_sos(solib-rtems.c) to collect the details of loaded files on the target. 1.2 how gdb collect the details? Target side: Each loaded elf object file has a corresponding link_map variable. all the link_map variables will be linked into a pointer named '_rtld_debug'. The link_map structrue contains all the section details of a elf object file. Host side: sparc-rtems4.11-gdb will locate the base address of _rtld_debug, then collect the elf object file details and section details of each elf object file. 1.3 How the symbols are correctly figured out? Because the symbols loaded by sparc-rtems4.11-gdb, but not(should not) transfered from target. Thus relocate_section_addresses should be implemented in gdb. It will assigned section addresses collected from _rtld_debug to target_section which can be handled by sparc-rtems4.11-gdb. And now, sparc-rtems4.11-gdb can catch the breakpoints. 2. A sample debug session. ./sparc-rtems4.11-gdb ../../../../rtl/build/sparc-rtems4.11-sis/rtld (gdb) tar sim Connected to the simulator. (gdb) load (gdb) *set solib-search-path ../../../../rtl/build/sparc-rtems4.11-sis/testcase/ (This step will be removed, using --rpath in rtems-ld)* (gdb) b hello *Function "hello" not defined. (hello is a function in the rap file)* Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (hello) pending. (gdb) tar sim Connected to the simulator. (gdb) load (gdb) r ...................... [/] # *rap ld ./test.rap (load the rap file)* In rtems() local = 1 *Breakpoint 1, hello (arg=arg@entry=1) at ../../testcase/1.c:16 (It stops here)* 16 switch (arg) { (gdb) p arg $1 = 1 (gdb) c Continuing. Inner-module call hello() In test() global = 1 *Breakpoint 1, hello (arg=arg@entry=2) at ../../testcase/1.c:16 (stops again)* 16 switch (arg) { Hope this explains cleary. If not, contact me or read the code[1][2][3]. Any adivces or comments. Thanks, Peng. [1]https://github.com/MrVan/gsoc2013-rtl [2]https://github.com/MrVan/gsoc2013-rtl-host [3]https://github.com/MrVan/gdb
_______________________________________________ rtems-devel mailing list rtems-devel@rtems.org http://www.rtems.org/mailman/listinfo/rtems-devel