From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32536 invoked by alias); 11 Nov 2006 00:26:05 -0000 Received: (qmail 32527 invoked by uid 22791); 11 Nov 2006 00:26:04 -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; Sat, 11 Nov 2006 00:25:58 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-nile.gnat.com (Postfix) with ESMTP id B7C2148CE43 for ; Fri, 10 Nov 2006 19:25:55 -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 26968-01-2 for ; Fri, 10 Nov 2006 19:25:55 -0500 (EST) Received: from takamaka.act-europe.fr (unknown [70.71.0.212]) by nile.gnat.com (Postfix) with ESMTP id 3C34348CDB7 for ; Fri, 10 Nov 2006 19:25:55 -0500 (EST) Received: by takamaka.act-europe.fr (Postfix, from userid 1000) id E477334C099; Fri, 10 Nov 2006 16:26:14 -0800 (PST) Date: Sat, 11 Nov 2006 00:26:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA/sparc64] internal-error printing return value (Ada array) Message-ID: <20061111002614.GD3746@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="/WwmFnJnmDyWGHa4" Content-Disposition: inline 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/msg00076.txt.bz2 --/WwmFnJnmDyWGHa4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2382 Hello, When working on GDB for sparc64-sun-solaris, I noticed that GDB reports an internal error when trying to print the return value of a function returning an Ada (fixed-size) array. I noticed this in gdb.ada/array_return.exp: FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Small FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Large Here is what happens. First the transcript: (gdb) b pck.adb:5 Breakpoint 1 at 0x100009e84: file pck.adb, line 5. (gdb) run Starting program: /[...]/p Breakpoint 1, pck.create_small () at pck.adb:5 5 return (others => 1); (gdb) fin Run till exit from #0 pck.create_small () at pck.adb:5 0x0000000100009fd0 in p () at p.adb:7 7 Small := Create_Small; sparc64-tdep.c:1092: internal-error: sparc64_extract_return_value: Assertion `sp arc64_integral_or_pointer_p (type)' failed. The type in question is a TYPE_CODE_ARRAY. It seems that this case is not handled yet by the function that extracts the return value: sparc64-tdep.c:sparc64_extract_return_value I am not sure yet whether this case is specific to Ada or if we can reproduce the same with C, I will double-check. In any case, these array objects are returned the same way as struct objects: Up to 32 bytes, they are passed by register, otherwise %o0 contains the address of the returned object. I think the best fix for this is to update sparc64_structure_or_union_p to accept arrays of 32 bytes or less. The name would become slightly misleading for its actual implementation, and I wouldn't mind changing it if felt necessary. I don't know if the same issue applies to 32bit GDB or not. I tried, but "fin" doesn't stop at the function return, so I never get the returned value printed by GDB. I'll have a look at this another time. I also noticed that the same problem happens for arrays larger than 32bytes. In fact, this is not specific to arrays, but to structures as well. Support for structures larger than 32 bytes seems to be missing. I can add that too, but let's make this another patch. 2006-11-10 Joel Brobecker * sparc64-tdep.c (sparc64_structure_or_union_p): Accept array types if the type length is 32 bytes or less. Fixes the two FAILs above, no regression. OK to apply? Thanks, -- Joel --/WwmFnJnmDyWGHa4 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sparc64-tdep.c.diff" Content-length: 602 Index: sparc64-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/sparc64-tdep.c,v retrieving revision 1.27 diff -u -p -r1.27 sparc64-tdep.c --- sparc64-tdep.c 22 Aug 2006 20:57:56 -0000 1.27 +++ sparc64-tdep.c 11 Nov 2006 00:24:36 -0000 @@ -114,6 +114,9 @@ sparc64_structure_or_union_p (const stru case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: return 1; + case TYPE_CODE_ARRAY: + /* Arrays of up to 32 bytes are returned the same way as record. */ + return (TYPE_LENGTH (type) <= 32); default: break; } --/WwmFnJnmDyWGHa4--