17d62b00eSchristos /* Cache and manage the values of registers 27d62b00eSchristos 3*6881a400Schristos Copyright (C) 2014-2023 Free Software Foundation, Inc. 47d62b00eSchristos 57d62b00eSchristos This file is part of GDB. 67d62b00eSchristos 77d62b00eSchristos This program is free software; you can redistribute it and/or modify 87d62b00eSchristos it under the terms of the GNU General Public License as published by 97d62b00eSchristos the Free Software Foundation; either version 3 of the License, or 107d62b00eSchristos (at your option) any later version. 117d62b00eSchristos 127d62b00eSchristos This program is distributed in the hope that it will be useful, 137d62b00eSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 147d62b00eSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 157d62b00eSchristos GNU General Public License for more details. 167d62b00eSchristos 177d62b00eSchristos You should have received a copy of the GNU General Public License 187d62b00eSchristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 197d62b00eSchristos 207d62b00eSchristos #ifndef COMMON_COMMON_REGCACHE_H 217d62b00eSchristos #define COMMON_COMMON_REGCACHE_H 227d62b00eSchristos 237d62b00eSchristos /* This header is a stopgap until we have an independent regcache. */ 247d62b00eSchristos 257d62b00eSchristos enum register_status : signed char 267d62b00eSchristos { 277d62b00eSchristos /* The register value is not in the cache, and we don't know yet 287d62b00eSchristos whether it's available in the target (or traceframe). */ 297d62b00eSchristos REG_UNKNOWN = 0, 307d62b00eSchristos 317d62b00eSchristos /* The register value is valid and cached. */ 327d62b00eSchristos REG_VALID = 1, 337d62b00eSchristos 347d62b00eSchristos /* The register value is unavailable. E.g., we're inspecting a 357d62b00eSchristos traceframe, and this register wasn't collected. Note that this 367d62b00eSchristos is different a different "unavailable" from saying the register 377d62b00eSchristos does not exist in the target's architecture --- in that case, 387d62b00eSchristos the target should have given us a target description that does 397d62b00eSchristos not include the register in the first place. */ 407d62b00eSchristos REG_UNAVAILABLE = -1 417d62b00eSchristos }; 427d62b00eSchristos 437d62b00eSchristos /* Return a pointer to the register cache associated with the 447d62b00eSchristos thread specified by PTID. This function must be provided by 457d62b00eSchristos the client. */ 467d62b00eSchristos 477d62b00eSchristos extern struct regcache *get_thread_regcache_for_ptid (ptid_t ptid); 487d62b00eSchristos 497d62b00eSchristos /* Return the size of register numbered N in REGCACHE. This function 507d62b00eSchristos must be provided by the client. */ 517d62b00eSchristos 527d62b00eSchristos extern int regcache_register_size (const struct regcache *regcache, int n); 537d62b00eSchristos 547d62b00eSchristos /* Read the PC register. This function must be provided by the 557d62b00eSchristos client. */ 567d62b00eSchristos 577d62b00eSchristos extern CORE_ADDR regcache_read_pc (struct regcache *regcache); 587d62b00eSchristos 597d62b00eSchristos /* Read the PC register. If PC cannot be read, return 0. 607d62b00eSchristos This is a wrapper around 'regcache_read_pc'. */ 617d62b00eSchristos 627d62b00eSchristos extern CORE_ADDR regcache_read_pc_protected (regcache *regcache); 637d62b00eSchristos 647d62b00eSchristos /* Read a raw register into a unsigned integer. */ 657d62b00eSchristos extern enum register_status regcache_raw_read_unsigned 667d62b00eSchristos (struct regcache *regcache, int regnum, ULONGEST *val); 677d62b00eSchristos 687d62b00eSchristos ULONGEST regcache_raw_get_unsigned (struct regcache *regcache, int regnum); 697d62b00eSchristos 707d62b00eSchristos struct reg_buffer_common 717d62b00eSchristos { 727d62b00eSchristos virtual ~reg_buffer_common () = default; 737d62b00eSchristos 747d62b00eSchristos /* Get the availability status of the value of register REGNUM in this 757d62b00eSchristos buffer. */ 767d62b00eSchristos virtual register_status get_register_status (int regnum) const = 0; 777d62b00eSchristos 787d62b00eSchristos /* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE. */ 797d62b00eSchristos virtual void raw_supply (int regnum, const void *buf) = 0; 807d62b00eSchristos 817d62b00eSchristos /* Collect register REGNUM from REGCACHE and store its contents in BUF. */ 827d62b00eSchristos virtual void raw_collect (int regnum, void *buf) const = 0; 837d62b00eSchristos 847d62b00eSchristos /* Compare the contents of the register stored in the regcache (ignoring the 857d62b00eSchristos first OFFSET bytes) to the contents of BUF (without any offset). Returns 867d62b00eSchristos true if the same. */ 877d62b00eSchristos virtual bool raw_compare (int regnum, const void *buf, int offset) const = 0; 887d62b00eSchristos }; 897d62b00eSchristos 907d62b00eSchristos #endif /* COMMON_COMMON_REGCACHE_H */ 91