diff options
author | Sergio Durigan Junior <sergiodj@redhat.com> | 2013-03-14 11:13:36 +0000 |
---|---|---|
committer | Sergio Durigan Junior <sergiodj@redhat.com> | 2013-03-14 11:13:36 +0000 |
commit | bb869963da27d88c24f770f0a5aae61112e568f9 (patch) | |
tree | d77b65581d9e01fc4a629f697f14fbb6053e13fc /gdb/cp-namespace.c | |
parent | b10bf8c587a51b028843702738c1fec4a856e67e (diff) | |
download | gdb-bb869963da27d88c24f770f0a5aae61112e568f9.zip gdb-bb869963da27d88c24f770f0a5aae61112e568f9.tar.gz gdb-bb869963da27d88c24f770f0a5aae61112e568f9.tar.bz2 |
From: Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH] Fix for PR c++/15203 and PR c++/15210
Date: Sat, 09 Mar 2013 02:50:49 -0300 (5 days, 4 hours, 57 minutes ago)
Message-ID: <m3a9qdnmti.fsf@redhat.com>
Hi,
This bug was reported internally at our Bugzilla, along with a proposed
fix. After talking to Keith about it, he investigated and came up with
another patch needed to really fix the issue on CVS HEAD.
The first part of the fix is the patch to cp-namespace.c. It handles
the case when we are accessing a static variable inside a function
(inside a class) by the full linespec (is it right, Keith?). E.g.:
class foo
{
public:
int bar()
{
static int var = 0;
}
};
And then, printing the value of `var':
(gdb) print 'foo::bar()::var'
GDB would fall in an internal_error:
gdb/cp-namespace.c:816: internal-error: cp_lookup_nested_symbol called on a non-aggregate type.
This is because `cp_lookup_nested_symbol' is not handling the case when
TYPE_CODE is either _FUNC or _METHOD. This patch fixes it by returning
NULL in this case.
The second part of the fix is the patch to elfread.c. It is needed
because the BSF_GNU_UNIQUE flag was added to some symbols in
<http://sourceware.org/ml/binutils/2009-06/msg00016.html>. Because of
that, (still) the command:
(gdb) print 'foo::bar()::var'
where `var' is a static variable returns:
"No symbol "foo::bar()::var" in current context."
So with the second patch applied the command finally DTRT:
(gdb) print 'foo::bar()::var'
$1 = 0
This may not be the ideal solution, according to Keith it would be good
to implement productions on c-exp.y in order to recognize
CLASS::FUNCTION::VARIABLE, but it is a solution which works with what we
have today.
I regtested it in Fedora 17 x86_64 with -m64 and -m32, including
gdbserver, without regressions.
gdb/:
2013-03-14 Keith Seitz <keiths@redhat.com>
Alan Matsuoka <alanm@redhat.com>
PR c++/15203
PR c++/15210
* cp-namespace.c (cp_lookup_nested_symbol): Handle TYPE_CODE_FUNC and
TYPE_CODE_METHOD.
* elfread.c (elf_symtab_read): Handle BSF_GNU_UNIQUE for certain
symbols.
gdb/testsuite/:
2013-03-14 Sergio Durigan Junior <sergiodj@redhat.com>
PR c++/15203
PR c++/15210
* gdb.cp/m-static.cc (keepalive_int): New function.
(gnu_obj_1::method): New variable `sintvar', call `keepalive_int'.
* gdb.cp/m-static.exp: New test for `sintvar'.
Diffstat (limited to 'gdb/cp-namespace.c')
-rw-r--r-- | gdb/cp-namespace.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 279021e..add4ccb 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -812,6 +812,11 @@ cp_lookup_nested_symbol (struct type *parent_type, base classes. */ return find_symbol_in_baseclass (parent_type, nested_name, block); } + + case TYPE_CODE_FUNC: + case TYPE_CODE_METHOD: + return NULL; + default: internal_error (__FILE__, __LINE__, _("cp_lookup_nested_symbol called " |