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