GDB (API)
|
00001 /* Cache and manage the values of registers for GDB, the GNU debugger. 00002 00003 Copyright (C) 1986-2013 Free Software Foundation, Inc. 00004 00005 This file is part of GDB. 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00019 00020 #ifndef REGCACHE_H 00021 #define REGCACHE_H 00022 00023 struct regcache; 00024 struct gdbarch; 00025 struct address_space; 00026 00027 extern struct regcache *get_current_regcache (void); 00028 extern struct regcache *get_thread_regcache (ptid_t ptid); 00029 extern struct regcache *get_thread_arch_regcache (ptid_t, struct gdbarch *); 00030 extern struct regcache *get_thread_arch_aspace_regcache (ptid_t, 00031 struct gdbarch *, 00032 struct address_space *); 00033 00034 void regcache_xfree (struct regcache *regcache); 00035 struct cleanup *make_cleanup_regcache_xfree (struct regcache *regcache); 00036 struct regcache *regcache_xmalloc (struct gdbarch *gdbarch, 00037 struct address_space *aspace); 00038 00039 /* Return REGCACHE's architecture. */ 00040 00041 extern struct gdbarch *get_regcache_arch (const struct regcache *regcache); 00042 00043 /* Return REGCACHE's address space. */ 00044 00045 extern struct address_space *get_regcache_aspace (const struct regcache *); 00046 00047 enum register_status 00048 { 00049 /* The register value is not in the cache, and we don't know yet 00050 whether it's available in the target (or traceframe). */ 00051 REG_UNKNOWN = 0, 00052 00053 /* The register value is valid and cached. */ 00054 REG_VALID = 1, 00055 00056 /* The register value is unavailable. E.g., we're inspecting a 00057 traceframe, and this register wasn't collected. Note that this 00058 is different a different "unavailable" from saying the register 00059 does not exist in the target's architecture --- in that case, 00060 the target should have given us a target description that does 00061 not include the register in the first place. */ 00062 REG_UNAVAILABLE = -1 00063 }; 00064 00065 enum register_status regcache_register_status (const struct regcache *regcache, 00066 int regnum); 00067 00068 /* Transfer a raw register [0..NUM_REGS) between core-gdb and the 00069 regcache. The read variants return the status of the register. */ 00070 00071 enum register_status regcache_raw_read (struct regcache *regcache, 00072 int rawnum, gdb_byte *buf); 00073 void regcache_raw_write (struct regcache *regcache, int rawnum, 00074 const gdb_byte *buf); 00075 extern enum register_status 00076 regcache_raw_read_signed (struct regcache *regcache, 00077 int regnum, LONGEST *val); 00078 extern enum register_status 00079 regcache_raw_read_unsigned (struct regcache *regcache, 00080 int regnum, ULONGEST *val); 00081 extern void regcache_raw_write_signed (struct regcache *regcache, 00082 int regnum, LONGEST val); 00083 extern void regcache_raw_write_unsigned (struct regcache *regcache, 00084 int regnum, ULONGEST val); 00085 00086 /* Partial transfer of raw registers. These perform read, modify, 00087 write style operations. The read variant returns the status of the 00088 register. */ 00089 00090 extern enum register_status 00091 regcache_raw_read_part (struct regcache *regcache, int regnum, 00092 int offset, int len, gdb_byte *buf); 00093 void regcache_raw_write_part (struct regcache *regcache, int regnum, 00094 int offset, int len, const gdb_byte *buf); 00095 00096 void regcache_invalidate (struct regcache *regcache, int regnum); 00097 00098 /* Transfer of pseudo-registers. The read variants return a register 00099 status, as an indication of when a ``cooked'' register was 00100 constructed from valid, invalid or unavailable ``raw'' 00101 registers. */ 00102 00103 /* Transfer a cooked register [0..NUM_REGS+NUM_PSEUDO_REGS). */ 00104 enum register_status regcache_cooked_read (struct regcache *regcache, 00105 int rawnum, gdb_byte *buf); 00106 void regcache_cooked_write (struct regcache *regcache, int rawnum, 00107 const gdb_byte *buf); 00108 00109 /* Read register REGNUM from REGCACHE and return a new value. This 00110 will call mark_value_bytes_unavailable as appropriate. */ 00111 00112 struct value *regcache_cooked_read_value (struct regcache *regcache, 00113 int regnum); 00114 00115 /* Read a register as a signed/unsigned quantity. */ 00116 extern enum register_status 00117 regcache_cooked_read_signed (struct regcache *regcache, 00118 int regnum, LONGEST *val); 00119 extern enum register_status 00120 regcache_cooked_read_unsigned (struct regcache *regcache, 00121 int regnum, ULONGEST *val); 00122 extern void regcache_cooked_write_signed (struct regcache *regcache, 00123 int regnum, LONGEST val); 00124 extern void regcache_cooked_write_unsigned (struct regcache *regcache, 00125 int regnum, ULONGEST val); 00126 00127 /* Partial transfer of a cooked register. These perform read, modify, 00128 write style operations. */ 00129 00130 enum register_status regcache_cooked_read_part (struct regcache *regcache, 00131 int regnum, int offset, 00132 int len, gdb_byte *buf); 00133 void regcache_cooked_write_part (struct regcache *regcache, int regnum, 00134 int offset, int len, const gdb_byte *buf); 00135 00136 /* Special routines to read/write the PC. */ 00137 00138 extern CORE_ADDR regcache_read_pc (struct regcache *regcache); 00139 extern void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc); 00140 00141 /* Transfer a raw register [0..NUM_REGS) between the regcache and the 00142 target. These functions are called by the target in response to a 00143 target_fetch_registers() or target_store_registers(). */ 00144 00145 extern void regcache_raw_supply (struct regcache *regcache, 00146 int regnum, const void *buf); 00147 extern void regcache_raw_collect (const struct regcache *regcache, 00148 int regnum, void *buf); 00149 00150 00151 /* The type of a register. This function is slightly more efficient 00152 then its gdbarch vector counterpart since it returns a precomputed 00153 value stored in a table. */ 00154 00155 extern struct type *register_type (struct gdbarch *gdbarch, int regnum); 00156 00157 00158 /* Return the size of register REGNUM. All registers should have only 00159 one size. */ 00160 00161 extern int register_size (struct gdbarch *gdbarch, int regnum); 00162 00163 00164 /* Save/restore a register cache. The set of registers saved / 00165 restored into the DST regcache determined by the save_reggroup / 00166 restore_reggroup respectively. COOKED_READ returns zero iff the 00167 register's value can't be returned. */ 00168 00169 typedef enum register_status (regcache_cooked_read_ftype) (void *src, 00170 int regnum, 00171 gdb_byte *buf); 00172 00173 extern void regcache_save (struct regcache *dst, 00174 regcache_cooked_read_ftype *cooked_read, 00175 void *cooked_read_context); 00176 00177 /* Copy/duplicate the contents of a register cache. By default, the 00178 operation is pass-through. Writes to DST and reads from SRC will 00179 go through to the target. 00180 00181 The ``cpy'' functions can not have overlapping SRC and DST buffers. 00182 00183 ``no passthrough'' versions do not go through to the target. They 00184 only transfer values already in the cache. */ 00185 00186 extern struct regcache *regcache_dup (struct regcache *regcache); 00187 extern void regcache_cpy (struct regcache *dest, struct regcache *src); 00188 extern void regcache_cpy_no_passthrough (struct regcache *dest, 00189 struct regcache *src); 00190 00191 extern void registers_changed (void); 00192 extern void registers_changed_ptid (ptid_t); 00193 00194 #endif /* REGCACHE_H */