From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: "Jirka Koutný" <koutnji2@gmail.com>
Cc: gdb@gnu.org
Subject: Re: question about why gdb needs executable's binary
Date: Thu, 14 Mar 2019 21:51:00 -0000 [thread overview]
Message-ID: <20190314214555.GA2221061@host1.jankratochvil.net> (raw)
In-Reply-To: <CAH5nFm8dpqyFWuttO+aZOCBAAMjEeuEtv=xwhyFjjMpu8cTs3g@mail.gmail.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-14 21:51 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 [this message]
2019-03-19 14:25 ` Jirka Koutný
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=20190314214555.GA2221061@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb@gnu.org \
--cc=koutnji2@gmail.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