From: "Jirka Koutný" <koutnji2@gmail.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb@gnu.org
Subject: Re: question about why gdb needs executable's binary
Date: Tue, 19 Mar 2019 14:25:00 -0000 [thread overview]
Message-ID: <CAH5nFm_6aKmacCUfbS5rhOC99qFXQrrn7AGA2OHL11vkqo_abA@mail.gmail.com> (raw)
In-Reply-To: <20190314214555.GA2221061@host1.jankratochvil.net>
Sorry for the delay, I needed some time to read up on DT_DEBUG and r_debug.
It makes a little bit more sense now, so thanks a lot. If you find time,
I'd still like to ask a few more questions:
PT_NOTE can't be read by gdb, that settles it, thanks *thumb up*. That
being said, how about dlopen()? How do these get in the trace? Surely not
from the executable.
For what I found out about DT_DEBUG this section gets initialized by ld as
you said. Do I understand you correctly, this is an alternative to the
first option, that in fact doesn't require the executable?
Thank you
Jirka
Den tor. 14. mar. 2019 kl. 21:45 skrev Jan Kratochvil <
jan.kratochvil@redhat.com>:
> On Wed, 13 Mar 2019 15:24:50 +0100, Jirka Koutný wrote:
> > I was wondering why does gdb still need the executable's binary as well?
> > Is there some additional information retrieved from the executable?
>
> Yes, without the main executable GDB cannot find the list of shared
> libraries.
>
>
> > PT_NOTE contains address ranges and shared libraries names as well,
>
> NT_FILE is a recent feature and GDB can only produce it, GDB cannot read
> it.
> GDB also cannot read /proc/PID/maps to recognize the list of shared
> libraries.
>
>
> > What is the missing bit of information there?
>
> To find the list of mapped shared libraries GDB needs to read DT_DEBUG
> which
> is located in DYNAMIC segment of the main executable.
>
> GDB can read also "_r_debug" but for that it needs to know ld.so which is
> a mapped shared library so that is a chicked-and-egg problem.
>
>
> eu-stack can do these:
>
> With main executable:
> $ eu-stack --core=sleep.core
> PID 1886638 - core
> TID 1886638:
> #0 0x00007f37e04707f8 __nanosleep
> #1 0x000055a9557f28d7 rpl_nanosleep
> #2 0x000055a9557f26b0 xnanosleep
> #3 0x000055a9557ef7c8 main
> #4 0x00007f37e03cb413 __libc_start_main
> #5 0x000055a9557ef89e _start
>
> Without main executable:
> $ eu-stack --core=sleep.core2
> PID 1886638 - core
> TID 1886638:
> #0 0x00007f37e04707f8 __nanosleep
> #1 0x000055a9557f28d7
> eu-stack: dwfl_thread_getframes tid 1886638 at 0x55a9557f28d6 in
> /usr/bin/sleep: Callback returned failure
>
> Just that eu-stack does not contain heuristics for unwinding frames with
> missing unwind information (.eh_frame/.debug_frame) and so if a frame is
> generated from the main executable it gives up for further unwinding.
>
>
> Jan
>
next prev parent reply other threads:[~2019-03-19 14:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-13 14:25 Jirka Koutný
2019-03-13 14:34 ` Andreas Schwab
2019-03-13 15:41 ` Jirka Koutný
2019-03-13 16:22 ` John Baldwin
2019-03-14 21:51 ` Jan Kratochvil
2019-03-19 14:25 ` Jirka Koutný [this message]
2019-03-19 14:35 ` Jan Kratochvil
2019-03-19 15:25 ` Jirka Koutný
2019-03-19 15:42 ` Jan Kratochvil
2019-03-19 15:47 ` Jirka Koutný
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAH5nFm_6aKmacCUfbS5rhOC99qFXQrrn7AGA2OHL11vkqo_abA@mail.gmail.com \
--to=koutnji2@gmail.com \
--cc=gdb@gnu.org \
--cc=jan.kratochvil@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox