This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] dwarf2read.c: set TYPE_DOMAIN_TYPE correctly for methods
- From: David Carlton <carlton at math dot stanford dot edu>
- To: Daniel Jacobowitz <drow at mvista dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Cc: carlton at math dot stanford dot edu
- Date: 22 Aug 2002 13:52:38 -0700
- Subject: Re: [RFA] dwarf2read.c: set TYPE_DOMAIN_TYPE correctly for methods
- References: <ro1r8gqpr6h.fsf@jackfruit.Stanford.EDU><20020822204211.GA31727@nevyn.them.org>
In article <20020822204211.GA31727@nevyn.them.org>, Daniel Jacobowitz <drow@mvista.com> writes:
>> * dwarf2read.c (dwarf2_add_member_fn): Add back in the type
>> argument that was deleted on 2002-06-14: it was needed after all,
>> as PR gdb/653 demonstrates. Update call to smash_to_method_type.
>> (read_structure_scope): Update call to dwarf2_add_member_fn.
> Can you explain why this is necessary? I could not find any path to
> that point where type != die->type.
dwarf2_add_member_fn is called by read_structure_scope. The 'die'
argument to dwarf2_add_member_fn is the 'child_die' variable of
read_structure_scope. So what dwarf2_add_member_fn thinks of as
'die->type' is what read_structure_scope thinks of as
'child_die->type', in other words the type associated to the method
that is being added to the structure in question.
But the second argument to smash_to_method_type is supposed to be the
domain of the given method, i.e. the type of the structure owning the
method. This is dramatically different from read_structure_scope's
child_die->type; it equals read_structure_scope's die->type.
So that's why we want to pass in read_structure_scope's die->type as
an argument. (I don't see any way to recover die->type from
child_die, though admittedly I didn't try very hard.)
For a reasonably dramatic illustration of the effects of this, try
compiling the following program
/* Create some objects, and try to print out their methods. */
class A {
public:
virtual void virt() {};
void nonvirt() {};
};
int main()
{
A *theA = new A;
return 0;
}
and debug it with GDB from the current CVS. Run it until theA has
been created, and then try 'p theA->virt'.
David Carlton
carlton@math.stanford.edu