* How does GDB load source line information during dlopen calls
@ 2018-01-05 6:48 shravan
2018-01-08 16:04 ` Simon Marchi
0 siblings, 1 reply; 3+ messages in thread
From: shravan @ 2018-01-05 6:48 UTC (permalink / raw)
To: gdb
Hi all,
First time poster to this list - so please bear with me :)
I am currently working on a project that has a custom dynamic loader for
shared libraries in the ELF format - it does NOT use dlopen. When debugging
this dynamically loaded library, I am hoping to be able to single step
through the C source code of functions in the library in tui mode.
If I had use dlopen this would work fine, but this does not work using the
custom dynamic loader. I am able to get the libraries symbols loaded with
"add-symbol-file". However the src line information is still not working.
For example "list someFunctionInLibrary" prints nothing and "layout src"
shows a blank screen
I am hoping for any information or suggestions. Is there some way to hint
to gdb to load the source line information from a particular file at a
particular address?
(Also please let me know if there is a better venue for the question).
Thanks!
Shravan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How does GDB load source line information during dlopen calls
2018-01-05 6:48 How does GDB load source line information during dlopen calls shravan
@ 2018-01-08 16:04 ` Simon Marchi
[not found] ` <CAEmVGBpNPeVqMed4AF5gLMASswi+7-PoCwKKUDP4OvVhpVdppQ@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2018-01-08 16:04 UTC (permalink / raw)
To: shravan, gdb
On 2018-01-05 01:48 AM, shravan wrote:
> Hi all,
> First time poster to this list - so please bear with me :)
> I am currently working on a project that has a custom dynamic loader for
> shared libraries in the ELF format - it does NOT use dlopen. When debugging
> this dynamically loaded library, I am hoping to be able to single step
> through the C source code of functions in the library in tui mode.
>
> If I had use dlopen this would work fine, but this does not work using the
> custom dynamic loader. I am able to get the libraries symbols loaded with
> "add-symbol-file". However the src line information is still not working.
> For example "list someFunctionInLibrary" prints nothing and "layout src"
> shows a blank screen
>
> I am hoping for any information or suggestions. Is there some way to hint
> to gdb to load the source line information from a particular file at a
> particular address?
>
> (Also please let me know if there is a better venue for the question).
>
> Thanks!
> Shravan
>
Hi Shravan,
For all I know, add-symbol-file should make GDB read the DWARF info
of the library, like it does for a automatically loaded libraries.
Are your libraries built with DWARF debug information?
I just tried making a small library with:
int
bob (void)
{
return 42;
}
I am able to pretend that this library was loaded at an arbitrary offset
and list lines from its source files:
(gdb) add-symbol-file lib/libbob.so 0x1000000
add symbol table from file "lib/libbob.so" at
.text_addr = 0x1000000
(y or n) y
Reading symbols from lib/libbob.so...done.
(gdb) list bob
1 int
2 bob (void)
3 {
4 return 42;
5 }
(gdb) p &bob
$1 = (int (*)(void)) 0x1000100 <bob>
(gdb) list *0x1000100
0x1000100 is in bob (bob.c:3).
1 int
2 bob (void)
3 {
4 return 42;
5 }
(gdb) b bob.c:4
Breakpoint 2 at 0x1000104: file bob.c, line 4.
So I think add-symbol-file should work for you, there is probably a missing
link somewhere. I don't think I can't help you without more information,
or an actual program to debug.
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How does GDB load source line information during dlopen calls
[not found] ` <CAEmVGBq5UQHr0HOoqWOZ6j8M=yh1K4J+ioaBZYUSjWYSpVN+aA@mail.gmail.com>
@ 2018-01-09 3:38 ` shravan
0 siblings, 0 replies; 3+ messages in thread
From: shravan @ 2018-01-09 3:38 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb
Thanks for the response! I did try add-symbol-file and have definitely
enabled "-g" flags on the target library, but source line info is still
missing (debug directories are set correctly too). Your prototype is
interesting - it definitely suggests that add-symbol-file should be enough.
I will retry this, and see if I can get a small example which I can easily
share here.
Fwiw, to help rule out some possibilities, I am able to get this working on
lldb using create-module and then mapping the section by address
On Jan 8, 2018 8:04 AM, "Simon Marchi" <simon.marchi@ericsson.com> wrote:
On 2018-01-05 01:48 AM, shravan wrote:
> Hi all,
> First time poster to this list - so please bear with me :)
> I am currently working on a project that has a custom dynamic loader for
> shared libraries in the ELF format - it does NOT use dlopen. When
debugging
> this dynamically loaded library, I am hoping to be able to single step
> through the C source code of functions in the library in tui mode.
>
> If I had use dlopen this would work fine, but this does not work using the
> custom dynamic loader. I am able to get the libraries symbols loaded with
> "add-symbol-file". However the src line information is still not working.
> For example "list someFunctionInLibrary" prints nothing and "layout src"
> shows a blank screen
>
> I am hoping for any information or suggestions. Is there some way to hint
> to gdb to load the source line information from a particular file at a
> particular address?
>
> (Also please let me know if there is a better venue for the question).
>
> Thanks!
> Shravan
>
Hi Shravan,
For all I know, add-symbol-file should make GDB read the DWARF info
of the library, like it does for a automatically loaded libraries.
Are your libraries built with DWARF debug information?
I just tried making a small library with:
int
bob (void)
{
return 42;
}
I am able to pretend that this library was loaded at an arbitrary offset
and list lines from its source files:
(gdb) add-symbol-file lib/libbob.so 0x1000000
add symbol table from file "lib/libbob.so" at
.text_addr = 0x1000000
(y or n) y
Reading symbols from lib/libbob.so...done.
(gdb) list bob
1 int
2 bob (void)
3 {
4 return 42;
5 }
(gdb) p &bob
$1 = (int (*)(void)) 0x1000100 <bob>
(gdb) list *0x1000100
0x1000100 is in bob (bob.c:3).
1 int
2 bob (void)
3 {
4 return 42;
5 }
(gdb) b bob.c:4
Breakpoint 2 at 0x1000104: file bob.c, line 4.
So I think add-symbol-file should work for you, there is probably a missing
link somewhere. I don't think I can't help you without more information,
or an actual program to debug.
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-09 3:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-05 6:48 How does GDB load source line information during dlopen calls shravan
2018-01-08 16:04 ` Simon Marchi
[not found] ` <CAEmVGBpNPeVqMed4AF5gLMASswi+7-PoCwKKUDP4OvVhpVdppQ@mail.gmail.com>
[not found] ` <CAEmVGBq5UQHr0HOoqWOZ6j8M=yh1K4J+ioaBZYUSjWYSpVN+aA@mail.gmail.com>
2018-01-09 3:38 ` shravan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox