Commit Graph

8 Commits

Author SHA1 Message Date
Tom Tromey fce632b6dc PR c++/9197:
* opencl-lang.c (evaluate_subexp_opencl) <STRUCTOP_STRUCT>: Use
	value_struct_elt, not lookup_struct_elt_type.
	* eval.c (evaluate_subexp_standard) <STRUCTOP_STRUCT,
	STRUCTOP_PTR>: Use value_struct_elt, not lookup_struct_elt_type.
	* expression.h (EVAL_AVOID_SIDE_EFFECTS): Update comment.
gdb/testsuite
	* gdb.cp/m-static.exp: Add constructor ptype tests.
	* gdb.cp/m-static.cc (single_constructor): New class.
	(main): Make instance of single_constructor.
2013-03-25 17:26:18 +00:00
Sergio Durigan Junior bb869963da 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
Tom Tromey e234dfafcd PR symtab/11464:
* c-exp.y (lex_one_token): Initialize other fields of yylval on
	NAME return.
	(classify_inner_name): Remove 'first_name' argument, add
	'context'.  Remove unused variable.
	(yylex): Explicitly maintain the context type.  Exit loop earlier
	if NAME result is seen.
gdb/testsuite
	* gdb.cp/m-static.cc (gnu_obj_1::~gnu_obj_1): New destructor.
	* gdb.cp/m-static.exp: Add tests to print quoted destructor.
2013-02-12 20:27:36 +00:00
Tom Tromey e910f0b61f * gdb.cp/m-static.cc (keepalive): New function.
(gnu_obj_1::method): Use it.
2012-06-19 15:47:02 +00:00
Tom Tromey 1c809c6883 gdb
PR c++/9708:
	* dwarf2read.c (die_needs_namespace) <DW_TAG_variable>: A variable
	in a lexical block does not need a namespace.
	(new_symbol) <DW_TAG_variable>: Put extern variables on
	list_in_scope in all cases.
gdb/testsuite
	PR c++/9708:
	* gdb.cp/m-static.exp: Add regression test.
	* gdb.cp/m-static.cc (method): New method.
	(main): Call it.
2010-03-13 00:27:12 +00:00
Daniel Jacobowitz 0219b378ea * gdb.base/find.c (main): Reference search buffers.
* gdb.base/included.c (main): Reference integer.
	* gdb.base/ptype.c (charfoo): Declare.
	(intfoo): Call charfoo.
	* gdb.base/scope0.c (useitp): New function.
	(usestatics): Use useitp.
	(useit): Add a type for val.
	* gdb.base/scope1.c (useit1): Take a pointer argument.
	(usestatics1): Update calls to useit1.
	* gdb.cp/call-c.cc: Declare foo.
	(main): Call foo.
	* gdb.cp/m-static.cc (main): Reference test4.elsewhere.
	* gdb.cp/namespace.cc (ensureOtherRefs): Declare.
	(main): Call C::ensureRefs and ensureOtherRefs.
	* gdb.cp/namespace1.cc (C::ensureOtherRefs): Also reference int
	variables.
	(ensureOtherRefs): New function.
	* gdb.cp/overload.cc (main): Call all overloadNamespace variants.
	* gdb.cp/templates.cc (main): Call t5i.value.
2009-12-28 21:45:24 +00:00
Daniel Jacobowitz c7e64c9a76 * gdb.cp/m-static.h (class gnu_obj_4): Add dummy member.
* gdb.cp/m-static.cc (main): Write to test4.dummy, so that test4
	is allocated by the compiler.
	* gdb.mi/var-cmd.c: (do_special_tests): Write to u, anonu, s,
	anons, e, anone to force their allocation by the compiler.
2006-05-05 18:04:09 +00:00
Michael Chastain 1105b7eff4 2003-08-22 Michael Chastain <mec@shout.net>
* gdb.cp: New directory.
	* gdb.cp/*: Copy from gdb.c++/*.
	* gdb.c++/*: Remove.
	* Makefile.in: Change gdb.c++ to gdb.cp.
	* configure.in:  Ditto.
	* configure: Regnerate.
2003-08-23 03:55:59 +00:00