From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17466 invoked by alias); 19 Jul 2006 21:26:35 -0000 Received: (qmail 17458 invoked by uid 22791); 19 Jul 2006 21:26:34 -0000 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 19 Jul 2006 21:26:29 +0000 Received: from elgar.sibelius.xs4all.nl (root@elgar.sibelius.xs4all.nl [192.168.0.2]) by sibelius.xs4all.nl (8.13.4/8.13.4) with ESMTP id k6JLPngY025016; Wed, 19 Jul 2006 23:25:49 +0200 (CEST) Received: from elgar.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.13.6/8.13.6) with ESMTP id k6JLPmnG016796; Wed, 19 Jul 2006 23:25:48 +0200 (CEST) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.13.6/8.13.6/Submit) id k6JLPmuV014206; Wed, 19 Jul 2006 23:25:48 +0200 (CEST) Date: Wed, 19 Jul 2006 21:26:00 -0000 Message-Id: <200607192125.k6JLPmuV014206@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: rearnsha@arm.com CC: gdb-patches@sourceware.org Subject: [PATCH/RFA] Fix returning small structs on OpenBSD/arm 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-07/txt/msg00263.txt.bz2 On OpenBSD/arm, all structures are returned in memory, i.e. the -fpcc-struct-return GCC option is the default. There are a couple of different ways we deal with pcc/reg struct return in GDB. This adapts the way things are done on i386 and m68k. This makes it easy to provide a user command to switch from one convention to the other like i386 already has. However, right now I don't actually see much reason to add that option on arm. Anyway, this shaves another 80 failures from the testsuite on OpenBSD/arm. ok? Index: ChangeLog =================================================================== RCS file: /cvs/src/src/gdb/ChangeLog,v retrieving revision 1.7834 diff -u -p -r1.7834 ChangeLog --- ChangeLog 19 Jul 2006 18:21:36 -0000 1.7834 +++ ChangeLog 19 Jul 2006 21:20:39 -0000 @@ -1,5 +1,15 @@ 2006-07-19 Mark Kettenis + * arm-tdep.h (enum struct_return): New. + (struct gdbarch_tdep): Add struct_return member. + * arm-tdep.c (arm_return_value): Return + RETURN_VALUE_STRUCT_CONVENTION for aggregates when the ABI uses + pcc_struct_return. + (arm_gdbarch_init): Default to reg_struct_return. + * armobsd-tdep.c (armobsd_init_abi): Set pcc_struct_return. + +2006-07-19 Mark Kettenis + * arm-tdep.c (arm_gdbarch_init): Get default floating-point model from ELF flags for binaries produced by the GNU toolchain. Index: arm-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/arm-tdep.c,v retrieving revision 1.212 diff -u -p -r1.212 arm-tdep.c --- arm-tdep.c 19 Jul 2006 18:21:36 -0000 1.212 +++ arm-tdep.c 19 Jul 2006 21:20:41 -0000 @@ -2259,11 +2259,14 @@ arm_return_value (struct gdbarch *gdbarc struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + if (TYPE_CODE (valtype) == TYPE_CODE_STRUCT || TYPE_CODE (valtype) == TYPE_CODE_UNION || TYPE_CODE (valtype) == TYPE_CODE_ARRAY) { - if (arm_return_in_memory (gdbarch, valtype)) + if (tdep->struct_return == pcc_struct_return + || arm_return_in_memory (gdbarch, valtype)) return RETURN_VALUE_STRUCT_CONVENTION; } @@ -2757,6 +2760,10 @@ arm_gdbarch_init (struct gdbarch_info in tdep->lowest_pc = 0x20; tdep->jb_pc = -1; /* Longjump support not enabled by default. */ + /* The default, for both APCS and AAPCS, is to return small + structures in registers. */ + tdep->struct_return = reg_struct_return; + set_gdbarch_push_dummy_call (gdbarch, arm_push_dummy_call); set_gdbarch_frame_align (gdbarch, arm_frame_align); Index: arm-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/arm-tdep.h,v retrieving revision 1.15 diff -u -p -r1.15 arm-tdep.h --- arm-tdep.h 12 Jul 2006 20:46:32 -0000 1.15 +++ arm-tdep.h 19 Jul 2006 21:20:41 -0000 @@ -125,6 +125,14 @@ enum arm_abi_kind ARM_ABI_LAST }; +/* Convention for returning structures. */ + +enum struct_return +{ + pcc_struct_return, /* Return "short" structures in memory. */ + reg_struct_return /* Return "short" structures in registers. */ +}; + /* Target-dependent structure in gdbarch. */ struct gdbarch_tdep { @@ -147,10 +155,15 @@ struct gdbarch_tdep will be disabled. */ size_t jb_elt_size; /* And the size of each entry in the buf. */ + /* Convention for returning structures. */ + enum struct_return struct_return; + /* Cached core file helpers. */ struct regset *gregset, *fpregset; }; + + #ifndef LOWEST_PC #define LOWEST_PC (gdbarch_tdep (current_gdbarch)->lowest_pc) #endif Index: armobsd-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/armobsd-tdep.c,v retrieving revision 1.3 diff -u -p -r1.3 armobsd-tdep.c --- armobsd-tdep.c 18 Jul 2006 21:10:28 -0000 1.3 +++ armobsd-tdep.c 19 Jul 2006 21:20:41 -0000 @@ -88,6 +88,9 @@ armobsd_init_abi (struct gdbarch_info in tdep->jb_pc = 24; tdep->jb_elt_size = 4; + + /* OpenBSD/arm uses -fpcc-struct-return by default. */ + tdep->struct_return = pcc_struct_return; } void