public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/18148] New: Definitions with DW_AT_const_value never make it into the psymtabs
@ 2015-03-19 19:19 wingo at igalia dot com
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
0 siblings, 2 replies; 3+ messages in thread
From: wingo at igalia dot com @ 2015-03-19 19:19 UTC (permalink / raw)
To: gdb-prs
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug symtab/18148] Definitions with DW_AT_const_value never make it into the psymtabs
2015-03-19 19:19 [Bug symtab/18148] New: Definitions with DW_AT_const_value never make it into the psymtabs wingo at igalia dot com
@ 2015-03-27 16:52 ` cvs-commit at gcc dot gnu.org
2015-04-01 23:57 ` dje at google dot com
1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-03-27 16:52 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=18148
--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andy Wingo <wingo@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ff908ebf8612a737d9e168eca0604ff6c97556bc
commit ff908ebf8612a737d9e168eca0604ff6c97556bc
Author: Andy Wingo <wingo@igalia.com>
Date: Thu Mar 26 19:41:15 2015 +0100
Properly intern constants into psymtab
Variables with a DW_AT_const_value but without a DW_AT_location were not
getting added to the partial symbol table. They are added to the full
symbol table, however, when the compilation unit's psymtabs are
expanded.
Before:
(gdb) p one
No symbol "one" in current context.
(gdb) mt flush-symbol-cache
(gdb) mt expand one.c
(gdb) p one
$1 = 1
After:
(gdb) p one
$1 = 1
To the user it's pretty strange, as depending on whether tab completion
has forced expansion of all CUs or not the lookup might succeed, or not
if the failure was already added to the symbol cache.
This commit simply makes sure to add constants to the partial symbol
tables.
gdb/testsuite/ChangeLog:
PR symtab/18148
* gdb.dwarf2/dw2-intercu.S (one, two): Add variables that have a
const_value but not a location.
* gdb.dwarf2/dw2-intercu.exp: Add tests that constants without
location defined in non-main CUs are visible.
gdb/ChangeLog:
PR symtab/18148
* dwarf2read.c (struct partial_die_info): Add has_const_value
member.
(add_partial_symbol): Don't punt on symbols that have const_value
attributes.
(read_partial_die): Detect DW_AT_const_value.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug symtab/18148] Definitions with DW_AT_const_value never make it into the psymtabs
2015-03-19 19:19 [Bug symtab/18148] New: Definitions with DW_AT_const_value never make it into the psymtabs wingo at igalia dot com
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
1 sibling, 0 replies; 3+ messages in thread
From: dje at google dot com @ 2015-04-01 23:57 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=18148
dje at google dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |dje at google dot com
Resolution|--- |FIXED
--- Comment #2 from dje at google dot com ---
Patch committed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-01 23:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-19 19:19 [Bug symtab/18148] New: Definitions with DW_AT_const_value never make it into the psymtabs wingo at igalia dot com
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
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).