From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5505 invoked by alias); 4 Oct 2003 11:39:44 -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 5496 invoked from network); 4 Oct 2003 11:39:43 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 4 Oct 2003 11:39:43 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200] (may be forged)) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h94Bdg106004 for ; Sat, 4 Oct 2003 07:39:43 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h94BdgD09493 for ; Sat, 4 Oct 2003 07:39:42 -0400 Received: from cygbert.vinschen.de (vpn50-13.rdu.redhat.com [172.16.50.13]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id h94Bdew01412 for ; Sat, 4 Oct 2003 04:39:41 -0700 Received: by cygbert.vinschen.de (Postfix, from userid 500) id 6DC9658044; Sat, 4 Oct 2003 13:39:39 +0200 (CEST) Date: Sat, 04 Oct 2003 11:39:00 -0000 From: Corinna Vinschen To: gdb-patches@sources.redhat.com Subject: [RFA] sh-tdep.c (sh_use_struct_convention): Restructure and fix Message-ID: <20031004113939.GK11435@cygbert.vinschen.de> Reply-To: gdb-patches@sources.redhat.com Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-SW-Source: 2003-10/txt/msg00076.txt.bz2 Hi, the below patch straightens out sh_use_struct_convention() so that it allows a far better readability than before, especially by allowing a bunch of comments spread out through the code. Additionally it fixes one bug: A struct of lenght 4 bytes, which consists of only a bitfield, is returned in register r0, not on the stack using the struct convention. So far, GDB got that wrong. Corinna * sh-tdep.c (sh_use_struct_convention): Clean up to have a more readable code. Accomodate 4 byte structs with 4 byte sized first field (e.g. bitfields). Index: sh-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/sh-tdep.c,v retrieving revision 1.145 diff -u -p -r1.145 sh-tdep.c --- sh-tdep.c 3 Oct 2003 08:13:37 -0000 1.145 +++ sh-tdep.c 4 Oct 2003 11:32:00 -0000 @@ -565,8 +565,25 @@ sh_use_struct_convention (int gcc_p, str { int len = TYPE_LENGTH (type); int nelem = TYPE_NFIELDS (type); - return ((len != 1 && len != 2 && len != 4 && len != 8) || nelem != 1) && - (len != 8 || TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) != 4); + + /* Non-power of 2 length types and types bigger than 8 bytes (which don't + fit in two registers anyway) use struct convention. */ + if (len != 1 && len != 2 && len != 4 && len != 8) + return 1; + /* Structs with more than 1 fields use struct convention, if... */ + if (nelem != 1) + { + /* ... they are 1 or 2 bytes in size (e.g. struct of two chars)... */ + if (len != 4 && len != 8) + return 1; + /* ... or, if the struct is 4 or 8 bytes and the first field is + not of size 4 bytes. Note that this also covers structs with + bitfields. */ + if (TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) != 4) + return 1; + } + /* Otherwise return in registers. */ + return 0; } /* Extract from an array REGBUF containing the (raw) register state -- Corinna Vinschen Cygwin Developer Red Hat, Inc.