Hi Peter, Happy new year.
On 17/1/20 9:01 am, Peter Dufault wrote: > I'm trying to hook the SLAC / Til Straumann PowerPC remote debugger stub in > to what's loaded by "libdl" via "dlopen()". *I know* this should be > integrated into "libdebugger", and I do keep my eye on that, but I need to > keep what is working working and working well. > > The "libdl" code has support for GDB both finding out when shared libraries > are loaded and resolving the new symbols in "rtl-debugger.c". It's based on > NetBSD and Android. I don't know how to get this code to kick in. You need a patch for GDB that enables the needed functionality in an RTEMS build of GDB. Have a look at the 2013 GSoC project's work ... https://lists.rtems.org/pipermail/devel/2013-September/004644.html The patch was never merged into gdb and as GDB has changed to C++ I doubt it will apply cleanly so it needs to be reworked and submitted. > I hacked the "libdl" "rtl" command to add an option for "rtl list -m", an > option that is "rtl list -gm" (Run time loader list a map in a GDB flavor) so > that after I load a library such as "loaded_lib" the command will produce > something like: > > add-symbol-file loaded_lib -s .text 0x12c0708 -s .rodata 0x12cbb88 -s .data > 0x12ce910 -s .bss 0x12cea18 This is all GDB does internal. There maybe some extra path handling or searching of archives. > After pasting the output of the "rtl list -gm" command into GDB everything > works wonderfully. There are no remote-stub commands that support this, as > far as I can tell, and I want to figure out how to do this based on the > existing remote-stub interface. Editorial note: If I can do it with > "add-symbol-file" I should be able to do it from the remote interface, but so > it goes. > > My question is: How, without modifying GDB, can I add a symbol table after > loading something via "dlopen()"? The interface in "rtl-debugger.c" imply > that GDB will poke around and set breakpoints based on a SVR4 dynamic loader > in order to locate the information, but I can't figure out how to do it. Sorry, it is all handled on the gdb side of things. The protocol that is used is GDB sets a break point on _rtld_debug_state [1] if it exists in the executable. This function is called by libdl when a state change happens and GDB internally catches the breakpoint. It then reads the linkmap table and internally processes what it finds loading the symbol tables on the host side. GDB then continues the target. The user does not see any of this. The implementation worked really well. You could set a break point on a function that was not loaded and gdb would ask if it is to loaded and once loaded gdb set the break point and it would stop when executed. A part of the GSoC patch deals with RAP format. Also I am not sure what happens with the extra sections that have been added since this work was done, for example on the PowerPC the small data allocations. You would need to chase down what happens here. Chris [1] https://git.rtems.org/rtems/tree/cpukit/libdl/rtl-debugger.c#n37 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel