Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@mvista.com>
To: Mark Kettenis <kettenis@chello.nl>
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
Date: Tue, 09 Mar 2004 15:39:00 -0000	[thread overview]
Message-ID: <20040309153937.GA27951@nevyn.them.org> (raw)
Message-ID: <20040309153900.gtQJ-PAI6gZlIE67fNdh2Yuwg4V2_wrk4r3y0h5a-48@z> (raw)
In-Reply-To: <200401111237.i0BCbVPL010349@elgar.kettenis.dyndns.org>

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


  parent reply	other threads:[~2004-03-09 15:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-10 18:00 Mark Kettenis
2004-01-10 18:36 ` Daniel Jacobowitz
2004-01-10 18:59   ` Mark Kettenis
2004-01-11  4:10     ` Daniel Jacobowitz
2004-01-11 12:38       ` Mark Kettenis
2004-01-11 13:29         ` Jan Hubicka
2004-01-12  5:37           ` Mark Mitchell
2004-01-11 15:05         ` Gabriel Dos Reis
2004-03-19  0:09         ` Daniel Jacobowitz [this message]
2004-03-09 15:39           ` Daniel Jacobowitz
2004-03-19  0:09           ` Mark Mitchell
2004-03-10  3:38             ` Mark Mitchell
2004-03-10  4:21             ` Daniel Jacobowitz
2004-03-19  0:09               ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040309153937.GA27951@nevyn.them.org \
    --to=drow@mvista.com \
    --cc=aj@suse.de \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jh@suse.cz \
    --cc=kettenis@chello.nl \
    --cc=mark@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox