2002-05-30 19:09:47 +00:00
|
|
|
// 2002-05-13
|
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
enum region { oriental, egyptian, greek, etruscan, roman };
|
2002-05-30 19:09:47 +00:00
|
|
|
|
2012-06-19 15:47:02 +00:00
|
|
|
void keepalive(bool *var) { }
|
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'.
2013-03-14 11:13:36 +00:00
|
|
|
void keepalive_int (int *var) { }
|
2012-06-19 15:47:02 +00:00
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
// Test one.
|
|
|
|
class gnu_obj_1
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
typedef region antiquities;
|
|
|
|
static const bool test = true;
|
|
|
|
static const int key1 = 5;
|
|
|
|
static long key2;
|
2002-05-30 19:09:47 +00:00
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
static antiquities value;
|
2002-05-30 19:09:47 +00:00
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
public:
|
|
|
|
gnu_obj_1(antiquities a, long l) {}
|
2013-02-12 20:27:36 +00:00
|
|
|
~gnu_obj_1() {}
|
2010-03-13 00:27:12 +00:00
|
|
|
|
|
|
|
long method ()
|
|
|
|
{
|
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'.
2013-03-14 11:13:36 +00:00
|
|
|
static int sintvar = 4;
|
2010-03-13 00:27:12 +00:00
|
|
|
static bool svar = true;
|
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'.
2013-03-14 11:13:36 +00:00
|
|
|
|
2012-06-19 15:47:02 +00:00
|
|
|
keepalive (&svar);
|
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'.
2013-03-14 11:13:36 +00:00
|
|
|
keepalive_int (&sintvar);
|
2010-03-13 00:27:12 +00:00
|
|
|
return key2;
|
|
|
|
}
|
2002-12-17 23:24:57 +00:00
|
|
|
};
|
2002-05-30 19:09:47 +00:00
|
|
|
|
2013-03-25 17:26:18 +00:00
|
|
|
// An object with a single constructor.
|
|
|
|
class single_constructor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
single_constructor () { }
|
|
|
|
~single_constructor () { }
|
|
|
|
};
|
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
const bool gnu_obj_1::test;
|
|
|
|
const int gnu_obj_1::key1;
|
|
|
|
long gnu_obj_1::key2 = 77;
|
|
|
|
gnu_obj_1::antiquities gnu_obj_1::value = oriental;
|
2002-05-30 19:09:47 +00:00
|
|
|
|
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
// Test two.
|
|
|
|
template<typename T>
|
|
|
|
class gnu_obj_2: public virtual gnu_obj_1
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static antiquities value_derived;
|
2002-05-30 19:09:47 +00:00
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
public:
|
|
|
|
gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { }
|
|
|
|
};
|
2002-05-30 19:09:47 +00:00
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
template<typename T>
|
|
|
|
typename gnu_obj_2<T>::antiquities gnu_obj_2<T>::value_derived = etruscan;
|
2002-05-30 19:09:47 +00:00
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
// Test three.
|
|
|
|
template<typename T>
|
|
|
|
class gnu_obj_3
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef region antiquities;
|
|
|
|
static gnu_obj_2<int> data;
|
2002-05-30 19:09:47 +00:00
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
public:
|
|
|
|
gnu_obj_3(antiquities b) { }
|
|
|
|
};
|
2002-05-30 19:09:47 +00:00
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
template<typename T>
|
|
|
|
gnu_obj_2<int> gnu_obj_3<T>::data(etruscan);
|
2002-09-18 18:48:43 +00:00
|
|
|
|
2002-12-17 23:24:57 +00:00
|
|
|
// 2002-08-16
|
|
|
|
// Test four.
|
2002-09-18 18:48:43 +00:00
|
|
|
#include "m-static.h"
|
2002-05-30 19:09:47 +00:00
|
|
|
|
|
|
|
// instantiate templates explicitly so their static members will exist
|
2002-12-17 23:24:57 +00:00
|
|
|
template class gnu_obj_2<int>;
|
|
|
|
template class gnu_obj_2<long>;
|
|
|
|
template class gnu_obj_3<long>;
|
2002-05-30 19:09:47 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
gnu_obj_1 test1(egyptian, 4589);
|
|
|
|
gnu_obj_2<long> test2(roman);
|
|
|
|
gnu_obj_3<long> test3(greek);
|
2002-09-18 18:48:43 +00:00
|
|
|
gnu_obj_4 test4;
|
2013-03-25 17:26:18 +00:00
|
|
|
single_constructor test5;
|
2002-05-30 19:09:47 +00:00
|
|
|
|
2009-12-28 21:45:24 +00:00
|
|
|
test4.dummy = test4.elsewhere;
|
2006-05-05 18:04:09 +00:00
|
|
|
test4.dummy = 0;
|
2010-03-13 00:27:12 +00:00
|
|
|
|
|
|
|
test1.method (); // breakpoint: constructs-done
|
|
|
|
|
|
|
|
return test4.dummy;
|
2002-05-30 19:09:47 +00:00
|
|
|
}
|