Add translations for various sub-directories
[binutils-gdb.git] / gdbsupport / common-regcache.h
blobc637163b6248870bc8c29ed60ee52ced2c84e0a7
1 /* Cache and manage the values of registers
3 Copyright (C) 2014-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef GDBSUPPORT_COMMON_REGCACHE_H
21 #define GDBSUPPORT_COMMON_REGCACHE_H
23 struct reg_buffer_common;
25 /* This header is a stopgap until we have an independent regcache. */
27 enum register_status : signed char
29 /* The register value is not in the cache, and we don't know yet
30 whether it's available in the target (or traceframe). */
31 REG_UNKNOWN = 0,
33 /* The register value is valid and cached. */
34 REG_VALID = 1,
36 /* The register value is unavailable. E.g., we're inspecting a
37 traceframe, and this register wasn't collected. Note that this
38 "unavailable" is different from saying the register does not
39 exist in the target's architecture --- in that case, the target
40 should have given us a target description that does not include
41 the register in the first place. */
42 REG_UNAVAILABLE = -1
45 /* Return a pointer to the register cache associated with the
46 thread specified by PTID. This function must be provided by
47 the client. */
49 extern reg_buffer_common *get_thread_regcache_for_ptid (ptid_t ptid);
51 /* Read the PC register. This function must be provided by the
52 client. */
54 extern CORE_ADDR regcache_read_pc (reg_buffer_common *regcache);
56 /* Read the PC register. If PC cannot be read, return 0.
57 This is a wrapper around 'regcache_read_pc'. */
59 extern CORE_ADDR regcache_read_pc_protected (reg_buffer_common *regcache);
61 /* Read a raw register into a unsigned integer. */
62 extern enum register_status
63 regcache_raw_read_unsigned (reg_buffer_common *regcache, int regnum,
64 ULONGEST *val);
66 ULONGEST regcache_raw_get_unsigned (reg_buffer_common *regcache, int regnum);
68 struct reg_buffer_common
70 virtual ~reg_buffer_common () = default;
72 /* Get the availability status of the value of register REGNUM in this
73 buffer. */
74 virtual register_status get_register_status (int regnum) const = 0;
76 /* Return the size of register numbered REGNUM in this buffer. */
77 virtual int register_size (int regnum) const = 0;
79 /* Supply register REGNUM, whose contents are stored in SRC, to this register
80 buffer. */
81 virtual void raw_supply (int regnum, gdb::array_view<const gdb_byte> src)
82 = 0;
84 void raw_supply (int regnum, const uint64_t *src)
86 raw_supply (regnum,
87 gdb::make_array_view ((const gdb_byte *) src, sizeof (*src)));
90 void raw_supply (int regnum, const gdb_byte *src)
91 { raw_supply (regnum, gdb::make_array_view (src, register_size (regnum))); }
93 /* Supply part of register REGNUM with zeroed value. Start at OFFSET in
94 the register, with size SIZE. The rest of the register is left
95 untouched. */
96 virtual void raw_supply_part_zeroed (int regnum, int offset, size_t size)
97 = 0;
99 /* Collect register REGNUM from this register buffer and store its contents in
100 DST. */
101 virtual void raw_collect (int regnum, gdb::array_view<gdb_byte> dst) const
102 = 0;
104 void raw_collect (int regnum, uint64_t *dst) const
106 raw_collect (regnum,
107 gdb::make_array_view ((gdb_byte *) dst, sizeof (*dst)));
110 void raw_collect (int regnum, gdb_byte *dst)
111 { raw_collect (regnum, gdb::make_array_view (dst, register_size (regnum))); }
113 /* Compare the contents of the register stored in the regcache (ignoring the
114 first OFFSET bytes) to the contents of BUF (without any offset). Returns
115 true if the same. */
116 virtual bool raw_compare (int regnum, const void *buf, int offset) const = 0;
119 #endif /* GDBSUPPORT_COMMON_REGCACHE_H */