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