From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18922 invoked by alias); 12 Nov 2006 21:55:35 -0000 Received: (qmail 18905 invoked by uid 22791); 12 Nov 2006 21:55:34 -0000 X-Spam-Check-By: sourceware.org Received: from nile.gnat.com (HELO nile.gnat.com) (205.232.38.5) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 12 Nov 2006 21:55:25 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-nile.gnat.com (Postfix) with ESMTP id 4BD0648D05C; Sun, 12 Nov 2006 16:55:23 -0500 (EST) Received: from nile.gnat.com ([127.0.0.1]) by localhost (nile.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 01269-01-2; Sun, 12 Nov 2006 16:55:23 -0500 (EST) Received: from takamaka.act-europe.fr (unknown [70.71.0.212]) by nile.gnat.com (Postfix) with ESMTP id F150148CFA8; Sun, 12 Nov 2006 16:55:22 -0500 (EST) Received: by takamaka.act-europe.fr (Postfix, from userid 1000) id 1623E34C099; Sun, 12 Nov 2006 13:55:43 -0800 (PST) Date: Sun, 12 Nov 2006 21:55:00 -0000 From: Joel Brobecker To: Mark Kettenis Cc: gdb-patches@sourceware.org Subject: Re: [RFA/sparc64] internal-error printing return value (Ada array) Message-ID: <20061112215542.GB22995@adacore.com> References: <20061111002614.GD3746@adacore.com> <24858.82.92.89.47.1163267262.squirrel@webmail.xs4all.nl> <20061112002226.GA22995@adacore.com> <6654.82.92.89.47.1163364566.squirrel@webmail.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6654.82.92.89.47.1163364566.squirrel@webmail.xs4all.nl> User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-11/txt/msg00092.txt.bz2 > Hmm, I gueass I should have asked how a gdb `struct type' looks for > these Ada arrays? In particular, if main_type->nfields is set and > whether main_type->fields is set to something useful. Ah, I understand now (sorry). Yes, main_type->nfields is 1, and main_type->fields contains the bounds. > > > You should also check how small arrays are passed as arguments to a > > > function. > > > > This is described by the Ada Reference Manual: Arrays are always > > passed by reference. So a function taking a parameter of our static > > array type will have the array passed by reference. As a result, > > the the array parameter will be a REF to a TYPE_CODE_ARRAY. > > So there is no way to pass a TYPE_CODE_ARRAY directly? Not as a parameter for a function or procedure, no. > > > Here the magic length will be 16 bytes instead of 32 bytes. > > > > I don't understand this part. Why 16 bytes instead of 32? > > If the total size of the array is 32 bytes, shouldn't the compiler > > return it through %o0 - %o7? > > The 16-byte limit is for passing structures as an argument to a function. > I presume this is because function arguments occupy 16-byte slots in the > ABI. Ah, OK, I think I see where you are going. I failed to notice that the function I modified is also used for storing/extracting function parameters. In terms of the argument passing, we don't need to worry in our case, because arrays are passed by reference. In terms of a return value, the ABI says that structs of up to 32 bytes can be returned. 3.2.3.3. Structure or Union return values Structure and union return types up to thirty-two bytes in size are returned in registers. The registers are assigned as if the value was being passed as the first argument to a function with a known prototype. This is why I used the magic number of 32 in this case. I still think it is correct, although more comments are certainly required to explain the above. What do you think? -- Joel