From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 7a+8GSW5fGd0yQUAWB0awg (envelope-from ) for ; Tue, 07 Jan 2025 00:18:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1736227109; bh=LQkMLjiGOijxWLRawltfgbsCyV4SoY5MjI8xljYJ14s=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=YkCoEhQQGi4IgmwE+db4C1BrDKZuFM/19IYRKxlxPDSMPFJhfXyA5JdumfiRFgedE 4Rbo0otM1yWku2JijtUHXUY/AoYaczHX/osWsIi7xsIlvPdMJ0BpIQ+HIVrgdEZXWH M9CjSek/Frn8dUOsssXwXHGAxSU6RbF+IiC8E9Sc= Received: by simark.ca (Postfix, from userid 112) id 57EAF1E0BB; Tue, 7 Jan 2025 00:18:29 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.0 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=aoHzF/fV; dkim=pass (1024-bit key) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=s/hDhVrs; dkim-atps=neutral Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E98E81E091 for ; Tue, 7 Jan 2025 00:18:24 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 93E65385840F for ; Tue, 7 Jan 2025 05:18:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93E65385840F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=aoHzF/fV; dkim=pass (1024-bit key) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=s/hDhVrs Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 9C3323858D29 for ; Tue, 7 Jan 2025 05:17:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C3323858D29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9C3323858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736227065; cv=none; b=vpWtnmbFOX1Iun33gOjtR4Fef//xoJbsix/wTShp+M3JIK+ySFyUR90WekyseYWAQ4DHDg9NGDmbPBq8sHwTzsQ+NT5fRHhU2xFIeamB5xTzFtZw2FfKLgSK7dyXm8+ENlZonJHC7YcRI3cx1DJT6JRjisx+7Kn1nSoogAKklzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736227065; c=relaxed/simple; bh=LQkMLjiGOijxWLRawltfgbsCyV4SoY5MjI8xljYJ14s=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version: Subject:To:From; b=lj+5YYdrB3w7anZiqXSAqIK0MuQT8hlazVqHmhzTulzXw2imPM5ylnMp8nG8XYJVt1D0Hpla0rVJuFlLbd4yNCUvpeHW05mfXC62i6FT+YQsDcc9aEFzZhHrDTOhy5iZtZ7lzRUwg6K2yC3CWlYL01bYyDP01ukQYaGk4vN6Jvs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C3323858D29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1736227065; bh=LQkMLjiGOijxWLRawltfgbsCyV4SoY5MjI8xljYJ14s=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=aoHzF/fVNqftwjpMFIDxgk3b87MDkif7RnoPuPdrRqFFJAT+U0G0FcV5IivtudWwU /BjmK/9GVywii3eQFZ1PMM6/X1tRnJcp+b7KLMoNoSA1o7EsSDoOGFLM4uflfMyzdR kxDPYo0UBGUkr4WfUrz8aD665mwcD8cLQNTfvFnw= Received: by simark.ca (Postfix, from userid 112) id 5FA9D1E0BB; Tue, 7 Jan 2025 00:17:45 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1736227055; bh=LQkMLjiGOijxWLRawltfgbsCyV4SoY5MjI8xljYJ14s=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=s/hDhVrsuRoxydrGvOR1BkHPYTjQ+xquDNlkJW4jgDsF5TcFdH+fecK9gCPP8rVX/ h25ZblTgM5cSzdX77UMEaqxqXBnxk77420SKMD+R0tmCFAuHPSX4ok679QHI+KD2Me Ci5uQWfiFHeS6yMHldhIDFbu37Zdcu4GfOA2f61I= Received: from [10.0.0.11] (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 77C2C1E091; Tue, 7 Jan 2025 00:17:35 -0500 (EST) Message-ID: Date: Tue, 7 Jan 2025 00:17:35 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 08/11] gdbserver: use REG_UNKNOWN for a regcache's register statuses To: Tankut Baris Aktemur , gdb-patches@sourceware.org Cc: simon.marchi@efficios.com References: <20241230-upstream-gdbserver-regcache-v2-0-020a9514fcf0@intel.com> <20241230-upstream-gdbserver-regcache-v2-8-020a9514fcf0@intel.com> Content-Language: en-US From: Simon Marchi In-Reply-To: <20241230-upstream-gdbserver-regcache-v2-8-020a9514fcf0@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 2024-12-30 05:49, Tankut Baris Aktemur wrote: > When a regcache is initialized, the values of registers are not > fetched yet. Thus, initialize the register statuses to REG_UNKNOWN > instead of REG_UNAVAILABLE, because the latter rather means "we > attempted to fetch but could not obtain the value". > > The definitions of the reg status enums (from > gdbsupport/common-regcache.h) as a reminder: > > /* The register value is not in the cache, and we don't know yet > whether it's available in the target (or traceframe). */ > REG_UNKNOWN = 0, > > /* The register value is valid and cached. */ > REG_VALID = 1, > > /* The register value is unavailable. E.g., we're inspecting a > traceframe, and this register wasn't collected. Note that this > "unavailable" is different from saying the register does not > exist in the target's architecture --- in that case, the target > should have given us a target description that does not include > the register in the first place. */ > REG_UNAVAILABLE = -1 > > Similarly, when the regcache is invalidated, change all the statuses > back to REG_UNKNOWN. The change makes sense to me. I just hope that there aren't any spots that rely on the default value being REG_UNAVAILABLE. At least in tracepoint.cc, all spots that fill regcache contents manually sets the status to unavailable if needed, so that's good. > --- > gdbserver/regcache.cc | 4 ++-- > gdbserver/regcache.h | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc > index eab6bdcfc86124c25013c565c5432c98dfc27500..03e975dc00154d01798765273534ca9cdcdc7eb7 100644 > --- a/gdbserver/regcache.cc > +++ b/gdbserver/regcache.cc > @@ -52,7 +52,7 @@ get_thread_regcache (thread_info *thread, bool fetch) > > switch_to_thread (thread); > /* Invalidate all registers, to prevent stale left-overs. */ > - memset (regcache->register_status, REG_UNAVAILABLE, > + memset (regcache->register_status, REG_UNKNOWN, > regcache->tdesc->reg_defs.size ()); > fetch_inferior_registers (regcache, -1); > regcache->registers_fetched = true; > @@ -142,7 +142,7 @@ regcache::regcache (const target_desc *tdesc) > this->registers_owned = true; > this->register_status > = (unsigned char *) xmalloc (tdesc->reg_defs.size ()); > - memset ((void *) this->register_status, REG_UNAVAILABLE, > + memset ((void *) this->register_status, REG_UNKNOWN, > tdesc->reg_defs.size ()); > } > > diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h > index 08c2ddd04e1307e0493b45a944bd30b762b0663b..f3e99de443b884e13b02c8d858ea9e6ee668700f 100644 > --- a/gdbserver/regcache.h > +++ b/gdbserver/regcache.h > @@ -43,7 +43,7 @@ struct regcache : public reg_buffer_common > bool registers_owned = false; > unsigned char *registers = nullptr; > #ifndef IN_PROCESS_AGENT > - /* One of REG_UNAVAILABLE or REG_VALID. */ > + /* See gdbsupport/common-regcache.h. */ > unsigned char *register_status = nullptr; I don't think this comment change is super clear. I guess you want to refer to `enum register_status`, defined in that file? The same in GDB was changed to use `enum register_status` as the element type, making it more self-documenting: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aac0d564cea04b1c5f386e8cea924ca59057e8b4 I think it would make sense to do it in gdbserver as well. Simon