1 /* Cache and manage the values of registers for GDB, the GNU debugger.
3 Copyright 1986, 1987, 1989, 1991, 1994, 1995, 1996, 1998, 2000,
4 2001, 2002, 2004 Free Software Foundation, Inc.
6 This file is part of GDB.
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.
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.
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. */
29 #include "reggroups.h"
30 #include "gdb_assert.h"
31 #include "gdb_string.h"
32 #include "gdbcmd.h" /* For maintenanceprintlist. */
38 * Here is the actual register cache.
41 /* Per-architecture object describing the layout of a register cache.
42 Computed once when the architecture is created */
44 struct gdbarch_data *regcache_descr_handle;
48 /* The architecture this descriptor belongs to. */
49 struct gdbarch *gdbarch;
51 /* The raw register cache. Each raw (or hard) register is supplied
52 by the target interface. The raw cache should not contain
53 redundant information - if the PC is constructed from two
54 registers then those regigisters and not the PC lives in the raw
57 long sizeof_raw_registers;
58 long sizeof_raw_register_valid_p;
60 /* The cooked register space. Each cooked register in the range
61 [0..NR_RAW_REGISTERS) is direct-mapped onto the corresponding raw
62 register. The remaining [NR_RAW_REGISTERS
63 .. NR_COOKED_REGISTERS) (a.k.a. pseudo registers) are mapped onto
64 both raw registers and memory by the architecture methods
65 gdbarch_pseudo_register_read and gdbarch_pseudo_register_write. */
66 int nr_cooked_registers;
67 long sizeof_cooked_registers;
68 long sizeof_cooked_register_valid_p;
70 /* Offset and size (in 8 bit bytes), of reach register in the
71 register cache. All registers (including those in the range
72 [NR_RAW_REGISTERS .. NR_COOKED_REGISTERS) are given an offset.
73 Assigning all registers an offset makes it possible to keep
74 legacy code, such as that found in read_register_bytes() and
75 write_register_bytes() working. */
76 long *register_offset;
77 long *sizeof_register;
79 /* Cached table containing the type of each register. */
80 struct type **register_type;
84 init_regcache_descr (struct gdbarch *gdbarch)
87 struct regcache_descr *descr;
88 gdb_assert (gdbarch != NULL);
90 /* Create an initial, zero filled, table. */
91 descr = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct regcache_descr);
92 descr->gdbarch = gdbarch;
94 /* Total size of the register space. The raw registers are mapped
95 directly onto the raw register cache while the pseudo's are
96 either mapped onto raw-registers or memory. */
97 descr->nr_cooked_registers = NUM_REGS + NUM_PSEUDO_REGS;
98 descr->sizeof_cooked_register_valid_p = NUM_REGS + NUM_PSEUDO_REGS;
100 /* Fill in a table of register types. */
102 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, struct type *);
103 for (i = 0; i < descr->nr_cooked_registers; i++)
104 descr->register_type[i] = gdbarch_register_type (gdbarch, i);
106 /* Construct a strictly RAW register cache. Don't allow pseudo's
107 into the register cache. */
108 descr->nr_raw_registers = NUM_REGS;
110 /* FIXME: cagney/2002-08-13: Overallocate the register_valid_p
111 array. This pretects GDB from erant code that accesses elements
112 of the global register_valid_p[] array in the range [NUM_REGS
113 .. NUM_REGS + NUM_PSEUDO_REGS). */
114 descr->sizeof_raw_register_valid_p = descr->sizeof_cooked_register_valid_p;
116 /* Lay out the register cache.
118 NOTE: cagney/2002-05-22: Only register_type() is used when
119 constructing the register cache. It is assumed that the
120 register's raw size, virtual size and type length are all the
125 descr->sizeof_register
126 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
127 descr->register_offset
128 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
129 for (i = 0; i < descr->nr_cooked_registers; i++)
131 descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]);
132 descr->register_offset[i] = offset;
133 offset += descr->sizeof_register[i];
134 gdb_assert (MAX_REGISTER_SIZE >= descr->sizeof_register[i]);
136 /* Set the real size of the register cache buffer. */
137 descr->sizeof_cooked_registers = offset;
140 /* FIXME: cagney/2002-05-22: Should only need to allocate space for
141 the raw registers. Unfortunately some code still accesses the
142 register array directly using the global registers[]. Until that
143 code has been purged, play safe and over allocating the register
145 descr->sizeof_raw_registers = descr->sizeof_cooked_registers;
147 /* Sanity check. Confirm that there is agreement between the
148 regcache and the target's redundant DEPRECATED_REGISTER_BYTE (new
149 targets should not even be defining it). */
150 for (i = 0; i < descr->nr_cooked_registers; i++)
152 if (DEPRECATED_REGISTER_BYTE_P ())
153 gdb_assert (descr->register_offset[i] == DEPRECATED_REGISTER_BYTE (i));
155 gdb_assert (descr->sizeof_register[i] == DEPRECATED_REGISTER_RAW_SIZE (i));
156 gdb_assert (descr->sizeof_register[i] == DEPRECATED_REGISTER_VIRTUAL_SIZE (i));
159 /* gdb_assert (descr->sizeof_raw_registers == DEPRECATED_REGISTER_BYTES (i)); */
164 static struct regcache_descr *
165 regcache_descr (struct gdbarch *gdbarch)
167 return gdbarch_data (gdbarch, regcache_descr_handle);
170 /* Utility functions returning useful register attributes stored in
171 the regcache descr. */
174 register_type (struct gdbarch *gdbarch, int regnum)
176 struct regcache_descr *descr = regcache_descr (gdbarch);
177 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
178 return descr->register_type[regnum];
181 /* Utility functions returning useful register attributes stored in
182 the regcache descr. */
185 register_size (struct gdbarch *gdbarch, int regnum)
187 struct regcache_descr *descr = regcache_descr (gdbarch);
189 gdb_assert (regnum >= 0 && regnum < (NUM_REGS + NUM_PSEUDO_REGS));
190 size = descr->sizeof_register[regnum];
194 /* The register cache for storing raw register values. */
198 struct regcache_descr *descr;
199 /* The register buffers. A read-only register cache can hold the
200 full [0 .. NUM_REGS + NUM_PSEUDO_REGS) while a read/write
201 register cache can only hold [0 .. NUM_REGS). */
203 char *register_valid_p;
204 /* Is this a read-only cache? A read-only cache is used for saving
205 the target's register state (e.g, across an inferior function
206 call or just before forcing a function return). A read-only
207 cache can only be updated via the methods regcache_dup() and
208 regcache_cpy(). The actual contents are determined by the
209 reggroup_save and reggroup_restore methods. */
214 regcache_xmalloc (struct gdbarch *gdbarch)
216 struct regcache_descr *descr;
217 struct regcache *regcache;
218 gdb_assert (gdbarch != NULL);
219 descr = regcache_descr (gdbarch);
220 regcache = XMALLOC (struct regcache);
221 regcache->descr = descr;
223 = XCALLOC (descr->sizeof_raw_registers, char);
224 regcache->register_valid_p
225 = XCALLOC (descr->sizeof_raw_register_valid_p, char);
226 regcache->readonly_p = 1;
231 regcache_xfree (struct regcache *regcache)
233 if (regcache == NULL)
235 xfree (regcache->registers);
236 xfree (regcache->register_valid_p);
241 do_regcache_xfree (void *data)
243 regcache_xfree (data);
247 make_cleanup_regcache_xfree (struct regcache *regcache)
249 return make_cleanup (do_regcache_xfree, regcache);
252 /* Return REGCACHE's architecture. */
255 get_regcache_arch (const struct regcache *regcache)
257 return regcache->descr->gdbarch;
260 /* Return a pointer to register REGNUM's buffer cache. */
263 register_buffer (const struct regcache *regcache, int regnum)
265 return regcache->registers + regcache->descr->register_offset[regnum];
269 regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read,
272 struct gdbarch *gdbarch = dst->descr->gdbarch;
273 char buf[MAX_REGISTER_SIZE];
275 /* The DST should be `read-only', if it wasn't then the save would
276 end up trying to write the register values back out to the
278 gdb_assert (dst->readonly_p);
279 /* Clear the dest. */
280 memset (dst->registers, 0, dst->descr->sizeof_cooked_registers);
281 memset (dst->register_valid_p, 0, dst->descr->sizeof_cooked_register_valid_p);
282 /* Copy over any registers (identified by their membership in the
283 save_reggroup) and mark them as valid. The full [0 .. NUM_REGS +
284 NUM_PSEUDO_REGS) range is checked since some architectures need
285 to save/restore `cooked' registers that live in memory. */
286 for (regnum = 0; regnum < dst->descr->nr_cooked_registers; regnum++)
288 if (gdbarch_register_reggroup_p (gdbarch, regnum, save_reggroup))
290 int valid = cooked_read (src, regnum, buf);
293 memcpy (register_buffer (dst, regnum), buf,
294 register_size (gdbarch, regnum));
295 dst->register_valid_p[regnum] = 1;
302 regcache_restore (struct regcache *dst,
303 regcache_cooked_read_ftype *cooked_read,
306 struct gdbarch *gdbarch = dst->descr->gdbarch;
307 char buf[MAX_REGISTER_SIZE];
309 /* The dst had better not be read-only. If it is, the `restore'
310 doesn't make much sense. */
311 gdb_assert (!dst->readonly_p);
312 /* Copy over any registers, being careful to only restore those that
313 were both saved and need to be restored. The full [0 .. NUM_REGS
314 + NUM_PSEUDO_REGS) range is checked since some architectures need
315 to save/restore `cooked' registers that live in memory. */
316 for (regnum = 0; regnum < dst->descr->nr_cooked_registers; regnum++)
318 if (gdbarch_register_reggroup_p (gdbarch, regnum, restore_reggroup))
320 int valid = cooked_read (src, regnum, buf);
322 regcache_cooked_write (dst, regnum, buf);
328 do_cooked_read (void *src, int regnum, void *buf)
330 struct regcache *regcache = src;
331 if (!regcache->register_valid_p[regnum] && regcache->readonly_p)
332 /* Don't even think about fetching a register from a read-only
333 cache when the register isn't yet valid. There isn't a target
334 from which the register value can be fetched. */
336 regcache_cooked_read (regcache, regnum, buf);
342 regcache_cpy (struct regcache *dst, struct regcache *src)
346 gdb_assert (src != NULL && dst != NULL);
347 gdb_assert (src->descr->gdbarch == dst->descr->gdbarch);
348 gdb_assert (src != dst);
349 gdb_assert (src->readonly_p || dst->readonly_p);
350 if (!src->readonly_p)
351 regcache_save (dst, do_cooked_read, src);
352 else if (!dst->readonly_p)
353 regcache_restore (dst, do_cooked_read, src);
355 regcache_cpy_no_passthrough (dst, src);
359 regcache_cpy_no_passthrough (struct regcache *dst, struct regcache *src)
362 gdb_assert (src != NULL && dst != NULL);
363 gdb_assert (src->descr->gdbarch == dst->descr->gdbarch);
364 /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough
365 move of data into the current_regcache(). Doing this would be
366 silly - it would mean that valid_p would be completely invalid. */
367 gdb_assert (dst != current_regcache);
368 memcpy (dst->registers, src->registers, dst->descr->sizeof_raw_registers);
369 memcpy (dst->register_valid_p, src->register_valid_p,
370 dst->descr->sizeof_raw_register_valid_p);
374 regcache_dup (struct regcache *src)
376 struct regcache *newbuf;
377 gdb_assert (current_regcache != NULL);
378 newbuf = regcache_xmalloc (src->descr->gdbarch);
379 regcache_cpy (newbuf, src);
384 regcache_dup_no_passthrough (struct regcache *src)
386 struct regcache *newbuf;
387 gdb_assert (current_regcache != NULL);
388 newbuf = regcache_xmalloc (src->descr->gdbarch);
389 regcache_cpy_no_passthrough (newbuf, src);
394 regcache_valid_p (struct regcache *regcache, int regnum)
396 gdb_assert (regcache != NULL);
397 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
398 return regcache->register_valid_p[regnum];
402 deprecated_grub_regcache_for_registers (struct regcache *regcache)
404 return regcache->registers;
407 /* Global structure containing the current regcache. */
408 /* FIXME: cagney/2002-05-11: The two global arrays registers[] and
409 deprecated_register_valid[] currently point into this structure. */
410 struct regcache *current_regcache;
412 /* NOTE: this is a write-through cache. There is no "dirty" bit for
413 recording if the register values have been changed (eg. by the
414 user). Therefore all registers must be written back to the
415 target when appropriate. */
417 /* REGISTERS contains the cached register values (in target byte order). */
419 char *deprecated_registers;
421 /* DEPRECATED_REGISTER_VALID is 0 if the register needs to be fetched,
422 1 if it has been fetched, and
423 -1 if the register value was not available.
425 "Not available" indicates that the target is not not able to supply
426 the register at this state. The register may become available at a
427 later time (after the next resume). This often occures when GDB is
428 manipulating a target that contains only a snapshot of the entire
429 system being debugged - some of the registers in such a system may
430 not have been saved. */
432 signed char *deprecated_register_valid;
434 /* The thread/process associated with the current set of registers. */
436 static ptid_t registers_ptid;
444 Returns 0 if the value is not in the cache (needs fetch).
445 >0 if the value is in the cache.
446 <0 if the value is permanently unavailable (don't ask again). */
449 register_cached (int regnum)
451 return deprecated_register_valid[regnum];
454 /* Record that REGNUM's value is cached if STATE is >0, uncached but
455 fetchable if STATE is 0, and uncached and unfetchable if STATE is <0. */
458 set_register_cached (int regnum, int state)
460 gdb_assert (regnum >= 0);
461 gdb_assert (regnum < current_regcache->descr->nr_raw_registers);
462 current_regcache->register_valid_p[regnum] = state;
465 /* Return whether register REGNUM is a real register. */
468 real_register (int regnum)
470 return regnum >= 0 && regnum < NUM_REGS;
473 /* Observer for the target_changed event. */
476 regcache_observer_target_changed (struct target_ops *target)
478 registers_changed ();
481 /* Low level examining and depositing of registers.
483 The caller is responsible for making sure that the inferior is
484 stopped before calling the fetching routines, or it will get
485 garbage. (a change from GDB version 3, in which the caller got the
486 value from the last stop). */
488 /* REGISTERS_CHANGED ()
490 Indicate that registers may have changed, so invalidate the cache. */
493 registers_changed (void)
497 registers_ptid = pid_to_ptid (-1);
499 /* Force cleanup of any alloca areas if using C alloca instead of
500 a builtin alloca. This particular call is used to clean up
501 areas allocated by low level target code which may build up
502 during lengthy interactions between gdb and the target before
503 gdb gives control to the user (ie watchpoints). */
506 for (i = 0; i < current_regcache->descr->nr_raw_registers; i++)
507 set_register_cached (i, 0);
509 if (deprecated_registers_changed_hook)
510 deprecated_registers_changed_hook ();
513 /* DEPRECATED_REGISTERS_FETCHED ()
515 Indicate that all registers have been fetched, so mark them all valid. */
517 /* FIXME: cagney/2001-12-04: This function is DEPRECATED. The target
518 code was blatting the registers[] array and then calling this.
519 Since targets should only be using regcache_raw_supply() the need for
520 this function/hack is eliminated. */
523 deprecated_registers_fetched (void)
527 for (i = 0; i < NUM_REGS; i++)
528 set_register_cached (i, 1);
529 /* Do not assume that the pseudo-regs have also been fetched.
530 Fetching all real regs NEVER accounts for pseudo-regs. */
533 /* deprecated_read_register_bytes and deprecated_write_register_bytes
534 are generally a *BAD* idea. They are inefficient because they need
535 to check for partial updates, which can only be done by scanning
536 through all of the registers and seeing if the bytes that are being
537 read/written fall inside of an invalid register. [The main reason
538 this is necessary is that register sizes can vary, so a simple
539 index won't suffice.] It is far better to call read_register_gen
540 and write_register_gen if you want to get at the raw register
541 contents, as it only takes a regnum as an argument, and therefore
542 can't do a partial register update.
544 Prior to the recent fixes to check for partial updates, both read
545 and deprecated_write_register_bytes always checked to see if any
546 registers were stale, and then called target_fetch_registers (-1)
547 to update the whole set. This caused really slowed things down for
550 /* Copy INLEN bytes of consecutive data from registers
551 starting with the INREGBYTE'th byte of register data
552 into memory at MYADDR. */
555 deprecated_read_register_bytes (int in_start, char *in_buf, int in_len)
557 int in_end = in_start + in_len;
559 char reg_buf[MAX_REGISTER_SIZE];
561 /* See if we are trying to read bytes from out-of-date registers. If so,
562 update just those registers. */
564 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
573 reg_start = DEPRECATED_REGISTER_BYTE (regnum);
574 reg_len = DEPRECATED_REGISTER_RAW_SIZE (regnum);
575 reg_end = reg_start + reg_len;
577 if (reg_end <= in_start || in_end <= reg_start)
578 /* The range the user wants to read doesn't overlap with regnum. */
581 if (REGISTER_NAME (regnum) != NULL && *REGISTER_NAME (regnum) != '\0')
582 /* Force the cache to fetch the entire register. */
583 deprecated_read_register_gen (regnum, reg_buf);
585 /* Legacy note: even though this register is ``invalid'' we
586 still need to return something. It would appear that some
587 code relies on apparent gaps in the register array also
589 /* FIXME: cagney/2001-08-18: This is just silly. It defeats
590 the entire register read/write flow of control. Must
591 resist temptation to return 0xdeadbeef. */
592 memcpy (reg_buf, &deprecated_registers[reg_start], reg_len);
594 /* Legacy note: This function, for some reason, allows a NULL
595 input buffer. If the buffer is NULL, the registers are still
596 fetched, just the final transfer is skipped. */
600 /* start = max (reg_start, in_start) */
601 if (reg_start > in_start)
606 /* end = min (reg_end, in_end) */
607 if (reg_end < in_end)
612 /* Transfer just the bytes common to both IN_BUF and REG_BUF */
613 for (byte = start; byte < end; byte++)
615 in_buf[byte - in_start] = reg_buf[byte - reg_start];
620 /* Read register REGNUM into memory at MYADDR, which must be large
621 enough for REGISTER_RAW_BYTES (REGNUM). Target byte-order. If the
622 register is known to be the size of a CORE_ADDR or smaller,
623 read_register can be used instead. */
626 legacy_read_register_gen (int regnum, char *myaddr)
628 gdb_assert (regnum >= 0 && regnum < (NUM_REGS + NUM_PSEUDO_REGS));
629 if (! ptid_equal (registers_ptid, inferior_ptid))
631 registers_changed ();
632 registers_ptid = inferior_ptid;
635 if (!register_cached (regnum))
636 target_fetch_registers (regnum);
638 memcpy (myaddr, register_buffer (current_regcache, regnum),
639 DEPRECATED_REGISTER_RAW_SIZE (regnum));
643 regcache_raw_read (struct regcache *regcache, int regnum, void *buf)
645 gdb_assert (regcache != NULL && buf != NULL);
646 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
647 /* Make certain that the register cache is up-to-date with respect
648 to the current thread. This switching shouldn't be necessary
649 only there is still only one target side register cache. Sigh!
650 On the bright side, at least there is a regcache object. */
651 if (!regcache->readonly_p)
653 gdb_assert (regcache == current_regcache);
654 if (! ptid_equal (registers_ptid, inferior_ptid))
656 registers_changed ();
657 registers_ptid = inferior_ptid;
659 if (!register_cached (regnum))
660 target_fetch_registers (regnum);
662 /* Copy the value directly into the register cache. */
663 memcpy (buf, register_buffer (regcache, regnum),
664 regcache->descr->sizeof_register[regnum]);
668 regcache_raw_read_signed (struct regcache *regcache, int regnum, LONGEST *val)
671 gdb_assert (regcache != NULL);
672 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
673 buf = alloca (regcache->descr->sizeof_register[regnum]);
674 regcache_raw_read (regcache, regnum, buf);
675 (*val) = extract_signed_integer (buf,
676 regcache->descr->sizeof_register[regnum]);
680 regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
684 gdb_assert (regcache != NULL);
685 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
686 buf = alloca (regcache->descr->sizeof_register[regnum]);
687 regcache_raw_read (regcache, regnum, buf);
688 (*val) = extract_unsigned_integer (buf,
689 regcache->descr->sizeof_register[regnum]);
693 regcache_raw_write_signed (struct regcache *regcache, int regnum, LONGEST val)
696 gdb_assert (regcache != NULL);
697 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
698 buf = alloca (regcache->descr->sizeof_register[regnum]);
699 store_signed_integer (buf, regcache->descr->sizeof_register[regnum], val);
700 regcache_raw_write (regcache, regnum, buf);
704 regcache_raw_write_unsigned (struct regcache *regcache, int regnum,
708 gdb_assert (regcache != NULL);
709 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
710 buf = alloca (regcache->descr->sizeof_register[regnum]);
711 store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], val);
712 regcache_raw_write (regcache, regnum, buf);
716 deprecated_read_register_gen (int regnum, char *buf)
718 gdb_assert (current_regcache != NULL);
719 gdb_assert (current_regcache->descr->gdbarch == current_gdbarch);
720 regcache_cooked_read (current_regcache, regnum, buf);
724 regcache_cooked_read (struct regcache *regcache, int regnum, void *buf)
726 gdb_assert (regnum >= 0);
727 gdb_assert (regnum < regcache->descr->nr_cooked_registers);
728 if (regnum < regcache->descr->nr_raw_registers)
729 regcache_raw_read (regcache, regnum, buf);
730 else if (regcache->readonly_p
731 && regnum < regcache->descr->nr_cooked_registers
732 && regcache->register_valid_p[regnum])
733 /* Read-only register cache, perhaps the cooked value was cached? */
734 memcpy (buf, register_buffer (regcache, regnum),
735 regcache->descr->sizeof_register[regnum]);
737 gdbarch_pseudo_register_read (regcache->descr->gdbarch, regcache,
742 regcache_cooked_read_signed (struct regcache *regcache, int regnum,
746 gdb_assert (regcache != NULL);
747 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
748 buf = alloca (regcache->descr->sizeof_register[regnum]);
749 regcache_cooked_read (regcache, regnum, buf);
750 (*val) = extract_signed_integer (buf,
751 regcache->descr->sizeof_register[regnum]);
755 regcache_cooked_read_unsigned (struct regcache *regcache, int regnum,
759 gdb_assert (regcache != NULL);
760 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
761 buf = alloca (regcache->descr->sizeof_register[regnum]);
762 regcache_cooked_read (regcache, regnum, buf);
763 (*val) = extract_unsigned_integer (buf,
764 regcache->descr->sizeof_register[regnum]);
768 regcache_cooked_write_signed (struct regcache *regcache, int regnum,
772 gdb_assert (regcache != NULL);
773 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
774 buf = alloca (regcache->descr->sizeof_register[regnum]);
775 store_signed_integer (buf, regcache->descr->sizeof_register[regnum], val);
776 regcache_cooked_write (regcache, regnum, buf);
780 regcache_cooked_write_unsigned (struct regcache *regcache, int regnum,
784 gdb_assert (regcache != NULL);
785 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
786 buf = alloca (regcache->descr->sizeof_register[regnum]);
787 store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], val);
788 regcache_cooked_write (regcache, regnum, buf);
791 /* Write register REGNUM at MYADDR to the target. MYADDR points at
792 REGISTER_RAW_BYTES(REGNUM), which must be in target byte-order. */
795 legacy_write_register_gen (int regnum, const void *myaddr)
798 gdb_assert (regnum >= 0 && regnum < (NUM_REGS + NUM_PSEUDO_REGS));
800 /* On the sparc, writing %g0 is a no-op, so we don't even want to
801 change the registers array if something writes to this register. */
802 if (CANNOT_STORE_REGISTER (regnum))
805 if (! ptid_equal (registers_ptid, inferior_ptid))
807 registers_changed ();
808 registers_ptid = inferior_ptid;
811 size = DEPRECATED_REGISTER_RAW_SIZE (regnum);
813 if (real_register (regnum))
815 /* If we have a valid copy of the register, and new value == old
816 value, then don't bother doing the actual store. */
817 if (register_cached (regnum)
818 && (memcmp (register_buffer (current_regcache, regnum), myaddr, size)
822 target_prepare_to_store ();
825 memcpy (register_buffer (current_regcache, regnum), myaddr, size);
827 set_register_cached (regnum, 1);
828 target_store_registers (regnum);
832 regcache_raw_write (struct regcache *regcache, int regnum, const void *buf)
834 gdb_assert (regcache != NULL && buf != NULL);
835 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
836 gdb_assert (!regcache->readonly_p);
838 /* On the sparc, writing %g0 is a no-op, so we don't even want to
839 change the registers array if something writes to this register. */
840 if (CANNOT_STORE_REGISTER (regnum))
843 /* Make certain that the correct cache is selected. */
844 gdb_assert (regcache == current_regcache);
845 if (! ptid_equal (registers_ptid, inferior_ptid))
847 registers_changed ();
848 registers_ptid = inferior_ptid;
851 /* If we have a valid copy of the register, and new value == old
852 value, then don't bother doing the actual store. */
853 if (regcache_valid_p (regcache, regnum)
854 && (memcmp (register_buffer (regcache, regnum), buf,
855 regcache->descr->sizeof_register[regnum]) == 0))
858 target_prepare_to_store ();
859 memcpy (register_buffer (regcache, regnum), buf,
860 regcache->descr->sizeof_register[regnum]);
861 regcache->register_valid_p[regnum] = 1;
862 target_store_registers (regnum);
866 deprecated_write_register_gen (int regnum, char *buf)
868 gdb_assert (current_regcache != NULL);
869 gdb_assert (current_regcache->descr->gdbarch == current_gdbarch);
870 regcache_cooked_write (current_regcache, regnum, buf);
874 regcache_cooked_write (struct regcache *regcache, int regnum, const void *buf)
876 gdb_assert (regnum >= 0);
877 gdb_assert (regnum < regcache->descr->nr_cooked_registers);
878 if (regnum < regcache->descr->nr_raw_registers)
879 regcache_raw_write (regcache, regnum, buf);
881 gdbarch_pseudo_register_write (regcache->descr->gdbarch, regcache,
885 /* Copy INLEN bytes of consecutive data from memory at MYADDR
886 into registers starting with the MYREGSTART'th byte of register data. */
889 deprecated_write_register_bytes (int myregstart, char *myaddr, int inlen)
891 int myregend = myregstart + inlen;
894 target_prepare_to_store ();
896 /* Scan through the registers updating any that are covered by the
897 range myregstart<=>myregend using write_register_gen, which does
898 nice things like handling threads, and avoiding updates when the
899 new and old contents are the same. */
901 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
903 int regstart, regend;
905 regstart = DEPRECATED_REGISTER_BYTE (regnum);
906 regend = regstart + DEPRECATED_REGISTER_RAW_SIZE (regnum);
908 /* Is this register completely outside the range the user is writing? */
909 if (myregend <= regstart || regend <= myregstart)
912 /* Is this register completely within the range the user is writing? */
913 else if (myregstart <= regstart && regend <= myregend)
914 deprecated_write_register_gen (regnum, myaddr + (regstart - myregstart));
916 /* The register partially overlaps the range being written. */
919 char regbuf[MAX_REGISTER_SIZE];
920 /* What's the overlap between this register's bytes and
921 those the caller wants to write? */
922 int overlapstart = max (regstart, myregstart);
923 int overlapend = min (regend, myregend);
925 /* We may be doing a partial update of an invalid register.
926 Update it from the target before scribbling on it. */
927 deprecated_read_register_gen (regnum, regbuf);
929 memcpy (&deprecated_registers[overlapstart],
930 myaddr + (overlapstart - myregstart),
931 overlapend - overlapstart);
933 target_store_registers (regnum);
938 /* Perform a partial register transfer using a read, modify, write
941 typedef void (regcache_read_ftype) (struct regcache *regcache, int regnum,
943 typedef void (regcache_write_ftype) (struct regcache *regcache, int regnum,
947 regcache_xfer_part (struct regcache *regcache, int regnum,
948 int offset, int len, void *in, const void *out,
949 regcache_read_ftype *read, regcache_write_ftype *write)
951 struct regcache_descr *descr = regcache->descr;
952 bfd_byte reg[MAX_REGISTER_SIZE];
953 gdb_assert (offset >= 0 && offset <= descr->sizeof_register[regnum]);
954 gdb_assert (len >= 0 && offset + len <= descr->sizeof_register[regnum]);
955 /* Something to do? */
956 if (offset + len == 0)
958 /* Read (when needed) ... */
961 || offset + len < descr->sizeof_register[regnum])
963 gdb_assert (read != NULL);
964 read (regcache, regnum, reg);
968 memcpy (in, reg + offset, len);
970 memcpy (reg + offset, out, len);
971 /* ... write (when needed). */
974 gdb_assert (write != NULL);
975 write (regcache, regnum, reg);
980 regcache_raw_read_part (struct regcache *regcache, int regnum,
981 int offset, int len, void *buf)
983 struct regcache_descr *descr = regcache->descr;
984 gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
985 regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
986 regcache_raw_read, regcache_raw_write);
990 regcache_raw_write_part (struct regcache *regcache, int regnum,
991 int offset, int len, const void *buf)
993 struct regcache_descr *descr = regcache->descr;
994 gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
995 regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
996 regcache_raw_read, regcache_raw_write);
1000 regcache_cooked_read_part (struct regcache *regcache, int regnum,
1001 int offset, int len, void *buf)
1003 struct regcache_descr *descr = regcache->descr;
1004 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
1005 regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
1006 regcache_cooked_read, regcache_cooked_write);
1010 regcache_cooked_write_part (struct regcache *regcache, int regnum,
1011 int offset, int len, const void *buf)
1013 struct regcache_descr *descr = regcache->descr;
1014 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
1015 regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
1016 regcache_cooked_read, regcache_cooked_write);
1019 /* Hack to keep code that view the register buffer as raw bytes
1023 register_offset_hack (struct gdbarch *gdbarch, int regnum)
1025 struct regcache_descr *descr = regcache_descr (gdbarch);
1026 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
1027 return descr->register_offset[regnum];
1030 /* Return the contents of register REGNUM as an unsigned integer. */
1033 read_register (int regnum)
1035 char *buf = alloca (DEPRECATED_REGISTER_RAW_SIZE (regnum));
1036 deprecated_read_register_gen (regnum, buf);
1037 return (extract_unsigned_integer (buf, DEPRECATED_REGISTER_RAW_SIZE (regnum)));
1041 read_register_pid (int regnum, ptid_t ptid)
1047 if (ptid_equal (ptid, inferior_ptid))
1048 return read_register (regnum);
1050 save_ptid = inferior_ptid;
1052 inferior_ptid = ptid;
1054 retval = read_register (regnum);
1056 inferior_ptid = save_ptid;
1061 /* Store VALUE into the raw contents of register number REGNUM. */
1064 write_register (int regnum, LONGEST val)
1068 size = DEPRECATED_REGISTER_RAW_SIZE (regnum);
1069 buf = alloca (size);
1070 store_signed_integer (buf, size, (LONGEST) val);
1071 deprecated_write_register_gen (regnum, buf);
1075 write_register_pid (int regnum, CORE_ADDR val, ptid_t ptid)
1079 if (ptid_equal (ptid, inferior_ptid))
1081 write_register (regnum, val);
1085 save_ptid = inferior_ptid;
1087 inferior_ptid = ptid;
1089 write_register (regnum, val);
1091 inferior_ptid = save_ptid;
1094 /* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE. */
1097 regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
1102 gdb_assert (regcache != NULL);
1103 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
1104 gdb_assert (!regcache->readonly_p);
1106 /* FIXME: kettenis/20030828: It shouldn't be necessary to handle
1107 CURRENT_REGCACHE specially here. */
1108 if (regcache == current_regcache
1109 && !ptid_equal (registers_ptid, inferior_ptid))
1111 registers_changed ();
1112 registers_ptid = inferior_ptid;
1115 regbuf = register_buffer (regcache, regnum);
1116 size = regcache->descr->sizeof_register[regnum];
1119 memcpy (regbuf, buf, size);
1121 memset (regbuf, 0, size);
1123 /* Mark the register as cached. */
1124 regcache->register_valid_p[regnum] = 1;
1127 /* Collect register REGNUM from REGCACHE and store its contents in BUF. */
1130 regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf)
1135 gdb_assert (regcache != NULL && buf != NULL);
1136 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
1138 regbuf = register_buffer (regcache, regnum);
1139 size = regcache->descr->sizeof_register[regnum];
1140 memcpy (buf, regbuf, size);
1144 /* read_pc, write_pc, read_sp, deprecated_read_fp, etc. Special
1145 handling for registers PC, SP, and FP. */
1147 /* NOTE: cagney/2001-02-18: The functions read_pc_pid(), read_pc(),
1148 read_sp(), and deprecated_read_fp(), will eventually be replaced by
1149 per-frame methods. Instead of relying on the global INFERIOR_PTID,
1150 they will use the contextual information provided by the FRAME.
1151 These functions do not belong in the register cache. */
1153 /* NOTE: cagney/2003-06-07: The functions generic_target_write_pc(),
1154 write_pc_pid(), write_pc(), and deprecated_read_fp(), all need to
1155 be replaced by something that does not rely on global state. But
1159 read_pc_pid (ptid_t ptid)
1161 ptid_t saved_inferior_ptid;
1164 /* In case ptid != inferior_ptid. */
1165 saved_inferior_ptid = inferior_ptid;
1166 inferior_ptid = ptid;
1168 if (TARGET_READ_PC_P ())
1169 pc_val = TARGET_READ_PC (ptid);
1170 /* Else use per-frame method on get_current_frame. */
1171 else if (PC_REGNUM >= 0)
1173 CORE_ADDR raw_val = read_register_pid (PC_REGNUM, ptid);
1174 pc_val = ADDR_BITS_REMOVE (raw_val);
1177 internal_error (__FILE__, __LINE__, "read_pc_pid: Unable to find PC");
1179 inferior_ptid = saved_inferior_ptid;
1186 return read_pc_pid (inferior_ptid);
1190 generic_target_write_pc (CORE_ADDR pc, ptid_t ptid)
1193 write_register_pid (PC_REGNUM, pc, ptid);
1195 internal_error (__FILE__, __LINE__,
1196 "generic_target_write_pc");
1200 write_pc_pid (CORE_ADDR pc, ptid_t ptid)
1202 ptid_t saved_inferior_ptid;
1204 /* In case ptid != inferior_ptid. */
1205 saved_inferior_ptid = inferior_ptid;
1206 inferior_ptid = ptid;
1208 TARGET_WRITE_PC (pc, ptid);
1210 inferior_ptid = saved_inferior_ptid;
1214 write_pc (CORE_ADDR pc)
1216 write_pc_pid (pc, inferior_ptid);
1219 /* Cope with strage ways of getting to the stack and frame pointers */
1224 if (TARGET_READ_SP_P ())
1225 return TARGET_READ_SP ();
1226 else if (gdbarch_unwind_sp_p (current_gdbarch))
1227 return get_frame_sp (get_current_frame ());
1228 else if (SP_REGNUM >= 0)
1229 /* Try SP_REGNUM last: this makes all sorts of [wrong] assumptions
1230 about the architecture so put it at the end. */
1231 return read_register (SP_REGNUM);
1232 internal_error (__FILE__, __LINE__, "read_sp: Unable to find SP");
1236 deprecated_write_sp (CORE_ADDR val)
1238 gdb_assert (SP_REGNUM >= 0);
1239 write_register (SP_REGNUM, val);
1243 deprecated_read_fp (void)
1245 if (DEPRECATED_TARGET_READ_FP_P ())
1246 return DEPRECATED_TARGET_READ_FP ();
1247 else if (DEPRECATED_FP_REGNUM >= 0)
1248 return read_register (DEPRECATED_FP_REGNUM);
1250 internal_error (__FILE__, __LINE__, "deprecated_read_fp");
1254 reg_flush_command (char *command, int from_tty)
1256 /* Force-flush the register cache. */
1257 registers_changed ();
1259 printf_filtered ("Register cache flushed.\n");
1263 build_regcache (void)
1265 current_regcache = regcache_xmalloc (current_gdbarch);
1266 current_regcache->readonly_p = 0;
1267 deprecated_registers = deprecated_grub_regcache_for_registers (current_regcache);
1268 deprecated_register_valid = current_regcache->register_valid_p;
1272 dump_endian_bytes (struct ui_file *file, enum bfd_endian endian,
1273 const unsigned char *buf, long len)
1278 case BFD_ENDIAN_BIG:
1279 for (i = 0; i < len; i++)
1280 fprintf_unfiltered (file, "%02x", buf[i]);
1282 case BFD_ENDIAN_LITTLE:
1283 for (i = len - 1; i >= 0; i--)
1284 fprintf_unfiltered (file, "%02x", buf[i]);
1287 internal_error (__FILE__, __LINE__, "Bad switch");
1291 enum regcache_dump_what
1293 regcache_dump_none, regcache_dump_raw, regcache_dump_cooked, regcache_dump_groups
1297 regcache_dump (struct regcache *regcache, struct ui_file *file,
1298 enum regcache_dump_what what_to_dump)
1300 struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
1301 struct gdbarch *gdbarch = regcache->descr->gdbarch;
1303 int footnote_nr = 0;
1304 int footnote_register_size = 0;
1305 int footnote_register_offset = 0;
1306 int footnote_register_type_name_null = 0;
1307 long register_offset = 0;
1308 unsigned char buf[MAX_REGISTER_SIZE];
1311 fprintf_unfiltered (file, "nr_raw_registers %d\n",
1312 regcache->descr->nr_raw_registers);
1313 fprintf_unfiltered (file, "nr_cooked_registers %d\n",
1314 regcache->descr->nr_cooked_registers);
1315 fprintf_unfiltered (file, "sizeof_raw_registers %ld\n",
1316 regcache->descr->sizeof_raw_registers);
1317 fprintf_unfiltered (file, "sizeof_raw_register_valid_p %ld\n",
1318 regcache->descr->sizeof_raw_register_valid_p);
1319 fprintf_unfiltered (file, "NUM_REGS %d\n", NUM_REGS);
1320 fprintf_unfiltered (file, "NUM_PSEUDO_REGS %d\n", NUM_PSEUDO_REGS);
1323 gdb_assert (regcache->descr->nr_cooked_registers
1324 == (NUM_REGS + NUM_PSEUDO_REGS));
1326 for (regnum = -1; regnum < regcache->descr->nr_cooked_registers; regnum++)
1330 fprintf_unfiltered (file, " %-10s", "Name");
1333 const char *p = REGISTER_NAME (regnum);
1336 else if (p[0] == '\0')
1338 fprintf_unfiltered (file, " %-10s", p);
1343 fprintf_unfiltered (file, " %4s", "Nr");
1345 fprintf_unfiltered (file, " %4d", regnum);
1347 /* Relative number. */
1349 fprintf_unfiltered (file, " %4s", "Rel");
1350 else if (regnum < NUM_REGS)
1351 fprintf_unfiltered (file, " %4d", regnum);
1353 fprintf_unfiltered (file, " %4d", (regnum - NUM_REGS));
1357 fprintf_unfiltered (file, " %6s ", "Offset");
1360 fprintf_unfiltered (file, " %6ld",
1361 regcache->descr->register_offset[regnum]);
1362 if (register_offset != regcache->descr->register_offset[regnum]
1363 || register_offset != DEPRECATED_REGISTER_BYTE (regnum)
1365 && (regcache->descr->register_offset[regnum]
1366 != (regcache->descr->register_offset[regnum - 1]
1367 + regcache->descr->sizeof_register[regnum - 1])))
1370 if (!footnote_register_offset)
1371 footnote_register_offset = ++footnote_nr;
1372 fprintf_unfiltered (file, "*%d", footnote_register_offset);
1375 fprintf_unfiltered (file, " ");
1376 register_offset = (regcache->descr->register_offset[regnum]
1377 + regcache->descr->sizeof_register[regnum]);
1382 fprintf_unfiltered (file, " %5s ", "Size");
1385 fprintf_unfiltered (file, " %5ld",
1386 regcache->descr->sizeof_register[regnum]);
1387 if ((regcache->descr->sizeof_register[regnum]
1388 != DEPRECATED_REGISTER_RAW_SIZE (regnum))
1389 || (regcache->descr->sizeof_register[regnum]
1390 != DEPRECATED_REGISTER_VIRTUAL_SIZE (regnum))
1391 || (regcache->descr->sizeof_register[regnum]
1392 != TYPE_LENGTH (register_type (regcache->descr->gdbarch,
1396 if (!footnote_register_size)
1397 footnote_register_size = ++footnote_nr;
1398 fprintf_unfiltered (file, "*%d", footnote_register_size);
1401 fprintf_unfiltered (file, " ");
1411 static const char blt[] = "builtin_type";
1412 t = TYPE_NAME (register_type (regcache->descr->gdbarch, regnum));
1416 if (!footnote_register_type_name_null)
1417 footnote_register_type_name_null = ++footnote_nr;
1418 n = xstrprintf ("*%d", footnote_register_type_name_null);
1419 make_cleanup (xfree, n);
1422 /* Chop a leading builtin_type. */
1423 if (strncmp (t, blt, strlen (blt)) == 0)
1426 fprintf_unfiltered (file, " %-15s", t);
1429 /* Leading space always present. */
1430 fprintf_unfiltered (file, " ");
1433 if (what_to_dump == regcache_dump_raw)
1436 fprintf_unfiltered (file, "Raw value");
1437 else if (regnum >= regcache->descr->nr_raw_registers)
1438 fprintf_unfiltered (file, "<cooked>");
1439 else if (!regcache_valid_p (regcache, regnum))
1440 fprintf_unfiltered (file, "<invalid>");
1443 regcache_raw_read (regcache, regnum, buf);
1444 fprintf_unfiltered (file, "0x");
1445 dump_endian_bytes (file, TARGET_BYTE_ORDER, buf,
1446 DEPRECATED_REGISTER_RAW_SIZE (regnum));
1450 /* Value, cooked. */
1451 if (what_to_dump == regcache_dump_cooked)
1454 fprintf_unfiltered (file, "Cooked value");
1457 regcache_cooked_read (regcache, regnum, buf);
1458 fprintf_unfiltered (file, "0x");
1459 dump_endian_bytes (file, TARGET_BYTE_ORDER, buf,
1460 DEPRECATED_REGISTER_VIRTUAL_SIZE (regnum));
1464 /* Group members. */
1465 if (what_to_dump == regcache_dump_groups)
1468 fprintf_unfiltered (file, "Groups");
1471 const char *sep = "";
1472 struct reggroup *group;
1473 for (group = reggroup_next (gdbarch, NULL);
1475 group = reggroup_next (gdbarch, group))
1477 if (gdbarch_register_reggroup_p (gdbarch, regnum, group))
1479 fprintf_unfiltered (file, "%s%s", sep, reggroup_name (group));
1486 fprintf_unfiltered (file, "\n");
1489 if (footnote_register_size)
1490 fprintf_unfiltered (file, "*%d: Inconsistent register sizes.\n",
1491 footnote_register_size);
1492 if (footnote_register_offset)
1493 fprintf_unfiltered (file, "*%d: Inconsistent register offsets.\n",
1494 footnote_register_offset);
1495 if (footnote_register_type_name_null)
1496 fprintf_unfiltered (file,
1497 "*%d: Register type's name NULL.\n",
1498 footnote_register_type_name_null);
1499 do_cleanups (cleanups);
1503 regcache_print (char *args, enum regcache_dump_what what_to_dump)
1506 regcache_dump (current_regcache, gdb_stdout, what_to_dump);
1509 struct ui_file *file = gdb_fopen (args, "w");
1511 perror_with_name ("maintenance print architecture");
1512 regcache_dump (current_regcache, file, what_to_dump);
1513 ui_file_delete (file);
1518 maintenance_print_registers (char *args, int from_tty)
1520 regcache_print (args, regcache_dump_none);
1524 maintenance_print_raw_registers (char *args, int from_tty)
1526 regcache_print (args, regcache_dump_raw);
1530 maintenance_print_cooked_registers (char *args, int from_tty)
1532 regcache_print (args, regcache_dump_cooked);
1536 maintenance_print_register_groups (char *args, int from_tty)
1538 regcache_print (args, regcache_dump_groups);
1541 extern initialize_file_ftype _initialize_regcache; /* -Wmissing-prototype */
1544 _initialize_regcache (void)
1546 regcache_descr_handle = gdbarch_data_register_post_init (init_regcache_descr);
1547 DEPRECATED_REGISTER_GDBARCH_SWAP (current_regcache);
1548 DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_registers);
1549 DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_register_valid);
1550 deprecated_register_gdbarch_swap (NULL, 0, build_regcache);
1552 observer_attach_target_changed (regcache_observer_target_changed);
1554 add_com ("flushregs", class_maintenance, reg_flush_command,
1555 "Force gdb to flush its register cache (maintainer command)");
1557 /* Initialize the thread/process associated with the current set of
1558 registers. For now, -1 is special, and means `no current process'. */
1559 registers_ptid = pid_to_ptid (-1);
1561 add_cmd ("registers", class_maintenance,
1562 maintenance_print_registers,
1563 "Print the internal register configuration.\
1564 Takes an optional file parameter.",
1565 &maintenanceprintlist);
1566 add_cmd ("raw-registers", class_maintenance,
1567 maintenance_print_raw_registers,
1568 "Print the internal register configuration including raw values.\
1569 Takes an optional file parameter.",
1570 &maintenanceprintlist);
1571 add_cmd ("cooked-registers", class_maintenance,
1572 maintenance_print_cooked_registers,
1573 "Print the internal register configuration including cooked values.\
1574 Takes an optional file parameter.",
1575 &maintenanceprintlist);
1576 add_cmd ("register-groups", class_maintenance,
1577 maintenance_print_register_groups,
1578 "Print the internal register configuration including each register's group.\
1579 Takes an optional file parameter.",
1580 &maintenanceprintlist);