From: Tankut Baris Aktemur Date: Wed, 29 Jan 2025 09:50:31 +0000 (+0100) Subject: gdbserver: use REG_UNKNOWN for a regcache's register statuses X-Git-Tag: binutils-2_45~1808 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5a42cbfd9643c3c418efc553dd84a9293e0336e;p=thirdparty%2Fbinutils-gdb.git gdbserver: use REG_UNKNOWN for a regcache's register statuses 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. Approved-By: Simon Marchi --- diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 99291e40e09..8cdca5083bc 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; @@ -133,7 +133,7 @@ regcache::regcache (const target_desc *tdesc) = (unsigned char *) xcalloc (1, tdesc->registers_size); 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 1a252d40255..287dc549d88 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; /* Construct a regcache using the register layout described by TDESC.