common-regcache.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Cache and manage the values of registers
  2. Copyright (C) 2014-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef COMMON_COMMON_REGCACHE_H
  15. #define COMMON_COMMON_REGCACHE_H
  16. /* This header is a stopgap until we have an independent regcache. */
  17. enum register_status : signed char
  18. {
  19. /* The register value is not in the cache, and we don't know yet
  20. whether it's available in the target (or traceframe). */
  21. REG_UNKNOWN = 0,
  22. /* The register value is valid and cached. */
  23. REG_VALID = 1,
  24. /* The register value is unavailable. E.g., we're inspecting a
  25. traceframe, and this register wasn't collected. Note that this
  26. is different a different "unavailable" from saying the register
  27. does not exist in the target's architecture --- in that case,
  28. the target should have given us a target description that does
  29. not include the register in the first place. */
  30. REG_UNAVAILABLE = -1
  31. };
  32. /* Return a pointer to the register cache associated with the
  33. thread specified by PTID. This function must be provided by
  34. the client. */
  35. extern struct regcache *get_thread_regcache_for_ptid (ptid_t ptid);
  36. /* Return the size of register numbered N in REGCACHE. This function
  37. must be provided by the client. */
  38. extern int regcache_register_size (const struct regcache *regcache, int n);
  39. /* Read the PC register. This function must be provided by the
  40. client. */
  41. extern CORE_ADDR regcache_read_pc (struct regcache *regcache);
  42. /* Read the PC register. If PC cannot be read, return 0.
  43. This is a wrapper around 'regcache_read_pc'. */
  44. extern CORE_ADDR regcache_read_pc_protected (regcache *regcache);
  45. /* Read a raw register into a unsigned integer. */
  46. extern enum register_status regcache_raw_read_unsigned
  47. (struct regcache *regcache, int regnum, ULONGEST *val);
  48. ULONGEST regcache_raw_get_unsigned (struct regcache *regcache, int regnum);
  49. struct reg_buffer_common
  50. {
  51. virtual ~reg_buffer_common () = default;
  52. /* Get the availability status of the value of register REGNUM in this
  53. buffer. */
  54. virtual register_status get_register_status (int regnum) const = 0;
  55. /* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE. */
  56. virtual void raw_supply (int regnum, const void *buf) = 0;
  57. /* Collect register REGNUM from REGCACHE and store its contents in BUF. */
  58. virtual void raw_collect (int regnum, void *buf) const = 0;
  59. /* Compare the contents of the register stored in the regcache (ignoring the
  60. first OFFSET bytes) to the contents of BUF (without any offset). Returns
  61. true if the same. */
  62. virtual bool raw_compare (int regnum, const void *buf, int offset) const = 0;
  63. };
  64. #endif /* COMMON_COMMON_REGCACHE_H */