From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98856 invoked by alias); 18 Nov 2018 09:13:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 98836 invoked by uid 89); 18 Nov 2018 09:13:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=buettner, Buettner, 50pm, 50PM X-HELO: jocasta.intra Received: from de.cellform.com (HELO jocasta.intra) (88.217.224.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 18 Nov 2018 09:13:52 +0000 Received: from jocasta.intra (localhost [127.0.0.1]) by jocasta.intra (8.15.2/8.15.2/Debian-8) with ESMTPS id wAI9DcHv017891 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 18 Nov 2018 10:13:38 +0100 Received: (from john@localhost) by jocasta.intra (8.15.2/8.15.2/Submit) id wAI9DbSF017890; Sun, 18 Nov 2018 10:13:37 +0100 Date: Sun, 18 Nov 2018 09:13:00 -0000 From: John Darrington To: Kevin Buettner Cc: gdb-patches@sourceware.org, John Darrington Subject: Re: [PATCH 2/2] GDB: S12Z: new function s12z_extract_return_value Message-ID: <20181118091337.tqzu3rhmaeyxw7zp@jocasta.intra> References: <20181112091721.28040-1-john@darrington.wattle.id.au> <20181112091721.28040-2-john@darrington.wattle.id.au> <20181117233550.09353eeb@pinnacle.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181117233550.09353eeb@pinnacle.lan> User-Agent: NeoMutt/20170113 (1.7.2) X-SW-Source: 2018-11/txt/msg00274.txt.bz2 Hi Kevin, Thanks for the review. On Sat, Nov 17, 2018 at 11:35:50PM -0700, Kevin Buettner wrote: > > gdb/ChangeLog: > * s12z-tdep.c (s12z_extract_return_value): New function. > (inv_reg_perm) New array. > (s12z_return_value): Populate readbuf if non-null. Make sure that this is indented correctly when it eventually goes in the ChangeLog file. Is it documented anywhere what "correctly" means? My two cents on all of the above... I think you'll have a lot less grief with this architecture port if you don't try to use the numbering defined in include/opcode/s12z.h. Create a new numbering with new constants for GDB's purposes ordered as shown in the reg_perm array. Then use these constants in place of the various REG_ constants that are currently in s12z-tdep.c. If you still want to be able to access registers[], it may make sense to have an array which maps GDB's constants to those in include/opcode. I'm beginning to think that you're right here. I may change it in the way you propose in a future patch. Also, if you want CCH and CCL to be show in "info registers" and/or allow the user to display and set them, these can be implemented via the use of pseudo-registers. A the moment, I don't think it's worth bothering about. CCH and CCL are merely the high and low bytes of a 16bit register CCW. The names CCH and CCL only exist because of two (rarely used) instructions in the ISA. > /* Return the name of the register REGNUM. */ > static const char * > @@ -467,11 +479,59 @@ s12z_print_registers_info (struct gdbarch *gdbarch, > > > > + > +static void > +s12z_extract_return_value (struct type *type, struct regcache *regcache, > + void *valbuf) > +{ > + int reg = -1; > + > + gdb_byte buf[4]; > + > + switch (TYPE_LENGTH (type)) > + { > + case 0: /* Nothing to do */ > + return; > + > + case 1: > + reg = REG_D0; > + break; > + > + case 2: > + reg = REG_D2; > + break; > + > + case 3: > + reg = REG_X; > + break; > + > + case 4: > + reg = REG_D6; > + break; > + > + default: > + error (_("bad size for return value")); > + return; > + } > + > + regcache->cooked_read (inv_reg_perm[reg], buf); > + memcpy (valbuf, buf, TYPE_LENGTH (type)); Is there any reason not to just pass valbuf in place of buf to cooked_read? Doing so will get rid of the memcpy. Probably not. Thanks for noticing this. J' -- Avoid eavesdropping. Send strong encrypted email. PGP Public key ID: 1024D/2DE827B3 fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3 See http://sks-keyservers.net or any PGP keyserver for public key.