<div dir="ltr">Hi,<div><br></div><div style>This is a new task, but is an intersting and challenging task.</div><div style> </div><div style>A <b>simple</b> implementation of debugging support is finished, but it needs improvement.</div>
<div style>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 <b>may</b> refactor the current implementation.</div><div style><br></div><div style>
The following is the details of the work. Because I am new to gdb internals, there maybe errors and hope you can correct them.</div><div style><br></div><div style>1. The work with the gdb part.</div><div style>    added files. solib-rtems.c, spart-rtems-tdep.c, solib-rtems.h to gdb.</div>
<div style>    I used solib-target.c and solib-svr4.c as the templates to code solib-rtems.c.</div><div style><br></div><div style>    1.1 how gdb dynamically loaded files on the target?</div><div style>         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.</div>
<div style><br></div><div style>   1.2 how gdb collect the details?</div><div style>       Target side:</div><div style>        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.</div>
<div style>      Host side:</div><div style>      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.</div><div style><br>
</div><div style>  1.3 How the symbols are correctly figured out?</div><div style>       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.</div>
<div style><br></div><div style>And now, sparc-rtems4.11-gdb can catch the breakpoints.</div><div style><br></div><div style>2. A sample debug session.</div><div style>./sparc-rtems4.11-gdb ../../../../rtl/build/sparc-rtems4.11-sis/rtld<br>
</div><div style><div>(gdb) tar sim</div><div>Connected to the simulator.</div><div>(gdb) load</div></div><div style><div style="font-family:arial,sans-serif;font-size:14px">(gdb) <b>set solib-search-path ../../../../rtl/build/sparc-rtems4.11-sis/testcase/ (This step will be removed, using --rpath in rtems-ld)</b></div>
<div style="font-family:arial,sans-serif;font-size:14px">(gdb) b hello</div><div style="font-family:arial,sans-serif;font-size:14px"><b>Function "hello" not defined. (hello is a function in the rap file)</b></div>
<div style="font-family:arial,sans-serif;font-size:14px">Make breakpoint pending on future shared library load? (y or [n]) y</div><div style="font-family:arial,sans-serif;font-size:14px">Breakpoint 1 (hello) pending.</div>
<div style="font-family:arial,sans-serif;font-size:14px">(gdb) tar sim</div><div style="font-family:arial,sans-serif;font-size:14px">Connected to the simulator.</div><div style="font-family:arial,sans-serif;font-size:14px">
(gdb) load</div><div style="font-family:arial,sans-serif;font-size:14px">(gdb) r</div><div style="font-family:arial,sans-serif;font-size:14px">......................</div><div><div><font face="arial, sans-serif"><span style="font-size:14px">[/] # <b>rap ld ./test.rap (load the rap file)</b></span></font></div>
<div><font face="arial, sans-serif"><span style="font-size:14px">In rtems() local = 1</span></font></div><div><font face="arial, sans-serif"><span style="font-size:14px"><br></span></font></div><div><font face="arial, sans-serif"><span style="font-size:14px"><b>Breakpoint 1, hello (arg=arg@entry=1) at ../../testcase/1.c:16 (It stops here)</b></span></font></div>
<div><font face="arial, sans-serif"><span style="font-size:14px">16<span class="" style="white-space:pre">      </span>  switch (arg) {</span></font></div><div><font face="arial, sans-serif"><span style="font-size:14px">(gdb) p arg</span></font></div>
<div><font face="arial, sans-serif"><span style="font-size:14px">$1 = 1</span></font></div><div><font face="arial, sans-serif"><span style="font-size:14px">(gdb) c</span></font></div><div><font face="arial, sans-serif"><span style="font-size:14px">Continuing.</span></font></div>
<div><font face="arial, sans-serif"><span style="font-size:14px">Inner-module call hello()</span></font></div><div><font face="arial, sans-serif"><span style="font-size:14px">In test() global = 1</span></font></div><div><font face="arial, sans-serif"><span style="font-size:14px"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="font-size:14px"><b>Breakpoint 1, hello (arg=arg@entry=2) at ../../testcase/1.c:16 (stops again)</b></span></font></div><div><font face="arial, sans-serif"><span style="font-size:14px">16<span class="" style="white-space:pre">    </span>  switch (arg) {</span></font></div>
</div></div><div style><br></div><div style><br></div><div style>Hope this explains cleary. If not, contact me or read the code[1][2][3]. </div><div style>Any adivces or comments. </div><div style><br></div><div style>Thanks,</div>
<div style>Peng.</div><div style><br></div><div style>[1]<a href="https://github.com/MrVan/gsoc2013-rtl">https://github.com/MrVan/gsoc2013-rtl</a></div><div style>[2]<a href="https://github.com/MrVan/gsoc2013-rtl-host">https://github.com/MrVan/gsoc2013-rtl-host</a></div>
<div style>[3]<a href="https://github.com/MrVan/gdb">https://github.com/MrVan/gdb</a></div><div style><br></div><div style><br></div><div style><br></div></div>