From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64585 invoked by alias); 26 Feb 2016 16:11:58 -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 64568 invoked by uid 89); 26 Feb 2016 16:11:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=exporting X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Feb 2016 16:11:54 +0000 Received: from svr-orw-fem-03.mgc.mentorg.com ([147.34.97.39]) by relay1.mentorg.com with esmtp id 1aZKzf-0004sz-Sm from Luis_Gustavo@mentor.com ; Fri, 26 Feb 2016 08:11:51 -0800 Received: from [172.30.3.146] (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.3.224.2; Fri, 26 Feb 2016 08:11:51 -0800 Subject: Re: [PATCH 2/2] arm-tdep.c: Refactor displaced stepping relocation functions References: <1456415245-24005-1-git-send-email-simon.marchi@ericsson.com> <1456415245-24005-3-git-send-email-simon.marchi@ericsson.com> To: Simon Marchi , Reply-To: Luis Machado From: Luis Machado Message-ID: <56D07946.2060104@codesourcery.com> Date: Fri, 26 Feb 2016 16:11:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1456415245-24005-3-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00868.txt.bz2 On 02/25/2016 12:47 PM, Simon Marchi wrote: > A small refactor so that arm_process_displaced_insn is the only function > specific to GDB. All functions called from this one will eventually be > moved to common/, so they need to be free of anything GDB-specific. I > also renamed those functions from "process_displaced" to "relocate", > since they won't be used exclusively for displaced stepping anymore. > > The call tree ends up like this: > > - arm_process_displaced_insn > - arm_relocate_insn_arm > ... > - arm_relocate_insn_thumb_32bit > ... > - arm_relocate_insn_thumb_16bit > ... > > gdb/ChangeLog: > > * arm-tdep.c (thumb_process_displaced_16bit_insn): Rename to... > (arm_relocate_insn_thumb_16bit): ... this, and add return error > code. > (thumb_process_displaced_32bit_insn): Rename to... > (arm_relocate_insn_thumb_32bit): ... this, and add return error > code. > (thumb_process_displaced_insn): Remove. > (arm_relocate_insn_arm): New function, extracted mostly from... > (arm_process_displaced_insn): ... this. Refactor to adapt to > other functions changes. > --- > gdb/arm-tdep.c | 122 ++++++++++++++++++++++++++++++--------------------------- > 1 file changed, 64 insertions(+), 58 deletions(-) > > diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c > index 43b61c2..ef48a90 100644 > --- a/gdb/arm-tdep.c > +++ b/gdb/arm-tdep.c > @@ -7111,9 +7111,8 @@ thumb_copy_pop_pc_16bit (uint16_t insn1, struct arm_insn_reloc_data *data) > return 0; > } > > -static void > -thumb_process_displaced_16bit_insn (uint16_t insn1, > - struct arm_insn_reloc_data *data) > +static int > +arm_relocate_insn_thumb_16bit (uint16_t insn1, struct arm_insn_reloc_data *data) > { > unsigned short op_bit_12_15 = bits (insn1, 12, 15); > unsigned short op_bit_10_11 = bits (insn1, 10, 11); > @@ -7202,9 +7201,7 @@ thumb_process_displaced_16bit_insn (uint16_t insn1, > err = 1; > } > > - if (err) > - internal_error (__FILE__, __LINE__, > - _("thumb_process_displaced_16bit_insn: Instruction decode error")); > + return err; Should we keep this internal error message under a different context instead of exporting just an error code? Maybe the error code should trigger this internal error for GDB? > } > > static int > @@ -7279,9 +7276,9 @@ decode_thumb_32bit_ld_mem_hints (uint16_t insn1, uint16_t insn2, > return 0; > } > > -static void > -thumb_process_displaced_32bit_insn (uint16_t insn1, uint16_t insn2, > - struct arm_insn_reloc_data *data) > +static int > +arm_relocate_insn_thumb_32bit (uint16_t insn1, uint16_t insn2, > + struct arm_insn_reloc_data *data) > { > int err = 0; > unsigned short op = bit (insn2, 15); > @@ -7393,34 +7390,41 @@ thumb_process_displaced_32bit_insn (uint16_t insn1, uint16_t insn2, > err = 1; > } > > - if (err) > - internal_error (__FILE__, __LINE__, > - _("thumb_process_displaced_32bit_insn: Instruction decode error")); > + return err; > The above one too? Otherwise it looks mostly ok to me, though the patch is a little convoluted due to code movement.