regcache.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* Register support routines for the remote server for GDB.
  2. Copyright (C) 2001-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 GDBSERVER_REGCACHE_H
  15. #define GDBSERVER_REGCACHE_H
  16. #include "gdbsupport/common-regcache.h"
  17. struct thread_info;
  18. struct target_desc;
  19. /* The data for the register cache. Note that we have one per
  20. inferior; this is primarily for simplicity, as the performance
  21. benefit is minimal. */
  22. struct regcache : public reg_buffer_common
  23. {
  24. /* The regcache's target description. */
  25. const struct target_desc *tdesc = nullptr;
  26. /* Whether the REGISTERS buffer's contents are valid. If false, we
  27. haven't fetched the registers from the target yet. Not that this
  28. register cache is _not_ pass-through, unlike GDB's. Note that
  29. "valid" here is unrelated to whether the registers are available
  30. in a traceframe. For that, check REGISTER_STATUS below. */
  31. int registers_valid = 0;
  32. int registers_owned = 0;
  33. unsigned char *registers = nullptr;
  34. #ifndef IN_PROCESS_AGENT
  35. /* One of REG_UNAVAILABLE or REG_VALID. */
  36. unsigned char *register_status = nullptr;
  37. #endif
  38. /* See gdbsupport/common-regcache.h. */
  39. enum register_status get_register_status (int regnum) const override;
  40. /* See gdbsupport/common-regcache.h. */
  41. void raw_supply (int regnum, const void *buf) override;
  42. /* See gdbsupport/common-regcache.h. */
  43. void raw_collect (int regnum, void *buf) const override;
  44. /* See gdbsupport/common-regcache.h. */
  45. bool raw_compare (int regnum, const void *buf, int offset) const override;
  46. };
  47. struct regcache *init_register_cache (struct regcache *regcache,
  48. const struct target_desc *tdesc,
  49. unsigned char *regbuf);
  50. void regcache_cpy (struct regcache *dst, struct regcache *src);
  51. /* Create a new register cache for INFERIOR. */
  52. struct regcache *new_register_cache (const struct target_desc *tdesc);
  53. struct regcache *get_thread_regcache (struct thread_info *thread, int fetch);
  54. /* Release all memory associated with the register cache for INFERIOR. */
  55. void free_register_cache (struct regcache *regcache);
  56. /* Invalidate cached registers for one thread. */
  57. void regcache_invalidate_thread (struct thread_info *);
  58. /* Invalidate cached registers for all threads of the given process. */
  59. void regcache_invalidate_pid (int pid);
  60. /* Invalidate cached registers for all threads of the current
  61. process. */
  62. void regcache_invalidate (void);
  63. /* Invalidate and release the register cache of all threads of the
  64. current process. */
  65. void regcache_release (void);
  66. /* Convert all registers to a string in the currently specified remote
  67. format. */
  68. void registers_to_string (struct regcache *regcache, char *buf);
  69. /* Convert a string to register values and fill our register cache. */
  70. void registers_from_string (struct regcache *regcache, char *buf);
  71. /* For regcache_read_pc see gdbsupport/common-regcache.h. */
  72. void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
  73. int register_cache_size (const struct target_desc *tdesc);
  74. int register_size (const struct target_desc *tdesc, int n);
  75. int find_regno (const struct target_desc *tdesc, const char *name);
  76. void supply_register (struct regcache *regcache, int n, const void *buf);
  77. void supply_register_zeroed (struct regcache *regcache, int n);
  78. void supply_register_by_name (struct regcache *regcache,
  79. const char *name, const void *buf);
  80. void supply_register_by_name_zeroed (struct regcache *regcache,
  81. const char *name);
  82. void supply_regblock (struct regcache *regcache, const void *buf);
  83. void collect_register (struct regcache *regcache, int n, void *buf);
  84. void collect_register_as_string (struct regcache *regcache, int n, char *buf);
  85. void collect_register_by_name (struct regcache *regcache,
  86. const char *name, void *buf);
  87. /* Read a raw register as an unsigned integer. Convenience wrapper
  88. around regcache_raw_get_unsigned that takes a register name instead
  89. of a register number. */
  90. ULONGEST regcache_raw_get_unsigned_by_name (struct regcache *regcache,
  91. const char *name);
  92. #endif /* GDBSERVER_REGCACHE_H */