From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wGQ1Mvtw2WNAgCYAWB0awg (envelope-from ) for ; Tue, 31 Jan 2023 14:50:19 -0500 Received: by simark.ca (Postfix, from userid 112) id C9B7A1E128; Tue, 31 Jan 2023 14:50:19 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=LyID4T7/; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6AC2A1E0D3 for ; Tue, 31 Jan 2023 14:50:19 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7440C3858C2D for ; Tue, 31 Jan 2023 19:50:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7440C3858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675194618; bh=cBQsrsHETAKpI3ah/XMRVID2jGHmTy3+Kiwl3UGeutw=; h=References:To:Cc:Subject:In-reply-to:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=LyID4T7/+htQFzKdAWYrbLNG3WI3hWgQN0zivYdNXBjPcCqNrvdoLlkdXTCzHv2py HSn90uL9pZwc01U2aYfmb58F1lkjhsowmqXFRcrlwDmZ9AWYx9xzJLkMgzknFSL18Z tVB2I75tU4d1N3CQSzTAK7+A3+sckgp3QPIneslw= Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id E76C93858D28 for ; Tue, 31 Jan 2023 19:49:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E76C93858D28 Received: by mail-ot1-x335.google.com with SMTP id cm26-20020a056830651a00b00684e5c0108dso5759369otb.9 for ; Tue, 31 Jan 2023 11:49:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cBQsrsHETAKpI3ah/XMRVID2jGHmTy3+Kiwl3UGeutw=; b=2wYvamMMo8rNY3VQbsirk6qbQFYvn96K53QLKXyZS8+Qh/Rqr+EV8jcJ4FzLqHacf4 Eevd1tlXphoHh9kv7lNiEm5nyyLh4kYAoaKqjMiFnASXqJhdZSofOwKiSgQl1UWBrE51 eZVqSUihgykvZL9DErcj2CTAQabrmP/eykQv/KEE5rpdr/DYg7vzCKuAzIUoSq9CwHFp GuZ88ATgK8JAT5i5/zJ2JbV9ExETBHiEyy9zsVYLp5cqGNbox8SBIJr0VPBhUN57r+d2 6btHhvzwbrPYQxZF0OVxuG3YcIRLSw6VWgeztxkWREPKMpk5h55oISyd1k2HfojL0vsc Nd4w== X-Gm-Message-State: AO0yUKVk98XoBzqnmXzB+fN0/jr07m0cm9O1+Bdt1IkGmUOKwBJcdG1e CvWT/e8Ijrp8kSc0lMxJe2vVLA== X-Google-Smtp-Source: AK7set//2zNHtJpEvtTZS/ufVaZwzdtiIrd3hZPU9yYjGemEOmcFJ3BxG/0PIe3qdvs/K4bTom5EDw== X-Received: by 2002:a05:6830:6488:b0:684:e36c:62cd with SMTP id ck8-20020a056830648800b00684e36c62cdmr7057191otb.19.1675194597157; Tue, 31 Jan 2023 11:49:57 -0800 (PST) Received: from localhost ([2804:14d:7e39:8470:790c:3048:7b67:93c]) by smtp.gmail.com with ESMTPSA id s33-20020a0568302aa100b0068bd3001922sm2745833otu.45.2023.01.31.11.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 11:49:56 -0800 (PST) References: <20230130044518.3322695-1-thiago.bauermann@linaro.org> <20230130044518.3322695-2-thiago.bauermann@linaro.org> User-agent: mu4e 1.8.13; emacs 28.2 To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v3 1/8] gdbserver: Add assert in find_register_by_number In-reply-to: Date: Tue, 31 Jan 2023 19:49:54 +0000 Message-ID: <87y1pilc0t.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Thiago Jung Bauermann via Gdb-patches Reply-To: Thiago Jung Bauermann Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hello Simon, Simon Marchi writes: > On 1/29/23 23:45, Thiago Jung Bauermann wrote: >> It helped me during development, catching bugs closer to when they actually >> happened. >> >> Also remove the equivalent gdb_assert in regcache_raw_read_unsigned, since >> it's checking the same condition a few frames above. >> >> Suggested-By: Simon Marchi >> --- >> gdbserver/regcache.cc | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc >> index 3aeefcc79a37..7b896a19767d 100644 >> --- a/gdbserver/regcache.cc >> +++ b/gdbserver/regcache.cc >> @@ -199,6 +199,8 @@ regcache_cpy (struct regcache *dst, struct regcache *src) >> static const struct gdb::reg & >> find_register_by_number (const struct target_desc *tdesc, int n) >> { >> + gdb_assert (n >= 0 && n < tdesc->reg_defs.size ()); > > Since you're moving this assertion, I would suggest breaking it up in > two. I general, I suggest avoiding multiple checks in a single > gdb_assert. It makes it a little less obvious from the crash report > which condition failed exactly. So: > > gdb_assert (n >= 0); > gdb_assert (n < tdesc->reg_defs.size ()); Good point. I made this change. > The patch is fine to push right away in any case, it's good > independently from the rest of the series: Indeed. I will do that. Is it OK if I push patch 2 as well? You approved it in v2, and the only changes in v3 are to implement your review comments. > Approved-By: Simon Marchi Thanks for your review! -- Thiago