Message ID | 893ba2a52032456c31cbb868c2f2ae4e0661b6e0.1677582745.git.tankut.baris.aktemur@intel.com |
---|---|
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 4FB63384FB67 for <patchwork@sourceware.org>; Tue, 28 Feb 2023 11:30:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4FB63384FB67 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677583851; bh=jXM6x1NbIvIi9IW6lSRvjyRwA6GdkaikXcCD7o39V2w=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=LV5k3kZvHNBDooJTmkQLKeFf2k42SOnTS6Y0UYOCcAdgHKMirQWFdq1E06/MJRHEU O2z7pPKceiIkYdltjCxOqhYXd1NjKw4IQv75u25bO42JQBGE0gkWxUtPk11vYh9oYc NpUHJoPFczCf8e5fE0xysMQULNQwv1REpA7fEAAw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 3BA633858C27 for <gdb-patches@sourceware.org>; Tue, 28 Feb 2023 11:30:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3BA633858C27 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="420374093" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="420374093" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:30:19 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="848213584" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="848213584" Received: from ultl2604.iul.intel.com (HELO localhost) ([172.28.48.47]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:30:18 -0800 To: gdb-patches@sourceware.org Subject: [PATCH 15/26] gdbserver: check for nullptr condition in regcache::get_register_status Date: Tue, 28 Feb 2023 12:28:13 +0100 Message-Id: <893ba2a52032456c31cbb868c2f2ae4e0661b6e0.1677582745.git.tankut.baris.aktemur@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <cover.1677582744.git.tankut.baris.aktemur@intel.com> References: <cover.1677582744.git.tankut.baris.aktemur@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, 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: Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
gdbserver: refactor regcache and allow gradually populating
|
|
Commit Message
Aktemur, Tankut Baris
Feb. 28, 2023, 11:28 a.m. UTC
A regcache can be initialized with a register value buffer, in which case, the register_status pointer is null. This condition is checked in set_register_status, but not in get_register_status. Do this check for consistence and safety. --- gdbserver/regcache.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Comments
On 2/28/23 06:28, Tankut Baris Aktemur via Gdb-patches wrote: > A regcache can be initialized with a register value buffer, in which > case, the register_status pointer is null. This condition is checked > in set_register_status, but not in get_register_status. Do this check > for consistence and safety. Ok, thanks, that answers my question on the previous patch :). Simon
On 2/28/23 06:28, Tankut Baris Aktemur via Gdb-patches wrote: > A regcache can be initialized with a register value buffer, in which > case, the register_status pointer is null. This condition is checked > in set_register_status, but not in get_register_status. Do this check > for consistence and safety. > --- > gdbserver/regcache.cc | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc > index ec11082be6f..0c6f1eb392b 100644 > --- a/gdbserver/regcache.cc > +++ b/gdbserver/regcache.cc > @@ -489,7 +489,10 @@ regcache::get_register_status (int regnum) const > { > #ifndef IN_PROCESS_AGENT > gdb_assert (regnum >= 0 && regnum < tdesc->reg_defs.size ()); > - return (enum register_status) (register_status[regnum]); > + if (register_status != nullptr) > + return (enum register_status) (register_status[regnum]); > + else > + return REG_VALID; > #else > return REG_VALID; > #endif > -- > 2.25.1 Thanks, that LGTM, I think it can be pushed on its own. Approved-By: Simon Marchi <simon.marchi@efficios.com> Simon
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index ec11082be6f..0c6f1eb392b 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -489,7 +489,10 @@ regcache::get_register_status (int regnum) const { #ifndef IN_PROCESS_AGENT gdb_assert (regnum >= 0 && regnum < tdesc->reg_defs.size ()); - return (enum register_status) (register_status[regnum]); + if (register_status != nullptr) + return (enum register_status) (register_status[regnum]); + else + return REG_VALID; #else return REG_VALID; #endif