libdl: How to debug dl object with GDB

Hesham Almatary heshamelmatary at gmail.com
Mon Nov 23 14:22:15 UTC 2020


Thanks, Chris for the detailed reply.

On Thu, 19 Nov 2020 at 22:56, Chris Johns <chrisj at rtems.org> wrote:
>
> On 19/11/20 5:33 pm, Hesham Almatary wrote:
> > Thanks for the info, Chris.
> >
> > On Wed, 18 Nov 2020 at 02:43, Chris Johns <chrisj at rtems.org> wrote:
> >> On 17/11/20 10:43 pm, Hesham Almatary wrote:
> >>> Hello,
> >>>
> >>> I am trying to debug a dynamically loaded ELF object with GDB: My setup is:
> >>> rtems-riscv64:
> >>> GDB: GNU gdb (GDB) 10.0.50.20200904-git (build with RSB/rtems6)
> >>> Host: Ubuntu 20.04.1 LTS
> >>>
> >>> GDB doesn't seem to notice when I dlopen an object (which gets loaded,
> >>> linked and run fine).
> >>
> >> libdl has the NetBSD type support built in for debugging. A function is called
> >> when a module is loaded and there is a table of modules GDB reads and then loads
> >> the object file.
> >>
> > Is that expected to work on Linux with recent GDB versions?
>
> We need a patch for GDB to add the support needed for RTEMS.
>
Right, that's what I thought too.

> > GDB
> > doesn't seem to detect when "_rtld_debug_state" is called from dlopen,
> > and consequently isn't aware of the list of objects. Does that need
> > GDB to be modified with solib-rtems* or something?
>
> A patch was created as part the 2013 RTL GSoC project (an excellent year for
> students :)). The repo is https://github.com/MrVan/gdb/commits/rtems-gdb. The
> only problem is GDB has moved to C++ since then and I am not sure what effect
> that has had on the patch.
>
That's really helpful. It would have been great if that got merged,
still, it's a good reference now for someone who might add back RTEMS
support.

> >>> Any instructions or idea how to troubleshoot that further?
> >>
> >> At this point the simplest path is to get the load address(es) and load the
> >> symbols with the VMA.
> >>
> > I can use "add-symbol-file" filename for each object and give it the
> > text_base address. This only allows me to break on functions within
> > loaded objects. If that's not what you mean, how can I load the
> > symbols with the VMA?
>
> I think using a command is always going to be a bit of a hack. The patch Peng
> created allowed you to set breakpoints in code that was not loaded and it would
> break when loaded _and_ executed.
>

> Chris



-- 
Hesham


More information about the devel mailing list