1 /* Cache and manage the values of registers for GDB, the GNU debugger.
3 Copyright (C) 1986-2015 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26 #include "reggroups.h"
35 * Here is the actual register cache.
38 /* Per-architecture object describing the layout of a register cache.
39 Computed once when the architecture is created. */
41 struct gdbarch_data
*regcache_descr_handle
;
45 /* The architecture this descriptor belongs to. */
46 struct gdbarch
*gdbarch
;
48 /* The raw register cache. Each raw (or hard) register is supplied
49 by the target interface. The raw cache should not contain
50 redundant information - if the PC is constructed from two
51 registers then those registers and not the PC lives in the raw
54 long sizeof_raw_registers
;
55 long sizeof_raw_register_status
;
57 /* The cooked register space. Each cooked register in the range
58 [0..NR_RAW_REGISTERS) is direct-mapped onto the corresponding raw
59 register. The remaining [NR_RAW_REGISTERS
60 .. NR_COOKED_REGISTERS) (a.k.a. pseudo registers) are mapped onto
61 both raw registers and memory by the architecture methods
62 gdbarch_pseudo_register_read and gdbarch_pseudo_register_write. */
63 int nr_cooked_registers
;
64 long sizeof_cooked_registers
;
65 long sizeof_cooked_register_status
;
67 /* Offset and size (in 8 bit bytes), of each register in the
68 register cache. All registers (including those in the range
69 [NR_RAW_REGISTERS .. NR_COOKED_REGISTERS) are given an
71 long *register_offset
;
72 long *sizeof_register
;
74 /* Cached table containing the type of each register. */
75 struct type
**register_type
;
79 init_regcache_descr (struct gdbarch
*gdbarch
)
82 struct regcache_descr
*descr
;
83 gdb_assert (gdbarch
!= NULL
);
85 /* Create an initial, zero filled, table. */
86 descr
= GDBARCH_OBSTACK_ZALLOC (gdbarch
, struct regcache_descr
);
87 descr
->gdbarch
= gdbarch
;
89 /* Total size of the register space. The raw registers are mapped
90 directly onto the raw register cache while the pseudo's are
91 either mapped onto raw-registers or memory. */
92 descr
->nr_cooked_registers
= gdbarch_num_regs (gdbarch
)
93 + gdbarch_num_pseudo_regs (gdbarch
);
94 descr
->sizeof_cooked_register_status
95 = gdbarch_num_regs (gdbarch
) + gdbarch_num_pseudo_regs (gdbarch
);
97 /* Fill in a table of register types. */
99 = GDBARCH_OBSTACK_CALLOC (gdbarch
, descr
->nr_cooked_registers
,
101 for (i
= 0; i
< descr
->nr_cooked_registers
; i
++)
102 descr
->register_type
[i
] = gdbarch_register_type (gdbarch
, i
);
104 /* Construct a strictly RAW register cache. Don't allow pseudo's
105 into the register cache. */
106 descr
->nr_raw_registers
= gdbarch_num_regs (gdbarch
);
107 descr
->sizeof_raw_register_status
= gdbarch_num_regs (gdbarch
);
109 /* Lay out the register cache.
111 NOTE: cagney/2002-05-22: Only register_type() is used when
112 constructing the register cache. It is assumed that the
113 register's raw size, virtual size and type length are all the
119 descr
->sizeof_register
120 = GDBARCH_OBSTACK_CALLOC (gdbarch
, descr
->nr_cooked_registers
, long);
121 descr
->register_offset
122 = GDBARCH_OBSTACK_CALLOC (gdbarch
, descr
->nr_cooked_registers
, long);
123 for (i
= 0; i
< descr
->nr_raw_registers
; i
++)
125 descr
->sizeof_register
[i
] = TYPE_LENGTH (descr
->register_type
[i
]);
126 descr
->register_offset
[i
] = offset
;
127 offset
+= descr
->sizeof_register
[i
];
128 gdb_assert (MAX_REGISTER_SIZE
>= descr
->sizeof_register
[i
]);
130 /* Set the real size of the raw register cache buffer. */
131 descr
->sizeof_raw_registers
= offset
;
133 for (; i
< descr
->nr_cooked_registers
; i
++)
135 descr
->sizeof_register
[i
] = TYPE_LENGTH (descr
->register_type
[i
]);
136 descr
->register_offset
[i
] = offset
;
137 offset
+= descr
->sizeof_register
[i
];
138 gdb_assert (MAX_REGISTER_SIZE
>= descr
->sizeof_register
[i
]);
140 /* Set the real size of the readonly register cache buffer. */
141 descr
->sizeof_cooked_registers
= offset
;
147 static struct regcache_descr
*
148 regcache_descr (struct gdbarch
*gdbarch
)
150 return (struct regcache_descr
*) gdbarch_data (gdbarch
,
151 regcache_descr_handle
);
154 /* Utility functions returning useful register attributes stored in
155 the regcache descr. */
158 register_type (struct gdbarch
*gdbarch
, int regnum
)
160 struct regcache_descr
*descr
= regcache_descr (gdbarch
);
162 gdb_assert (regnum
>= 0 && regnum
< descr
->nr_cooked_registers
);
163 return descr
->register_type
[regnum
];
166 /* Utility functions returning useful register attributes stored in
167 the regcache descr. */
170 register_size (struct gdbarch
*gdbarch
, int regnum
)
172 struct regcache_descr
*descr
= regcache_descr (gdbarch
);
175 gdb_assert (regnum
>= 0
176 && regnum
< (gdbarch_num_regs (gdbarch
)
177 + gdbarch_num_pseudo_regs (gdbarch
)));
178 size
= descr
->sizeof_register
[regnum
];
182 /* The register cache for storing raw register values. */
186 struct regcache_descr
*descr
;
188 /* The address space of this register cache (for registers where it
189 makes sense, like PC or SP). */
190 struct address_space
*aspace
;
192 /* The register buffers. A read-only register cache can hold the
193 full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) while a read/write
194 register cache can only hold [0 .. gdbarch_num_regs). */
196 /* Register cache status. */
197 signed char *register_status
;
198 /* Is this a read-only cache? A read-only cache is used for saving
199 the target's register state (e.g, across an inferior function
200 call or just before forcing a function return). A read-only
201 cache can only be updated via the methods regcache_dup() and
202 regcache_cpy(). The actual contents are determined by the
203 reggroup_save and reggroup_restore methods. */
205 /* If this is a read-write cache, which thread's registers is
210 static struct regcache
*
211 regcache_xmalloc_1 (struct gdbarch
*gdbarch
, struct address_space
*aspace
,
214 struct regcache_descr
*descr
;
215 struct regcache
*regcache
;
217 gdb_assert (gdbarch
!= NULL
);
218 descr
= regcache_descr (gdbarch
);
219 regcache
= XNEW (struct regcache
);
220 regcache
->descr
= descr
;
221 regcache
->readonly_p
= readonly_p
;
225 = XCNEWVEC (gdb_byte
, descr
->sizeof_cooked_registers
);
226 regcache
->register_status
227 = XCNEWVEC (signed char, descr
->sizeof_cooked_register_status
);
232 = XCNEWVEC (gdb_byte
, descr
->sizeof_raw_registers
);
233 regcache
->register_status
234 = XCNEWVEC (signed char, descr
->sizeof_raw_register_status
);
236 regcache
->aspace
= aspace
;
237 regcache
->ptid
= minus_one_ptid
;
242 regcache_xmalloc (struct gdbarch
*gdbarch
, struct address_space
*aspace
)
244 return regcache_xmalloc_1 (gdbarch
, aspace
, 1);
248 regcache_xfree (struct regcache
*regcache
)
250 if (regcache
== NULL
)
252 xfree (regcache
->registers
);
253 xfree (regcache
->register_status
);
258 do_regcache_xfree (void *data
)
260 regcache_xfree ((struct regcache
*) data
);
264 make_cleanup_regcache_xfree (struct regcache
*regcache
)
266 return make_cleanup (do_regcache_xfree
, regcache
);
269 /* Cleanup routines for invalidating a register. */
271 struct register_to_invalidate
273 struct regcache
*regcache
;
278 do_regcache_invalidate (void *data
)
280 struct register_to_invalidate
*reg
= (struct register_to_invalidate
*) data
;
282 regcache_invalidate (reg
->regcache
, reg
->regnum
);
285 static struct cleanup
*
286 make_cleanup_regcache_invalidate (struct regcache
*regcache
, int regnum
)
288 struct register_to_invalidate
* reg
= XNEW (struct register_to_invalidate
);
290 reg
->regcache
= regcache
;
291 reg
->regnum
= regnum
;
292 return make_cleanup_dtor (do_regcache_invalidate
, (void *) reg
, xfree
);
295 /* Return REGCACHE's architecture. */
298 get_regcache_arch (const struct regcache
*regcache
)
300 return regcache
->descr
->gdbarch
;
303 struct address_space
*
304 get_regcache_aspace (const struct regcache
*regcache
)
306 return regcache
->aspace
;
309 /* Return a pointer to register REGNUM's buffer cache. */
312 register_buffer (const struct regcache
*regcache
, int regnum
)
314 return regcache
->registers
+ regcache
->descr
->register_offset
[regnum
];
318 regcache_save (struct regcache
*dst
, regcache_cooked_read_ftype
*cooked_read
,
321 struct gdbarch
*gdbarch
= dst
->descr
->gdbarch
;
322 gdb_byte buf
[MAX_REGISTER_SIZE
];
325 /* The DST should be `read-only', if it wasn't then the save would
326 end up trying to write the register values back out to the
328 gdb_assert (dst
->readonly_p
);
329 /* Clear the dest. */
330 memset (dst
->registers
, 0, dst
->descr
->sizeof_cooked_registers
);
331 memset (dst
->register_status
, 0,
332 dst
->descr
->sizeof_cooked_register_status
);
333 /* Copy over any registers (identified by their membership in the
334 save_reggroup) and mark them as valid. The full [0 .. gdbarch_num_regs +
335 gdbarch_num_pseudo_regs) range is checked since some architectures need
336 to save/restore `cooked' registers that live in memory. */
337 for (regnum
= 0; regnum
< dst
->descr
->nr_cooked_registers
; regnum
++)
339 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, save_reggroup
))
341 enum register_status status
= cooked_read (src
, regnum
, buf
);
343 if (status
== REG_VALID
)
344 memcpy (register_buffer (dst
, regnum
), buf
,
345 register_size (gdbarch
, regnum
));
348 gdb_assert (status
!= REG_UNKNOWN
);
350 memset (register_buffer (dst
, regnum
), 0,
351 register_size (gdbarch
, regnum
));
353 dst
->register_status
[regnum
] = status
;
359 regcache_restore (struct regcache
*dst
,
360 regcache_cooked_read_ftype
*cooked_read
,
361 void *cooked_read_context
)
363 struct gdbarch
*gdbarch
= dst
->descr
->gdbarch
;
364 gdb_byte buf
[MAX_REGISTER_SIZE
];
367 /* The dst had better not be read-only. If it is, the `restore'
368 doesn't make much sense. */
369 gdb_assert (!dst
->readonly_p
);
370 /* Copy over any registers, being careful to only restore those that
371 were both saved and need to be restored. The full [0 .. gdbarch_num_regs
372 + gdbarch_num_pseudo_regs) range is checked since some architectures need
373 to save/restore `cooked' registers that live in memory. */
374 for (regnum
= 0; regnum
< dst
->descr
->nr_cooked_registers
; regnum
++)
376 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, restore_reggroup
))
378 enum register_status status
;
380 status
= cooked_read (cooked_read_context
, regnum
, buf
);
381 if (status
== REG_VALID
)
382 regcache_cooked_write (dst
, regnum
, buf
);
387 static enum register_status
388 do_cooked_read (void *src
, int regnum
, gdb_byte
*buf
)
390 struct regcache
*regcache
= (struct regcache
*) src
;
392 return regcache_cooked_read (regcache
, regnum
, buf
);
395 static void regcache_cpy_no_passthrough (struct regcache
*dst
,
396 struct regcache
*src
);
399 regcache_cpy (struct regcache
*dst
, struct regcache
*src
)
401 gdb_assert (src
!= NULL
&& dst
!= NULL
);
402 gdb_assert (src
->descr
->gdbarch
== dst
->descr
->gdbarch
);
403 gdb_assert (src
!= dst
);
404 gdb_assert (src
->readonly_p
|| dst
->readonly_p
);
406 if (!src
->readonly_p
)
407 regcache_save (dst
, do_cooked_read
, src
);
408 else if (!dst
->readonly_p
)
409 regcache_restore (dst
, do_cooked_read
, src
);
411 regcache_cpy_no_passthrough (dst
, src
);
414 /* Copy/duplicate the contents of a register cache. Unlike regcache_cpy,
415 which is pass-through, this does not go through to the target.
416 Only values values already in the cache are transferred. The SRC and DST
417 buffers must not overlap. */
420 regcache_cpy_no_passthrough (struct regcache
*dst
, struct regcache
*src
)
422 gdb_assert (src
!= NULL
&& dst
!= NULL
);
423 gdb_assert (src
->descr
->gdbarch
== dst
->descr
->gdbarch
);
424 /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough
425 move of data into a thread's regcache. Doing this would be silly
426 - it would mean that regcache->register_status would be
427 completely invalid. */
428 gdb_assert (dst
->readonly_p
&& src
->readonly_p
);
430 memcpy (dst
->registers
, src
->registers
,
431 dst
->descr
->sizeof_cooked_registers
);
432 memcpy (dst
->register_status
, src
->register_status
,
433 dst
->descr
->sizeof_cooked_register_status
);
437 regcache_dup (struct regcache
*src
)
439 struct regcache
*newbuf
;
441 newbuf
= regcache_xmalloc (src
->descr
->gdbarch
, get_regcache_aspace (src
));
442 regcache_cpy (newbuf
, src
);
447 regcache_register_status (const struct regcache
*regcache
, int regnum
)
449 gdb_assert (regcache
!= NULL
);
450 gdb_assert (regnum
>= 0);
451 if (regcache
->readonly_p
)
452 gdb_assert (regnum
< regcache
->descr
->nr_cooked_registers
);
454 gdb_assert (regnum
< regcache
->descr
->nr_raw_registers
);
456 return (enum register_status
) regcache
->register_status
[regnum
];
460 regcache_invalidate (struct regcache
*regcache
, int regnum
)
462 gdb_assert (regcache
!= NULL
);
463 gdb_assert (regnum
>= 0);
464 gdb_assert (!regcache
->readonly_p
);
465 gdb_assert (regnum
< regcache
->descr
->nr_raw_registers
);
466 regcache
->register_status
[regnum
] = REG_UNKNOWN
;
470 /* Global structure containing the current regcache. */
472 /* NOTE: this is a write-through cache. There is no "dirty" bit for
473 recording if the register values have been changed (eg. by the
474 user). Therefore all registers must be written back to the
475 target when appropriate. */
479 struct regcache
*regcache
;
480 struct regcache_list
*next
;
483 static struct regcache_list
*current_regcache
;
486 get_thread_arch_aspace_regcache (ptid_t ptid
, struct gdbarch
*gdbarch
,
487 struct address_space
*aspace
)
489 struct regcache_list
*list
;
490 struct regcache
*new_regcache
;
492 for (list
= current_regcache
; list
; list
= list
->next
)
493 if (ptid_equal (list
->regcache
->ptid
, ptid
)
494 && get_regcache_arch (list
->regcache
) == gdbarch
)
495 return list
->regcache
;
497 new_regcache
= regcache_xmalloc_1 (gdbarch
, aspace
, 0);
498 new_regcache
->ptid
= ptid
;
500 list
= XNEW (struct regcache_list
);
501 list
->regcache
= new_regcache
;
502 list
->next
= current_regcache
;
503 current_regcache
= list
;
509 get_thread_arch_regcache (ptid_t ptid
, struct gdbarch
*gdbarch
)
511 struct address_space
*aspace
;
513 /* For the benefit of "maint print registers" & co when debugging an
514 executable, allow dumping the regcache even when there is no
515 thread selected (target_thread_address_space internal-errors if
516 no address space is found). Note that normal user commands will
517 fail higher up on the call stack due to no
518 target_has_registers. */
519 aspace
= (ptid_equal (null_ptid
, ptid
)
521 : target_thread_address_space (ptid
));
523 return get_thread_arch_aspace_regcache (ptid
, gdbarch
, aspace
);
526 static ptid_t current_thread_ptid
;
527 static struct gdbarch
*current_thread_arch
;
530 get_thread_regcache (ptid_t ptid
)
532 if (!current_thread_arch
|| !ptid_equal (current_thread_ptid
, ptid
))
534 current_thread_ptid
= ptid
;
535 current_thread_arch
= target_thread_architecture (ptid
);
538 return get_thread_arch_regcache (ptid
, current_thread_arch
);
542 get_current_regcache (void)
544 return get_thread_regcache (inferior_ptid
);
547 /* See common/common-regcache.h. */
550 get_thread_regcache_for_ptid (ptid_t ptid
)
552 return get_thread_regcache (ptid
);
555 /* Observer for the target_changed event. */
558 regcache_observer_target_changed (struct target_ops
*target
)
560 registers_changed ();
563 /* Update global variables old ptids to hold NEW_PTID if they were
566 regcache_thread_ptid_changed (ptid_t old_ptid
, ptid_t new_ptid
)
568 struct regcache_list
*list
;
570 for (list
= current_regcache
; list
; list
= list
->next
)
571 if (ptid_equal (list
->regcache
->ptid
, old_ptid
))
572 list
->regcache
->ptid
= new_ptid
;
575 /* Low level examining and depositing of registers.
577 The caller is responsible for making sure that the inferior is
578 stopped before calling the fetching routines, or it will get
579 garbage. (a change from GDB version 3, in which the caller got the
580 value from the last stop). */
582 /* REGISTERS_CHANGED ()
584 Indicate that registers may have changed, so invalidate the cache. */
587 registers_changed_ptid (ptid_t ptid
)
589 struct regcache_list
*list
, **list_link
;
591 list
= current_regcache
;
592 list_link
= ¤t_regcache
;
595 if (ptid_match (list
->regcache
->ptid
, ptid
))
597 struct regcache_list
*dead
= list
;
599 *list_link
= list
->next
;
600 regcache_xfree (list
->regcache
);
606 list_link
= &list
->next
;
610 if (ptid_match (current_thread_ptid
, ptid
))
612 current_thread_ptid
= null_ptid
;
613 current_thread_arch
= NULL
;
616 if (ptid_match (inferior_ptid
, ptid
))
618 /* We just deleted the regcache of the current thread. Need to
619 forget about any frames we have cached, too. */
620 reinit_frame_cache ();
625 registers_changed (void)
627 registers_changed_ptid (minus_one_ptid
);
629 /* Force cleanup of any alloca areas if using C alloca instead of
630 a builtin alloca. This particular call is used to clean up
631 areas allocated by low level target code which may build up
632 during lengthy interactions between gdb and the target before
633 gdb gives control to the user (ie watchpoints). */
638 regcache_raw_read (struct regcache
*regcache
, int regnum
, gdb_byte
*buf
)
640 gdb_assert (regcache
!= NULL
&& buf
!= NULL
);
641 gdb_assert (regnum
>= 0 && regnum
< regcache
->descr
->nr_raw_registers
);
642 /* Make certain that the register cache is up-to-date with respect
643 to the current thread. This switching shouldn't be necessary
644 only there is still only one target side register cache. Sigh!
645 On the bright side, at least there is a regcache object. */
646 if (!regcache
->readonly_p
647 && regcache_register_status (regcache
, regnum
) == REG_UNKNOWN
)
649 struct cleanup
*old_chain
= save_inferior_ptid ();
651 inferior_ptid
= regcache
->ptid
;
652 target_fetch_registers (regcache
, regnum
);
653 do_cleanups (old_chain
);
655 /* A number of targets can't access the whole set of raw
656 registers (because the debug API provides no means to get at
658 if (regcache
->register_status
[regnum
] == REG_UNKNOWN
)
659 regcache
->register_status
[regnum
] = REG_UNAVAILABLE
;
662 if (regcache
->register_status
[regnum
] != REG_VALID
)
663 memset (buf
, 0, regcache
->descr
->sizeof_register
[regnum
]);
665 memcpy (buf
, register_buffer (regcache
, regnum
),
666 regcache
->descr
->sizeof_register
[regnum
]);
668 return (enum register_status
) regcache
->register_status
[regnum
];
672 regcache_raw_read_signed (struct regcache
*regcache
, int regnum
, LONGEST
*val
)
675 enum register_status status
;
677 gdb_assert (regcache
!= NULL
);
678 gdb_assert (regnum
>= 0 && regnum
< regcache
->descr
->nr_raw_registers
);
679 buf
= (gdb_byte
*) alloca (regcache
->descr
->sizeof_register
[regnum
]);
680 status
= regcache_raw_read (regcache
, regnum
, buf
);
681 if (status
== REG_VALID
)
682 *val
= extract_signed_integer
683 (buf
, regcache
->descr
->sizeof_register
[regnum
],
684 gdbarch_byte_order (regcache
->descr
->gdbarch
));
691 regcache_raw_read_unsigned (struct regcache
*regcache
, int regnum
,
695 enum register_status status
;
697 gdb_assert (regcache
!= NULL
);
698 gdb_assert (regnum
>= 0 && regnum
< regcache
->descr
->nr_raw_registers
);
699 buf
= (gdb_byte
*) alloca (regcache
->descr
->sizeof_register
[regnum
]);
700 status
= regcache_raw_read (regcache
, regnum
, buf
);
701 if (status
== REG_VALID
)
702 *val
= extract_unsigned_integer
703 (buf
, regcache
->descr
->sizeof_register
[regnum
],
704 gdbarch_byte_order (regcache
->descr
->gdbarch
));
711 regcache_raw_write_signed (struct regcache
*regcache
, int regnum
, LONGEST val
)
715 gdb_assert (regcache
!= NULL
);
716 gdb_assert (regnum
>=0 && regnum
< regcache
->descr
->nr_raw_registers
);
717 buf
= (gdb_byte
*) alloca (regcache
->descr
->sizeof_register
[regnum
]);
718 store_signed_integer (buf
, regcache
->descr
->sizeof_register
[regnum
],
719 gdbarch_byte_order (regcache
->descr
->gdbarch
), val
);
720 regcache_raw_write (regcache
, regnum
, buf
);
724 regcache_raw_write_unsigned (struct regcache
*regcache
, int regnum
,
729 gdb_assert (regcache
!= NULL
);
730 gdb_assert (regnum
>=0 && regnum
< regcache
->descr
->nr_raw_registers
);
731 buf
= (gdb_byte
*) alloca (regcache
->descr
->sizeof_register
[regnum
]);
732 store_unsigned_integer (buf
, regcache
->descr
->sizeof_register
[regnum
],
733 gdbarch_byte_order (regcache
->descr
->gdbarch
), val
);
734 regcache_raw_write (regcache
, regnum
, buf
);
738 regcache_cooked_read (struct regcache
*regcache
, int regnum
, gdb_byte
*buf
)
740 gdb_assert (regnum
>= 0);
741 gdb_assert (regnum
< regcache
->descr
->nr_cooked_registers
);
742 if (regnum
< regcache
->descr
->nr_raw_registers
)
743 return regcache_raw_read (regcache
, regnum
, buf
);
744 else if (regcache
->readonly_p
745 && regcache
->register_status
[regnum
] != REG_UNKNOWN
)
747 /* Read-only register cache, perhaps the cooked value was
749 if (regcache
->register_status
[regnum
] == REG_VALID
)
750 memcpy (buf
, register_buffer (regcache
, regnum
),
751 regcache
->descr
->sizeof_register
[regnum
]);
753 memset (buf
, 0, regcache
->descr
->sizeof_register
[regnum
]);
755 return (enum register_status
) regcache
->register_status
[regnum
];
757 else if (gdbarch_pseudo_register_read_value_p (regcache
->descr
->gdbarch
))
759 struct value
*mark
, *computed
;
760 enum register_status result
= REG_VALID
;
762 mark
= value_mark ();
764 computed
= gdbarch_pseudo_register_read_value (regcache
->descr
->gdbarch
,
766 if (value_entirely_available (computed
))
767 memcpy (buf
, value_contents_raw (computed
),
768 regcache
->descr
->sizeof_register
[regnum
]);
771 memset (buf
, 0, regcache
->descr
->sizeof_register
[regnum
]);
772 result
= REG_UNAVAILABLE
;
775 value_free_to_mark (mark
);
780 return gdbarch_pseudo_register_read (regcache
->descr
->gdbarch
, regcache
,
785 regcache_cooked_read_value (struct regcache
*regcache
, int regnum
)
787 gdb_assert (regnum
>= 0);
788 gdb_assert (regnum
< regcache
->descr
->nr_cooked_registers
);
790 if (regnum
< regcache
->descr
->nr_raw_registers
791 || (regcache
->readonly_p
792 && regcache
->register_status
[regnum
] != REG_UNKNOWN
)
793 || !gdbarch_pseudo_register_read_value_p (regcache
->descr
->gdbarch
))
795 struct value
*result
;
797 result
= allocate_value (register_type (regcache
->descr
->gdbarch
,
799 VALUE_LVAL (result
) = lval_register
;
800 VALUE_REGNUM (result
) = regnum
;
802 /* It is more efficient in general to do this delegation in this
803 direction than in the other one, even though the value-based
805 if (regcache_cooked_read (regcache
, regnum
,
806 value_contents_raw (result
)) == REG_UNAVAILABLE
)
807 mark_value_bytes_unavailable (result
, 0,
808 TYPE_LENGTH (value_type (result
)));
813 return gdbarch_pseudo_register_read_value (regcache
->descr
->gdbarch
,
818 regcache_cooked_read_signed (struct regcache
*regcache
, int regnum
,
821 enum register_status status
;
824 gdb_assert (regcache
!= NULL
);
825 gdb_assert (regnum
>= 0 && regnum
< regcache
->descr
->nr_cooked_registers
);
826 buf
= (gdb_byte
*) alloca (regcache
->descr
->sizeof_register
[regnum
]);
827 status
= regcache_cooked_read (regcache
, regnum
, buf
);
828 if (status
== REG_VALID
)
829 *val
= extract_signed_integer
830 (buf
, regcache
->descr
->sizeof_register
[regnum
],
831 gdbarch_byte_order (regcache
->descr
->gdbarch
));
838 regcache_cooked_read_unsigned (struct regcache
*regcache
, int regnum
,
841 enum register_status status
;
844 gdb_assert (regcache
!= NULL
);
845 gdb_assert (regnum
>= 0 && regnum
< regcache
->descr
->nr_cooked_registers
);
846 buf
= (gdb_byte
*) alloca (regcache
->descr
->sizeof_register
[regnum
]);
847 status
= regcache_cooked_read (regcache
, regnum
, buf
);
848 if (status
== REG_VALID
)
849 *val
= extract_unsigned_integer
850 (buf
, regcache
->descr
->sizeof_register
[regnum
],
851 gdbarch_byte_order (regcache
->descr
->gdbarch
));
858 regcache_cooked_write_signed (struct regcache
*regcache
, int regnum
,
863 gdb_assert (regcache
!= NULL
);
864 gdb_assert (regnum
>=0 && regnum
< regcache
->descr
->nr_cooked_registers
);
865 buf
= (gdb_byte
*) alloca (regcache
->descr
->sizeof_register
[regnum
]);
866 store_signed_integer (buf
, regcache
->descr
->sizeof_register
[regnum
],
867 gdbarch_byte_order (regcache
->descr
->gdbarch
), val
);
868 regcache_cooked_write (regcache
, regnum
, buf
);
872 regcache_cooked_write_unsigned (struct regcache
*regcache
, int regnum
,
877 gdb_assert (regcache
!= NULL
);
878 gdb_assert (regnum
>=0 && regnum
< regcache
->descr
->nr_cooked_registers
);
879 buf
= (gdb_byte
*) alloca (regcache
->descr
->sizeof_register
[regnum
]);
880 store_unsigned_integer (buf
, regcache
->descr
->sizeof_register
[regnum
],
881 gdbarch_byte_order (regcache
->descr
->gdbarch
), val
);
882 regcache_cooked_write (regcache
, regnum
, buf
);
886 regcache_raw_write (struct regcache
*regcache
, int regnum
,
889 struct cleanup
*chain_before_save_inferior
;
890 struct cleanup
*chain_before_invalidate_register
;
892 gdb_assert (regcache
!= NULL
&& buf
!= NULL
);
893 gdb_assert (regnum
>= 0 && regnum
< regcache
->descr
->nr_raw_registers
);
894 gdb_assert (!regcache
->readonly_p
);
896 /* On the sparc, writing %g0 is a no-op, so we don't even want to
897 change the registers array if something writes to this register. */
898 if (gdbarch_cannot_store_register (get_regcache_arch (regcache
), regnum
))
901 /* If we have a valid copy of the register, and new value == old
902 value, then don't bother doing the actual store. */
903 if (regcache_register_status (regcache
, regnum
) == REG_VALID
904 && (memcmp (register_buffer (regcache
, regnum
), buf
,
905 regcache
->descr
->sizeof_register
[regnum
]) == 0))
908 chain_before_save_inferior
= save_inferior_ptid ();
909 inferior_ptid
= regcache
->ptid
;
911 target_prepare_to_store (regcache
);
912 memcpy (register_buffer (regcache
, regnum
), buf
,
913 regcache
->descr
->sizeof_register
[regnum
]);
914 regcache
->register_status
[regnum
] = REG_VALID
;
916 /* Register a cleanup function for invalidating the register after it is
917 written, in case of a failure. */
918 chain_before_invalidate_register
919 = make_cleanup_regcache_invalidate (regcache
, regnum
);
921 target_store_registers (regcache
, regnum
);
923 /* The target did not throw an error so we can discard invalidating the
924 register and restore the cleanup chain to what it was. */
925 discard_cleanups (chain_before_invalidate_register
);
927 do_cleanups (chain_before_save_inferior
);
931 regcache_cooked_write (struct regcache
*regcache
, int regnum
,
934 gdb_assert (regnum
>= 0);
935 gdb_assert (regnum
< regcache
->descr
->nr_cooked_registers
);
936 if (regnum
< regcache
->descr
->nr_raw_registers
)
937 regcache_raw_write (regcache
, regnum
, buf
);
939 gdbarch_pseudo_register_write (regcache
->descr
->gdbarch
, regcache
,
943 /* Perform a partial register transfer using a read, modify, write
946 typedef void (regcache_read_ftype
) (struct regcache
*regcache
, int regnum
,
948 typedef void (regcache_write_ftype
) (struct regcache
*regcache
, int regnum
,
951 static enum register_status
952 regcache_xfer_part (struct regcache
*regcache
, int regnum
,
953 int offset
, int len
, void *in
, const void *out
,
954 enum register_status (*read
) (struct regcache
*regcache
,
957 void (*write
) (struct regcache
*regcache
, int regnum
,
958 const gdb_byte
*buf
))
960 struct regcache_descr
*descr
= regcache
->descr
;
961 gdb_byte reg
[MAX_REGISTER_SIZE
];
963 gdb_assert (offset
>= 0 && offset
<= descr
->sizeof_register
[regnum
]);
964 gdb_assert (len
>= 0 && offset
+ len
<= descr
->sizeof_register
[regnum
]);
965 /* Something to do? */
966 if (offset
+ len
== 0)
968 /* Read (when needed) ... */
971 || offset
+ len
< descr
->sizeof_register
[regnum
])
973 enum register_status status
;
975 gdb_assert (read
!= NULL
);
976 status
= read (regcache
, regnum
, reg
);
977 if (status
!= REG_VALID
)
982 memcpy (in
, reg
+ offset
, len
);
984 memcpy (reg
+ offset
, out
, len
);
985 /* ... write (when needed). */
988 gdb_assert (write
!= NULL
);
989 write (regcache
, regnum
, reg
);
996 regcache_raw_read_part (struct regcache
*regcache
, int regnum
,
997 int offset
, int len
, gdb_byte
*buf
)
999 struct regcache_descr
*descr
= regcache
->descr
;
1001 gdb_assert (regnum
>= 0 && regnum
< descr
->nr_raw_registers
);
1002 return regcache_xfer_part (regcache
, regnum
, offset
, len
, buf
, NULL
,
1003 regcache_raw_read
, regcache_raw_write
);
1007 regcache_raw_write_part (struct regcache
*regcache
, int regnum
,
1008 int offset
, int len
, const gdb_byte
*buf
)
1010 struct regcache_descr
*descr
= regcache
->descr
;
1012 gdb_assert (regnum
>= 0 && regnum
< descr
->nr_raw_registers
);
1013 regcache_xfer_part (regcache
, regnum
, offset
, len
, NULL
, buf
,
1014 regcache_raw_read
, regcache_raw_write
);
1017 enum register_status
1018 regcache_cooked_read_part (struct regcache
*regcache
, int regnum
,
1019 int offset
, int len
, gdb_byte
*buf
)
1021 struct regcache_descr
*descr
= regcache
->descr
;
1023 gdb_assert (regnum
>= 0 && regnum
< descr
->nr_cooked_registers
);
1024 return regcache_xfer_part (regcache
, regnum
, offset
, len
, buf
, NULL
,
1025 regcache_cooked_read
, regcache_cooked_write
);
1029 regcache_cooked_write_part (struct regcache
*regcache
, int regnum
,
1030 int offset
, int len
, const gdb_byte
*buf
)
1032 struct regcache_descr
*descr
= regcache
->descr
;
1034 gdb_assert (regnum
>= 0 && regnum
< descr
->nr_cooked_registers
);
1035 regcache_xfer_part (regcache
, regnum
, offset
, len
, NULL
, buf
,
1036 regcache_cooked_read
, regcache_cooked_write
);
1039 /* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE. */
1042 regcache_raw_supply (struct regcache
*regcache
, int regnum
, const void *buf
)
1047 gdb_assert (regcache
!= NULL
);
1048 gdb_assert (regnum
>= 0 && regnum
< regcache
->descr
->nr_raw_registers
);
1049 gdb_assert (!regcache
->readonly_p
);
1051 regbuf
= register_buffer (regcache
, regnum
);
1052 size
= regcache
->descr
->sizeof_register
[regnum
];
1056 memcpy (regbuf
, buf
, size
);
1057 regcache
->register_status
[regnum
] = REG_VALID
;
1061 /* This memset not strictly necessary, but better than garbage
1062 in case the register value manages to escape somewhere (due
1063 to a bug, no less). */
1064 memset (regbuf
, 0, size
);
1065 regcache
->register_status
[regnum
] = REG_UNAVAILABLE
;
1069 /* Collect register REGNUM from REGCACHE and store its contents in BUF. */
1072 regcache_raw_collect (const struct regcache
*regcache
, int regnum
, void *buf
)
1077 gdb_assert (regcache
!= NULL
&& buf
!= NULL
);
1078 gdb_assert (regnum
>= 0 && regnum
< regcache
->descr
->nr_raw_registers
);
1080 regbuf
= register_buffer (regcache
, regnum
);
1081 size
= regcache
->descr
->sizeof_register
[regnum
];
1082 memcpy (buf
, regbuf
, size
);
1085 /* Transfer a single or all registers belonging to a certain register
1086 set to or from a buffer. This is the main worker function for
1087 regcache_supply_regset and regcache_collect_regset. */
1090 regcache_transfer_regset (const struct regset
*regset
,
1091 const struct regcache
*regcache
,
1092 struct regcache
*out_regcache
,
1093 int regnum
, const void *in_buf
,
1094 void *out_buf
, size_t size
)
1096 const struct regcache_map_entry
*map
;
1097 int offs
= 0, count
;
1099 for (map
= (const struct regcache_map_entry
*) regset
->regmap
;
1100 (count
= map
->count
) != 0;
1103 int regno
= map
->regno
;
1104 int slot_size
= map
->size
;
1106 if (slot_size
== 0 && regno
!= REGCACHE_MAP_SKIP
)
1107 slot_size
= regcache
->descr
->sizeof_register
[regno
];
1109 if (regno
== REGCACHE_MAP_SKIP
1111 && (regnum
< regno
|| regnum
>= regno
+ count
)))
1112 offs
+= count
* slot_size
;
1114 else if (regnum
== -1)
1115 for (; count
--; regno
++, offs
+= slot_size
)
1117 if (offs
+ slot_size
> size
)
1121 regcache_raw_collect (regcache
, regno
,
1122 (gdb_byte
*) out_buf
+ offs
);
1124 regcache_raw_supply (out_regcache
, regno
, in_buf
1125 ? (const gdb_byte
*) in_buf
+ offs
1130 /* Transfer a single register and return. */
1131 offs
+= (regnum
- regno
) * slot_size
;
1132 if (offs
+ slot_size
> size
)
1136 regcache_raw_collect (regcache
, regnum
,
1137 (gdb_byte
*) out_buf
+ offs
);
1139 regcache_raw_supply (out_regcache
, regnum
, in_buf
1140 ? (const gdb_byte
*) in_buf
+ offs
1147 /* Supply register REGNUM from BUF to REGCACHE, using the register map
1148 in REGSET. If REGNUM is -1, do this for all registers in REGSET.
1149 If BUF is NULL, set the register(s) to "unavailable" status. */
1152 regcache_supply_regset (const struct regset
*regset
,
1153 struct regcache
*regcache
,
1154 int regnum
, const void *buf
, size_t size
)
1156 regcache_transfer_regset (regset
, regcache
, regcache
, regnum
,
1160 /* Collect register REGNUM from REGCACHE to BUF, using the register
1161 map in REGSET. If REGNUM is -1, do this for all registers in
1165 regcache_collect_regset (const struct regset
*regset
,
1166 const struct regcache
*regcache
,
1167 int regnum
, void *buf
, size_t size
)
1169 regcache_transfer_regset (regset
, regcache
, NULL
, regnum
,
1174 /* Special handling for register PC. */
1177 regcache_read_pc (struct regcache
*regcache
)
1179 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
1183 if (gdbarch_read_pc_p (gdbarch
))
1184 pc_val
= gdbarch_read_pc (gdbarch
, regcache
);
1185 /* Else use per-frame method on get_current_frame. */
1186 else if (gdbarch_pc_regnum (gdbarch
) >= 0)
1190 if (regcache_cooked_read_unsigned (regcache
,
1191 gdbarch_pc_regnum (gdbarch
),
1192 &raw_val
) == REG_UNAVAILABLE
)
1193 throw_error (NOT_AVAILABLE_ERROR
, _("PC register is not available"));
1195 pc_val
= gdbarch_addr_bits_remove (gdbarch
, raw_val
);
1198 internal_error (__FILE__
, __LINE__
,
1199 _("regcache_read_pc: Unable to find PC"));
1204 regcache_write_pc (struct regcache
*regcache
, CORE_ADDR pc
)
1206 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
1208 if (gdbarch_write_pc_p (gdbarch
))
1209 gdbarch_write_pc (gdbarch
, regcache
, pc
);
1210 else if (gdbarch_pc_regnum (gdbarch
) >= 0)
1211 regcache_cooked_write_unsigned (regcache
,
1212 gdbarch_pc_regnum (gdbarch
), pc
);
1214 internal_error (__FILE__
, __LINE__
,
1215 _("regcache_write_pc: Unable to update PC"));
1217 /* Writing the PC (for instance, from "load") invalidates the
1219 reinit_frame_cache ();
1224 reg_flush_command (char *command
, int from_tty
)
1226 /* Force-flush the register cache. */
1227 registers_changed ();
1229 printf_filtered (_("Register cache flushed.\n"));
1232 enum regcache_dump_what
1234 regcache_dump_none
, regcache_dump_raw
,
1235 regcache_dump_cooked
, regcache_dump_groups
,
1236 regcache_dump_remote
1240 regcache_dump (struct regcache
*regcache
, struct ui_file
*file
,
1241 enum regcache_dump_what what_to_dump
)
1243 struct cleanup
*cleanups
= make_cleanup (null_cleanup
, NULL
);
1244 struct gdbarch
*gdbarch
= regcache
->descr
->gdbarch
;
1246 int footnote_nr
= 0;
1247 int footnote_register_size
= 0;
1248 int footnote_register_offset
= 0;
1249 int footnote_register_type_name_null
= 0;
1250 long register_offset
= 0;
1251 gdb_byte buf
[MAX_REGISTER_SIZE
];
1254 fprintf_unfiltered (file
, "nr_raw_registers %d\n",
1255 regcache
->descr
->nr_raw_registers
);
1256 fprintf_unfiltered (file
, "nr_cooked_registers %d\n",
1257 regcache
->descr
->nr_cooked_registers
);
1258 fprintf_unfiltered (file
, "sizeof_raw_registers %ld\n",
1259 regcache
->descr
->sizeof_raw_registers
);
1260 fprintf_unfiltered (file
, "sizeof_raw_register_status %ld\n",
1261 regcache
->descr
->sizeof_raw_register_status
);
1262 fprintf_unfiltered (file
, "gdbarch_num_regs %d\n",
1263 gdbarch_num_regs (gdbarch
));
1264 fprintf_unfiltered (file
, "gdbarch_num_pseudo_regs %d\n",
1265 gdbarch_num_pseudo_regs (gdbarch
));
1268 gdb_assert (regcache
->descr
->nr_cooked_registers
1269 == (gdbarch_num_regs (gdbarch
)
1270 + gdbarch_num_pseudo_regs (gdbarch
)));
1272 for (regnum
= -1; regnum
< regcache
->descr
->nr_cooked_registers
; regnum
++)
1276 fprintf_unfiltered (file
, " %-10s", "Name");
1279 const char *p
= gdbarch_register_name (gdbarch
, regnum
);
1283 else if (p
[0] == '\0')
1285 fprintf_unfiltered (file
, " %-10s", p
);
1290 fprintf_unfiltered (file
, " %4s", "Nr");
1292 fprintf_unfiltered (file
, " %4d", regnum
);
1294 /* Relative number. */
1296 fprintf_unfiltered (file
, " %4s", "Rel");
1297 else if (regnum
< gdbarch_num_regs (gdbarch
))
1298 fprintf_unfiltered (file
, " %4d", regnum
);
1300 fprintf_unfiltered (file
, " %4d",
1301 (regnum
- gdbarch_num_regs (gdbarch
)));
1305 fprintf_unfiltered (file
, " %6s ", "Offset");
1308 fprintf_unfiltered (file
, " %6ld",
1309 regcache
->descr
->register_offset
[regnum
]);
1310 if (register_offset
!= regcache
->descr
->register_offset
[regnum
]
1312 && (regcache
->descr
->register_offset
[regnum
]
1313 != (regcache
->descr
->register_offset
[regnum
- 1]
1314 + regcache
->descr
->sizeof_register
[regnum
- 1])))
1317 if (!footnote_register_offset
)
1318 footnote_register_offset
= ++footnote_nr
;
1319 fprintf_unfiltered (file
, "*%d", footnote_register_offset
);
1322 fprintf_unfiltered (file
, " ");
1323 register_offset
= (regcache
->descr
->register_offset
[regnum
]
1324 + regcache
->descr
->sizeof_register
[regnum
]);
1329 fprintf_unfiltered (file
, " %5s ", "Size");
1331 fprintf_unfiltered (file
, " %5ld",
1332 regcache
->descr
->sizeof_register
[regnum
]);
1342 static const char blt
[] = "builtin_type";
1344 t
= TYPE_NAME (register_type (regcache
->descr
->gdbarch
, regnum
));
1349 if (!footnote_register_type_name_null
)
1350 footnote_register_type_name_null
= ++footnote_nr
;
1351 n
= xstrprintf ("*%d", footnote_register_type_name_null
);
1352 make_cleanup (xfree
, n
);
1355 /* Chop a leading builtin_type. */
1356 if (startswith (t
, blt
))
1359 fprintf_unfiltered (file
, " %-15s", t
);
1362 /* Leading space always present. */
1363 fprintf_unfiltered (file
, " ");
1366 if (what_to_dump
== regcache_dump_raw
)
1369 fprintf_unfiltered (file
, "Raw value");
1370 else if (regnum
>= regcache
->descr
->nr_raw_registers
)
1371 fprintf_unfiltered (file
, "<cooked>");
1372 else if (regcache_register_status (regcache
, regnum
) == REG_UNKNOWN
)
1373 fprintf_unfiltered (file
, "<invalid>");
1374 else if (regcache_register_status (regcache
, regnum
) == REG_UNAVAILABLE
)
1375 fprintf_unfiltered (file
, "<unavailable>");
1378 regcache_raw_read (regcache
, regnum
, buf
);
1379 print_hex_chars (file
, buf
,
1380 regcache
->descr
->sizeof_register
[regnum
],
1381 gdbarch_byte_order (gdbarch
));
1385 /* Value, cooked. */
1386 if (what_to_dump
== regcache_dump_cooked
)
1389 fprintf_unfiltered (file
, "Cooked value");
1392 enum register_status status
;
1394 status
= regcache_cooked_read (regcache
, regnum
, buf
);
1395 if (status
== REG_UNKNOWN
)
1396 fprintf_unfiltered (file
, "<invalid>");
1397 else if (status
== REG_UNAVAILABLE
)
1398 fprintf_unfiltered (file
, "<unavailable>");
1400 print_hex_chars (file
, buf
,
1401 regcache
->descr
->sizeof_register
[regnum
],
1402 gdbarch_byte_order (gdbarch
));
1406 /* Group members. */
1407 if (what_to_dump
== regcache_dump_groups
)
1410 fprintf_unfiltered (file
, "Groups");
1413 const char *sep
= "";
1414 struct reggroup
*group
;
1416 for (group
= reggroup_next (gdbarch
, NULL
);
1418 group
= reggroup_next (gdbarch
, group
))
1420 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, group
))
1422 fprintf_unfiltered (file
,
1423 "%s%s", sep
, reggroup_name (group
));
1430 /* Remote packet configuration. */
1431 if (what_to_dump
== regcache_dump_remote
)
1435 fprintf_unfiltered (file
, "Rmt Nr g/G Offset");
1437 else if (regnum
< regcache
->descr
->nr_raw_registers
)
1441 if (remote_register_number_and_offset (get_regcache_arch (regcache
), regnum
,
1443 fprintf_unfiltered (file
, "%7d %11d", pnum
, poffset
);
1447 fprintf_unfiltered (file
, "\n");
1450 if (footnote_register_size
)
1451 fprintf_unfiltered (file
, "*%d: Inconsistent register sizes.\n",
1452 footnote_register_size
);
1453 if (footnote_register_offset
)
1454 fprintf_unfiltered (file
, "*%d: Inconsistent register offsets.\n",
1455 footnote_register_offset
);
1456 if (footnote_register_type_name_null
)
1457 fprintf_unfiltered (file
,
1458 "*%d: Register type's name NULL.\n",
1459 footnote_register_type_name_null
);
1460 do_cleanups (cleanups
);
1464 regcache_print (char *args
, enum regcache_dump_what what_to_dump
)
1467 regcache_dump (get_current_regcache (), gdb_stdout
, what_to_dump
);
1470 struct cleanup
*cleanups
;
1471 struct ui_file
*file
= gdb_fopen (args
, "w");
1474 perror_with_name (_("maintenance print architecture"));
1475 cleanups
= make_cleanup_ui_file_delete (file
);
1476 regcache_dump (get_current_regcache (), file
, what_to_dump
);
1477 do_cleanups (cleanups
);
1482 maintenance_print_registers (char *args
, int from_tty
)
1484 regcache_print (args
, regcache_dump_none
);
1488 maintenance_print_raw_registers (char *args
, int from_tty
)
1490 regcache_print (args
, regcache_dump_raw
);
1494 maintenance_print_cooked_registers (char *args
, int from_tty
)
1496 regcache_print (args
, regcache_dump_cooked
);
1500 maintenance_print_register_groups (char *args
, int from_tty
)
1502 regcache_print (args
, regcache_dump_groups
);
1506 maintenance_print_remote_registers (char *args
, int from_tty
)
1508 regcache_print (args
, regcache_dump_remote
);
1511 extern initialize_file_ftype _initialize_regcache
; /* -Wmissing-prototype */
1514 _initialize_regcache (void)
1516 regcache_descr_handle
1517 = gdbarch_data_register_post_init (init_regcache_descr
);
1519 observer_attach_target_changed (regcache_observer_target_changed
);
1520 observer_attach_thread_ptid_changed (regcache_thread_ptid_changed
);
1522 add_com ("flushregs", class_maintenance
, reg_flush_command
,
1523 _("Force gdb to flush its register cache (maintainer command)"));
1525 add_cmd ("registers", class_maintenance
, maintenance_print_registers
,
1526 _("Print the internal register configuration.\n"
1527 "Takes an optional file parameter."), &maintenanceprintlist
);
1528 add_cmd ("raw-registers", class_maintenance
,
1529 maintenance_print_raw_registers
,
1530 _("Print the internal register configuration "
1531 "including raw values.\n"
1532 "Takes an optional file parameter."), &maintenanceprintlist
);
1533 add_cmd ("cooked-registers", class_maintenance
,
1534 maintenance_print_cooked_registers
,
1535 _("Print the internal register configuration "
1536 "including cooked values.\n"
1537 "Takes an optional file parameter."), &maintenanceprintlist
);
1538 add_cmd ("register-groups", class_maintenance
,
1539 maintenance_print_register_groups
,
1540 _("Print the internal register configuration "
1541 "including each register's group.\n"
1542 "Takes an optional file parameter."),
1543 &maintenanceprintlist
);
1544 add_cmd ("remote-registers", class_maintenance
,
1545 maintenance_print_remote_registers
, _("\
1546 Print the internal register configuration including each register's\n\
1547 remote register number and buffer offset in the g/G packets.\n\
1548 Takes an optional file parameter."),
1549 &maintenanceprintlist
);