Message ID | 20230130044518.3322695-2-thiago.bauermann@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB4F23858031 for <patchwork@sourceware.org>; Mon, 30 Jan 2023 04:46:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB4F23858031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675053964; bh=T556B1qDxApN1W5PgdX1i1AUoiIe1HwTGpyed7z3xJs=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=xsBFyZKFnZonXvumOqZkEolW0iLSOdfZvtJuyNRejoJirY8NCmJg0AlPC2ojYIIsn fQRnrUnbOMxO/0cdpB+EuJeEyTdEiQvtjMiQF5giJ/ofnf1Hh7LDNEOQ+VjBmVxSHQ vvqKeQaB4jqmA0kOuzEtgIBGUWvjfcyElUwoQIhM= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 6E3CC3858D38 for <gdb-patches@sourceware.org>; Mon, 30 Jan 2023 04:45:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E3CC3858D38 Received: by mail-ot1-x329.google.com with SMTP id 70-20020a9d084c000000b0068bccf754f1so722294oty.7 for <gdb-patches@sourceware.org>; Sun, 29 Jan 2023 20:45:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T556B1qDxApN1W5PgdX1i1AUoiIe1HwTGpyed7z3xJs=; b=MggqA/9ChqQW2HSIdandLfA8BY358xqxOtKU3xfcISBz7w2q5IglhP/WjipDkggYvg lH37+khhw3fDZ30u6U9SODh+0BiJLyUSud+DhjEpyKBX/V5uI/Vg9qSmXv5W4MCYpZgF 7jUbIh2b72lVccazWe5jRVeUgTlTu1YHvdodSrTHJHp1GqFVGIEt+MY+XTZPX3sLH3gb 8PkXAnAvPk+tpuQR3U40fqJXXj0K9JbiDEtRN7W5u+eYfVfa/m7B1ymc+NWsXzi3Gt7U nDsP8ThtrmOySCA54Ev+3Qiah/Tm5mu9wPJijI7XbVKWhg6JaICV9XqiLTKi0h0pBfTL cvXQ== X-Gm-Message-State: AO0yUKX2l7sF5OMQkaJ0r9bnfM+faTshFP0H0WwB75H3AEVu0zUC038x KHXUgLaAbSk2GkptqCcxXn5ALPVqtngeRAZN X-Google-Smtp-Source: AK7set/XX8snF8Y9m6rL3FIRuSiuTIgscBymbTgms+lPrlvF4s75OZz9DypIAHXx/5OskR0ZbmtDvA== X-Received: by 2002:a9d:7190:0:b0:68b:c44a:b616 with SMTP id o16-20020a9d7190000000b0068bc44ab616mr701544otj.19.1675053939728; Sun, 29 Jan 2023 20:45:39 -0800 (PST) Received: from localhost ([2804:14d:7e39:8470:df99:10bd:7dca:b2e9]) by smtp.gmail.com with ESMTPSA id j9-20020a056830270900b0068b6bcaa037sm4005484otu.40.2023.01.29.20.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jan 2023 20:45:39 -0800 (PST) To: gdb-patches@sourceware.org Cc: Thiago Jung Bauermann <thiago.bauermann@linaro.org>, Simon Marchi <simon.marchi@efficios.com> Subject: [PATCH v3 1/8] gdbserver: Add assert in find_register_by_number Date: Mon, 30 Jan 2023 04:45:11 +0000 Message-Id: <20230130044518.3322695-2-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130044518.3322695-1-thiago.bauermann@linaro.org> References: <20230130044518.3322695-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Thiago Jung Bauermann via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Thiago Jung Bauermann <thiago.bauermann@linaro.org> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
gdbserver improvements for AArch64 SVE support
|
|
Commit Message
Thiago Jung Bauermann
Jan. 30, 2023, 4:45 a.m. UTC
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 <simon.marchi@efficios.com> --- gdbserver/regcache.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
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 <simon.marchi@efficios.com> > --- > 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 ()); The patch is fine to push right away in any case, it's good independently from the rest of the series: Approved-By: Simon Marchi <simon.marchi@efficios.com> Simon
Hello Simon, Simon Marchi <simon.marchi@efficios.com> 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 <simon.marchi@efficios.com> >> --- >> 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 <simon.marchi@efficios.com> Thanks for your review!
On 1/31/23 14:49, Thiago Jung Bauermann via Gdb-patches wrote: > > Hello Simon, > > Simon Marchi <simon.marchi@efficios.com> 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 <simon.marchi@efficios.com> >>> --- >>> 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. Probably, I will take a look (Andrew has left a comment already though). Simon
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 ()); + return tdesc->reg_defs[n]; } @@ -440,8 +442,6 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum, int size; gdb_assert (regcache != NULL); - gdb_assert (regnum >= 0 - && regnum < regcache->tdesc->reg_defs.size ()); size = register_size (regcache->tdesc, regnum);