Add reg_buffer_common
[deliverable/binutils-gdb.git] / gdb / gdbserver / regcache.h
1 /* Register support routines for the remote server for GDB.
2 Copyright (C) 2001-2018 Free Software Foundation, Inc.
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
8 the Free Software Foundation; either version 3 of the License, or
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
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #ifndef REGCACHE_H
20 #define REGCACHE_H
21
22 #include "common-regcache.h"
23
24 struct thread_info;
25 struct target_desc;
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
31 struct regcache : public reg_buffer_common
32 {
33 /* The regcache's target description. */
34 const struct target_desc *tdesc = nullptr;
35
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. */
41 int registers_valid = 0;
42 int registers_owned = 0;
43 unsigned char *registers = nullptr;
44 #ifndef IN_PROCESS_AGENT
45 /* One of REG_UNAVAILBLE or REG_VALID. */
46 unsigned char *register_status = nullptr;
47 #endif
48
49 /* See common/common-regcache.h. */
50 enum register_status get_register_status (int regnum) const override;
51
52 /* See common/common-regcache.h. */
53 void raw_supply (int regnum, const void *buf) override;
54
55 /* See common/common-regcache.h. */
56 void raw_collect (int regnum, void *buf) const override;
57 };
58
59 struct regcache *init_register_cache (struct regcache *regcache,
60 const struct target_desc *tdesc,
61 unsigned char *regbuf);
62
63 void regcache_cpy (struct regcache *dst, struct regcache *src);
64
65 /* Create a new register cache for INFERIOR. */
66
67 struct regcache *new_register_cache (const struct target_desc *tdesc);
68
69 struct regcache *get_thread_regcache (struct thread_info *thread, int fetch);
70
71 /* Release all memory associated with the register cache for INFERIOR. */
72
73 void free_register_cache (struct regcache *regcache);
74
75 /* Invalidate cached registers for one thread. */
76
77 void regcache_invalidate_thread (struct thread_info *);
78
79 /* Invalidate cached registers for all threads of the given process. */
80
81 void regcache_invalidate_pid (int pid);
82
83 /* Invalidate cached registers for all threads of the current
84 process. */
85
86 void regcache_invalidate (void);
87
88 /* Invalidate and release the register cache of all threads of the
89 current process. */
90
91 void regcache_release (void);
92
93 /* Convert all registers to a string in the currently specified remote
94 format. */
95
96 void registers_to_string (struct regcache *regcache, char *buf);
97
98 /* Convert a string to register values and fill our register cache. */
99
100 void registers_from_string (struct regcache *regcache, char *buf);
101
102 /* For regcache_read_pc see common/common-regcache.h. */
103
104 void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
105
106 int register_cache_size (const struct target_desc *tdesc);
107
108 int register_size (const struct target_desc *tdesc, int n);
109
110 int find_regno (const struct target_desc *tdesc, const char *name);
111
112 void supply_register (struct regcache *regcache, int n, const void *buf);
113
114 void supply_register_zeroed (struct regcache *regcache, int n);
115
116 void supply_register_by_name (struct regcache *regcache,
117 const char *name, const void *buf);
118
119 void supply_register_by_name_zeroed (struct regcache *regcache,
120 const char *name);
121
122 void supply_regblock (struct regcache *regcache, const void *buf);
123
124 void collect_register (struct regcache *regcache, int n, void *buf);
125
126 void collect_register_as_string (struct regcache *regcache, int n, char *buf);
127
128 void collect_register_by_name (struct regcache *regcache,
129 const char *name, void *buf);
130
131 #endif /* REGCACHE_H */
This page took 0.032544 seconds and 4 git commands to generate.