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 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. */
37 * Here is the actual register cache.
40 /* Per-architecture object describing the layout of a register cache.
41 Computed once when the architecture is created */
43 struct gdbarch_data *regcache_descr_handle;
47 /* The architecture this descriptor belongs to. */
48 struct gdbarch *gdbarch;
50 /* Is this a ``legacy'' register cache? Such caches reserve space
51 for raw and pseudo registers and allow access to both. */
54 /* The raw register cache. This should contain just [0
55 .. NUM_RAW_REGISTERS). However, for older targets, it contains
56 space for the full [0 .. NUM_RAW_REGISTERS +
57 NUM_PSEUDO_REGISTERS). */
59 long sizeof_raw_registers;
60 long sizeof_raw_register_valid_p;
62 /* The cooked register space. Each cooked register in the range
63 [0..NR_RAW_REGISTERS) is direct-mapped onto the corresponding raw
64 register. The remaining [NR_RAW_REGISTERS
65 .. NR_COOKED_REGISTERS) (a.k.a. pseudo regiters) are mapped onto
66 both raw registers and memory by the architecture methods
67 gdbarch_register_read and gdbarch_register_write. */
68 int nr_cooked_registers;
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 /* Useful constant. Largest of all the registers. */
80 long max_register_size;
82 /* Cached table containing the type of each register. */
83 struct type **register_type;
87 init_legacy_regcache_descr (struct gdbarch *gdbarch,
88 struct regcache_descr *descr)
91 /* FIXME: cagney/2002-05-11: gdbarch_data() should take that
92 ``gdbarch'' as a parameter. */
93 gdb_assert (gdbarch != NULL);
95 /* FIXME: cagney/2002-05-11: Shouldn't be including pseudo-registers
96 in the register buffer. Unfortunatly some architectures do. */
97 descr->nr_raw_registers = descr->nr_cooked_registers;
98 descr->sizeof_raw_register_valid_p = descr->nr_cooked_registers;
100 /* FIXME: cagney/2002-05-11: Instead of using REGISTER_BYTE() this
101 code should compute the offets et.al. at runtime. This currently
102 isn't possible because some targets overlap register locations -
103 see the mess in read_register_bytes() and write_register_bytes()
105 descr->sizeof_register = XCALLOC (descr->nr_cooked_registers, long);
106 descr->register_offset = XCALLOC (descr->nr_cooked_registers, long);
107 descr->max_register_size = 0;
108 for (i = 0; i < descr->nr_cooked_registers; i++)
110 descr->register_offset[i] = REGISTER_BYTE (i);
111 descr->sizeof_register[i] = REGISTER_RAW_SIZE (i);
112 if (descr->max_register_size < REGISTER_RAW_SIZE (i))
113 descr->max_register_size = REGISTER_RAW_SIZE (i);
114 if (descr->max_register_size < REGISTER_VIRTUAL_SIZE (i))
115 descr->max_register_size = REGISTER_VIRTUAL_SIZE (i);
118 /* Come up with the real size of the registers buffer. */
119 descr->sizeof_raw_registers = REGISTER_BYTES; /* OK use. */
120 for (i = 0; i < descr->nr_cooked_registers; i++)
123 /* Keep extending the buffer so that there is always enough
124 space for all registers. The comparison is necessary since
125 legacy code is free to put registers in random places in the
126 buffer separated by holes. Once REGISTER_BYTE() is killed
127 this can be greatly simplified. */
128 /* FIXME: cagney/2001-12-04: This code shouldn't need to use
129 REGISTER_BYTE(). Unfortunatly, legacy code likes to lay the
130 buffer out so that certain registers just happen to overlap.
131 Ulgh! New targets use gdbarch's register read/write and
132 entirely avoid this uglyness. */
133 regend = descr->register_offset[i] + descr->sizeof_register[i];
134 if (descr->sizeof_raw_registers < regend)
135 descr->sizeof_raw_registers = regend;
140 init_regcache_descr (struct gdbarch *gdbarch)
143 struct regcache_descr *descr;
144 gdb_assert (gdbarch != NULL);
146 /* Create an initial, zero filled, table. */
147 descr = XCALLOC (1, struct regcache_descr);
148 descr->gdbarch = gdbarch;
150 /* Total size of the register space. The raw registers are mapped
151 directly onto the raw register cache while the pseudo's are
152 either mapped onto raw-registers or memory. */
153 descr->nr_cooked_registers = NUM_REGS + NUM_PSEUDO_REGS;
155 /* Fill in a table of register types. */
156 descr->register_type = XCALLOC (descr->nr_cooked_registers,
158 for (i = 0; i < descr->nr_cooked_registers; i++)
160 descr->register_type[i] = REGISTER_VIRTUAL_TYPE (i);
163 /* If an old style architecture, fill in the remainder of the
164 register cache descriptor using the register macros. */
165 if (!gdbarch_pseudo_register_read_p (gdbarch)
166 && !gdbarch_pseudo_register_write_p (gdbarch))
169 init_legacy_regcache_descr (gdbarch, descr);
173 /* Construct a strictly RAW register cache. Don't allow pseudo's
174 into the register cache. */
175 descr->nr_raw_registers = NUM_REGS;
177 /* FIXME: cagney/2002-08-13: Overallocate the register_valid_p
178 array. This pretects GDB from erant code that accesses elements
179 of the global register_valid_p[] array in the range [NUM_REGS
180 .. NUM_REGS + NUM_PSEUDO_REGS). */
181 descr->sizeof_raw_register_valid_p = NUM_REGS + NUM_PSEUDO_REGS;
183 /* Lay out the register cache. The pseud-registers are included in
184 the layout even though their value isn't stored in the register
185 cache. Some code, via read_register_bytes() access a register
186 using an offset/length rather than a register number.
188 NOTE: cagney/2002-05-22: Only register_type() is used when
189 constructing the register cache. It is assumed that the
190 register's raw size, virtual size and type length are all the
195 descr->sizeof_register = XCALLOC (descr->nr_cooked_registers, long);
196 descr->register_offset = XCALLOC (descr->nr_cooked_registers, long);
197 descr->max_register_size = 0;
198 for (i = 0; i < descr->nr_cooked_registers; i++)
200 descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]);
201 descr->register_offset[i] = offset;
202 offset += descr->sizeof_register[i];
203 if (descr->max_register_size < descr->sizeof_register[i])
204 descr->max_register_size = descr->sizeof_register[i];
206 /* Set the real size of the register cache buffer. */
207 /* FIXME: cagney/2002-05-22: Should only need to allocate space
208 for the raw registers. Unfortunatly some code still accesses
209 the register array directly using the global registers[].
210 Until that code has been purged, play safe and over allocating
211 the register buffer. Ulgh! */
212 descr->sizeof_raw_registers = offset;
213 /* = descr->register_offset[descr->nr_raw_registers]; */
217 /* Sanity check. Confirm that the assumptions about gdbarch are
218 true. The REGCACHE_DESCR_HANDLE is set before doing the checks
219 so that targets using the generic methods supplied by regcache
220 don't go into infinite recursion trying to, again, create the
222 set_gdbarch_data (gdbarch, regcache_descr_handle, descr);
223 for (i = 0; i < descr->nr_cooked_registers; i++)
225 gdb_assert (descr->sizeof_register[i] == REGISTER_RAW_SIZE (i));
226 gdb_assert (descr->sizeof_register[i] == REGISTER_VIRTUAL_SIZE (i));
227 gdb_assert (descr->register_offset[i] == REGISTER_BYTE (i));
229 /* gdb_assert (descr->sizeof_raw_registers == REGISTER_BYTES (i)); */
235 static struct regcache_descr *
236 regcache_descr (struct gdbarch *gdbarch)
238 return gdbarch_data (gdbarch, regcache_descr_handle);
242 xfree_regcache_descr (struct gdbarch *gdbarch, void *ptr)
244 struct regcache_descr *descr = ptr;
247 xfree (descr->register_offset);
248 xfree (descr->sizeof_register);
249 descr->register_offset = NULL;
250 descr->sizeof_register = NULL;
254 /* Utility functions returning useful register attributes stored in
255 the regcache descr. */
258 register_type (struct gdbarch *gdbarch, int regnum)
260 struct regcache_descr *descr = regcache_descr (gdbarch);
261 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
262 return descr->register_type[regnum];
265 /* Utility functions returning useful register attributes stored in
266 the regcache descr. */
269 max_register_size (struct gdbarch *gdbarch)
271 struct regcache_descr *descr = regcache_descr (gdbarch);
272 return descr->max_register_size;
275 /* The register cache for storing raw register values. */
279 struct regcache_descr *descr;
280 /* The register buffers. A read-only register cache can hold the
281 full [0 .. NUM_REGS + NUM_PSEUDO_REGS) while a read/write
282 register cache can only hold [0 .. NUM_REGS). */
284 char *register_valid_p;
285 /* If a value isn't in the cache should the corresponding target be
286 queried for a value. */
291 regcache_xmalloc (struct gdbarch *gdbarch)
293 struct regcache_descr *descr;
294 struct regcache *regcache;
295 gdb_assert (gdbarch != NULL);
296 descr = regcache_descr (gdbarch);
297 regcache = XMALLOC (struct regcache);
298 regcache->descr = descr;
300 = XCALLOC (descr->sizeof_raw_registers, char);
301 regcache->register_valid_p
302 = XCALLOC (descr->sizeof_raw_register_valid_p, char);
303 regcache->passthrough_p = 0;
308 regcache_xfree (struct regcache *regcache)
310 if (regcache == NULL)
312 xfree (regcache->registers);
313 xfree (regcache->register_valid_p);
318 do_regcache_xfree (void *data)
320 regcache_xfree (data);
324 make_cleanup_regcache_xfree (struct regcache *regcache)
326 return make_cleanup (do_regcache_xfree, regcache);
329 /* Return a pointer to register REGNUM's buffer cache. */
332 register_buffer (struct regcache *regcache, int regnum)
334 return regcache->registers + regcache->descr->register_offset[regnum];
338 regcache_cpy (struct regcache *dst, struct regcache *src)
342 gdb_assert (src != NULL && dst != NULL);
343 gdb_assert (src->descr->gdbarch == dst->descr->gdbarch);
344 gdb_assert (src != dst);
345 /* FIXME: cagney/2002-05-17: To say this bit is bad is being polite.
346 It keeps the existing code working where things rely on going
347 through to the register cache. */
348 if (src == current_regcache && src->descr->legacy_p)
350 /* ULGH!!!! Old way. Use REGISTER bytes and let code below
352 read_register_bytes (0, dst->registers, REGISTER_BYTES);
355 /* FIXME: cagney/2002-05-17: To say this bit is bad is being polite.
356 It keeps the existing code working where things rely on going
357 through to the register cache. */
358 if (dst == current_regcache && dst->descr->legacy_p)
360 /* ULGH!!!! Old way. Use REGISTER bytes and let code below
362 write_register_bytes (0, src->registers, REGISTER_BYTES);
365 buf = alloca (src->descr->max_register_size);
366 for (i = 0; i < src->descr->nr_raw_registers; i++)
368 /* Should we worry about the valid bit here? */
369 regcache_raw_read (src, i, buf);
370 regcache_raw_write (dst, i, buf);
375 regcache_cpy_no_passthrough (struct regcache *dst, struct regcache *src)
378 gdb_assert (src != NULL && dst != NULL);
379 gdb_assert (src->descr->gdbarch == dst->descr->gdbarch);
380 /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough
381 move of data into the current_regcache(). Doing this would be
382 silly - it would mean that valid_p would be completly invalid. */
383 gdb_assert (dst != current_regcache);
384 memcpy (dst->registers, src->registers, dst->descr->sizeof_raw_registers);
385 memcpy (dst->register_valid_p, src->register_valid_p,
386 dst->descr->sizeof_raw_register_valid_p);
390 regcache_dup (struct regcache *src)
392 struct regcache *newbuf;
393 gdb_assert (current_regcache != NULL);
394 newbuf = regcache_xmalloc (src->descr->gdbarch);
395 regcache_cpy (newbuf, src);
400 regcache_dup_no_passthrough (struct regcache *src)
402 struct regcache *newbuf;
403 gdb_assert (current_regcache != NULL);
404 newbuf = regcache_xmalloc (src->descr->gdbarch);
405 regcache_cpy_no_passthrough (newbuf, src);
410 regcache_valid_p (struct regcache *regcache, int regnum)
412 gdb_assert (regcache != NULL);
413 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
414 return regcache->register_valid_p[regnum];
418 deprecated_grub_regcache_for_registers (struct regcache *regcache)
420 return regcache->registers;
424 deprecated_grub_regcache_for_register_valid (struct regcache *regcache)
426 return regcache->register_valid_p;
429 /* Global structure containing the current regcache. */
430 /* FIXME: cagney/2002-05-11: The two global arrays registers[] and
431 deprecated_register_valid[] currently point into this structure. */
432 struct regcache *current_regcache;
434 /* NOTE: this is a write-through cache. There is no "dirty" bit for
435 recording if the register values have been changed (eg. by the
436 user). Therefore all registers must be written back to the
437 target when appropriate. */
439 /* REGISTERS contains the cached register values (in target byte order). */
443 /* DEPRECATED_REGISTER_VALID is 0 if the register needs to be fetched,
444 1 if it has been fetched, and
445 -1 if the register value was not available.
447 "Not available" indicates that the target is not not able to supply
448 the register at this state. The register may become available at a
449 later time (after the next resume). This often occures when GDB is
450 manipulating a target that contains only a snapshot of the entire
451 system being debugged - some of the registers in such a system may
452 not have been saved. */
454 signed char *deprecated_register_valid;
456 /* The thread/process associated with the current set of registers. */
458 static ptid_t registers_ptid;
466 Returns 0 if the value is not in the cache (needs fetch).
467 >0 if the value is in the cache.
468 <0 if the value is permanently unavailable (don't ask again). */
471 register_cached (int regnum)
473 return deprecated_register_valid[regnum];
476 /* Record that REGNUM's value is cached if STATE is >0, uncached but
477 fetchable if STATE is 0, and uncached and unfetchable if STATE is <0. */
480 set_register_cached (int regnum, int state)
482 gdb_assert (regnum >= 0);
483 gdb_assert (regnum < current_regcache->descr->nr_raw_registers);
484 current_regcache->register_valid_p[regnum] = state;
487 /* Return whether register REGNUM is a real register. */
490 real_register (int regnum)
492 return regnum >= 0 && regnum < NUM_REGS;
495 /* Low level examining and depositing of registers.
497 The caller is responsible for making sure that the inferior is
498 stopped before calling the fetching routines, or it will get
499 garbage. (a change from GDB version 3, in which the caller got the
500 value from the last stop). */
502 /* REGISTERS_CHANGED ()
504 Indicate that registers may have changed, so invalidate the cache. */
507 registers_changed (void)
511 registers_ptid = pid_to_ptid (-1);
513 /* Force cleanup of any alloca areas if using C alloca instead of
514 a builtin alloca. This particular call is used to clean up
515 areas allocated by low level target code which may build up
516 during lengthy interactions between gdb and the target before
517 gdb gives control to the user (ie watchpoints). */
520 for (i = 0; i < current_regcache->descr->nr_raw_registers; i++)
521 set_register_cached (i, 0);
523 if (registers_changed_hook)
524 registers_changed_hook ();
527 /* DEPRECATED_REGISTERS_FETCHED ()
529 Indicate that all registers have been fetched, so mark them all valid. */
531 /* NOTE: cagney/2001-12-04: This function does not set valid on the
532 pseudo-register range since pseudo registers are always supplied
533 using supply_register(). */
534 /* FIXME: cagney/2001-12-04: This function is DEPRECATED. The target
535 code was blatting the registers[] array and then calling this.
536 Since targets should only be using supply_register() the need for
537 this function/hack is eliminated. */
540 deprecated_registers_fetched (void)
544 for (i = 0; i < NUM_REGS; i++)
545 set_register_cached (i, 1);
546 /* Do not assume that the pseudo-regs have also been fetched.
547 Fetching all real regs NEVER accounts for pseudo-regs. */
550 /* read_register_bytes and write_register_bytes are generally a *BAD*
551 idea. They are inefficient because they need to check for partial
552 updates, which can only be done by scanning through all of the
553 registers and seeing if the bytes that are being read/written fall
554 inside of an invalid register. [The main reason this is necessary
555 is that register sizes can vary, so a simple index won't suffice.]
556 It is far better to call read_register_gen and write_register_gen
557 if you want to get at the raw register contents, as it only takes a
558 regnum as an argument, and therefore can't do a partial register
561 Prior to the recent fixes to check for partial updates, both read
562 and write_register_bytes always checked to see if any registers
563 were stale, and then called target_fetch_registers (-1) to update
564 the whole set. This caused really slowed things down for remote
567 /* Copy INLEN bytes of consecutive data from registers
568 starting with the INREGBYTE'th byte of register data
569 into memory at MYADDR. */
572 read_register_bytes (int in_start, char *in_buf, int in_len)
574 int in_end = in_start + in_len;
576 char *reg_buf = alloca (MAX_REGISTER_RAW_SIZE);
578 /* See if we are trying to read bytes from out-of-date registers. If so,
579 update just those registers. */
581 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
590 reg_start = REGISTER_BYTE (regnum);
591 reg_len = REGISTER_RAW_SIZE (regnum);
592 reg_end = reg_start + reg_len;
594 if (reg_end <= in_start || in_end <= reg_start)
595 /* The range the user wants to read doesn't overlap with regnum. */
598 if (REGISTER_NAME (regnum) != NULL && *REGISTER_NAME (regnum) != '\0')
599 /* Force the cache to fetch the entire register. */
600 deprecated_read_register_gen (regnum, reg_buf);
602 /* Legacy note: even though this register is ``invalid'' we
603 still need to return something. It would appear that some
604 code relies on apparent gaps in the register array also
606 /* FIXME: cagney/2001-08-18: This is just silly. It defeats
607 the entire register read/write flow of control. Must
608 resist temptation to return 0xdeadbeef. */
609 memcpy (reg_buf, registers + reg_start, reg_len);
611 /* Legacy note: This function, for some reason, allows a NULL
612 input buffer. If the buffer is NULL, the registers are still
613 fetched, just the final transfer is skipped. */
617 /* start = max (reg_start, in_start) */
618 if (reg_start > in_start)
623 /* end = min (reg_end, in_end) */
624 if (reg_end < in_end)
629 /* Transfer just the bytes common to both IN_BUF and REG_BUF */
630 for (byte = start; byte < end; byte++)
632 in_buf[byte - in_start] = reg_buf[byte - reg_start];
637 /* Read register REGNUM into memory at MYADDR, which must be large
638 enough for REGISTER_RAW_BYTES (REGNUM). Target byte-order. If the
639 register is known to be the size of a CORE_ADDR or smaller,
640 read_register can be used instead. */
643 legacy_read_register_gen (int regnum, char *myaddr)
645 gdb_assert (regnum >= 0 && regnum < (NUM_REGS + NUM_PSEUDO_REGS));
646 if (! ptid_equal (registers_ptid, inferior_ptid))
648 registers_changed ();
649 registers_ptid = inferior_ptid;
652 if (!register_cached (regnum))
653 target_fetch_registers (regnum);
655 memcpy (myaddr, register_buffer (current_regcache, regnum),
656 REGISTER_RAW_SIZE (regnum));
660 regcache_raw_read (struct regcache *regcache, int regnum, void *buf)
662 gdb_assert (regcache != NULL && buf != NULL);
663 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
664 if (regcache->descr->legacy_p
665 && regcache->passthrough_p)
667 gdb_assert (regcache == current_regcache);
668 /* For moment, just use underlying legacy code. Ulgh!!! This
669 silently and very indirectly updates the regcache's regcache
670 via the global deprecated_register_valid[]. */
671 legacy_read_register_gen (regnum, buf);
674 /* Make certain that the register cache is up-to-date with respect
675 to the current thread. This switching shouldn't be necessary
676 only there is still only one target side register cache. Sigh!
677 On the bright side, at least there is a regcache object. */
678 if (regcache->passthrough_p)
680 gdb_assert (regcache == current_regcache);
681 if (! ptid_equal (registers_ptid, inferior_ptid))
683 registers_changed ();
684 registers_ptid = inferior_ptid;
686 if (!register_cached (regnum))
687 target_fetch_registers (regnum);
689 /* Copy the value directly into the register cache. */
690 memcpy (buf, register_buffer (regcache, regnum),
691 regcache->descr->sizeof_register[regnum]);
695 regcache_raw_read_signed (struct regcache *regcache, int regnum, LONGEST *val)
698 gdb_assert (regcache != NULL);
699 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
700 buf = alloca (regcache->descr->sizeof_register[regnum]);
701 regcache_raw_read (regcache, regnum, buf);
702 (*val) = extract_signed_integer (buf,
703 regcache->descr->sizeof_register[regnum]);
707 regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
711 gdb_assert (regcache != NULL);
712 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
713 buf = alloca (regcache->descr->sizeof_register[regnum]);
714 regcache_raw_read (regcache, regnum, buf);
715 (*val) = extract_unsigned_integer (buf,
716 regcache->descr->sizeof_register[regnum]);
720 regcache_raw_write_signed (struct regcache *regcache, int regnum, LONGEST val)
723 gdb_assert (regcache != NULL);
724 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
725 buf = alloca (regcache->descr->sizeof_register[regnum]);
726 store_signed_integer (buf, regcache->descr->sizeof_register[regnum], val);
727 regcache_raw_write (regcache, regnum, buf);
731 regcache_raw_write_unsigned (struct regcache *regcache, int regnum,
735 gdb_assert (regcache != NULL);
736 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
737 buf = alloca (regcache->descr->sizeof_register[regnum]);
738 store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], val);
739 regcache_raw_write (regcache, regnum, buf);
743 deprecated_read_register_gen (int regnum, char *buf)
745 gdb_assert (current_regcache != NULL);
746 gdb_assert (current_regcache->descr->gdbarch == current_gdbarch);
747 if (current_regcache->descr->legacy_p)
749 legacy_read_register_gen (regnum, buf);
752 regcache_cooked_read (current_regcache, regnum, buf);
756 regcache_cooked_read (struct regcache *regcache, int regnum, void *buf)
758 gdb_assert (regnum >= 0);
759 gdb_assert (regnum < regcache->descr->nr_cooked_registers);
760 if (regnum < regcache->descr->nr_raw_registers)
761 regcache_raw_read (regcache, regnum, buf);
763 gdbarch_pseudo_register_read (regcache->descr->gdbarch, regcache,
768 regcache_cooked_read_signed (struct regcache *regcache, int regnum,
772 gdb_assert (regcache != NULL);
773 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
774 buf = alloca (regcache->descr->sizeof_register[regnum]);
775 regcache_cooked_read (regcache, regnum, buf);
776 (*val) = extract_signed_integer (buf,
777 regcache->descr->sizeof_register[regnum]);
781 regcache_cooked_read_unsigned (struct regcache *regcache, int regnum,
785 gdb_assert (regcache != NULL);
786 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
787 buf = alloca (regcache->descr->sizeof_register[regnum]);
788 regcache_cooked_read (regcache, regnum, buf);
789 (*val) = extract_unsigned_integer (buf,
790 regcache->descr->sizeof_register[regnum]);
793 /* Write register REGNUM at MYADDR to the target. MYADDR points at
794 REGISTER_RAW_BYTES(REGNUM), which must be in target byte-order. */
797 legacy_write_register_gen (int regnum, const void *myaddr)
800 gdb_assert (regnum >= 0 && regnum < (NUM_REGS + NUM_PSEUDO_REGS));
802 /* On the sparc, writing %g0 is a no-op, so we don't even want to
803 change the registers array if something writes to this register. */
804 if (CANNOT_STORE_REGISTER (regnum))
807 if (! ptid_equal (registers_ptid, inferior_ptid))
809 registers_changed ();
810 registers_ptid = inferior_ptid;
813 size = REGISTER_RAW_SIZE (regnum);
815 if (real_register (regnum))
817 /* If we have a valid copy of the register, and new value == old
818 value, then don't bother doing the actual store. */
819 if (register_cached (regnum)
820 && (memcmp (register_buffer (current_regcache, regnum), myaddr, size)
824 target_prepare_to_store ();
827 memcpy (register_buffer (current_regcache, regnum), myaddr, size);
829 set_register_cached (regnum, 1);
830 target_store_registers (regnum);
834 regcache_raw_write (struct regcache *regcache, int regnum, const void *buf)
836 gdb_assert (regcache != NULL && buf != NULL);
837 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
839 if (regcache->passthrough_p
840 && regcache->descr->legacy_p)
842 /* For moment, just use underlying legacy code. Ulgh!!! This
843 silently and very indirectly updates the regcache's buffers
844 via the globals deprecated_register_valid[] and registers[]. */
845 gdb_assert (regcache == current_regcache);
846 legacy_write_register_gen (regnum, buf);
850 /* On the sparc, writing %g0 is a no-op, so we don't even want to
851 change the registers array if something writes to this register. */
852 if (CANNOT_STORE_REGISTER (regnum))
855 /* Handle the simple case first -> not write through so just store
857 if (!regcache->passthrough_p)
859 memcpy (register_buffer (regcache, regnum), buf,
860 regcache->descr->sizeof_register[regnum]);
861 regcache->register_valid_p[regnum] = 1;
865 /* Make certain that the correct cache is selected. */
866 gdb_assert (regcache == current_regcache);
867 if (! ptid_equal (registers_ptid, inferior_ptid))
869 registers_changed ();
870 registers_ptid = inferior_ptid;
873 /* If we have a valid copy of the register, and new value == old
874 value, then don't bother doing the actual store. */
875 if (regcache_valid_p (regcache, regnum)
876 && (memcmp (register_buffer (regcache, regnum), buf,
877 regcache->descr->sizeof_register[regnum]) == 0))
880 target_prepare_to_store ();
881 memcpy (register_buffer (regcache, regnum), buf,
882 regcache->descr->sizeof_register[regnum]);
883 regcache->register_valid_p[regnum] = 1;
884 target_store_registers (regnum);
888 deprecated_write_register_gen (int regnum, char *buf)
890 gdb_assert (current_regcache != NULL);
891 gdb_assert (current_regcache->descr->gdbarch == current_gdbarch);
892 if (current_regcache->descr->legacy_p)
894 legacy_write_register_gen (regnum, buf);
897 regcache_cooked_write (current_regcache, regnum, buf);
901 regcache_cooked_write (struct regcache *regcache, int regnum, const void *buf)
903 gdb_assert (regnum >= 0);
904 gdb_assert (regnum < regcache->descr->nr_cooked_registers);
905 if (regnum < regcache->descr->nr_raw_registers)
906 regcache_raw_write (regcache, regnum, buf);
908 gdbarch_pseudo_register_write (regcache->descr->gdbarch, regcache,
912 /* Copy INLEN bytes of consecutive data from memory at MYADDR
913 into registers starting with the MYREGSTART'th byte of register data. */
916 write_register_bytes (int myregstart, char *myaddr, int inlen)
918 int myregend = myregstart + inlen;
921 target_prepare_to_store ();
923 /* Scan through the registers updating any that are covered by the
924 range myregstart<=>myregend using write_register_gen, which does
925 nice things like handling threads, and avoiding updates when the
926 new and old contents are the same. */
928 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
930 int regstart, regend;
932 regstart = REGISTER_BYTE (regnum);
933 regend = regstart + REGISTER_RAW_SIZE (regnum);
935 /* Is this register completely outside the range the user is writing? */
936 if (myregend <= regstart || regend <= myregstart)
939 /* Is this register completely within the range the user is writing? */
940 else if (myregstart <= regstart && regend <= myregend)
941 deprecated_write_register_gen (regnum, myaddr + (regstart - myregstart));
943 /* The register partially overlaps the range being written. */
946 char *regbuf = (char*) alloca (MAX_REGISTER_RAW_SIZE);
947 /* What's the overlap between this register's bytes and
948 those the caller wants to write? */
949 int overlapstart = max (regstart, myregstart);
950 int overlapend = min (regend, myregend);
952 /* We may be doing a partial update of an invalid register.
953 Update it from the target before scribbling on it. */
954 deprecated_read_register_gen (regnum, regbuf);
956 memcpy (registers + overlapstart,
957 myaddr + (overlapstart - myregstart),
958 overlapend - overlapstart);
960 target_store_registers (regnum);
965 /* Perform a partial register transfer using a read, modify, write
968 typedef void (regcache_read_ftype) (struct regcache *regcache, int regnum,
970 typedef void (regcache_write_ftype) (struct regcache *regcache, int regnum,
974 regcache_xfer_part (struct regcache *regcache, int regnum,
975 int offset, int len, void *in, const void *out,
976 regcache_read_ftype *read, regcache_write_ftype *write)
978 struct regcache_descr *descr = regcache->descr;
979 bfd_byte *reg = alloca (descr->max_register_size);
980 gdb_assert (offset >= 0 && offset <= descr->sizeof_register[regnum]);
981 gdb_assert (len >= 0 && offset + len <= descr->sizeof_register[regnum]);
982 /* Something to do? */
983 if (offset + len == 0)
985 /* Read (when needed) ... */
988 || offset + len < descr->sizeof_register[regnum])
990 gdb_assert (read != NULL);
991 read (regcache, regnum, reg);
995 memcpy (in, reg + offset, len);
997 memcpy (reg + offset, out, len);
998 /* ... write (when needed). */
1001 gdb_assert (write != NULL);
1002 write (regcache, regnum, reg);
1007 regcache_raw_read_part (struct regcache *regcache, int regnum,
1008 int offset, int len, void *buf)
1010 struct regcache_descr *descr = regcache->descr;
1011 gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
1012 regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
1013 regcache_raw_read, regcache_raw_write);
1017 regcache_raw_write_part (struct regcache *regcache, int regnum,
1018 int offset, int len, const void *buf)
1020 struct regcache_descr *descr = regcache->descr;
1021 gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
1022 regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
1023 regcache_raw_read, regcache_raw_write);
1027 regcache_cooked_read_part (struct regcache *regcache, int regnum,
1028 int offset, int len, void *buf)
1030 struct regcache_descr *descr = regcache->descr;
1031 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
1032 regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
1033 regcache_cooked_read, regcache_cooked_write);
1037 regcache_cooked_write_part (struct regcache *regcache, int regnum,
1038 int offset, int len, const void *buf)
1040 struct regcache_descr *descr = regcache->descr;
1041 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
1042 regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
1043 regcache_cooked_read, regcache_cooked_write);
1046 /* Hack to keep code that view the register buffer as raw bytes
1050 register_offset_hack (struct gdbarch *gdbarch, int regnum)
1052 struct regcache_descr *descr = regcache_descr (gdbarch);
1053 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
1054 return descr->register_offset[regnum];
1057 /* Return the contents of register REGNUM as an unsigned integer. */
1060 read_register (int regnum)
1062 char *buf = alloca (REGISTER_RAW_SIZE (regnum));
1063 deprecated_read_register_gen (regnum, buf);
1064 return (extract_unsigned_integer (buf, REGISTER_RAW_SIZE (regnum)));
1068 read_register_pid (int regnum, ptid_t ptid)
1074 if (ptid_equal (ptid, inferior_ptid))
1075 return read_register (regnum);
1077 save_ptid = inferior_ptid;
1079 inferior_ptid = ptid;
1081 retval = read_register (regnum);
1083 inferior_ptid = save_ptid;
1088 /* Return the contents of register REGNUM as a signed integer. */
1091 read_signed_register (int regnum)
1093 void *buf = alloca (REGISTER_RAW_SIZE (regnum));
1094 deprecated_read_register_gen (regnum, buf);
1095 return (extract_signed_integer (buf, REGISTER_RAW_SIZE (regnum)));
1099 read_signed_register_pid (int regnum, ptid_t ptid)
1104 if (ptid_equal (ptid, inferior_ptid))
1105 return read_signed_register (regnum);
1107 save_ptid = inferior_ptid;
1109 inferior_ptid = ptid;
1111 retval = read_signed_register (regnum);
1113 inferior_ptid = save_ptid;
1118 /* Store VALUE into the raw contents of register number REGNUM. */
1121 write_register (int regnum, LONGEST val)
1125 size = REGISTER_RAW_SIZE (regnum);
1126 buf = alloca (size);
1127 store_signed_integer (buf, size, (LONGEST) val);
1128 deprecated_write_register_gen (regnum, buf);
1132 write_register_pid (int regnum, CORE_ADDR val, ptid_t ptid)
1136 if (ptid_equal (ptid, inferior_ptid))
1138 write_register (regnum, val);
1142 save_ptid = inferior_ptid;
1144 inferior_ptid = ptid;
1146 write_register (regnum, val);
1148 inferior_ptid = save_ptid;
1151 /* SUPPLY_REGISTER()
1153 Record that register REGNUM contains VAL. This is used when the
1154 value is obtained from the inferior or core dump, so there is no
1155 need to store the value there.
1157 If VAL is a NULL pointer, then it's probably an unsupported register.
1158 We just set its value to all zeros. We might want to record this
1159 fact, and report it to the users of read_register and friends. */
1162 supply_register (int regnum, const void *val)
1165 if (! ptid_equal (registers_ptid, inferior_ptid))
1167 registers_changed ();
1168 registers_ptid = inferior_ptid;
1172 set_register_cached (regnum, 1);
1174 memcpy (register_buffer (current_regcache, regnum), val,
1175 REGISTER_RAW_SIZE (regnum));
1177 memset (register_buffer (current_regcache, regnum), '\000',
1178 REGISTER_RAW_SIZE (regnum));
1180 /* On some architectures, e.g. HPPA, there are a few stray bits in
1181 some registers, that the rest of the code would like to ignore. */
1183 /* NOTE: cagney/2001-03-16: The macro CLEAN_UP_REGISTER_VALUE is
1184 going to be deprecated. Instead architectures will leave the raw
1185 register value as is and instead clean things up as they pass
1186 through the method gdbarch_pseudo_register_read() clean up the
1189 #ifdef DEPRECATED_CLEAN_UP_REGISTER_VALUE
1190 DEPRECATED_CLEAN_UP_REGISTER_VALUE \
1191 (regnum, register_buffer (current_regcache, regnum));
1196 regcache_collect (int regnum, void *buf)
1198 memcpy (buf, register_buffer (current_regcache, regnum),
1199 REGISTER_RAW_SIZE (regnum));
1203 /* read_pc, write_pc, read_sp, write_sp, read_fp, etc. Special
1204 handling for registers PC, SP, and FP. */
1206 /* NOTE: cagney/2001-02-18: The functions generic_target_read_pc(),
1207 read_pc_pid(), read_pc(), generic_target_write_pc(),
1208 write_pc_pid(), write_pc(), generic_target_read_sp(), read_sp(),
1209 generic_target_write_sp(), write_sp(), generic_target_read_fp() and
1210 read_fp(), will eventually be moved out of the reg-cache into
1211 either frame.[hc] or to the multi-arch framework. The are not part
1212 of the raw register cache. */
1214 /* This routine is getting awfully cluttered with #if's. It's probably
1215 time to turn this into READ_PC and define it in the tm.h file.
1218 1999-06-08: The following were re-written so that it assumes the
1219 existence of a TARGET_READ_PC et.al. macro. A default generic
1220 version of that macro is made available where needed.
1222 Since the ``TARGET_READ_PC'' et.al. macro is going to be controlled
1223 by the multi-arch framework, it will eventually be possible to
1224 eliminate the intermediate read_pc_pid(). The client would call
1225 TARGET_READ_PC directly. (cagney). */
1228 generic_target_read_pc (ptid_t ptid)
1233 CORE_ADDR pc_val = ADDR_BITS_REMOVE ((CORE_ADDR) read_register_pid (PC_REGNUM, ptid));
1237 internal_error (__FILE__, __LINE__,
1238 "generic_target_read_pc");
1243 read_pc_pid (ptid_t ptid)
1245 ptid_t saved_inferior_ptid;
1248 /* In case ptid != inferior_ptid. */
1249 saved_inferior_ptid = inferior_ptid;
1250 inferior_ptid = ptid;
1252 pc_val = TARGET_READ_PC (ptid);
1254 inferior_ptid = saved_inferior_ptid;
1261 return read_pc_pid (inferior_ptid);
1265 generic_target_write_pc (CORE_ADDR pc, ptid_t ptid)
1269 write_register_pid (PC_REGNUM, pc, ptid);
1270 if (NPC_REGNUM >= 0)
1271 write_register_pid (NPC_REGNUM, pc + 4, ptid);
1273 internal_error (__FILE__, __LINE__,
1274 "generic_target_write_pc");
1279 write_pc_pid (CORE_ADDR pc, ptid_t ptid)
1281 ptid_t saved_inferior_ptid;
1283 /* In case ptid != inferior_ptid. */
1284 saved_inferior_ptid = inferior_ptid;
1285 inferior_ptid = ptid;
1287 TARGET_WRITE_PC (pc, ptid);
1289 inferior_ptid = saved_inferior_ptid;
1293 write_pc (CORE_ADDR pc)
1295 write_pc_pid (pc, inferior_ptid);
1298 /* Cope with strage ways of getting to the stack and frame pointers */
1301 generic_target_read_sp (void)
1305 return read_register (SP_REGNUM);
1307 internal_error (__FILE__, __LINE__,
1308 "generic_target_read_sp");
1314 return TARGET_READ_SP ();
1318 generic_target_write_sp (CORE_ADDR val)
1323 write_register (SP_REGNUM, val);
1327 internal_error (__FILE__, __LINE__,
1328 "generic_target_write_sp");
1332 write_sp (CORE_ADDR val)
1334 TARGET_WRITE_SP (val);
1338 generic_target_read_fp (void)
1342 return read_register (FP_REGNUM);
1344 internal_error (__FILE__, __LINE__,
1345 "generic_target_read_fp");
1351 return TARGET_READ_FP ();
1356 reg_flush_command (char *command, int from_tty)
1358 /* Force-flush the register cache. */
1359 registers_changed ();
1361 printf_filtered ("Register cache flushed.\n");
1365 build_regcache (void)
1367 current_regcache = regcache_xmalloc (current_gdbarch);
1368 current_regcache->passthrough_p = 1;
1369 registers = deprecated_grub_regcache_for_registers (current_regcache);
1370 deprecated_register_valid = deprecated_grub_regcache_for_register_valid (current_regcache);
1374 dump_endian_bytes (struct ui_file *file, enum bfd_endian endian,
1375 const unsigned char *buf, long len)
1380 case BFD_ENDIAN_BIG:
1381 for (i = 0; i < len; i++)
1382 fprintf_unfiltered (file, "%02x", buf[i]);
1384 case BFD_ENDIAN_LITTLE:
1385 for (i = len - 1; i >= 0; i--)
1386 fprintf_unfiltered (file, "%02x", buf[i]);
1389 internal_error (__FILE__, __LINE__, "Bad switch");
1393 enum regcache_dump_what
1395 regcache_dump_none, regcache_dump_raw, regcache_dump_cooked, regcache_dump_groups
1399 regcache_dump (struct regcache *regcache, struct ui_file *file,
1400 enum regcache_dump_what what_to_dump)
1402 struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
1403 struct gdbarch *gdbarch = regcache->descr->gdbarch;
1404 struct reggroup *const *groups = reggroups (gdbarch);
1406 int footnote_nr = 0;
1407 int footnote_register_size = 0;
1408 int footnote_register_offset = 0;
1409 int footnote_register_type_name_null = 0;
1410 long register_offset = 0;
1411 unsigned char *buf = alloca (regcache->descr->max_register_size);
1414 fprintf_unfiltered (file, "legacy_p %d\n", regcache->descr->legacy_p);
1415 fprintf_unfiltered (file, "nr_raw_registers %d\n",
1416 regcache->descr->nr_raw_registers);
1417 fprintf_unfiltered (file, "nr_cooked_registers %d\n",
1418 regcache->descr->nr_cooked_registers);
1419 fprintf_unfiltered (file, "sizeof_raw_registers %ld\n",
1420 regcache->descr->sizeof_raw_registers);
1421 fprintf_unfiltered (file, "sizeof_raw_register_valid_p %ld\n",
1422 regcache->descr->sizeof_raw_register_valid_p);
1423 fprintf_unfiltered (file, "max_register_size %ld\n",
1424 regcache->descr->max_register_size);
1425 fprintf_unfiltered (file, "NUM_REGS %d\n", NUM_REGS);
1426 fprintf_unfiltered (file, "NUM_PSEUDO_REGS %d\n", NUM_PSEUDO_REGS);
1429 gdb_assert (regcache->descr->nr_cooked_registers
1430 == (NUM_REGS + NUM_PSEUDO_REGS));
1432 for (regnum = -1; regnum < regcache->descr->nr_cooked_registers; regnum++)
1436 fprintf_unfiltered (file, " %-10s", "Name");
1439 const char *p = REGISTER_NAME (regnum);
1442 else if (p[0] == '\0')
1444 fprintf_unfiltered (file, " %-10s", p);
1449 fprintf_unfiltered (file, " %4s", "Nr");
1451 fprintf_unfiltered (file, " %4d", regnum);
1453 /* Relative number. */
1455 fprintf_unfiltered (file, " %4s", "Rel");
1456 else if (regnum < NUM_REGS)
1457 fprintf_unfiltered (file, " %4d", regnum);
1459 fprintf_unfiltered (file, " %4d", (regnum - NUM_REGS));
1463 fprintf_unfiltered (file, " %6s ", "Offset");
1466 fprintf_unfiltered (file, " %6ld",
1467 regcache->descr->register_offset[regnum]);
1468 if (register_offset != regcache->descr->register_offset[regnum]
1469 || register_offset != REGISTER_BYTE (regnum)
1471 && (regcache->descr->register_offset[regnum]
1472 != (regcache->descr->register_offset[regnum - 1]
1473 + regcache->descr->sizeof_register[regnum - 1])))
1476 if (!footnote_register_offset)
1477 footnote_register_offset = ++footnote_nr;
1478 fprintf_unfiltered (file, "*%d", footnote_register_offset);
1481 fprintf_unfiltered (file, " ");
1482 register_offset = (regcache->descr->register_offset[regnum]
1483 + regcache->descr->sizeof_register[regnum]);
1488 fprintf_unfiltered (file, " %5s ", "Size");
1491 fprintf_unfiltered (file, " %5ld",
1492 regcache->descr->sizeof_register[regnum]);
1493 if ((regcache->descr->sizeof_register[regnum]
1494 != REGISTER_RAW_SIZE (regnum))
1495 || (regcache->descr->sizeof_register[regnum]
1496 != REGISTER_VIRTUAL_SIZE (regnum))
1497 || (regcache->descr->sizeof_register[regnum]
1498 != TYPE_LENGTH (register_type (regcache->descr->gdbarch,
1502 if (!footnote_register_size)
1503 footnote_register_size = ++footnote_nr;
1504 fprintf_unfiltered (file, "*%d", footnote_register_size);
1507 fprintf_unfiltered (file, " ");
1517 static const char blt[] = "builtin_type";
1518 t = TYPE_NAME (register_type (regcache->descr->gdbarch, regnum));
1522 if (!footnote_register_type_name_null)
1523 footnote_register_type_name_null = ++footnote_nr;
1524 xasprintf (&n, "*%d", footnote_register_type_name_null);
1525 make_cleanup (xfree, n);
1528 /* Chop a leading builtin_type. */
1529 if (strncmp (t, blt, strlen (blt)) == 0)
1532 fprintf_unfiltered (file, " %-15s", t);
1535 /* Leading space always present. */
1536 fprintf_unfiltered (file, " ");
1539 if (what_to_dump == regcache_dump_raw)
1542 fprintf_unfiltered (file, "Raw value");
1543 else if (regnum >= regcache->descr->nr_raw_registers)
1544 fprintf_unfiltered (file, "<cooked>");
1545 else if (!regcache_valid_p (regcache, regnum))
1546 fprintf_unfiltered (file, "<invalid>");
1549 regcache_raw_read (regcache, regnum, buf);
1550 fprintf_unfiltered (file, "0x");
1551 dump_endian_bytes (file, TARGET_BYTE_ORDER, buf,
1552 REGISTER_RAW_SIZE (regnum));
1556 /* Value, cooked. */
1557 if (what_to_dump == regcache_dump_cooked)
1560 fprintf_unfiltered (file, "Cooked value");
1563 regcache_cooked_read (regcache, regnum, buf);
1564 fprintf_unfiltered (file, "0x");
1565 dump_endian_bytes (file, TARGET_BYTE_ORDER, buf,
1566 REGISTER_VIRTUAL_SIZE (regnum));
1570 /* Group members. */
1571 if (what_to_dump == regcache_dump_groups)
1574 fprintf_unfiltered (file, "Groups");
1578 const char *sep = "";
1579 for (i = 0; groups[i] != NULL; i++)
1581 if (gdbarch_register_reggroup_p (gdbarch, regnum, groups[i]))
1583 fprintf_unfiltered (file, "%s%s", sep, reggroup_name (groups[i]));
1590 fprintf_unfiltered (file, "\n");
1593 if (footnote_register_size)
1594 fprintf_unfiltered (file, "*%d: Inconsistent register sizes.\n",
1595 footnote_register_size);
1596 if (footnote_register_offset)
1597 fprintf_unfiltered (file, "*%d: Inconsistent register offsets.\n",
1598 footnote_register_offset);
1599 if (footnote_register_type_name_null)
1600 fprintf_unfiltered (file,
1601 "*%d: Register type's name NULL.\n",
1602 footnote_register_type_name_null);
1603 do_cleanups (cleanups);
1607 regcache_print (char *args, enum regcache_dump_what what_to_dump)
1610 regcache_dump (current_regcache, gdb_stdout, what_to_dump);
1613 struct ui_file *file = gdb_fopen (args, "w");
1615 perror_with_name ("maintenance print architecture");
1616 regcache_dump (current_regcache, file, what_to_dump);
1617 ui_file_delete (file);
1622 maintenance_print_registers (char *args, int from_tty)
1624 regcache_print (args, regcache_dump_none);
1628 maintenance_print_raw_registers (char *args, int from_tty)
1630 regcache_print (args, regcache_dump_raw);
1634 maintenance_print_cooked_registers (char *args, int from_tty)
1636 regcache_print (args, regcache_dump_cooked);
1640 maintenance_print_register_groups (char *args, int from_tty)
1642 regcache_print (args, regcache_dump_groups);
1646 _initialize_regcache (void)
1648 regcache_descr_handle = register_gdbarch_data (init_regcache_descr,
1649 xfree_regcache_descr);
1650 REGISTER_GDBARCH_SWAP (current_regcache);
1651 register_gdbarch_swap (®isters, sizeof (registers), NULL);
1652 register_gdbarch_swap (&deprecated_register_valid, sizeof (deprecated_register_valid), NULL);
1653 register_gdbarch_swap (NULL, 0, build_regcache);
1655 add_com ("flushregs", class_maintenance, reg_flush_command,
1656 "Force gdb to flush its register cache (maintainer command)");
1658 /* Initialize the thread/process associated with the current set of
1659 registers. For now, -1 is special, and means `no current process'. */
1660 registers_ptid = pid_to_ptid (-1);
1662 add_cmd ("registers", class_maintenance,
1663 maintenance_print_registers,
1664 "Print the internal register configuration.\
1665 Takes an optional file parameter.",
1666 &maintenanceprintlist);
1667 add_cmd ("raw-registers", class_maintenance,
1668 maintenance_print_raw_registers,
1669 "Print the internal register configuration including raw values.\
1670 Takes an optional file parameter.",
1671 &maintenanceprintlist);
1672 add_cmd ("cooked-registers", class_maintenance,
1673 maintenance_print_cooked_registers,
1674 "Print the internal register configuration including cooked values.\
1675 Takes an optional file parameter.",
1676 &maintenanceprintlist);
1677 add_cmd ("register-groups", class_maintenance,
1678 maintenance_print_register_groups,
1679 "Print the internal register configuration including each register's group.\
1680 Takes an optional file parameter.",
1681 &maintenanceprintlist);