daily update
[deliverable/binutils-gdb.git] / gdb / regcache.c
CommitLineData
32178cab 1/* Cache and manage the values of registers for GDB, the GNU debugger.
3fadccb3
AC
2
3 Copyright 1986, 1987, 1989, 1991, 1994, 1995, 1996, 1998, 2000,
9564ee9f 4 2001, 2002, 2004 Free Software Foundation, Inc.
32178cab
MS
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
22
23#include "defs.h"
32178cab
MS
24#include "inferior.h"
25#include "target.h"
26#include "gdbarch.h"
705152c5 27#include "gdbcmd.h"
4e052eda 28#include "regcache.h"
b59ff9d5 29#include "reggroups.h"
61a0eb5b 30#include "gdb_assert.h"
b66d6d2e 31#include "gdb_string.h"
af030b9a 32#include "gdbcmd.h" /* For maintenanceprintlist. */
f4c5303c 33#include "observer.h"
32178cab
MS
34
35/*
36 * DATA STRUCTURE
37 *
38 * Here is the actual register cache.
39 */
40
3fadccb3
AC
41/* Per-architecture object describing the layout of a register cache.
42 Computed once when the architecture is created */
43
44struct gdbarch_data *regcache_descr_handle;
45
46struct regcache_descr
47{
48 /* The architecture this descriptor belongs to. */
49 struct gdbarch *gdbarch;
50
51 /* Is this a ``legacy'' register cache? Such caches reserve space
52 for raw and pseudo registers and allow access to both. */
53 int legacy_p;
54
bb1db049
AC
55 /* The raw register cache. Each raw (or hard) register is supplied
56 by the target interface. The raw cache should not contain
57 redundant information - if the PC is constructed from two
58 registers then those regigisters and not the PC lives in the raw
59 cache. */
3fadccb3
AC
60 int nr_raw_registers;
61 long sizeof_raw_registers;
62 long sizeof_raw_register_valid_p;
63
d138e37a
AC
64 /* The cooked register space. Each cooked register in the range
65 [0..NR_RAW_REGISTERS) is direct-mapped onto the corresponding raw
66 register. The remaining [NR_RAW_REGISTERS
67 .. NR_COOKED_REGISTERS) (a.k.a. pseudo regiters) are mapped onto
68 both raw registers and memory by the architecture methods
69 gdbarch_register_read and gdbarch_register_write. */
70 int nr_cooked_registers;
067df2e5
AC
71 long sizeof_cooked_registers;
72 long sizeof_cooked_register_valid_p;
d138e37a
AC
73
74 /* Offset and size (in 8 bit bytes), of reach register in the
75 register cache. All registers (including those in the range
76 [NR_RAW_REGISTERS .. NR_COOKED_REGISTERS) are given an offset.
77 Assigning all registers an offset makes it possible to keep
78 legacy code, such as that found in read_register_bytes() and
79 write_register_bytes() working. */
3fadccb3 80 long *register_offset;
3fadccb3 81 long *sizeof_register;
3fadccb3 82
bb425013
AC
83 /* Cached table containing the type of each register. */
84 struct type **register_type;
3fadccb3
AC
85};
86
b9362cc7 87static void
bb425013
AC
88init_legacy_regcache_descr (struct gdbarch *gdbarch,
89 struct regcache_descr *descr)
3fadccb3
AC
90{
91 int i;
3fadccb3
AC
92 /* FIXME: cagney/2002-05-11: gdbarch_data() should take that
93 ``gdbarch'' as a parameter. */
94 gdb_assert (gdbarch != NULL);
95
067df2e5 96 /* Compute the offset of each register. Legacy architectures define
62700349
AC
97 DEPRECATED_REGISTER_BYTE() so use that. */
98 /* FIXME: cagney/2002-11-07: Instead of using
99 DEPRECATED_REGISTER_BYTE() this code should, as is done in
100 init_regcache_descr(), compute the offets at runtime. This
101 currently isn't possible as some ISAs define overlapping register
102 regions - see the mess in read_register_bytes() and
103 write_register_bytes() registers. */
116f06ea
AC
104 descr->sizeof_register
105 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
106 descr->register_offset
107 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
d138e37a 108 for (i = 0; i < descr->nr_cooked_registers; i++)
3fadccb3 109 {
067df2e5 110 /* FIXME: cagney/2001-12-04: This code shouldn't need to use
ce2826aa 111 DEPRECATED_REGISTER_BYTE(). Unfortunately, legacy code likes
62700349
AC
112 to lay the buffer out so that certain registers just happen
113 to overlap. Ulgh! New targets use gdbarch's register
114 read/write and entirely avoid this uglyness. */
115 descr->register_offset[i] = DEPRECATED_REGISTER_BYTE (i);
12c266ea
AC
116 descr->sizeof_register[i] = DEPRECATED_REGISTER_RAW_SIZE (i);
117 gdb_assert (MAX_REGISTER_SIZE >= DEPRECATED_REGISTER_RAW_SIZE (i));
f30992d4 118 gdb_assert (MAX_REGISTER_SIZE >= DEPRECATED_REGISTER_VIRTUAL_SIZE (i));
3fadccb3
AC
119 }
120
067df2e5 121 /* Compute the real size of the register buffer. Start out by
b8b527c5
AC
122 trusting DEPRECATED_REGISTER_BYTES, but then adjust it upwards
123 should that be found to not be sufficient. */
124 /* FIXME: cagney/2002-11-05: Instead of using the macro
125 DEPRECATED_REGISTER_BYTES, this code should, as is done in
126 init_regcache_descr(), compute the total number of register bytes
127 using the accumulated offsets. */
128 descr->sizeof_cooked_registers = DEPRECATED_REGISTER_BYTES; /* OK */
d138e37a 129 for (i = 0; i < descr->nr_cooked_registers; i++)
3fadccb3
AC
130 {
131 long regend;
132 /* Keep extending the buffer so that there is always enough
133 space for all registers. The comparison is necessary since
134 legacy code is free to put registers in random places in the
62700349
AC
135 buffer separated by holes. Once DEPRECATED_REGISTER_BYTE()
136 is killed this can be greatly simplified. */
3fadccb3 137 regend = descr->register_offset[i] + descr->sizeof_register[i];
067df2e5
AC
138 if (descr->sizeof_cooked_registers < regend)
139 descr->sizeof_cooked_registers = regend;
3fadccb3 140 }
067df2e5 141 /* FIXME: cagney/2002-05-11: Shouldn't be including pseudo-registers
ce2826aa 142 in the register cache. Unfortunately some architectures still
067df2e5
AC
143 rely on this and the pseudo_register_write() method. */
144 descr->sizeof_raw_registers = descr->sizeof_cooked_registers;
3fadccb3
AC
145}
146
147static void *
148init_regcache_descr (struct gdbarch *gdbarch)
149{
150 int i;
151 struct regcache_descr *descr;
152 gdb_assert (gdbarch != NULL);
153
bb425013 154 /* Create an initial, zero filled, table. */
116f06ea 155 descr = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct regcache_descr);
3fadccb3 156 descr->gdbarch = gdbarch;
3fadccb3 157
d138e37a
AC
158 /* Total size of the register space. The raw registers are mapped
159 directly onto the raw register cache while the pseudo's are
3fadccb3 160 either mapped onto raw-registers or memory. */
d138e37a 161 descr->nr_cooked_registers = NUM_REGS + NUM_PSEUDO_REGS;
067df2e5 162 descr->sizeof_cooked_register_valid_p = NUM_REGS + NUM_PSEUDO_REGS;
3fadccb3 163
bb425013 164 /* Fill in a table of register types. */
116f06ea
AC
165 descr->register_type
166 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, struct type *);
bb425013
AC
167 for (i = 0; i < descr->nr_cooked_registers; i++)
168 {
35cac7cf
AC
169 if (gdbarch_register_type_p (gdbarch))
170 {
2e092625 171 gdb_assert (!DEPRECATED_REGISTER_VIRTUAL_TYPE_P ()); /* OK */
35cac7cf
AC
172 descr->register_type[i] = gdbarch_register_type (gdbarch, i);
173 }
174 else
2e092625 175 descr->register_type[i] = DEPRECATED_REGISTER_VIRTUAL_TYPE (i); /* OK */
bb425013
AC
176 }
177
bb1db049
AC
178 /* Construct a strictly RAW register cache. Don't allow pseudo's
179 into the register cache. */
180 descr->nr_raw_registers = NUM_REGS;
181
182 /* FIXME: cagney/2002-08-13: Overallocate the register_valid_p
183 array. This pretects GDB from erant code that accesses elements
184 of the global register_valid_p[] array in the range [NUM_REGS
185 .. NUM_REGS + NUM_PSEUDO_REGS). */
186 descr->sizeof_raw_register_valid_p = descr->sizeof_cooked_register_valid_p;
187
bb425013
AC
188 /* If an old style architecture, fill in the remainder of the
189 register cache descriptor using the register macros. */
62700349 190 /* NOTE: cagney/2003-06-29: If either of DEPRECATED_REGISTER_BYTE or
12c266ea 191 DEPRECATED_REGISTER_RAW_SIZE are still present, things are most likely
dadd712e 192 totally screwed. Ex: an architecture with raw register sizes
62700349
AC
193 smaller than what DEPRECATED_REGISTER_BYTE indicates; non
194 monotonic DEPRECATED_REGISTER_BYTE values. For GDB 6 check for
195 these nasty methods and fall back to legacy code when present.
196 Sigh! */
dadd712e
AC
197 if ((!gdbarch_pseudo_register_read_p (gdbarch)
198 && !gdbarch_pseudo_register_write_p (gdbarch)
199 && !gdbarch_register_type_p (gdbarch))
12c266ea
AC
200 || DEPRECATED_REGISTER_BYTE_P ()
201 || DEPRECATED_REGISTER_RAW_SIZE_P ())
bb425013
AC
202 {
203 descr->legacy_p = 1;
204 init_legacy_regcache_descr (gdbarch, descr);
205 return descr;
206 }
207
067df2e5 208 /* Lay out the register cache.
3fadccb3 209
bb425013
AC
210 NOTE: cagney/2002-05-22: Only register_type() is used when
211 constructing the register cache. It is assumed that the
212 register's raw size, virtual size and type length are all the
213 same. */
3fadccb3
AC
214
215 {
216 long offset = 0;
116f06ea
AC
217 descr->sizeof_register
218 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
219 descr->register_offset
220 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
d138e37a 221 for (i = 0; i < descr->nr_cooked_registers; i++)
3fadccb3 222 {
bb425013 223 descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]);
3fadccb3
AC
224 descr->register_offset[i] = offset;
225 offset += descr->sizeof_register[i];
123a958e 226 gdb_assert (MAX_REGISTER_SIZE >= descr->sizeof_register[i]);
3fadccb3
AC
227 }
228 /* Set the real size of the register cache buffer. */
067df2e5 229 descr->sizeof_cooked_registers = offset;
3fadccb3
AC
230 }
231
067df2e5 232 /* FIXME: cagney/2002-05-22: Should only need to allocate space for
ce2826aa 233 the raw registers. Unfortunately some code still accesses the
067df2e5
AC
234 register array directly using the global registers[]. Until that
235 code has been purged, play safe and over allocating the register
236 buffer. Ulgh! */
237 descr->sizeof_raw_registers = descr->sizeof_cooked_registers;
238
46654a5b 239 /* Sanity check. Confirm that there is agreement between the
62700349
AC
240 regcache and the target's redundant DEPRECATED_REGISTER_BYTE (new
241 targets should not even be defining it). */
d138e37a 242 for (i = 0; i < descr->nr_cooked_registers; i++)
3fadccb3 243 {
62700349
AC
244 if (DEPRECATED_REGISTER_BYTE_P ())
245 gdb_assert (descr->register_offset[i] == DEPRECATED_REGISTER_BYTE (i));
46654a5b 246#if 0
12c266ea 247 gdb_assert (descr->sizeof_register[i] == DEPRECATED_REGISTER_RAW_SIZE (i));
f30992d4 248 gdb_assert (descr->sizeof_register[i] == DEPRECATED_REGISTER_VIRTUAL_SIZE (i));
46654a5b 249#endif
3fadccb3 250 }
b8b527c5 251 /* gdb_assert (descr->sizeof_raw_registers == DEPRECATED_REGISTER_BYTES (i)); */
3fadccb3
AC
252
253 return descr;
254}
255
256static struct regcache_descr *
257regcache_descr (struct gdbarch *gdbarch)
258{
259 return gdbarch_data (gdbarch, regcache_descr_handle);
260}
261
bb425013
AC
262/* Utility functions returning useful register attributes stored in
263 the regcache descr. */
264
265struct type *
266register_type (struct gdbarch *gdbarch, int regnum)
267{
268 struct regcache_descr *descr = regcache_descr (gdbarch);
269 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
270 return descr->register_type[regnum];
271}
272
0ed04cce
AC
273/* Utility functions returning useful register attributes stored in
274 the regcache descr. */
275
08a617da
AC
276int
277register_size (struct gdbarch *gdbarch, int regnum)
278{
279 struct regcache_descr *descr = regcache_descr (gdbarch);
280 int size;
281 gdb_assert (regnum >= 0 && regnum < (NUM_REGS + NUM_PSEUDO_REGS));
282 size = descr->sizeof_register[regnum];
12c266ea 283 /* NB: The deprecated DEPRECATED_REGISTER_RAW_SIZE, if not provided, defaults
96a4ee76 284 to the size of the register's type. */
12c266ea 285 gdb_assert (size == DEPRECATED_REGISTER_RAW_SIZE (regnum)); /* OK */
96a4ee76
AC
286 /* NB: Don't check the register's virtual size. It, in say the case
287 of the MIPS, may not match the raw size! */
08a617da
AC
288 return size;
289}
290
3fadccb3
AC
291/* The register cache for storing raw register values. */
292
293struct regcache
294{
295 struct regcache_descr *descr;
51b1fe4e
AC
296 /* The register buffers. A read-only register cache can hold the
297 full [0 .. NUM_REGS + NUM_PSEUDO_REGS) while a read/write
298 register cache can only hold [0 .. NUM_REGS). */
299 char *registers;
300 char *register_valid_p;
2d28509a
AC
301 /* Is this a read-only cache? A read-only cache is used for saving
302 the target's register state (e.g, across an inferior function
303 call or just before forcing a function return). A read-only
304 cache can only be updated via the methods regcache_dup() and
305 regcache_cpy(). The actual contents are determined by the
306 reggroup_save and reggroup_restore methods. */
307 int readonly_p;
3fadccb3
AC
308};
309
310struct regcache *
311regcache_xmalloc (struct gdbarch *gdbarch)
312{
313 struct regcache_descr *descr;
314 struct regcache *regcache;
315 gdb_assert (gdbarch != NULL);
316 descr = regcache_descr (gdbarch);
317 regcache = XMALLOC (struct regcache);
318 regcache->descr = descr;
51b1fe4e 319 regcache->registers
3fadccb3 320 = XCALLOC (descr->sizeof_raw_registers, char);
51b1fe4e 321 regcache->register_valid_p
3fadccb3 322 = XCALLOC (descr->sizeof_raw_register_valid_p, char);
2d28509a 323 regcache->readonly_p = 1;
3fadccb3
AC
324 return regcache;
325}
326
327void
328regcache_xfree (struct regcache *regcache)
329{
330 if (regcache == NULL)
331 return;
51b1fe4e
AC
332 xfree (regcache->registers);
333 xfree (regcache->register_valid_p);
3fadccb3
AC
334 xfree (regcache);
335}
336
b9362cc7 337static void
36160dc4
AC
338do_regcache_xfree (void *data)
339{
340 regcache_xfree (data);
341}
342
343struct cleanup *
344make_cleanup_regcache_xfree (struct regcache *regcache)
345{
346 return make_cleanup (do_regcache_xfree, regcache);
347}
348
41d35cb0
MK
349/* Return REGCACHE's architecture. */
350
351struct gdbarch *
352get_regcache_arch (const struct regcache *regcache)
353{
354 return regcache->descr->gdbarch;
355}
356
51b1fe4e
AC
357/* Return a pointer to register REGNUM's buffer cache. */
358
359static char *
9a661b68 360register_buffer (const struct regcache *regcache, int regnum)
51b1fe4e
AC
361{
362 return regcache->registers + regcache->descr->register_offset[regnum];
363}
364
2d28509a 365void
5602984a
AC
366regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read,
367 void *src)
2d28509a
AC
368{
369 struct gdbarch *gdbarch = dst->descr->gdbarch;
123a958e 370 char buf[MAX_REGISTER_SIZE];
2d28509a 371 int regnum;
2d28509a 372 /* The DST should be `read-only', if it wasn't then the save would
5602984a 373 end up trying to write the register values back out to the
2d28509a 374 target. */
2d28509a
AC
375 gdb_assert (dst->readonly_p);
376 /* Clear the dest. */
377 memset (dst->registers, 0, dst->descr->sizeof_cooked_registers);
378 memset (dst->register_valid_p, 0, dst->descr->sizeof_cooked_register_valid_p);
379 /* Copy over any registers (identified by their membership in the
5602984a
AC
380 save_reggroup) and mark them as valid. The full [0 .. NUM_REGS +
381 NUM_PSEUDO_REGS) range is checked since some architectures need
382 to save/restore `cooked' registers that live in memory. */
2d28509a
AC
383 for (regnum = 0; regnum < dst->descr->nr_cooked_registers; regnum++)
384 {
385 if (gdbarch_register_reggroup_p (gdbarch, regnum, save_reggroup))
386 {
5602984a
AC
387 int valid = cooked_read (src, regnum, buf);
388 if (valid)
389 {
390 memcpy (register_buffer (dst, regnum), buf,
391 register_size (gdbarch, regnum));
392 dst->register_valid_p[regnum] = 1;
393 }
2d28509a
AC
394 }
395 }
396}
397
398void
5602984a
AC
399regcache_restore (struct regcache *dst,
400 regcache_cooked_read_ftype *cooked_read,
401 void *src)
2d28509a
AC
402{
403 struct gdbarch *gdbarch = dst->descr->gdbarch;
123a958e 404 char buf[MAX_REGISTER_SIZE];
2d28509a 405 int regnum;
5602984a
AC
406 /* The dst had better not be read-only. If it is, the `restore'
407 doesn't make much sense. */
2d28509a 408 gdb_assert (!dst->readonly_p);
2d28509a 409 /* Copy over any registers, being careful to only restore those that
5602984a
AC
410 were both saved and need to be restored. The full [0 .. NUM_REGS
411 + NUM_PSEUDO_REGS) range is checked since some architectures need
412 to save/restore `cooked' registers that live in memory. */
413 for (regnum = 0; regnum < dst->descr->nr_cooked_registers; regnum++)
2d28509a 414 {
5602984a 415 if (gdbarch_register_reggroup_p (gdbarch, regnum, restore_reggroup))
2d28509a 416 {
5602984a
AC
417 int valid = cooked_read (src, regnum, buf);
418 if (valid)
419 regcache_cooked_write (dst, regnum, buf);
2d28509a
AC
420 }
421 }
422}
423
5602984a
AC
424static int
425do_cooked_read (void *src, int regnum, void *buf)
426{
427 struct regcache *regcache = src;
6f4e5a41 428 if (!regcache->register_valid_p[regnum] && regcache->readonly_p)
5602984a
AC
429 /* Don't even think about fetching a register from a read-only
430 cache when the register isn't yet valid. There isn't a target
431 from which the register value can be fetched. */
432 return 0;
433 regcache_cooked_read (regcache, regnum, buf);
434 return 1;
435}
436
437
3fadccb3
AC
438void
439regcache_cpy (struct regcache *dst, struct regcache *src)
440{
441 int i;
442 char *buf;
443 gdb_assert (src != NULL && dst != NULL);
444 gdb_assert (src->descr->gdbarch == dst->descr->gdbarch);
445 gdb_assert (src != dst);
2d28509a
AC
446 gdb_assert (src->readonly_p || dst->readonly_p);
447 if (!src->readonly_p)
5602984a 448 regcache_save (dst, do_cooked_read, src);
2d28509a 449 else if (!dst->readonly_p)
5602984a 450 regcache_restore (dst, do_cooked_read, src);
2d28509a
AC
451 else
452 regcache_cpy_no_passthrough (dst, src);
3fadccb3
AC
453}
454
455void
456regcache_cpy_no_passthrough (struct regcache *dst, struct regcache *src)
457{
458 int i;
459 gdb_assert (src != NULL && dst != NULL);
460 gdb_assert (src->descr->gdbarch == dst->descr->gdbarch);
461 /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough
462 move of data into the current_regcache(). Doing this would be
9564ee9f 463 silly - it would mean that valid_p would be completely invalid. */
3fadccb3 464 gdb_assert (dst != current_regcache);
51b1fe4e
AC
465 memcpy (dst->registers, src->registers, dst->descr->sizeof_raw_registers);
466 memcpy (dst->register_valid_p, src->register_valid_p,
3fadccb3
AC
467 dst->descr->sizeof_raw_register_valid_p);
468}
469
470struct regcache *
471regcache_dup (struct regcache *src)
472{
473 struct regcache *newbuf;
474 gdb_assert (current_regcache != NULL);
475 newbuf = regcache_xmalloc (src->descr->gdbarch);
476 regcache_cpy (newbuf, src);
477 return newbuf;
478}
479
480struct regcache *
481regcache_dup_no_passthrough (struct regcache *src)
482{
483 struct regcache *newbuf;
484 gdb_assert (current_regcache != NULL);
485 newbuf = regcache_xmalloc (src->descr->gdbarch);
486 regcache_cpy_no_passthrough (newbuf, src);
487 return newbuf;
488}
489
490int
491regcache_valid_p (struct regcache *regcache, int regnum)
492{
493 gdb_assert (regcache != NULL);
494 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
51b1fe4e 495 return regcache->register_valid_p[regnum];
3fadccb3
AC
496}
497
3fadccb3
AC
498char *
499deprecated_grub_regcache_for_registers (struct regcache *regcache)
500{
51b1fe4e 501 return regcache->registers;
3fadccb3
AC
502}
503
3fadccb3
AC
504/* Global structure containing the current regcache. */
505/* FIXME: cagney/2002-05-11: The two global arrays registers[] and
8262ee23 506 deprecated_register_valid[] currently point into this structure. */
3fadccb3
AC
507struct regcache *current_regcache;
508
5ebd2499 509/* NOTE: this is a write-through cache. There is no "dirty" bit for
32178cab
MS
510 recording if the register values have been changed (eg. by the
511 user). Therefore all registers must be written back to the
512 target when appropriate. */
513
514/* REGISTERS contains the cached register values (in target byte order). */
515
524d7c18 516char *deprecated_registers;
32178cab 517
8262ee23 518/* DEPRECATED_REGISTER_VALID is 0 if the register needs to be fetched,
32178cab
MS
519 1 if it has been fetched, and
520 -1 if the register value was not available.
c97dcfc7
AC
521
522 "Not available" indicates that the target is not not able to supply
523 the register at this state. The register may become available at a
524 later time (after the next resume). This often occures when GDB is
525 manipulating a target that contains only a snapshot of the entire
526 system being debugged - some of the registers in such a system may
527 not have been saved. */
32178cab 528
8262ee23 529signed char *deprecated_register_valid;
32178cab 530
39f77062 531/* The thread/process associated with the current set of registers. */
32178cab 532
39f77062 533static ptid_t registers_ptid;
32178cab
MS
534
535/*
536 * FUNCTIONS:
537 */
538
539/* REGISTER_CACHED()
540
541 Returns 0 if the value is not in the cache (needs fetch).
542 >0 if the value is in the cache.
543 <0 if the value is permanently unavailable (don't ask again). */
544
545int
546register_cached (int regnum)
547{
8262ee23 548 return deprecated_register_valid[regnum];
32178cab
MS
549}
550
7302a204
ND
551/* Record that REGNUM's value is cached if STATE is >0, uncached but
552 fetchable if STATE is 0, and uncached and unfetchable if STATE is <0. */
553
554void
555set_register_cached (int regnum, int state)
556{
53826de9
AC
557 gdb_assert (regnum >= 0);
558 gdb_assert (regnum < current_regcache->descr->nr_raw_registers);
51b1fe4e 559 current_regcache->register_valid_p[regnum] = state;
7302a204
ND
560}
561
562/* Return whether register REGNUM is a real register. */
563
564static int
565real_register (int regnum)
566{
567 return regnum >= 0 && regnum < NUM_REGS;
568}
569
f4c5303c
OF
570/* Observer for the target_changed event. */
571
572void
573regcache_observer_target_changed (struct target_ops *target)
574{
575 registers_changed ();
576}
577
32178cab
MS
578/* Low level examining and depositing of registers.
579
580 The caller is responsible for making sure that the inferior is
581 stopped before calling the fetching routines, or it will get
582 garbage. (a change from GDB version 3, in which the caller got the
583 value from the last stop). */
584
585/* REGISTERS_CHANGED ()
586
587 Indicate that registers may have changed, so invalidate the cache. */
588
589void
590registers_changed (void)
591{
592 int i;
32178cab 593
39f77062 594 registers_ptid = pid_to_ptid (-1);
32178cab
MS
595
596 /* Force cleanup of any alloca areas if using C alloca instead of
597 a builtin alloca. This particular call is used to clean up
598 areas allocated by low level target code which may build up
599 during lengthy interactions between gdb and the target before
600 gdb gives control to the user (ie watchpoints). */
601 alloca (0);
602
53826de9 603 for (i = 0; i < current_regcache->descr->nr_raw_registers; i++)
7302a204 604 set_register_cached (i, 0);
32178cab 605
9a4105ab
AC
606 if (deprecated_registers_changed_hook)
607 deprecated_registers_changed_hook ();
32178cab
MS
608}
609
2b9e5f3f 610/* DEPRECATED_REGISTERS_FETCHED ()
32178cab
MS
611
612 Indicate that all registers have been fetched, so mark them all valid. */
613
31e9866e
AC
614/* NOTE: cagney/2001-12-04: This function does not set valid on the
615 pseudo-register range since pseudo registers are always supplied
616 using supply_register(). */
617/* FIXME: cagney/2001-12-04: This function is DEPRECATED. The target
618 code was blatting the registers[] array and then calling this.
619 Since targets should only be using supply_register() the need for
620 this function/hack is eliminated. */
32178cab
MS
621
622void
2b9e5f3f 623deprecated_registers_fetched (void)
32178cab
MS
624{
625 int i;
32178cab 626
a728f042 627 for (i = 0; i < NUM_REGS; i++)
7302a204 628 set_register_cached (i, 1);
fcdc5976 629 /* Do not assume that the pseudo-regs have also been fetched.
31e9866e 630 Fetching all real regs NEVER accounts for pseudo-regs. */
32178cab
MS
631}
632
73937e03
AC
633/* deprecated_read_register_bytes and deprecated_write_register_bytes
634 are generally a *BAD* idea. They are inefficient because they need
635 to check for partial updates, which can only be done by scanning
636 through all of the registers and seeing if the bytes that are being
637 read/written fall inside of an invalid register. [The main reason
638 this is necessary is that register sizes can vary, so a simple
639 index won't suffice.] It is far better to call read_register_gen
640 and write_register_gen if you want to get at the raw register
641 contents, as it only takes a regnum as an argument, and therefore
642 can't do a partial register update.
32178cab
MS
643
644 Prior to the recent fixes to check for partial updates, both read
73937e03
AC
645 and deprecated_write_register_bytes always checked to see if any
646 registers were stale, and then called target_fetch_registers (-1)
647 to update the whole set. This caused really slowed things down for
648 remote targets. */
32178cab
MS
649
650/* Copy INLEN bytes of consecutive data from registers
651 starting with the INREGBYTE'th byte of register data
652 into memory at MYADDR. */
653
654void
73937e03 655deprecated_read_register_bytes (int in_start, char *in_buf, int in_len)
32178cab 656{
61a0eb5b 657 int in_end = in_start + in_len;
5ebd2499 658 int regnum;
d9d9c31f 659 char reg_buf[MAX_REGISTER_SIZE];
32178cab
MS
660
661 /* See if we are trying to read bytes from out-of-date registers. If so,
662 update just those registers. */
663
5ebd2499 664 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
32178cab 665 {
61a0eb5b
AC
666 int reg_start;
667 int reg_end;
668 int reg_len;
669 int start;
670 int end;
671 int byte;
32178cab 672
62700349 673 reg_start = DEPRECATED_REGISTER_BYTE (regnum);
12c266ea 674 reg_len = DEPRECATED_REGISTER_RAW_SIZE (regnum);
61a0eb5b 675 reg_end = reg_start + reg_len;
32178cab 676
61a0eb5b 677 if (reg_end <= in_start || in_end <= reg_start)
5ebd2499 678 /* The range the user wants to read doesn't overlap with regnum. */
32178cab
MS
679 continue;
680
275f450c
AC
681 if (REGISTER_NAME (regnum) != NULL && *REGISTER_NAME (regnum) != '\0')
682 /* Force the cache to fetch the entire register. */
4caf0990 683 deprecated_read_register_gen (regnum, reg_buf);
275f450c
AC
684 else
685 /* Legacy note: even though this register is ``invalid'' we
686 still need to return something. It would appear that some
687 code relies on apparent gaps in the register array also
688 being returned. */
689 /* FIXME: cagney/2001-08-18: This is just silly. It defeats
690 the entire register read/write flow of control. Must
691 resist temptation to return 0xdeadbeef. */
524d7c18 692 memcpy (reg_buf, &deprecated_registers[reg_start], reg_len);
32178cab 693
61a0eb5b
AC
694 /* Legacy note: This function, for some reason, allows a NULL
695 input buffer. If the buffer is NULL, the registers are still
696 fetched, just the final transfer is skipped. */
697 if (in_buf == NULL)
698 continue;
699
700 /* start = max (reg_start, in_start) */
701 if (reg_start > in_start)
702 start = reg_start;
703 else
704 start = in_start;
705
706 /* end = min (reg_end, in_end) */
707 if (reg_end < in_end)
708 end = reg_end;
709 else
710 end = in_end;
711
712 /* Transfer just the bytes common to both IN_BUF and REG_BUF */
713 for (byte = start; byte < end; byte++)
165cd47f 714 {
61a0eb5b 715 in_buf[byte - in_start] = reg_buf[byte - reg_start];
165cd47f 716 }
32178cab 717 }
32178cab
MS
718}
719
5ebd2499
ND
720/* Read register REGNUM into memory at MYADDR, which must be large
721 enough for REGISTER_RAW_BYTES (REGNUM). Target byte-order. If the
32178cab
MS
722 register is known to be the size of a CORE_ADDR or smaller,
723 read_register can be used instead. */
724
61a0eb5b
AC
725static void
726legacy_read_register_gen (int regnum, char *myaddr)
32178cab 727{
61a0eb5b 728 gdb_assert (regnum >= 0 && regnum < (NUM_REGS + NUM_PSEUDO_REGS));
39f77062 729 if (! ptid_equal (registers_ptid, inferior_ptid))
32178cab
MS
730 {
731 registers_changed ();
39f77062 732 registers_ptid = inferior_ptid;
32178cab
MS
733 }
734
7302a204 735 if (!register_cached (regnum))
5c27f28a 736 target_fetch_registers (regnum);
7302a204 737
3fadccb3 738 memcpy (myaddr, register_buffer (current_regcache, regnum),
12c266ea 739 DEPRECATED_REGISTER_RAW_SIZE (regnum));
32178cab
MS
740}
741
61a0eb5b 742void
1aaa5f99 743regcache_raw_read (struct regcache *regcache, int regnum, void *buf)
61a0eb5b 744{
3fadccb3
AC
745 gdb_assert (regcache != NULL && buf != NULL);
746 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
747 if (regcache->descr->legacy_p
2d28509a 748 && !regcache->readonly_p)
3fadccb3
AC
749 {
750 gdb_assert (regcache == current_regcache);
751 /* For moment, just use underlying legacy code. Ulgh!!! This
752 silently and very indirectly updates the regcache's regcache
8262ee23 753 via the global deprecated_register_valid[]. */
3fadccb3
AC
754 legacy_read_register_gen (regnum, buf);
755 return;
756 }
757 /* Make certain that the register cache is up-to-date with respect
758 to the current thread. This switching shouldn't be necessary
759 only there is still only one target side register cache. Sigh!
760 On the bright side, at least there is a regcache object. */
2d28509a 761 if (!regcache->readonly_p)
3fadccb3
AC
762 {
763 gdb_assert (regcache == current_regcache);
764 if (! ptid_equal (registers_ptid, inferior_ptid))
765 {
766 registers_changed ();
767 registers_ptid = inferior_ptid;
768 }
769 if (!register_cached (regnum))
5c27f28a 770 target_fetch_registers (regnum);
3fadccb3
AC
771 }
772 /* Copy the value directly into the register cache. */
51b1fe4e 773 memcpy (buf, register_buffer (regcache, regnum),
3fadccb3 774 regcache->descr->sizeof_register[regnum]);
61a0eb5b
AC
775}
776
28fc6740
AC
777void
778regcache_raw_read_signed (struct regcache *regcache, int regnum, LONGEST *val)
779{
780 char *buf;
781 gdb_assert (regcache != NULL);
782 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
783 buf = alloca (regcache->descr->sizeof_register[regnum]);
784 regcache_raw_read (regcache, regnum, buf);
785 (*val) = extract_signed_integer (buf,
786 regcache->descr->sizeof_register[regnum]);
787}
788
789void
790regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
791 ULONGEST *val)
792{
793 char *buf;
794 gdb_assert (regcache != NULL);
795 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
796 buf = alloca (regcache->descr->sizeof_register[regnum]);
797 regcache_raw_read (regcache, regnum, buf);
798 (*val) = extract_unsigned_integer (buf,
799 regcache->descr->sizeof_register[regnum]);
800}
801
c00dcbe9
MK
802void
803regcache_raw_write_signed (struct regcache *regcache, int regnum, LONGEST val)
804{
805 void *buf;
806 gdb_assert (regcache != NULL);
807 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
808 buf = alloca (regcache->descr->sizeof_register[regnum]);
809 store_signed_integer (buf, regcache->descr->sizeof_register[regnum], val);
810 regcache_raw_write (regcache, regnum, buf);
811}
812
813void
814regcache_raw_write_unsigned (struct regcache *regcache, int regnum,
815 ULONGEST val)
816{
817 void *buf;
818 gdb_assert (regcache != NULL);
819 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
820 buf = alloca (regcache->descr->sizeof_register[regnum]);
821 store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], val);
822 regcache_raw_write (regcache, regnum, buf);
823}
824
61a0eb5b 825void
4caf0990 826deprecated_read_register_gen (int regnum, char *buf)
61a0eb5b 827{
3fadccb3
AC
828 gdb_assert (current_regcache != NULL);
829 gdb_assert (current_regcache->descr->gdbarch == current_gdbarch);
830 if (current_regcache->descr->legacy_p)
61a0eb5b
AC
831 {
832 legacy_read_register_gen (regnum, buf);
833 return;
834 }
68365089
AC
835 regcache_cooked_read (current_regcache, regnum, buf);
836}
837
838void
29e1842b 839regcache_cooked_read (struct regcache *regcache, int regnum, void *buf)
68365089 840{
d138e37a 841 gdb_assert (regnum >= 0);
68365089
AC
842 gdb_assert (regnum < regcache->descr->nr_cooked_registers);
843 if (regnum < regcache->descr->nr_raw_registers)
844 regcache_raw_read (regcache, regnum, buf);
2d28509a
AC
845 else if (regcache->readonly_p
846 && regnum < regcache->descr->nr_cooked_registers
847 && regcache->register_valid_p[regnum])
848 /* Read-only register cache, perhaphs the cooked value was cached? */
849 memcpy (buf, register_buffer (regcache, regnum),
850 regcache->descr->sizeof_register[regnum]);
d138e37a 851 else
68365089
AC
852 gdbarch_pseudo_register_read (regcache->descr->gdbarch, regcache,
853 regnum, buf);
61a0eb5b
AC
854}
855
a378f419
AC
856void
857regcache_cooked_read_signed (struct regcache *regcache, int regnum,
858 LONGEST *val)
859{
860 char *buf;
861 gdb_assert (regcache != NULL);
a66a9c23 862 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
a378f419
AC
863 buf = alloca (regcache->descr->sizeof_register[regnum]);
864 regcache_cooked_read (regcache, regnum, buf);
865 (*val) = extract_signed_integer (buf,
866 regcache->descr->sizeof_register[regnum]);
867}
868
869void
870regcache_cooked_read_unsigned (struct regcache *regcache, int regnum,
871 ULONGEST *val)
872{
873 char *buf;
874 gdb_assert (regcache != NULL);
a66a9c23 875 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
a378f419
AC
876 buf = alloca (regcache->descr->sizeof_register[regnum]);
877 regcache_cooked_read (regcache, regnum, buf);
878 (*val) = extract_unsigned_integer (buf,
879 regcache->descr->sizeof_register[regnum]);
880}
881
a66a9c23
AC
882void
883regcache_cooked_write_signed (struct regcache *regcache, int regnum,
884 LONGEST val)
885{
886 void *buf;
887 gdb_assert (regcache != NULL);
888 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
889 buf = alloca (regcache->descr->sizeof_register[regnum]);
890 store_signed_integer (buf, regcache->descr->sizeof_register[regnum], val);
891 regcache_cooked_write (regcache, regnum, buf);
892}
893
894void
895regcache_cooked_write_unsigned (struct regcache *regcache, int regnum,
896 ULONGEST val)
897{
898 void *buf;
899 gdb_assert (regcache != NULL);
900 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
901 buf = alloca (regcache->descr->sizeof_register[regnum]);
902 store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], val);
903 regcache_cooked_write (regcache, regnum, buf);
904}
905
5ebd2499
ND
906/* Write register REGNUM at MYADDR to the target. MYADDR points at
907 REGISTER_RAW_BYTES(REGNUM), which must be in target byte-order. */
32178cab 908
61a0eb5b 909static void
1aaa5f99 910legacy_write_register_gen (int regnum, const void *myaddr)
32178cab
MS
911{
912 int size;
61a0eb5b 913 gdb_assert (regnum >= 0 && regnum < (NUM_REGS + NUM_PSEUDO_REGS));
32178cab
MS
914
915 /* On the sparc, writing %g0 is a no-op, so we don't even want to
916 change the registers array if something writes to this register. */
5ebd2499 917 if (CANNOT_STORE_REGISTER (regnum))
32178cab
MS
918 return;
919
39f77062 920 if (! ptid_equal (registers_ptid, inferior_ptid))
32178cab
MS
921 {
922 registers_changed ();
39f77062 923 registers_ptid = inferior_ptid;
32178cab
MS
924 }
925
12c266ea 926 size = DEPRECATED_REGISTER_RAW_SIZE (regnum);
32178cab 927
7302a204 928 if (real_register (regnum))
1297a2f0
MS
929 {
930 /* If we have a valid copy of the register, and new value == old
931 value, then don't bother doing the actual store. */
932 if (register_cached (regnum)
3fadccb3
AC
933 && (memcmp (register_buffer (current_regcache, regnum), myaddr, size)
934 == 0))
1297a2f0
MS
935 return;
936 else
937 target_prepare_to_store ();
938 }
32178cab 939
3fadccb3 940 memcpy (register_buffer (current_regcache, regnum), myaddr, size);
32178cab 941
7302a204 942 set_register_cached (regnum, 1);
5c27f28a 943 target_store_registers (regnum);
32178cab
MS
944}
945
61a0eb5b 946void
1aaa5f99 947regcache_raw_write (struct regcache *regcache, int regnum, const void *buf)
61a0eb5b 948{
3fadccb3
AC
949 gdb_assert (regcache != NULL && buf != NULL);
950 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
2d28509a 951 gdb_assert (!regcache->readonly_p);
3fadccb3 952
2d28509a 953 if (regcache->descr->legacy_p)
3fadccb3
AC
954 {
955 /* For moment, just use underlying legacy code. Ulgh!!! This
956 silently and very indirectly updates the regcache's buffers
8262ee23 957 via the globals deprecated_register_valid[] and registers[]. */
3fadccb3
AC
958 gdb_assert (regcache == current_regcache);
959 legacy_write_register_gen (regnum, buf);
960 return;
961 }
962
963 /* On the sparc, writing %g0 is a no-op, so we don't even want to
964 change the registers array if something writes to this register. */
965 if (CANNOT_STORE_REGISTER (regnum))
966 return;
967
3fadccb3
AC
968 /* Make certain that the correct cache is selected. */
969 gdb_assert (regcache == current_regcache);
970 if (! ptid_equal (registers_ptid, inferior_ptid))
971 {
972 registers_changed ();
973 registers_ptid = inferior_ptid;
974 }
975
976 /* If we have a valid copy of the register, and new value == old
977 value, then don't bother doing the actual store. */
978 if (regcache_valid_p (regcache, regnum)
979 && (memcmp (register_buffer (regcache, regnum), buf,
980 regcache->descr->sizeof_register[regnum]) == 0))
981 return;
982
983 target_prepare_to_store ();
984 memcpy (register_buffer (regcache, regnum), buf,
985 regcache->descr->sizeof_register[regnum]);
51b1fe4e 986 regcache->register_valid_p[regnum] = 1;
5c27f28a 987 target_store_registers (regnum);
61a0eb5b
AC
988}
989
990void
4caf0990 991deprecated_write_register_gen (int regnum, char *buf)
61a0eb5b 992{
3fadccb3
AC
993 gdb_assert (current_regcache != NULL);
994 gdb_assert (current_regcache->descr->gdbarch == current_gdbarch);
995 if (current_regcache->descr->legacy_p)
61a0eb5b
AC
996 {
997 legacy_write_register_gen (regnum, buf);
998 return;
999 }
68365089
AC
1000 regcache_cooked_write (current_regcache, regnum, buf);
1001}
1002
1003void
29e1842b 1004regcache_cooked_write (struct regcache *regcache, int regnum, const void *buf)
68365089 1005{
d138e37a 1006 gdb_assert (regnum >= 0);
68365089
AC
1007 gdb_assert (regnum < regcache->descr->nr_cooked_registers);
1008 if (regnum < regcache->descr->nr_raw_registers)
1009 regcache_raw_write (regcache, regnum, buf);
d138e37a 1010 else
68365089 1011 gdbarch_pseudo_register_write (regcache->descr->gdbarch, regcache,
d8124050 1012 regnum, buf);
61a0eb5b
AC
1013}
1014
32178cab
MS
1015/* Copy INLEN bytes of consecutive data from memory at MYADDR
1016 into registers starting with the MYREGSTART'th byte of register data. */
1017
1018void
73937e03 1019deprecated_write_register_bytes (int myregstart, char *myaddr, int inlen)
32178cab
MS
1020{
1021 int myregend = myregstart + inlen;
5ebd2499 1022 int regnum;
32178cab
MS
1023
1024 target_prepare_to_store ();
1025
1026 /* Scan through the registers updating any that are covered by the
1027 range myregstart<=>myregend using write_register_gen, which does
1028 nice things like handling threads, and avoiding updates when the
1029 new and old contents are the same. */
1030
5ebd2499 1031 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
32178cab
MS
1032 {
1033 int regstart, regend;
1034
62700349 1035 regstart = DEPRECATED_REGISTER_BYTE (regnum);
12c266ea 1036 regend = regstart + DEPRECATED_REGISTER_RAW_SIZE (regnum);
32178cab
MS
1037
1038 /* Is this register completely outside the range the user is writing? */
1039 if (myregend <= regstart || regend <= myregstart)
1040 /* do nothing */ ;
1041
1042 /* Is this register completely within the range the user is writing? */
1043 else if (myregstart <= regstart && regend <= myregend)
4caf0990 1044 deprecated_write_register_gen (regnum, myaddr + (regstart - myregstart));
32178cab
MS
1045
1046 /* The register partially overlaps the range being written. */
1047 else
1048 {
d9d9c31f 1049 char regbuf[MAX_REGISTER_SIZE];
32178cab
MS
1050 /* What's the overlap between this register's bytes and
1051 those the caller wants to write? */
1052 int overlapstart = max (regstart, myregstart);
1053 int overlapend = min (regend, myregend);
1054
1055 /* We may be doing a partial update of an invalid register.
1056 Update it from the target before scribbling on it. */
4caf0990 1057 deprecated_read_register_gen (regnum, regbuf);
32178cab 1058
524d7c18 1059 memcpy (&deprecated_registers[overlapstart],
32178cab
MS
1060 myaddr + (overlapstart - myregstart),
1061 overlapend - overlapstart);
1062
5c27f28a 1063 target_store_registers (regnum);
32178cab
MS
1064 }
1065 }
1066}
1067
06c0b04e
AC
1068/* Perform a partial register transfer using a read, modify, write
1069 operation. */
1070
1071typedef void (regcache_read_ftype) (struct regcache *regcache, int regnum,
1072 void *buf);
1073typedef void (regcache_write_ftype) (struct regcache *regcache, int regnum,
1074 const void *buf);
1075
b9362cc7 1076static void
06c0b04e
AC
1077regcache_xfer_part (struct regcache *regcache, int regnum,
1078 int offset, int len, void *in, const void *out,
1079 regcache_read_ftype *read, regcache_write_ftype *write)
1080{
1081 struct regcache_descr *descr = regcache->descr;
123a958e 1082 bfd_byte reg[MAX_REGISTER_SIZE];
06c0b04e
AC
1083 gdb_assert (offset >= 0 && offset <= descr->sizeof_register[regnum]);
1084 gdb_assert (len >= 0 && offset + len <= descr->sizeof_register[regnum]);
1085 /* Something to do? */
1086 if (offset + len == 0)
1087 return;
1088 /* Read (when needed) ... */
1089 if (in != NULL
1090 || offset > 0
1091 || offset + len < descr->sizeof_register[regnum])
1092 {
1093 gdb_assert (read != NULL);
1094 read (regcache, regnum, reg);
1095 }
1096 /* ... modify ... */
1097 if (in != NULL)
1098 memcpy (in, reg + offset, len);
1099 if (out != NULL)
1100 memcpy (reg + offset, out, len);
1101 /* ... write (when needed). */
1102 if (out != NULL)
1103 {
1104 gdb_assert (write != NULL);
1105 write (regcache, regnum, reg);
1106 }
1107}
1108
1109void
1110regcache_raw_read_part (struct regcache *regcache, int regnum,
1111 int offset, int len, void *buf)
1112{
1113 struct regcache_descr *descr = regcache->descr;
1114 gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
1115 regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
1116 regcache_raw_read, regcache_raw_write);
1117}
1118
1119void
1120regcache_raw_write_part (struct regcache *regcache, int regnum,
1121 int offset, int len, const void *buf)
1122{
1123 struct regcache_descr *descr = regcache->descr;
1124 gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
1125 regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
1126 regcache_raw_read, regcache_raw_write);
1127}
1128
1129void
1130regcache_cooked_read_part (struct regcache *regcache, int regnum,
1131 int offset, int len, void *buf)
1132{
1133 struct regcache_descr *descr = regcache->descr;
1134 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
1135 regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
1136 regcache_cooked_read, regcache_cooked_write);
1137}
1138
1139void
1140regcache_cooked_write_part (struct regcache *regcache, int regnum,
1141 int offset, int len, const void *buf)
1142{
1143 struct regcache_descr *descr = regcache->descr;
1144 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
1145 regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
1146 regcache_cooked_read, regcache_cooked_write);
1147}
32178cab 1148
d3b22ed5
AC
1149/* Hack to keep code that view the register buffer as raw bytes
1150 working. */
1151
1152int
1153register_offset_hack (struct gdbarch *gdbarch, int regnum)
1154{
1155 struct regcache_descr *descr = regcache_descr (gdbarch);
1156 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
1157 return descr->register_offset[regnum];
1158}
1159
5ebd2499 1160/* Return the contents of register REGNUM as an unsigned integer. */
32178cab 1161
173155e8 1162ULONGEST
5ebd2499 1163read_register (int regnum)
32178cab 1164{
12c266ea 1165 char *buf = alloca (DEPRECATED_REGISTER_RAW_SIZE (regnum));
4caf0990 1166 deprecated_read_register_gen (regnum, buf);
12c266ea 1167 return (extract_unsigned_integer (buf, DEPRECATED_REGISTER_RAW_SIZE (regnum)));
32178cab
MS
1168}
1169
173155e8 1170ULONGEST
39f77062 1171read_register_pid (int regnum, ptid_t ptid)
32178cab 1172{
39f77062 1173 ptid_t save_ptid;
32178cab
MS
1174 int save_pid;
1175 CORE_ADDR retval;
1176
39f77062 1177 if (ptid_equal (ptid, inferior_ptid))
5ebd2499 1178 return read_register (regnum);
32178cab 1179
39f77062 1180 save_ptid = inferior_ptid;
32178cab 1181
39f77062 1182 inferior_ptid = ptid;
32178cab 1183
5ebd2499 1184 retval = read_register (regnum);
32178cab 1185
39f77062 1186 inferior_ptid = save_ptid;
32178cab
MS
1187
1188 return retval;
1189}
1190
5ebd2499 1191/* Store VALUE into the raw contents of register number REGNUM. */
32178cab
MS
1192
1193void
5ebd2499 1194write_register (int regnum, LONGEST val)
32178cab 1195{
61a0eb5b 1196 void *buf;
32178cab 1197 int size;
12c266ea 1198 size = DEPRECATED_REGISTER_RAW_SIZE (regnum);
32178cab
MS
1199 buf = alloca (size);
1200 store_signed_integer (buf, size, (LONGEST) val);
4caf0990 1201 deprecated_write_register_gen (regnum, buf);
32178cab
MS
1202}
1203
1204void
39f77062 1205write_register_pid (int regnum, CORE_ADDR val, ptid_t ptid)
32178cab 1206{
39f77062 1207 ptid_t save_ptid;
32178cab 1208
39f77062 1209 if (ptid_equal (ptid, inferior_ptid))
32178cab 1210 {
5ebd2499 1211 write_register (regnum, val);
32178cab
MS
1212 return;
1213 }
1214
39f77062 1215 save_ptid = inferior_ptid;
32178cab 1216
39f77062 1217 inferior_ptid = ptid;
32178cab 1218
5ebd2499 1219 write_register (regnum, val);
32178cab 1220
39f77062 1221 inferior_ptid = save_ptid;
32178cab
MS
1222}
1223
9a661b68
MK
1224/* FIXME: kettenis/20030828: We should get rid of supply_register and
1225 regcache_collect in favour of regcache_raw_supply and
1226 regcache_raw_collect. */
1227
32178cab
MS
1228/* SUPPLY_REGISTER()
1229
5ebd2499 1230 Record that register REGNUM contains VAL. This is used when the
32178cab
MS
1231 value is obtained from the inferior or core dump, so there is no
1232 need to store the value there.
1233
1234 If VAL is a NULL pointer, then it's probably an unsupported register.
5ebd2499 1235 We just set its value to all zeros. We might want to record this
32178cab
MS
1236 fact, and report it to the users of read_register and friends. */
1237
1238void
1aaa5f99 1239supply_register (int regnum, const void *val)
32178cab 1240{
7bace51b 1241 regcache_raw_supply (current_regcache, regnum, val);
32178cab
MS
1242}
1243
193cb69f
AC
1244void
1245regcache_collect (int regnum, void *buf)
1246{
7bace51b 1247 regcache_raw_collect (current_regcache, regnum, buf);
193cb69f
AC
1248}
1249
a16d75cc 1250/* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE. */
9a661b68
MK
1251
1252void
1253regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
1254{
1255 void *regbuf;
1256 size_t size;
1257
a16d75cc 1258 gdb_assert (regcache != NULL);
9a661b68
MK
1259 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
1260 gdb_assert (!regcache->readonly_p);
1261
1262 /* FIXME: kettenis/20030828: It shouldn't be necessary to handle
1263 CURRENT_REGCACHE specially here. */
1264 if (regcache == current_regcache
1265 && !ptid_equal (registers_ptid, inferior_ptid))
1266 {
1267 registers_changed ();
1268 registers_ptid = inferior_ptid;
1269 }
1270
1271 regbuf = register_buffer (regcache, regnum);
1272 size = regcache->descr->sizeof_register[regnum];
1273
1274 if (buf)
1275 memcpy (regbuf, buf, size);
1276 else
1277 memset (regbuf, 0, size);
1278
1279 /* Mark the register as cached. */
1280 regcache->register_valid_p[regnum] = 1;
1281}
1282
1283/* Collect register REGNUM from REGCACHE and store its contents in BUF. */
1284
1285void
1286regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf)
1287{
1288 const void *regbuf;
1289 size_t size;
1290
1291 gdb_assert (regcache != NULL && buf != NULL);
1292 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
1293
1294 regbuf = register_buffer (regcache, regnum);
1295 size = regcache->descr->sizeof_register[regnum];
1296 memcpy (buf, regbuf, size);
1297}
1298
193cb69f 1299
0ba6dca9
AC
1300/* read_pc, write_pc, read_sp, deprecated_read_fp, etc. Special
1301 handling for registers PC, SP, and FP. */
32178cab 1302
cde9ea48
AC
1303/* NOTE: cagney/2001-02-18: The functions read_pc_pid(), read_pc(),
1304 read_sp(), and deprecated_read_fp(), will eventually be replaced by
1305 per-frame methods. Instead of relying on the global INFERIOR_PTID,
1306 they will use the contextual information provided by the FRAME.
1307 These functions do not belong in the register cache. */
32178cab 1308
cde9ea48
AC
1309/* NOTE: cagney/2003-06-07: The functions generic_target_write_pc(),
1310 write_pc_pid(), write_pc(), and deprecated_read_fp(), all need to
1311 be replaced by something that does not rely on global state. But
1312 what? */
32178cab
MS
1313
1314CORE_ADDR
39f77062 1315read_pc_pid (ptid_t ptid)
32178cab 1316{
39f77062 1317 ptid_t saved_inferior_ptid;
32178cab
MS
1318 CORE_ADDR pc_val;
1319
39f77062
KB
1320 /* In case ptid != inferior_ptid. */
1321 saved_inferior_ptid = inferior_ptid;
1322 inferior_ptid = ptid;
32178cab 1323
cde9ea48
AC
1324 if (TARGET_READ_PC_P ())
1325 pc_val = TARGET_READ_PC (ptid);
1326 /* Else use per-frame method on get_current_frame. */
1327 else if (PC_REGNUM >= 0)
1328 {
1329 CORE_ADDR raw_val = read_register_pid (PC_REGNUM, ptid);
6ba34a8d 1330 pc_val = ADDR_BITS_REMOVE (raw_val);
cde9ea48
AC
1331 }
1332 else
1333 internal_error (__FILE__, __LINE__, "read_pc_pid: Unable to find PC");
32178cab 1334
39f77062 1335 inferior_ptid = saved_inferior_ptid;
32178cab
MS
1336 return pc_val;
1337}
1338
1339CORE_ADDR
1340read_pc (void)
1341{
39f77062 1342 return read_pc_pid (inferior_ptid);
32178cab
MS
1343}
1344
32178cab 1345void
39f77062 1346generic_target_write_pc (CORE_ADDR pc, ptid_t ptid)
32178cab 1347{
32178cab 1348 if (PC_REGNUM >= 0)
39f77062 1349 write_register_pid (PC_REGNUM, pc, ptid);
afb18d0f
AC
1350 else
1351 internal_error (__FILE__, __LINE__,
1352 "generic_target_write_pc");
32178cab
MS
1353}
1354
1355void
39f77062 1356write_pc_pid (CORE_ADDR pc, ptid_t ptid)
32178cab 1357{
39f77062 1358 ptid_t saved_inferior_ptid;
32178cab 1359
39f77062
KB
1360 /* In case ptid != inferior_ptid. */
1361 saved_inferior_ptid = inferior_ptid;
1362 inferior_ptid = ptid;
32178cab 1363
39f77062 1364 TARGET_WRITE_PC (pc, ptid);
32178cab 1365
39f77062 1366 inferior_ptid = saved_inferior_ptid;
32178cab
MS
1367}
1368
1369void
1370write_pc (CORE_ADDR pc)
1371{
39f77062 1372 write_pc_pid (pc, inferior_ptid);
32178cab
MS
1373}
1374
1375/* Cope with strage ways of getting to the stack and frame pointers */
1376
32178cab
MS
1377CORE_ADDR
1378read_sp (void)
1379{
bd1ce8ba
AC
1380 if (TARGET_READ_SP_P ())
1381 return TARGET_READ_SP ();
a9e5fdc2
AC
1382 else if (gdbarch_unwind_sp_p (current_gdbarch))
1383 return get_frame_sp (get_current_frame ());
bd1ce8ba 1384 else if (SP_REGNUM >= 0)
a9e5fdc2
AC
1385 /* Try SP_REGNUM last: this makes all sorts of [wrong] assumptions
1386 about the architecture so put it at the end. */
bd1ce8ba
AC
1387 return read_register (SP_REGNUM);
1388 internal_error (__FILE__, __LINE__, "read_sp: Unable to find SP");
32178cab
MS
1389}
1390
32178cab 1391void
b46e02f6 1392deprecated_write_sp (CORE_ADDR val)
32178cab 1393{
b46e02f6
AC
1394 gdb_assert (SP_REGNUM >= 0);
1395 write_register (SP_REGNUM, val);
32178cab
MS
1396}
1397
32178cab 1398CORE_ADDR
0ba6dca9 1399deprecated_read_fp (void)
32178cab 1400{
0ba6dca9
AC
1401 if (DEPRECATED_TARGET_READ_FP_P ())
1402 return DEPRECATED_TARGET_READ_FP ();
1403 else if (DEPRECATED_FP_REGNUM >= 0)
1404 return read_register (DEPRECATED_FP_REGNUM);
1405 else
1406 internal_error (__FILE__, __LINE__, "deprecated_read_fp");
32178cab
MS
1407}
1408
705152c5
MS
1409static void
1410reg_flush_command (char *command, int from_tty)
1411{
1412 /* Force-flush the register cache. */
1413 registers_changed ();
1414 if (from_tty)
1415 printf_filtered ("Register cache flushed.\n");
1416}
1417
32178cab
MS
1418static void
1419build_regcache (void)
3fadccb3
AC
1420{
1421 current_regcache = regcache_xmalloc (current_gdbarch);
2d28509a 1422 current_regcache->readonly_p = 0;
524d7c18 1423 deprecated_registers = deprecated_grub_regcache_for_registers (current_regcache);
b923b08d 1424 deprecated_register_valid = current_regcache->register_valid_p;
3fadccb3
AC
1425}
1426
af030b9a
AC
1427static void
1428dump_endian_bytes (struct ui_file *file, enum bfd_endian endian,
1429 const unsigned char *buf, long len)
1430{
1431 int i;
1432 switch (endian)
1433 {
1434 case BFD_ENDIAN_BIG:
1435 for (i = 0; i < len; i++)
1436 fprintf_unfiltered (file, "%02x", buf[i]);
1437 break;
1438 case BFD_ENDIAN_LITTLE:
1439 for (i = len - 1; i >= 0; i--)
1440 fprintf_unfiltered (file, "%02x", buf[i]);
1441 break;
1442 default:
1443 internal_error (__FILE__, __LINE__, "Bad switch");
1444 }
1445}
1446
1447enum regcache_dump_what
1448{
b59ff9d5 1449 regcache_dump_none, regcache_dump_raw, regcache_dump_cooked, regcache_dump_groups
af030b9a
AC
1450};
1451
1452static void
1453regcache_dump (struct regcache *regcache, struct ui_file *file,
1454 enum regcache_dump_what what_to_dump)
1455{
1456 struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
b59ff9d5 1457 struct gdbarch *gdbarch = regcache->descr->gdbarch;
af030b9a
AC
1458 int regnum;
1459 int footnote_nr = 0;
1460 int footnote_register_size = 0;
1461 int footnote_register_offset = 0;
1462 int footnote_register_type_name_null = 0;
1463 long register_offset = 0;
123a958e 1464 unsigned char buf[MAX_REGISTER_SIZE];
af030b9a
AC
1465
1466#if 0
1467 fprintf_unfiltered (file, "legacy_p %d\n", regcache->descr->legacy_p);
1468 fprintf_unfiltered (file, "nr_raw_registers %d\n",
1469 regcache->descr->nr_raw_registers);
1470 fprintf_unfiltered (file, "nr_cooked_registers %d\n",
1471 regcache->descr->nr_cooked_registers);
1472 fprintf_unfiltered (file, "sizeof_raw_registers %ld\n",
1473 regcache->descr->sizeof_raw_registers);
1474 fprintf_unfiltered (file, "sizeof_raw_register_valid_p %ld\n",
1475 regcache->descr->sizeof_raw_register_valid_p);
af030b9a
AC
1476 fprintf_unfiltered (file, "NUM_REGS %d\n", NUM_REGS);
1477 fprintf_unfiltered (file, "NUM_PSEUDO_REGS %d\n", NUM_PSEUDO_REGS);
1478#endif
1479
1480 gdb_assert (regcache->descr->nr_cooked_registers
1481 == (NUM_REGS + NUM_PSEUDO_REGS));
1482
1483 for (regnum = -1; regnum < regcache->descr->nr_cooked_registers; regnum++)
1484 {
1485 /* Name. */
1486 if (regnum < 0)
1487 fprintf_unfiltered (file, " %-10s", "Name");
1488 else
1489 {
1490 const char *p = REGISTER_NAME (regnum);
1491 if (p == NULL)
1492 p = "";
1493 else if (p[0] == '\0')
1494 p = "''";
1495 fprintf_unfiltered (file, " %-10s", p);
1496 }
1497
1498 /* Number. */
1499 if (regnum < 0)
1500 fprintf_unfiltered (file, " %4s", "Nr");
1501 else
1502 fprintf_unfiltered (file, " %4d", regnum);
1503
1504 /* Relative number. */
1505 if (regnum < 0)
1506 fprintf_unfiltered (file, " %4s", "Rel");
1507 else if (regnum < NUM_REGS)
1508 fprintf_unfiltered (file, " %4d", regnum);
1509 else
1510 fprintf_unfiltered (file, " %4d", (regnum - NUM_REGS));
1511
1512 /* Offset. */
1513 if (regnum < 0)
1514 fprintf_unfiltered (file, " %6s ", "Offset");
1515 else
1516 {
1517 fprintf_unfiltered (file, " %6ld",
1518 regcache->descr->register_offset[regnum]);
a7e3c2ad 1519 if (register_offset != regcache->descr->register_offset[regnum]
62700349 1520 || register_offset != DEPRECATED_REGISTER_BYTE (regnum)
d3b22ed5
AC
1521 || (regnum > 0
1522 && (regcache->descr->register_offset[regnum]
1523 != (regcache->descr->register_offset[regnum - 1]
1524 + regcache->descr->sizeof_register[regnum - 1])))
1525 )
af030b9a
AC
1526 {
1527 if (!footnote_register_offset)
1528 footnote_register_offset = ++footnote_nr;
1529 fprintf_unfiltered (file, "*%d", footnote_register_offset);
1530 }
1531 else
1532 fprintf_unfiltered (file, " ");
1533 register_offset = (regcache->descr->register_offset[regnum]
1534 + regcache->descr->sizeof_register[regnum]);
1535 }
1536
1537 /* Size. */
1538 if (regnum < 0)
1539 fprintf_unfiltered (file, " %5s ", "Size");
1540 else
1541 {
1542 fprintf_unfiltered (file, " %5ld",
1543 regcache->descr->sizeof_register[regnum]);
1544 if ((regcache->descr->sizeof_register[regnum]
12c266ea 1545 != DEPRECATED_REGISTER_RAW_SIZE (regnum))
af030b9a 1546 || (regcache->descr->sizeof_register[regnum]
f30992d4 1547 != DEPRECATED_REGISTER_VIRTUAL_SIZE (regnum))
af030b9a 1548 || (regcache->descr->sizeof_register[regnum]
bb425013
AC
1549 != TYPE_LENGTH (register_type (regcache->descr->gdbarch,
1550 regnum)))
af030b9a
AC
1551 )
1552 {
1553 if (!footnote_register_size)
1554 footnote_register_size = ++footnote_nr;
1555 fprintf_unfiltered (file, "*%d", footnote_register_size);
1556 }
1557 else
1558 fprintf_unfiltered (file, " ");
1559 }
1560
1561 /* Type. */
b59ff9d5
AC
1562 {
1563 const char *t;
1564 if (regnum < 0)
1565 t = "Type";
1566 else
1567 {
1568 static const char blt[] = "builtin_type";
1569 t = TYPE_NAME (register_type (regcache->descr->gdbarch, regnum));
1570 if (t == NULL)
1571 {
1572 char *n;
1573 if (!footnote_register_type_name_null)
1574 footnote_register_type_name_null = ++footnote_nr;
1575 xasprintf (&n, "*%d", footnote_register_type_name_null);
1576 make_cleanup (xfree, n);
1577 t = n;
1578 }
1579 /* Chop a leading builtin_type. */
1580 if (strncmp (t, blt, strlen (blt)) == 0)
1581 t += strlen (blt);
1582 }
1583 fprintf_unfiltered (file, " %-15s", t);
1584 }
1585
1586 /* Leading space always present. */
1587 fprintf_unfiltered (file, " ");
af030b9a
AC
1588
1589 /* Value, raw. */
1590 if (what_to_dump == regcache_dump_raw)
1591 {
1592 if (regnum < 0)
1593 fprintf_unfiltered (file, "Raw value");
1594 else if (regnum >= regcache->descr->nr_raw_registers)
1595 fprintf_unfiltered (file, "<cooked>");
1596 else if (!regcache_valid_p (regcache, regnum))
1597 fprintf_unfiltered (file, "<invalid>");
1598 else
1599 {
1600 regcache_raw_read (regcache, regnum, buf);
1601 fprintf_unfiltered (file, "0x");
1602 dump_endian_bytes (file, TARGET_BYTE_ORDER, buf,
12c266ea 1603 DEPRECATED_REGISTER_RAW_SIZE (regnum));
af030b9a
AC
1604 }
1605 }
1606
1607 /* Value, cooked. */
1608 if (what_to_dump == regcache_dump_cooked)
1609 {
1610 if (regnum < 0)
1611 fprintf_unfiltered (file, "Cooked value");
1612 else
1613 {
1614 regcache_cooked_read (regcache, regnum, buf);
1615 fprintf_unfiltered (file, "0x");
1616 dump_endian_bytes (file, TARGET_BYTE_ORDER, buf,
f30992d4 1617 DEPRECATED_REGISTER_VIRTUAL_SIZE (regnum));
af030b9a
AC
1618 }
1619 }
1620
b59ff9d5
AC
1621 /* Group members. */
1622 if (what_to_dump == regcache_dump_groups)
1623 {
1624 if (regnum < 0)
1625 fprintf_unfiltered (file, "Groups");
1626 else
1627 {
b59ff9d5 1628 const char *sep = "";
6c7d17ba
AC
1629 struct reggroup *group;
1630 for (group = reggroup_next (gdbarch, NULL);
1631 group != NULL;
1632 group = reggroup_next (gdbarch, group))
b59ff9d5 1633 {
6c7d17ba 1634 if (gdbarch_register_reggroup_p (gdbarch, regnum, group))
b59ff9d5 1635 {
6c7d17ba 1636 fprintf_unfiltered (file, "%s%s", sep, reggroup_name (group));
b59ff9d5
AC
1637 sep = ",";
1638 }
1639 }
1640 }
1641 }
1642
af030b9a
AC
1643 fprintf_unfiltered (file, "\n");
1644 }
1645
1646 if (footnote_register_size)
1647 fprintf_unfiltered (file, "*%d: Inconsistent register sizes.\n",
1648 footnote_register_size);
1649 if (footnote_register_offset)
1650 fprintf_unfiltered (file, "*%d: Inconsistent register offsets.\n",
1651 footnote_register_offset);
1652 if (footnote_register_type_name_null)
1653 fprintf_unfiltered (file,
1654 "*%d: Register type's name NULL.\n",
1655 footnote_register_type_name_null);
1656 do_cleanups (cleanups);
1657}
1658
1659static void
1660regcache_print (char *args, enum regcache_dump_what what_to_dump)
1661{
1662 if (args == NULL)
1663 regcache_dump (current_regcache, gdb_stdout, what_to_dump);
1664 else
1665 {
1666 struct ui_file *file = gdb_fopen (args, "w");
1667 if (file == NULL)
1668 perror_with_name ("maintenance print architecture");
1669 regcache_dump (current_regcache, file, what_to_dump);
1670 ui_file_delete (file);
1671 }
1672}
1673
1674static void
1675maintenance_print_registers (char *args, int from_tty)
1676{
1677 regcache_print (args, regcache_dump_none);
1678}
1679
1680static void
1681maintenance_print_raw_registers (char *args, int from_tty)
1682{
1683 regcache_print (args, regcache_dump_raw);
1684}
1685
1686static void
1687maintenance_print_cooked_registers (char *args, int from_tty)
1688{
1689 regcache_print (args, regcache_dump_cooked);
1690}
1691
b59ff9d5
AC
1692static void
1693maintenance_print_register_groups (char *args, int from_tty)
1694{
1695 regcache_print (args, regcache_dump_groups);
1696}
1697
b9362cc7
AC
1698extern initialize_file_ftype _initialize_regcache; /* -Wmissing-prototype */
1699
32178cab
MS
1700void
1701_initialize_regcache (void)
1702{
030f20e1 1703 regcache_descr_handle = gdbarch_data_register_post_init (init_regcache_descr);
046a4708
AC
1704 DEPRECATED_REGISTER_GDBARCH_SWAP (current_regcache);
1705 DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_registers);
1706 DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_register_valid);
1707 deprecated_register_gdbarch_swap (NULL, 0, build_regcache);
705152c5 1708
f4c5303c
OF
1709 observer_attach_target_changed (regcache_observer_target_changed);
1710
705152c5
MS
1711 add_com ("flushregs", class_maintenance, reg_flush_command,
1712 "Force gdb to flush its register cache (maintainer command)");
39f77062
KB
1713
1714 /* Initialize the thread/process associated with the current set of
1715 registers. For now, -1 is special, and means `no current process'. */
1716 registers_ptid = pid_to_ptid (-1);
af030b9a
AC
1717
1718 add_cmd ("registers", class_maintenance,
1719 maintenance_print_registers,
1720 "Print the internal register configuration.\
1721Takes an optional file parameter.",
1722 &maintenanceprintlist);
1723 add_cmd ("raw-registers", class_maintenance,
1724 maintenance_print_raw_registers,
1725 "Print the internal register configuration including raw values.\
1726Takes an optional file parameter.",
1727 &maintenanceprintlist);
1728 add_cmd ("cooked-registers", class_maintenance,
1729 maintenance_print_cooked_registers,
1730 "Print the internal register configuration including cooked values.\
b59ff9d5
AC
1731Takes an optional file parameter.",
1732 &maintenanceprintlist);
1733 add_cmd ("register-groups", class_maintenance,
1734 maintenance_print_register_groups,
1735 "Print the internal register configuration including each register's group.\
af030b9a
AC
1736Takes an optional file parameter.",
1737 &maintenanceprintlist);
1738
32178cab 1739}
This page took 0.472254 seconds and 4 git commands to generate.