From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85253 invoked by alias); 8 Mar 2018 17:38:10 -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 85244 invoked by uid 89); 8 Mar 2018 17:38:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:2421 X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Mar 2018 17:38:08 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E42EF41250E1; Thu, 8 Mar 2018 17:38:06 +0000 (UTC) Received: from localhost (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA56010A85AE; Thu, 8 Mar 2018 17:38:06 +0000 (UTC) From: Sergio Durigan Junior To: Andrew Burgess Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb: Fix riscv ARI issues References: <20180307224121.19941-1-andrew.burgess@embecosm.com> Date: Thu, 08 Mar 2018 17:38:00 -0000 In-Reply-To: <20180307224121.19941-1-andrew.burgess@embecosm.com> (Andrew Burgess's message of "Wed, 7 Mar 2018 22:41:21 +0000") Message-ID: <871sgutqm9.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00171.txt.bz2 On Wednesday, March 07 2018, Andrew Burgess wrote: > Fixes some ARI issues in recently added riscv code, the ARI email is: > > https://sourceware.org/ml/gdb-patches/2018-03/msg00156.html Thanks for the patch, Andrew. Comment below. > gdb/ChangeLog: > > * riscv-tdep.c (riscv_register_name): Use xsnprintf instead of > sprintf. > (riscv_insn::fetch_instruction): Use gdb_assert instead of > internal_error. > (riscv_print_arg_location): Use gdb_assert_not_reached instead of > error. > (riscv_push_dummy_call): Likewise. > --- > gdb/ChangeLog | 10 ++++++++++ > gdb/riscv-tdep.c | 14 ++++++-------- > 2 files changed, 16 insertions(+), 8 deletions(-) > > diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c > index 11b12279321..d84e7aba76a 100644 > --- a/gdb/riscv-tdep.c > +++ b/gdb/riscv-tdep.c > @@ -481,7 +481,7 @@ riscv_register_name (struct gdbarch *gdbarch, int regnum) > { > static char buf[20]; > > - sprintf (buf, "csr%d", regnum - RISCV_FIRST_CSR_REGNUM); > + xsnprintf (buf, 20, "csr%d", regnum - RISCV_FIRST_CSR_REGNUM); > return buf; > } > > @@ -1049,12 +1049,10 @@ riscv_insn::fetch_instruction (struct gdbarch *gdbarch, > > /* If we need more, grab it now. */ > instlen = riscv_insn_length (buf[0]); > + gdb_assert (instlen <= sizeof (buf)); > *len = instlen; > - if (instlen > sizeof (buf)) > - internal_error (__FILE__, __LINE__, > - _("%s: riscv_insn_length returned %i"), > - __func__, instlen); > - else if (instlen > 2) > + > + if (instlen > 2) > { > status = target_read_memory (addr + 2, buf + 2, instlen - 2); > if (status) > @@ -2009,7 +2007,7 @@ riscv_print_arg_location (ui_file *stream, struct gdbarch *gdbarch, > break; > > default: > - error ("unknown argument location type"); > + gdb_assert_not_reached ("unknown argument location type"); Strings must be marked for localization, with _(): gdb_assert_not_reached (_("unknown argument location type")); I also think it's a good thing to start the sentence with a capital letter. > } > } > > @@ -2149,7 +2147,7 @@ riscv_push_dummy_call (struct gdbarch *gdbarch, > break; > > default: > - error ("unknown argument location type"); > + gdb_assert_not_reached ("unknown argument location type"); Likewise. > } > > if (second_arg_length > 0) > -- > 2.14.3 Thanks, -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/