From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22873 invoked by alias); 18 Jan 2013 18:25:33 -0000 Received: (qmail 22855 invoked by uid 22791); 18 Jan 2013 18:25:31 -0000 X-SWARE-Spam-Status: No, hits=-7.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Jan 2013 18:25:23 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0IIPFjL020966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Jan 2013 13:25:16 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0IIP4vN007580; Fri, 18 Jan 2013 13:25:05 -0500 Message-ID: <50F9937F.5000508@redhat.com> Date: Fri, 18 Jan 2013 18:25:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Joel Brobecker CC: Kaushik Phatak , "gdb-patches@sourceware.org" , "binutils@sourceware.org" , Pedro Alves , Yao Qi , nick clifton , Tom Tromey Subject: Re: [RFA 3/5] New port: CR16: gdb port References: <507279C7.8080401@codesourcery.com> <20121022224107.GB3713@adacore.com> <20121023135502.GA3555@adacore.com> <20121115174313.GC3790@adacore.com> <20121122175010.GG9964@adacore.com> <20130117085919.GA3564@adacore.com> In-Reply-To: <20130117085919.GA3564@adacore.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2013-01/txt/msg00446.txt.bz2 On 01/17/2013 08:59 AM, Joel Brobecker wrote: >> + /* Read 6 bytes, max 48 bit opcode. */ >> + target_read_memory (pc, buf, 6); >> + cr16_words[0] = buf[1] << 8 | buf[0]; >> + cr16_words[1] = buf[3] << 8 | buf[2]; >> + cr16_words[2] = buf[5] << 8 | buf[4]; >> + cr16_allWords = (((ULONGLONG) cr16_words[0] << 32) >> + + ((ULONGLONG) cr16_words[1] << 16) >> + + cr16_words[2]); >> + >> + /* Find a matching opcode in table. >> + Nonzero means instruction has a match. */ >> + is_decoded = cr16_match_opcode (); >> + cr16_make_instruction (); >> + length = cr16_currInsn.size; > > It hurts every time I read this code... Nothing you can do short > of improving opcode, but this is really awful :-(. This seems pretty isolated. How about exporting a function that hides these opcodes details? I don't even pretend to understand what the code is trying to do, and it'd be an opportunity to comment it in the function description. :-) /* Take BUF, do something with it, and write length to LENGTH. Blah, blah. */ cr16_do_something (buf, *length, ...); > static const char *const reg_names[] = > +{ ... > + "r0r1_orig", This too looks like a ptrace detail escaping all the way to the user, similar to the gdbserver issues. Any reason not to split those up? I think it'd be nicer. ... > +}; Joel Brobecker wrote: > The rest still looks pretty good to me :) I agree. :-) -- Pedro Alves