public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "wingo at igalia dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/18148] New: Definitions with DW_AT_const_value never make it into the psymtabs
Date: Thu, 19 Mar 2015 19:19:00 -0000 [thread overview]
Message-ID: <bug-18148-4717@http.sourceware.org/bugzilla/> (raw)
https://sourceware.org/bugzilla/show_bug.cgi?id=18148
Bug ID: 18148
Summary: Definitions with DW_AT_const_value never make it into
the psymtabs
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: symtab
Assignee: unassigned at sourceware dot org
Reporter: wingo at igalia dot com
LLVM will not allocate storage for the "foo" in "static const int foo = 1".
Instead it inlines the value at the use sites, and emits a DW_TAG_variable with
DW_AT_const_value for the definition of "foo".
GCC will allocate storage for both at -O0 but at -O2 the same problem exists.
Unfortunately, partial debug info (PDI) instances without a location don't get
added to the psymtabs table. That means that if you do the following:
cat <<EOF > one.c
static const int one = 1;
extern int fetch_two (void);
int main (int argc, char *argv[])
{
return one + fetch_two ();
}
EOF
cat <<EOF > two.c
static const int two = 2;
int fetch_two (void)
{
return two;
}
EOF
gcc -g -O2 -c -o one.o one.c
gcc -g -O2 -c -o two.o two.c
gcc -g -o test one.o two.o
gdb ./test
Then at the GDB prompt:
(gdb) p one
$1 = 1
(gdb) p two
No symbol "two" in current context.
The reason we can get "one" and not "two" is because the symtab for one.c has
been expanded, when we went to look for main. If we expand the compilation
unit for two.c and flush the symbol cache, if on GDB trunk:
(gdb) mt expand foo.c
# only needed on trunk
(gdb) mt flush-symbol-cache
(gdb) print two
$2 = 2
The ultimate cause is that dwarf2read.c:add_partial_symbol punts if the symbol
has no location, thinking it's a declaration and not a definition. Well if it
has a DT_AT_const_value, it might be a definition too. Patch coming tomorrow.
--
You are receiving this mail because:
You are on the CC list for the bug.
next reply other threads:[~2015-03-19 18:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 19:19 wingo at igalia dot com [this message]
2015-03-27 16:52 ` [Bug symtab/18148] " cvs-commit at gcc dot gnu.org
2015-04-01 23:57 ` dje at google dot com
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=bug-18148-4717@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=gdb-prs@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).