Commit | Line | Data |
---|---|---|
0a30fbc4 | 1 | /* Register support routines for the remote server for GDB. |
b811d2c2 | 2 | Copyright (C) 2001-2020 Free Software Foundation, Inc. |
0a30fbc4 DJ |
3 | |
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 8 | the Free Software Foundation; either version 3 of the License, or |
0a30fbc4 DJ |
9 | (at your option) any later version. |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
0a30fbc4 | 18 | |
1a5c2598 TT |
19 | #ifndef GDBSERVER_REGCACHE_H |
20 | #define GDBSERVER_REGCACHE_H | |
0a30fbc4 | 21 | |
268a13a5 | 22 | #include "gdbsupport/common-regcache.h" |
361c8ade | 23 | |
442ea881 | 24 | struct thread_info; |
3aee8918 | 25 | struct target_desc; |
442ea881 PA |
26 | |
27 | /* The data for the register cache. Note that we have one per | |
28 | inferior; this is primarily for simplicity, as the performance | |
29 | benefit is minimal. */ | |
30 | ||
9c861883 | 31 | struct regcache : public reg_buffer_common |
442ea881 | 32 | { |
3aee8918 | 33 | /* The regcache's target description. */ |
9c861883 | 34 | const struct target_desc *tdesc = nullptr; |
3aee8918 | 35 | |
1c79eb8a PA |
36 | /* Whether the REGISTERS buffer's contents are valid. If false, we |
37 | haven't fetched the registers from the target yet. Not that this | |
38 | register cache is _not_ pass-through, unlike GDB's. Note that | |
39 | "valid" here is unrelated to whether the registers are available | |
40 | in a traceframe. For that, check REGISTER_STATUS below. */ | |
9c861883 AH |
41 | int registers_valid = 0; |
42 | int registers_owned = 0; | |
43 | unsigned char *registers = nullptr; | |
1c79eb8a | 44 | #ifndef IN_PROCESS_AGENT |
30baf67b | 45 | /* One of REG_UNAVAILABLE or REG_VALID. */ |
9c861883 | 46 | unsigned char *register_status = nullptr; |
1c79eb8a | 47 | #endif |
9c861883 | 48 | |
268a13a5 | 49 | /* See gdbsupport/common-regcache.h. */ |
9c861883 AH |
50 | enum register_status get_register_status (int regnum) const override; |
51 | ||
268a13a5 | 52 | /* See gdbsupport/common-regcache.h. */ |
9c861883 AH |
53 | void raw_supply (int regnum, const void *buf) override; |
54 | ||
268a13a5 | 55 | /* See gdbsupport/common-regcache.h. */ |
9c861883 | 56 | void raw_collect (int regnum, void *buf) const override; |
f868386e | 57 | |
268a13a5 | 58 | /* See gdbsupport/common-regcache.h. */ |
f868386e | 59 | bool raw_compare (int regnum, const void *buf, int offset) const override; |
442ea881 | 60 | }; |
d06f167a | 61 | |
219f2f23 | 62 | struct regcache *init_register_cache (struct regcache *regcache, |
3aee8918 | 63 | const struct target_desc *tdesc, |
219f2f23 PA |
64 | unsigned char *regbuf); |
65 | ||
66 | void regcache_cpy (struct regcache *dst, struct regcache *src); | |
67 | ||
c04a1aa8 DJ |
68 | /* Create a new register cache for INFERIOR. */ |
69 | ||
3aee8918 | 70 | struct regcache *new_register_cache (const struct target_desc *tdesc); |
442ea881 PA |
71 | |
72 | struct regcache *get_thread_regcache (struct thread_info *thread, int fetch); | |
c04a1aa8 DJ |
73 | |
74 | /* Release all memory associated with the register cache for INFERIOR. */ | |
75 | ||
442ea881 | 76 | void free_register_cache (struct regcache *regcache); |
0d62e5e8 | 77 | |
3aee8918 PA |
78 | /* Invalidate cached registers for one thread. */ |
79 | ||
80 | void regcache_invalidate_thread (struct thread_info *); | |
81 | ||
80d82c19 JB |
82 | /* Invalidate cached registers for all threads of the given process. */ |
83 | ||
84 | void regcache_invalidate_pid (int pid); | |
85 | ||
3aee8918 PA |
86 | /* Invalidate cached registers for all threads of the current |
87 | process. */ | |
0d62e5e8 | 88 | |
0d62e5e8 | 89 | void regcache_invalidate (void); |
c04a1aa8 | 90 | |
3aee8918 PA |
91 | /* Invalidate and release the register cache of all threads of the |
92 | current process. */ | |
93 | ||
94 | void regcache_release (void); | |
95 | ||
0a30fbc4 DJ |
96 | /* Convert all registers to a string in the currently specified remote |
97 | format. */ | |
98 | ||
442ea881 | 99 | void registers_to_string (struct regcache *regcache, char *buf); |
0a30fbc4 DJ |
100 | |
101 | /* Convert a string to register values and fill our register cache. */ | |
102 | ||
442ea881 | 103 | void registers_from_string (struct regcache *regcache, char *buf); |
0a30fbc4 | 104 | |
268a13a5 | 105 | /* For regcache_read_pc see gdbsupport/common-regcache.h. */ |
219f2f23 PA |
106 | |
107 | void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc); | |
108 | ||
3aee8918 | 109 | int register_cache_size (const struct target_desc *tdesc); |
219f2f23 | 110 | |
3aee8918 | 111 | int register_size (const struct target_desc *tdesc, int n); |
0a30fbc4 | 112 | |
3aee8918 | 113 | int find_regno (const struct target_desc *tdesc, const char *name); |
0a30fbc4 | 114 | |
442ea881 | 115 | void supply_register (struct regcache *regcache, int n, const void *buf); |
0729219d | 116 | |
1c79eb8a PA |
117 | void supply_register_zeroed (struct regcache *regcache, int n); |
118 | ||
442ea881 PA |
119 | void supply_register_by_name (struct regcache *regcache, |
120 | const char *name, const void *buf); | |
0729219d | 121 | |
8ee22052 AB |
122 | void supply_register_by_name_zeroed (struct regcache *regcache, |
123 | const char *name); | |
124 | ||
219f2f23 PA |
125 | void supply_regblock (struct regcache *regcache, const void *buf); |
126 | ||
442ea881 | 127 | void collect_register (struct regcache *regcache, int n, void *buf); |
0729219d | 128 | |
442ea881 | 129 | void collect_register_as_string (struct regcache *regcache, int n, char *buf); |
0d62e5e8 | 130 | |
493e2a69 MS |
131 | void collect_register_by_name (struct regcache *regcache, |
132 | const char *name, void *buf); | |
0729219d | 133 | |
cb197132 PA |
134 | /* Read a raw register as an unsigned integer. Convenience wrapper |
135 | around regcache_raw_get_unsigned that takes a register name instead | |
136 | of a register number. */ | |
137 | ||
138 | ULONGEST regcache_raw_get_unsigned_by_name (struct regcache *regcache, | |
139 | const char *name); | |
140 | ||
1a5c2598 | 141 | #endif /* GDBSERVER_REGCACHE_H */ |