From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4111 invoked by alias); 9 Mar 2004 15:39:45 -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 4104 invoked from network); 9 Mar 2004 15:39:44 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sources.redhat.com with SMTP; 9 Mar 2004 15:39:44 -0000 Received: from drow by nevyn.them.org with local (Exim 4.30 #1 (Debian)) id 1B0jKT-0007KK-4j; Tue, 09 Mar 2004 10:39:37 -0500 Date: Fri, 19 Mar 2004 00:09:00 -0000 From: Daniel Jacobowitz To: Mark Kettenis Cc: jh@suse.cz, aj@suse.de, mark@codesourcery.com, gdb-patches@sources.redhat.com Subject: Re: [PATCH] Classify non-POD struct types more or less correctly on AMD64 Message-ID: <20040309153937.GA27951@nevyn.them.org> Mail-Followup-To: Mark Kettenis , jh@suse.cz, aj@suse.de, mark@codesourcery.com, gdb-patches@sources.redhat.com References: <200401101800.i0AI0Zm6026623@elgar.kettenis.dyndns.org> <20040110183622.GA8108@nevyn.them.org> <200401101858.i0AIwdhk032901@elgar.kettenis.dyndns.org> <20040111041009.GA15714@nevyn.them.org> <200401111237.i0BCbVPL010349@elgar.kettenis.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200401111237.i0BCbVPL010349@elgar.kettenis.dyndns.org> User-Agent: Mutt/1.5.1i X-SW-Source: 2004-03/txt/msg00195.txt.bz2 On Sun, Jan 11, 2004 at 01:37:31PM +0100, Mark Kettenis wrote: > That function just implements the rules for normal C structures. Th > rules are a bit more complex than you say above, but that bit is > implemented correctly in GDB. At least that's the intention. The > decision to not pass certain C++ classes in registers is made > somewhere else, most notably in cp/class.c:finish_struct_bits(), where > TYPE_MODE is set to BLKmode, and TREE_ADDRESSABLE is set. Both > conditions are enough to get the type returned in memory instead of > registers. However, there are more places where TREE_ADDRESSABLE is > tweaked. Hi Mark, As it happens I just ran into the same problem on ARM and on MIPS n32. I don't have a patch yet, but I can excerpt code I'm using at the moment: + /* This is... rough. If we have a non-trivial copy constructor or + destructor, use reference. This should be in common code. */ + int i, j; + for (i = 0; i < TYPE_NFN_FIELDS (type); i++) + for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (type, i); j++) + { + struct fn_field *fn = TYPE_FN_FIELDLIST1 (type, i); + if (TYPE_FN_FIELD_ARTIFICIAL (fn, j)) + continue; + if (TYPE_FN_FIELDLIST_NAME (type, i)[0] == '~') + return RETURN_VALUE_STRUCT_CONVENTION; + if (strncmp (TYPE_NAME (type), + TYPE_FN_FIELDLIST_NAME (type, i), + strlen (TYPE_NAME (type))) == 0 + && (TYPE_FN_FIELDLIST_NAME (type, i)[strlen (TYPE_NAME (type))] == '\0' + || TYPE_FN_FIELDLIST_NAME (type, i)[strlen (TYPE_NAME (type))] == '<') + && TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (fn, j)) == 2 + && TYPE_CODE (TYPE_FIELD_TYPE (TYPE_FN_FIELD_TYPE (fn, j), 1)) == TYPE_CODE_REF + && TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (TYPE_FN_FIELD_TYPE (fn, j), 1)) == type) + return RETURN_VALUE_STRUCT_CONVENTION; + } This doesn't address everything that GCC does to change the pass-by-invisible-reference/return-by-invisible-reference behavior, but it's a pretty good start and fixes one test in the GDB testsuite. Note that we can't implement the TYPE_FN_FIELD_ARTIFICIAL test with stabs. This also doesn't handle anything about calling constructors or destructors, which GDB just isn't set up for yet... I don't know if this sort of information should be in the dwarf2 information somehow. It definitely is in the C++ GNU v3 ABI: http://www.codesourcery.com/cxx-abi/abi.html#calls I'm guessing that this is what the x86-64 ABI was referring to, rather than the actual term POD. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4111 invoked by alias); 9 Mar 2004 15:39:45 -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 4104 invoked from network); 9 Mar 2004 15:39:44 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sources.redhat.com with SMTP; 9 Mar 2004 15:39:44 -0000 Received: from drow by nevyn.them.org with local (Exim 4.30 #1 (Debian)) id 1B0jKT-0007KK-4j; Tue, 09 Mar 2004 10:39:37 -0500 Date: Tue, 09 Mar 2004 15:39:00 -0000 From: Daniel Jacobowitz To: Mark Kettenis Cc: jh@suse.cz, aj@suse.de, mark@codesourcery.com, gdb-patches@sources.redhat.com Subject: Re: [PATCH] Classify non-POD struct types more or less correctly on AMD64 Message-ID: <20040309153937.GA27951@nevyn.them.org> Mail-Followup-To: Mark Kettenis , jh@suse.cz, aj@suse.de, mark@codesourcery.com, gdb-patches@sources.redhat.com References: <200401101800.i0AI0Zm6026623@elgar.kettenis.dyndns.org> <20040110183622.GA8108@nevyn.them.org> <200401101858.i0AIwdhk032901@elgar.kettenis.dyndns.org> <20040111041009.GA15714@nevyn.them.org> <200401111237.i0BCbVPL010349@elgar.kettenis.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200401111237.i0BCbVPL010349@elgar.kettenis.dyndns.org> User-Agent: Mutt/1.5.1i X-SW-Source: 2004-03.o/txt/msg00195.txt Message-ID: <20040309153900.gtQJ-PAI6gZlIE67fNdh2Yuwg4V2_wrk4r3y0h5a-48@z> On Sun, Jan 11, 2004 at 01:37:31PM +0100, Mark Kettenis wrote: > That function just implements the rules for normal C structures. Th > rules are a bit more complex than you say above, but that bit is > implemented correctly in GDB. At least that's the intention. The > decision to not pass certain C++ classes in registers is made > somewhere else, most notably in cp/class.c:finish_struct_bits(), where > TYPE_MODE is set to BLKmode, and TREE_ADDRESSABLE is set. Both > conditions are enough to get the type returned in memory instead of > registers. However, there are more places where TREE_ADDRESSABLE is > tweaked. Hi Mark, As it happens I just ran into the same problem on ARM and on MIPS n32. I don't have a patch yet, but I can excerpt code I'm using at the moment: + /* This is... rough. If we have a non-trivial copy constructor or + destructor, use reference. This should be in common code. */ + int i, j; + for (i = 0; i < TYPE_NFN_FIELDS (type); i++) + for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (type, i); j++) + { + struct fn_field *fn = TYPE_FN_FIELDLIST1 (type, i); + if (TYPE_FN_FIELD_ARTIFICIAL (fn, j)) + continue; + if (TYPE_FN_FIELDLIST_NAME (type, i)[0] == '~') + return RETURN_VALUE_STRUCT_CONVENTION; + if (strncmp (TYPE_NAME (type), + TYPE_FN_FIELDLIST_NAME (type, i), + strlen (TYPE_NAME (type))) == 0 + && (TYPE_FN_FIELDLIST_NAME (type, i)[strlen (TYPE_NAME (type))] == '\0' + || TYPE_FN_FIELDLIST_NAME (type, i)[strlen (TYPE_NAME (type))] == '<') + && TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (fn, j)) == 2 + && TYPE_CODE (TYPE_FIELD_TYPE (TYPE_FN_FIELD_TYPE (fn, j), 1)) == TYPE_CODE_REF + && TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (TYPE_FN_FIELD_TYPE (fn, j), 1)) == type) + return RETURN_VALUE_STRUCT_CONVENTION; + } This doesn't address everything that GCC does to change the pass-by-invisible-reference/return-by-invisible-reference behavior, but it's a pretty good start and fixes one test in the GDB testsuite. Note that we can't implement the TYPE_FN_FIELD_ARTIFICIAL test with stabs. This also doesn't handle anything about calling constructors or destructors, which GDB just isn't set up for yet... I don't know if this sort of information should be in the dwarf2 information somehow. It definitely is in the C++ GNU v3 ABI: http://www.codesourcery.com/cxx-abi/abi.html#calls I'm guessing that this is what the x86-64 ABI was referring to, rather than the actual term POD. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer