This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

src/gdb ChangeLog eval.c testsuite/ChangeLog t ...


CVSROOT:	/cvs/src
Module name:	src
Changes by:	palves@sourceware.org	2013-02-14 12:43:46

Modified files:
	gdb            : ChangeLog eval.c 
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.cp: userdef.exp 

Log message:
	Fix ptype bug actually exercised in userdef.exp
	
	I happened to notice a bug with ptype &Ref, and found out userdef.exp
	actually exercises the bug.  With:
	
	class Container
	{
	public:
	Member m;
	
	Member& operator* ();
	};
	
	Member& Container::operator* ()
	{
	return this->m;
	}
	
	And 'c' is of type Container:
	
	(gdb) p c
	$1 = {m = {z = -9192}}
	(gdb) p *c
	$2 = (Member &) @0x7fffffffda20: {z = -9192}
	(gdb) ptype *c
	type = class Member {
	public:
	int z;
	} &
	
	(gdb) p &*c
	$3 = (Member *) 0x7fffffffda20
	
	(gdb) ptype &*c
	type = class Member {
	public:
	int z;
	} &*
	(gdb)
	
	Notice that last print (&*c) on says the type is a pointer - that's
	how you get the address behind a reference.  But notice the last ptype
	instead says the type of the same expression is a pointer _reference_.
	This looks like a bug to me.
	
	This patch fixes it.  The issue is that we're entering the VALUE_LVAL
	(x) == lval_memory branch by mistake for references.  The fix is just
	to swap the tests so references are checked first, like value_addr
	also handles references first.
	
	Tested on x86_64 Fedora 17.
	
	2013-02-14  Pedro Alves  <palves@redhat.com>
	
	* eval.c (evaluate_subexp_for_address) <default_case_after_eval,
	EVAL_AVOID_SIDE_EFFECTS>: Swap and handle TYPE_CODE_REF before
	lval_memory.
	
	2013-02-14  Pedro Alves  <palves@redhat.com>
	
	* gdb.cp/userdef.exp (ptype &*c): Don't expect an &.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.15149&r2=1.15150
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/eval.c.diff?cvsroot=src&r1=1.177&r2=1.178
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3561&r2=1.3562
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/userdef.exp.diff?cvsroot=src&r1=1.23&r2=1.24


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]