GDBserver

regcache.h
Go to the documentation of this file.
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
32 {
33 /* The regcache's target description. */
34 const struct target_desc *tdesc;
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;
42 int registers_owned;
43 unsigned char *registers;
44 #ifndef IN_PROCESS_AGENT
45 /* One of REG_UNAVAILBLE or REG_VALID. */
46 unsigned char *register_status;
47 #endif
48 };
49
50 struct regcache *init_register_cache (struct regcache *regcache,
51 const struct target_desc *tdesc,
52 unsigned char *regbuf);
53
54 void regcache_cpy (struct regcache *dst, struct regcache *src);
55
56 /* Create a new register cache for INFERIOR. */
57
58 struct regcache *new_register_cache (const struct target_desc *tdesc);
59
60 struct regcache *get_thread_regcache (struct thread_info *thread, int fetch);
61
62 /* Release all memory associated with the register cache for INFERIOR. */
63
64 void free_register_cache (struct regcache *regcache);
65
66 /* Invalidate cached registers for one thread. */
67
68 void regcache_invalidate_thread (struct thread_info *);
69
70 /* Invalidate cached registers for all threads of the given process. */
71
72 void regcache_invalidate_pid (int pid);
73
74 /* Invalidate cached registers for all threads of the current
75 process. */
76
77 void regcache_invalidate (void);
78
79 /* Invalidate and release the register cache of all threads of the
80 current process. */
81
82 void regcache_release (void);
83
84 /* Convert all registers to a string in the currently specified remote
85 format. */
86
87 void registers_to_string (struct regcache *regcache, char *buf);
88
89 /* Convert a string to register values and fill our register cache. */
90
91 void registers_from_string (struct regcache *regcache, char *buf);
92
93 /* For regcache_read_pc see common/common-regcache.h. */
94
95 void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
96
97 /* Return a pointer to the description of register ``n''. */
98
99 struct reg *find_register_by_number (const struct target_desc *tdesc, int n);
100
101 int register_cache_size (const struct target_desc *tdesc);
102
103 int register_size (const struct target_desc *tdesc, int n);
104
105 int find_regno (const struct target_desc *tdesc, const char *name);
106
107 void supply_register (struct regcache *regcache, int n, const void *buf);
108
109 void supply_register_zeroed (struct regcache *regcache, int n);
110
111 void supply_register_by_name (struct regcache *regcache,
112 const char *name, const void *buf);
113
114 void supply_regblock (struct regcache *regcache, const void *buf);
115
116 void collect_register (struct regcache *regcache, int n, void *buf);
117
118 void collect_register_as_string (struct regcache *regcache, int n, char *buf);
119
120 void collect_register_by_name (struct regcache *regcache,
121 const char *name, void *buf);
122
123 #endif /* REGCACHE_H */
regcache::tdesc
const struct target_desc * tdesc
Definition: regcache.h:34
registers_to_string
void registers_to_string(struct regcache *regcache, char *buf)
Definition: regcache.c:203
regcache::registers_valid
int registers_valid
Definition: regcache.h:41
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
common-regcache.h
regcache_invalidate_thread
void regcache_invalidate_thread(struct thread_info *)
Definition: regcache.c:75
name
const char * name
Definition: tracepoint.c:180
supply_regblock
void supply_regblock(struct regcache *regcache, const void *buf)
Definition: regcache.c:358
regcache::registers_owned
int registers_owned
Definition: regcache.h:42
find_register_by_number
struct reg * find_register_by_number(const struct target_desc *tdesc, int n)
Definition: regcache.c:259
regcache
Definition: regcache.h:31
regcache::registers
unsigned char * registers
Definition: regcache.h:43
regcache::register_status
unsigned char * register_status
Definition: regcache.h:46
thread_info
Definition: gdbthread.h:30
free_register_cache
void free_register_cache(struct regcache *regcache)
Definition: regcache.c:170
collect_register
void collect_register(struct regcache *regcache, int n, void *buf)
Definition: regcache.c:402
regcache_write_pc
void regcache_write_pc(struct regcache *regcache, CORE_ADDR pc)
Definition: regcache.c:464
regcache_invalidate_pid
void regcache_invalidate_pid(int pid)
Definition: regcache.c:99
register_size
int register_size(const struct target_desc *tdesc, int n)
Definition: regcache.c:293
collect_register_as_string
void collect_register_as_string(struct regcache *regcache, int n, char *buf)
Definition: regcache.c:434
find_regno
int find_regno(const struct target_desc *tdesc, const char *name)
Definition: regcache.c:243
supply_register_zeroed
void supply_register_zeroed(struct regcache *regcache, int n)
Definition: regcache.c:343
get_thread_regcache
struct regcache * get_thread_regcache(struct thread_info *thread, int fetch)
Definition: regcache.c:27
regcache_invalidate
void regcache_invalidate(void)
Definition: regcache.c:108
regcache_cpy
void regcache_cpy(struct regcache *dst, struct regcache *src)
Definition: regcache.c:184
regcache_release
void regcache_release(void)
Definition: regcache.c:279
registers_from_string
void registers_from_string(struct regcache *regcache, char *buf)
Definition: regcache.c:226
new_register_cache
struct regcache * new_register_cache(const struct target_desc *tdesc)
Definition: regcache.c:160
target_desc
Definition: tdesc.h:33
collect_register_by_name
void collect_register_by_name(struct regcache *regcache, const char *name, void *buf)
Definition: regcache.c:441
supply_register
void supply_register(struct regcache *regcache, int n, const void *buf)
Definition: regcache.c:318
supply_register_by_name
void supply_register_by_name(struct regcache *regcache, const char *name, const void *buf)
Definition: regcache.c:393
init_register_cache
struct regcache * init_register_cache(struct regcache *regcache, const struct target_desc *tdesc, unsigned char *regbuf)
Definition: regcache.c:119
register_cache_size
int register_cache_size(const struct target_desc *tdesc)
Definition: regcache.c:287