From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7021 invoked by alias); 22 Aug 2002 20:52:40 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 7013 invoked from network); 22 Aug 2002 20:52:40 -0000 Received: from unknown (HELO jackfruit.Stanford.EDU) (171.64.38.136) by sources.redhat.com with SMTP; 22 Aug 2002 20:52:40 -0000 Received: (from carlton@localhost) by jackfruit.Stanford.EDU (8.11.6/8.11.6) id g7MKqc515759; Thu, 22 Aug 2002 13:52:38 -0700 X-Authentication-Warning: jackfruit.Stanford.EDU: carlton set sender to carlton@math.stanford.edu using -f To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] dwarf2read.c: set TYPE_DOMAIN_TYPE correctly for methods References: <20020822204211.GA31727@nevyn.them.org> Cc: carlton@math.stanford.edu Content-Type: text/plain; charset=US-ASCII From: David Carlton Date: Thu, 22 Aug 2002 13:56:00 -0000 In-Reply-To: <20020822204211.GA31727@nevyn.them.org> Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp) MIME-Version: 1.0 X-SW-Source: 2002-08/txt/msg00712.txt.bz2 In article <20020822204211.GA31727@nevyn.them.org>, Daniel Jacobowitz 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