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