From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-x335.google.com with SMTP id cm26-20020a056830651a00b00684e5c0108dso5759369otb.9 for ; Tue, 31 Jan 2023 11:49:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=cBQsrsHETAKpI3ah/XMRVID2jGHmTy3+Kiwl3UGeutw=; b=qyYqXiNeaYg7ocOTddqenFjuv2rptzFNdn/Nxs0+sNPKV3R+wU6I2JTHK5OfhWT5wO 9K3JSUgTYZilK/dZT1BxJ13Ph3q6sbTLphqjTha3/W0svzvlyrIMmZaGP2AN1qgx9XLO Ev0LNZrp2OQ8VILAcumXb0A5Xd4vcl5Wl+u9TJQ3LOornRtDKhsRX9iuGT3c9gv6etXn AsRkt6Yum9HH0BphBhqYvUrE9Sik69pWR31ArFIHqfB+pwIumui/aoPP99GMkjl9BH3F 5sjfz07dxKIpuWlbiFL6VaGFDvGLTUac7CXbJ6G9bhqFAXRXUVC5SqR5ml+aPK37BWDG QvEg== 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 From: Thiago Jung Bauermann 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-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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