* target.h (struct target_ops): New member to_thread_architecture.
[deliverable/binutils-gdb.git] / gdb / regcache.c
CommitLineData
32178cab 1/* Cache and manage the values of registers for GDB, the GNU debugger.
3fadccb3 2
6aba47ca 3 Copyright (C) 1986, 1987, 1989, 1991, 1994, 1995, 1996, 1998, 2000, 2001,
0fb0cc75 4 2002, 2004, 2007, 2008, 2009 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
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
32178cab
MS
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
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
32178cab
MS
20
21#include "defs.h"
32178cab
MS
22#include "inferior.h"
23#include "target.h"
24#include "gdbarch.h"
705152c5 25#include "gdbcmd.h"
4e052eda 26#include "regcache.h"
b59ff9d5 27#include "reggroups.h"
61a0eb5b 28#include "gdb_assert.h"
b66d6d2e 29#include "gdb_string.h"
af030b9a 30#include "gdbcmd.h" /* For maintenanceprintlist. */
f4c5303c 31#include "observer.h"
32178cab
MS
32
33/*
34 * DATA STRUCTURE
35 *
36 * Here is the actual register cache.
37 */
38
3fadccb3
AC
39/* Per-architecture object describing the layout of a register cache.
40 Computed once when the architecture is created */
41
42struct gdbarch_data *regcache_descr_handle;
43
44struct regcache_descr
45{
46 /* The architecture this descriptor belongs to. */
47 struct gdbarch *gdbarch;
48
bb1db049
AC
49 /* The raw register cache. Each raw (or hard) register is supplied
50 by the target interface. The raw cache should not contain
51 redundant information - if the PC is constructed from two
d2f0b918 52 registers then those registers and not the PC lives in the raw
bb1db049 53 cache. */
3fadccb3
AC
54 int nr_raw_registers;
55 long sizeof_raw_registers;
56 long sizeof_raw_register_valid_p;
57
d138e37a
AC
58 /* The cooked register space. Each cooked register in the range
59 [0..NR_RAW_REGISTERS) is direct-mapped onto the corresponding raw
60 register. The remaining [NR_RAW_REGISTERS
02f60eae 61 .. NR_COOKED_REGISTERS) (a.k.a. pseudo registers) are mapped onto
d138e37a 62 both raw registers and memory by the architecture methods
02f60eae 63 gdbarch_pseudo_register_read and gdbarch_pseudo_register_write. */
d138e37a 64 int nr_cooked_registers;
067df2e5
AC
65 long sizeof_cooked_registers;
66 long sizeof_cooked_register_valid_p;
d138e37a
AC
67
68 /* Offset and size (in 8 bit bytes), of reach register in the
69 register cache. All registers (including those in the range
70 [NR_RAW_REGISTERS .. NR_COOKED_REGISTERS) are given an offset.
71 Assigning all registers an offset makes it possible to keep
72 legacy code, such as that found in read_register_bytes() and
73 write_register_bytes() working. */
3fadccb3 74 long *register_offset;
3fadccb3 75 long *sizeof_register;
3fadccb3 76
bb425013
AC
77 /* Cached table containing the type of each register. */
78 struct type **register_type;
3fadccb3
AC
79};
80
3fadccb3
AC
81static void *
82init_regcache_descr (struct gdbarch *gdbarch)
83{
84 int i;
85 struct regcache_descr *descr;
86 gdb_assert (gdbarch != NULL);
87
bb425013 88 /* Create an initial, zero filled, table. */
116f06ea 89 descr = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct regcache_descr);
3fadccb3 90 descr->gdbarch = gdbarch;
3fadccb3 91
d138e37a
AC
92 /* Total size of the register space. The raw registers are mapped
93 directly onto the raw register cache while the pseudo's are
3fadccb3 94 either mapped onto raw-registers or memory. */
214e098a
UW
95 descr->nr_cooked_registers = gdbarch_num_regs (gdbarch)
96 + gdbarch_num_pseudo_regs (gdbarch);
97 descr->sizeof_cooked_register_valid_p = gdbarch_num_regs (gdbarch)
f57d151a 98 + gdbarch_num_pseudo_regs
214e098a 99 (gdbarch);
3fadccb3 100
bb425013 101 /* Fill in a table of register types. */
116f06ea
AC
102 descr->register_type
103 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, struct type *);
bb425013 104 for (i = 0; i < descr->nr_cooked_registers; i++)
336a3131 105 descr->register_type[i] = gdbarch_register_type (gdbarch, i);
bb425013 106
bb1db049
AC
107 /* Construct a strictly RAW register cache. Don't allow pseudo's
108 into the register cache. */
214e098a 109 descr->nr_raw_registers = gdbarch_num_regs (gdbarch);
bb1db049
AC
110
111 /* FIXME: cagney/2002-08-13: Overallocate the register_valid_p
112 array. This pretects GDB from erant code that accesses elements
f57d151a
UW
113 of the global register_valid_p[] array in the range
114 [gdbarch_num_regs .. gdbarch_num_regs + gdbarch_num_pseudo_regs). */
bb1db049
AC
115 descr->sizeof_raw_register_valid_p = descr->sizeof_cooked_register_valid_p;
116
067df2e5 117 /* Lay out the register cache.
3fadccb3 118
bb425013
AC
119 NOTE: cagney/2002-05-22: Only register_type() is used when
120 constructing the register cache. It is assumed that the
121 register's raw size, virtual size and type length are all the
122 same. */
3fadccb3
AC
123
124 {
125 long offset = 0;
116f06ea
AC
126 descr->sizeof_register
127 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
128 descr->register_offset
129 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
d138e37a 130 for (i = 0; i < descr->nr_cooked_registers; i++)
3fadccb3 131 {
bb425013 132 descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]);
3fadccb3
AC
133 descr->register_offset[i] = offset;
134 offset += descr->sizeof_register[i];
123a958e 135 gdb_assert (MAX_REGISTER_SIZE >= descr->sizeof_register[i]);
3fadccb3
AC
136 }
137 /* Set the real size of the register cache buffer. */
067df2e5 138 descr->sizeof_cooked_registers = offset;
3fadccb3
AC
139 }
140
067df2e5 141 /* FIXME: cagney/2002-05-22: Should only need to allocate space for
ce2826aa 142 the raw registers. Unfortunately some code still accesses the
067df2e5
AC
143 register array directly using the global registers[]. Until that
144 code has been purged, play safe and over allocating the register
145 buffer. Ulgh! */
146 descr->sizeof_raw_registers = descr->sizeof_cooked_registers;
147
3fadccb3
AC
148 return descr;
149}
150
151static struct regcache_descr *
152regcache_descr (struct gdbarch *gdbarch)
153{
154 return gdbarch_data (gdbarch, regcache_descr_handle);
155}
156
bb425013
AC
157/* Utility functions returning useful register attributes stored in
158 the regcache descr. */
159
160struct type *
161register_type (struct gdbarch *gdbarch, int regnum)
162{
163 struct regcache_descr *descr = regcache_descr (gdbarch);
164 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
165 return descr->register_type[regnum];
166}
167
0ed04cce
AC
168/* Utility functions returning useful register attributes stored in
169 the regcache descr. */
170
08a617da
AC
171int
172register_size (struct gdbarch *gdbarch, int regnum)
173{
174 struct regcache_descr *descr = regcache_descr (gdbarch);
175 int size;
f57d151a 176 gdb_assert (regnum >= 0
214e098a
UW
177 && regnum < (gdbarch_num_regs (gdbarch)
178 + gdbarch_num_pseudo_regs (gdbarch)));
08a617da 179 size = descr->sizeof_register[regnum];
08a617da
AC
180 return size;
181}
182
3fadccb3
AC
183/* The register cache for storing raw register values. */
184
185struct regcache
186{
187 struct regcache_descr *descr;
51b1fe4e 188 /* The register buffers. A read-only register cache can hold the
f57d151a
UW
189 full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) while a read/write
190 register cache can only hold [0 .. gdbarch_num_regs). */
2d522557 191 gdb_byte *registers;
b05e64e5
FR
192 /* Register cache status:
193 register_valid_p[REG] == 0 if REG value is not in the cache
194 > 0 if REG value is in the cache
195 < 0 if REG value is permanently unavailable */
196 signed char *register_valid_p;
2d28509a
AC
197 /* Is this a read-only cache? A read-only cache is used for saving
198 the target's register state (e.g, across an inferior function
199 call or just before forcing a function return). A read-only
200 cache can only be updated via the methods regcache_dup() and
201 regcache_cpy(). The actual contents are determined by the
202 reggroup_save and reggroup_restore methods. */
203 int readonly_p;
594f7785
UW
204 /* If this is a read-write cache, which thread's registers is
205 it connected to? */
206 ptid_t ptid;
3fadccb3
AC
207};
208
209struct regcache *
210regcache_xmalloc (struct gdbarch *gdbarch)
211{
212 struct regcache_descr *descr;
213 struct regcache *regcache;
214 gdb_assert (gdbarch != NULL);
215 descr = regcache_descr (gdbarch);
216 regcache = XMALLOC (struct regcache);
217 regcache->descr = descr;
51b1fe4e 218 regcache->registers
2d522557 219 = XCALLOC (descr->sizeof_raw_registers, gdb_byte);
51b1fe4e 220 regcache->register_valid_p
2d522557 221 = XCALLOC (descr->sizeof_raw_register_valid_p, gdb_byte);
2d28509a 222 regcache->readonly_p = 1;
594f7785 223 regcache->ptid = minus_one_ptid;
3fadccb3
AC
224 return regcache;
225}
226
227void
228regcache_xfree (struct regcache *regcache)
229{
230 if (regcache == NULL)
231 return;
51b1fe4e
AC
232 xfree (regcache->registers);
233 xfree (regcache->register_valid_p);
3fadccb3
AC
234 xfree (regcache);
235}
236
b9362cc7 237static void
36160dc4
AC
238do_regcache_xfree (void *data)
239{
240 regcache_xfree (data);
241}
242
243struct cleanup *
244make_cleanup_regcache_xfree (struct regcache *regcache)
245{
246 return make_cleanup (do_regcache_xfree, regcache);
247}
248
41d35cb0
MK
249/* Return REGCACHE's architecture. */
250
251struct gdbarch *
252get_regcache_arch (const struct regcache *regcache)
253{
254 return regcache->descr->gdbarch;
255}
256
51b1fe4e
AC
257/* Return a pointer to register REGNUM's buffer cache. */
258
2d522557 259static gdb_byte *
9a661b68 260register_buffer (const struct regcache *regcache, int regnum)
51b1fe4e
AC
261{
262 return regcache->registers + regcache->descr->register_offset[regnum];
263}
264
2d28509a 265void
5602984a
AC
266regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read,
267 void *src)
2d28509a
AC
268{
269 struct gdbarch *gdbarch = dst->descr->gdbarch;
2d522557 270 gdb_byte buf[MAX_REGISTER_SIZE];
2d28509a 271 int regnum;
2d28509a 272 /* The DST should be `read-only', if it wasn't then the save would
5602984a 273 end up trying to write the register values back out to the
2d28509a 274 target. */
2d28509a
AC
275 gdb_assert (dst->readonly_p);
276 /* Clear the dest. */
277 memset (dst->registers, 0, dst->descr->sizeof_cooked_registers);
278 memset (dst->register_valid_p, 0, dst->descr->sizeof_cooked_register_valid_p);
279 /* Copy over any registers (identified by their membership in the
f57d151a
UW
280 save_reggroup) and mark them as valid. The full [0 .. gdbarch_num_regs +
281 gdbarch_num_pseudo_regs) range is checked since some architectures need
5602984a 282 to save/restore `cooked' registers that live in memory. */
2d28509a
AC
283 for (regnum = 0; regnum < dst->descr->nr_cooked_registers; regnum++)
284 {
285 if (gdbarch_register_reggroup_p (gdbarch, regnum, save_reggroup))
286 {
5602984a
AC
287 int valid = cooked_read (src, regnum, buf);
288 if (valid)
289 {
290 memcpy (register_buffer (dst, regnum), buf,
291 register_size (gdbarch, regnum));
292 dst->register_valid_p[regnum] = 1;
293 }
2d28509a
AC
294 }
295 }
296}
297
298void
5602984a
AC
299regcache_restore (struct regcache *dst,
300 regcache_cooked_read_ftype *cooked_read,
2d522557 301 void *cooked_read_context)
2d28509a
AC
302{
303 struct gdbarch *gdbarch = dst->descr->gdbarch;
2d522557 304 gdb_byte buf[MAX_REGISTER_SIZE];
2d28509a 305 int regnum;
5602984a
AC
306 /* The dst had better not be read-only. If it is, the `restore'
307 doesn't make much sense. */
2d28509a 308 gdb_assert (!dst->readonly_p);
2d28509a 309 /* Copy over any registers, being careful to only restore those that
f57d151a
UW
310 were both saved and need to be restored. The full [0 .. gdbarch_num_regs
311 + gdbarch_num_pseudo_regs) range is checked since some architectures need
5602984a
AC
312 to save/restore `cooked' registers that live in memory. */
313 for (regnum = 0; regnum < dst->descr->nr_cooked_registers; regnum++)
2d28509a 314 {
5602984a 315 if (gdbarch_register_reggroup_p (gdbarch, regnum, restore_reggroup))
2d28509a 316 {
2d522557 317 int valid = cooked_read (cooked_read_context, regnum, buf);
5602984a
AC
318 if (valid)
319 regcache_cooked_write (dst, regnum, buf);
2d28509a
AC
320 }
321 }
322}
323
5602984a 324static int
2d522557 325do_cooked_read (void *src, int regnum, gdb_byte *buf)
5602984a
AC
326{
327 struct regcache *regcache = src;
6f4e5a41 328 if (!regcache->register_valid_p[regnum] && regcache->readonly_p)
5602984a
AC
329 /* Don't even think about fetching a register from a read-only
330 cache when the register isn't yet valid. There isn't a target
331 from which the register value can be fetched. */
332 return 0;
333 regcache_cooked_read (regcache, regnum, buf);
334 return 1;
335}
336
337
3fadccb3
AC
338void
339regcache_cpy (struct regcache *dst, struct regcache *src)
340{
341 int i;
2d522557 342 gdb_byte *buf;
3fadccb3
AC
343 gdb_assert (src != NULL && dst != NULL);
344 gdb_assert (src->descr->gdbarch == dst->descr->gdbarch);
345 gdb_assert (src != dst);
2d28509a
AC
346 gdb_assert (src->readonly_p || dst->readonly_p);
347 if (!src->readonly_p)
5602984a 348 regcache_save (dst, do_cooked_read, src);
2d28509a 349 else if (!dst->readonly_p)
5602984a 350 regcache_restore (dst, do_cooked_read, src);
2d28509a
AC
351 else
352 regcache_cpy_no_passthrough (dst, src);
3fadccb3
AC
353}
354
355void
356regcache_cpy_no_passthrough (struct regcache *dst, struct regcache *src)
357{
358 int i;
359 gdb_assert (src != NULL && dst != NULL);
360 gdb_assert (src->descr->gdbarch == dst->descr->gdbarch);
361 /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough
594f7785 362 move of data into the current regcache. Doing this would be
9564ee9f 363 silly - it would mean that valid_p would be completely invalid. */
594f7785 364 gdb_assert (dst->readonly_p);
51b1fe4e
AC
365 memcpy (dst->registers, src->registers, dst->descr->sizeof_raw_registers);
366 memcpy (dst->register_valid_p, src->register_valid_p,
3fadccb3
AC
367 dst->descr->sizeof_raw_register_valid_p);
368}
369
370struct regcache *
371regcache_dup (struct regcache *src)
372{
373 struct regcache *newbuf;
3fadccb3
AC
374 newbuf = regcache_xmalloc (src->descr->gdbarch);
375 regcache_cpy (newbuf, src);
376 return newbuf;
377}
378
379struct regcache *
380regcache_dup_no_passthrough (struct regcache *src)
381{
382 struct regcache *newbuf;
3fadccb3
AC
383 newbuf = regcache_xmalloc (src->descr->gdbarch);
384 regcache_cpy_no_passthrough (newbuf, src);
385 return newbuf;
386}
387
388int
6ed7ea50 389regcache_valid_p (const struct regcache *regcache, int regnum)
3fadccb3
AC
390{
391 gdb_assert (regcache != NULL);
6ed7ea50
UW
392 gdb_assert (regnum >= 0);
393 if (regcache->readonly_p)
394 gdb_assert (regnum < regcache->descr->nr_cooked_registers);
395 else
396 gdb_assert (regnum < regcache->descr->nr_raw_registers);
397
51b1fe4e 398 return regcache->register_valid_p[regnum];
3fadccb3
AC
399}
400
9c5ea4d9
UW
401void
402regcache_invalidate (struct regcache *regcache, int regnum)
403{
404 gdb_assert (regcache != NULL);
405 gdb_assert (regnum >= 0);
406 gdb_assert (!regcache->readonly_p);
407 gdb_assert (regnum < regcache->descr->nr_raw_registers);
408 regcache->register_valid_p[regnum] = 0;
409}
410
411
3fadccb3 412/* Global structure containing the current regcache. */
3fadccb3 413
5ebd2499 414/* NOTE: this is a write-through cache. There is no "dirty" bit for
32178cab
MS
415 recording if the register values have been changed (eg. by the
416 user). Therefore all registers must be written back to the
417 target when appropriate. */
418
c2250ad1 419struct regcache_list
594f7785 420{
c2250ad1
UW
421 struct regcache *regcache;
422 struct regcache_list *next;
423};
424
425static struct regcache_list *current_regcache;
426
427struct regcache *
428get_thread_arch_regcache (ptid_t ptid, struct gdbarch *gdbarch)
429{
430 struct regcache_list *list;
431 struct regcache *new_regcache;
594f7785 432
c2250ad1
UW
433 for (list = current_regcache; list; list = list->next)
434 if (ptid_equal (list->regcache->ptid, ptid)
435 && get_regcache_arch (list->regcache) == gdbarch)
436 return list->regcache;
594f7785 437
c2250ad1
UW
438 new_regcache = regcache_xmalloc (gdbarch);
439 new_regcache->readonly_p = 0;
440 new_regcache->ptid = ptid;
594f7785 441
c2250ad1
UW
442 list = xmalloc (sizeof (struct regcache_list));
443 list->regcache = new_regcache;
444 list->next = current_regcache;
445 current_regcache = list;
594f7785 446
c2250ad1 447 return new_regcache;
594f7785
UW
448}
449
c2250ad1
UW
450static ptid_t current_thread_ptid;
451static struct gdbarch *current_thread_arch;
452
453struct regcache *
454get_thread_regcache (ptid_t ptid)
455{
456 if (!current_thread_arch || !ptid_equal (current_thread_ptid, ptid))
457 {
458 current_thread_ptid = ptid;
459 current_thread_arch = target_thread_architecture (ptid);
460 }
461
462 return get_thread_arch_regcache (ptid, current_thread_arch);
463}
464
465struct regcache *
466get_current_regcache (void)
594f7785
UW
467{
468 return get_thread_regcache (inferior_ptid);
469}
32178cab 470
32178cab 471
f4c5303c
OF
472/* Observer for the target_changed event. */
473
2c0b251b 474static void
f4c5303c
OF
475regcache_observer_target_changed (struct target_ops *target)
476{
477 registers_changed ();
478}
479
5231c1fd
PA
480/* Update global variables old ptids to hold NEW_PTID if they were
481 holding OLD_PTID. */
482static void
483regcache_thread_ptid_changed (ptid_t old_ptid, ptid_t new_ptid)
484{
c2250ad1
UW
485 struct regcache_list *list;
486
487 for (list = current_regcache; list; list = list->next)
488 if (ptid_equal (list->regcache->ptid, old_ptid))
489 list->regcache->ptid = new_ptid;
5231c1fd
PA
490}
491
32178cab
MS
492/* Low level examining and depositing of registers.
493
494 The caller is responsible for making sure that the inferior is
495 stopped before calling the fetching routines, or it will get
496 garbage. (a change from GDB version 3, in which the caller got the
497 value from the last stop). */
498
499/* REGISTERS_CHANGED ()
500
501 Indicate that registers may have changed, so invalidate the cache. */
502
503void
504registers_changed (void)
505{
c2250ad1
UW
506 struct regcache_list *list, *next;
507
508 for (list = current_regcache; list; list = next)
509 {
510 next = list->next;
511 regcache_xfree (list->regcache);
512 xfree (list);
513 }
32178cab 514
594f7785 515 current_regcache = NULL;
32178cab 516
c2250ad1
UW
517 current_thread_ptid = null_ptid;
518 current_thread_arch = NULL;
519
a5d9d57d
DJ
520 /* Need to forget about any frames we have cached, too. */
521 reinit_frame_cache ();
522
32178cab
MS
523 /* Force cleanup of any alloca areas if using C alloca instead of
524 a builtin alloca. This particular call is used to clean up
525 areas allocated by low level target code which may build up
526 during lengthy interactions between gdb and the target before
527 gdb gives control to the user (ie watchpoints). */
528 alloca (0);
32178cab
MS
529}
530
32178cab 531
61a0eb5b 532void
2d522557 533regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf)
61a0eb5b 534{
3fadccb3
AC
535 gdb_assert (regcache != NULL && buf != NULL);
536 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
3fadccb3
AC
537 /* Make certain that the register cache is up-to-date with respect
538 to the current thread. This switching shouldn't be necessary
539 only there is still only one target side register cache. Sigh!
540 On the bright side, at least there is a regcache object. */
2d28509a 541 if (!regcache->readonly_p)
3fadccb3 542 {
594f7785 543 if (!regcache_valid_p (regcache, regnum))
3fadccb3 544 {
594f7785
UW
545 struct cleanup *old_chain = save_inferior_ptid ();
546 inferior_ptid = regcache->ptid;
547 target_fetch_registers (regcache, regnum);
548 do_cleanups (old_chain);
3fadccb3 549 }
0a8146bf
AC
550#if 0
551 /* FIXME: cagney/2004-08-07: At present a number of targets
04c663e3
DA
552 forget (or didn't know that they needed) to set this leading to
553 panics. Also is the problem that targets need to indicate
0a8146bf
AC
554 that a register is in one of the possible states: valid,
555 undefined, unknown. The last of which isn't yet
556 possible. */
9c5ea4d9 557 gdb_assert (regcache_valid_p (regcache, regnum));
0a8146bf 558#endif
3fadccb3
AC
559 }
560 /* Copy the value directly into the register cache. */
51b1fe4e 561 memcpy (buf, register_buffer (regcache, regnum),
3fadccb3 562 regcache->descr->sizeof_register[regnum]);
61a0eb5b
AC
563}
564
28fc6740
AC
565void
566regcache_raw_read_signed (struct regcache *regcache, int regnum, LONGEST *val)
567{
2d522557 568 gdb_byte *buf;
28fc6740
AC
569 gdb_assert (regcache != NULL);
570 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
571 buf = alloca (regcache->descr->sizeof_register[regnum]);
572 regcache_raw_read (regcache, regnum, buf);
573 (*val) = extract_signed_integer (buf,
574 regcache->descr->sizeof_register[regnum]);
575}
576
577void
578regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
579 ULONGEST *val)
580{
2d522557 581 gdb_byte *buf;
28fc6740
AC
582 gdb_assert (regcache != NULL);
583 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
584 buf = alloca (regcache->descr->sizeof_register[regnum]);
585 regcache_raw_read (regcache, regnum, buf);
586 (*val) = extract_unsigned_integer (buf,
587 regcache->descr->sizeof_register[regnum]);
588}
589
c00dcbe9
MK
590void
591regcache_raw_write_signed (struct regcache *regcache, int regnum, LONGEST val)
592{
593 void *buf;
594 gdb_assert (regcache != NULL);
595 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
596 buf = alloca (regcache->descr->sizeof_register[regnum]);
597 store_signed_integer (buf, regcache->descr->sizeof_register[regnum], val);
598 regcache_raw_write (regcache, regnum, buf);
599}
600
601void
602regcache_raw_write_unsigned (struct regcache *regcache, int regnum,
603 ULONGEST val)
604{
605 void *buf;
606 gdb_assert (regcache != NULL);
607 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
608 buf = alloca (regcache->descr->sizeof_register[regnum]);
609 store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], val);
610 regcache_raw_write (regcache, regnum, buf);
611}
612
68365089 613void
2d522557 614regcache_cooked_read (struct regcache *regcache, int regnum, gdb_byte *buf)
68365089 615{
d138e37a 616 gdb_assert (regnum >= 0);
68365089
AC
617 gdb_assert (regnum < regcache->descr->nr_cooked_registers);
618 if (regnum < regcache->descr->nr_raw_registers)
619 regcache_raw_read (regcache, regnum, buf);
2d28509a
AC
620 else if (regcache->readonly_p
621 && regnum < regcache->descr->nr_cooked_registers
622 && regcache->register_valid_p[regnum])
b2fa5097 623 /* Read-only register cache, perhaps the cooked value was cached? */
2d28509a
AC
624 memcpy (buf, register_buffer (regcache, regnum),
625 regcache->descr->sizeof_register[regnum]);
d138e37a 626 else
68365089
AC
627 gdbarch_pseudo_register_read (regcache->descr->gdbarch, regcache,
628 regnum, buf);
61a0eb5b
AC
629}
630
a378f419
AC
631void
632regcache_cooked_read_signed (struct regcache *regcache, int regnum,
633 LONGEST *val)
634{
2d522557 635 gdb_byte *buf;
a378f419 636 gdb_assert (regcache != NULL);
a66a9c23 637 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
a378f419
AC
638 buf = alloca (regcache->descr->sizeof_register[regnum]);
639 regcache_cooked_read (regcache, regnum, buf);
640 (*val) = extract_signed_integer (buf,
641 regcache->descr->sizeof_register[regnum]);
642}
643
644void
645regcache_cooked_read_unsigned (struct regcache *regcache, int regnum,
646 ULONGEST *val)
647{
2d522557 648 gdb_byte *buf;
a378f419 649 gdb_assert (regcache != NULL);
a66a9c23 650 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
a378f419
AC
651 buf = alloca (regcache->descr->sizeof_register[regnum]);
652 regcache_cooked_read (regcache, regnum, buf);
653 (*val) = extract_unsigned_integer (buf,
654 regcache->descr->sizeof_register[regnum]);
655}
656
a66a9c23
AC
657void
658regcache_cooked_write_signed (struct regcache *regcache, int regnum,
659 LONGEST val)
660{
661 void *buf;
662 gdb_assert (regcache != NULL);
663 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
664 buf = alloca (regcache->descr->sizeof_register[regnum]);
665 store_signed_integer (buf, regcache->descr->sizeof_register[regnum], val);
666 regcache_cooked_write (regcache, regnum, buf);
667}
668
669void
670regcache_cooked_write_unsigned (struct regcache *regcache, int regnum,
671 ULONGEST val)
672{
673 void *buf;
674 gdb_assert (regcache != NULL);
675 gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
676 buf = alloca (regcache->descr->sizeof_register[regnum]);
677 store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], val);
678 regcache_cooked_write (regcache, regnum, buf);
679}
680
61a0eb5b 681void
2d522557
AC
682regcache_raw_write (struct regcache *regcache, int regnum,
683 const gdb_byte *buf)
61a0eb5b 684{
594f7785
UW
685 struct cleanup *old_chain;
686
3fadccb3
AC
687 gdb_assert (regcache != NULL && buf != NULL);
688 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
2d28509a 689 gdb_assert (!regcache->readonly_p);
3fadccb3 690
3fadccb3
AC
691 /* On the sparc, writing %g0 is a no-op, so we don't even want to
692 change the registers array if something writes to this register. */
214e098a 693 if (gdbarch_cannot_store_register (get_regcache_arch (regcache), regnum))
3fadccb3
AC
694 return;
695
3fadccb3
AC
696 /* If we have a valid copy of the register, and new value == old
697 value, then don't bother doing the actual store. */
698 if (regcache_valid_p (regcache, regnum)
699 && (memcmp (register_buffer (regcache, regnum), buf,
700 regcache->descr->sizeof_register[regnum]) == 0))
701 return;
702
594f7785
UW
703 old_chain = save_inferior_ptid ();
704 inferior_ptid = regcache->ptid;
705
316f2060 706 target_prepare_to_store (regcache);
3fadccb3
AC
707 memcpy (register_buffer (regcache, regnum), buf,
708 regcache->descr->sizeof_register[regnum]);
51b1fe4e 709 regcache->register_valid_p[regnum] = 1;
56be3814 710 target_store_registers (regcache, regnum);
594f7785
UW
711
712 do_cleanups (old_chain);
61a0eb5b
AC
713}
714
68365089 715void
2d522557
AC
716regcache_cooked_write (struct regcache *regcache, int regnum,
717 const gdb_byte *buf)
68365089 718{
d138e37a 719 gdb_assert (regnum >= 0);
68365089
AC
720 gdb_assert (regnum < regcache->descr->nr_cooked_registers);
721 if (regnum < regcache->descr->nr_raw_registers)
722 regcache_raw_write (regcache, regnum, buf);
d138e37a 723 else
68365089 724 gdbarch_pseudo_register_write (regcache->descr->gdbarch, regcache,
d8124050 725 regnum, buf);
61a0eb5b
AC
726}
727
06c0b04e
AC
728/* Perform a partial register transfer using a read, modify, write
729 operation. */
730
731typedef void (regcache_read_ftype) (struct regcache *regcache, int regnum,
732 void *buf);
733typedef void (regcache_write_ftype) (struct regcache *regcache, int regnum,
734 const void *buf);
735
b9362cc7 736static void
06c0b04e
AC
737regcache_xfer_part (struct regcache *regcache, int regnum,
738 int offset, int len, void *in, const void *out,
2d522557
AC
739 void (*read) (struct regcache *regcache, int regnum,
740 gdb_byte *buf),
741 void (*write) (struct regcache *regcache, int regnum,
742 const gdb_byte *buf))
06c0b04e
AC
743{
744 struct regcache_descr *descr = regcache->descr;
fc1a4b47 745 gdb_byte reg[MAX_REGISTER_SIZE];
06c0b04e
AC
746 gdb_assert (offset >= 0 && offset <= descr->sizeof_register[regnum]);
747 gdb_assert (len >= 0 && offset + len <= descr->sizeof_register[regnum]);
748 /* Something to do? */
749 if (offset + len == 0)
750 return;
751 /* Read (when needed) ... */
752 if (in != NULL
753 || offset > 0
754 || offset + len < descr->sizeof_register[regnum])
755 {
756 gdb_assert (read != NULL);
757 read (regcache, regnum, reg);
758 }
759 /* ... modify ... */
760 if (in != NULL)
761 memcpy (in, reg + offset, len);
762 if (out != NULL)
763 memcpy (reg + offset, out, len);
764 /* ... write (when needed). */
765 if (out != NULL)
766 {
767 gdb_assert (write != NULL);
768 write (regcache, regnum, reg);
769 }
770}
771
772void
773regcache_raw_read_part (struct regcache *regcache, int regnum,
2d522557 774 int offset, int len, gdb_byte *buf)
06c0b04e
AC
775{
776 struct regcache_descr *descr = regcache->descr;
777 gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
778 regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
779 regcache_raw_read, regcache_raw_write);
780}
781
782void
783regcache_raw_write_part (struct regcache *regcache, int regnum,
2d522557 784 int offset, int len, const gdb_byte *buf)
06c0b04e
AC
785{
786 struct regcache_descr *descr = regcache->descr;
787 gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
788 regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
789 regcache_raw_read, regcache_raw_write);
790}
791
792void
793regcache_cooked_read_part (struct regcache *regcache, int regnum,
2d522557 794 int offset, int len, gdb_byte *buf)
06c0b04e
AC
795{
796 struct regcache_descr *descr = regcache->descr;
797 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
798 regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
799 regcache_cooked_read, regcache_cooked_write);
800}
801
802void
803regcache_cooked_write_part (struct regcache *regcache, int regnum,
2d522557 804 int offset, int len, const gdb_byte *buf)
06c0b04e
AC
805{
806 struct regcache_descr *descr = regcache->descr;
807 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
808 regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
809 regcache_cooked_read, regcache_cooked_write);
810}
32178cab 811
a16d75cc 812/* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE. */
9a661b68
MK
813
814void
6618125d 815regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
9a661b68
MK
816{
817 void *regbuf;
818 size_t size;
819
a16d75cc 820 gdb_assert (regcache != NULL);
9a661b68
MK
821 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
822 gdb_assert (!regcache->readonly_p);
823
9a661b68
MK
824 regbuf = register_buffer (regcache, regnum);
825 size = regcache->descr->sizeof_register[regnum];
826
827 if (buf)
828 memcpy (regbuf, buf, size);
829 else
830 memset (regbuf, 0, size);
831
832 /* Mark the register as cached. */
833 regcache->register_valid_p[regnum] = 1;
834}
835
836/* Collect register REGNUM from REGCACHE and store its contents in BUF. */
837
838void
6618125d 839regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf)
9a661b68
MK
840{
841 const void *regbuf;
842 size_t size;
843
844 gdb_assert (regcache != NULL && buf != NULL);
845 gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
846
847 regbuf = register_buffer (regcache, regnum);
848 size = regcache->descr->sizeof_register[regnum];
849 memcpy (buf, regbuf, size);
850}
851
193cb69f 852
515630c5 853/* Special handling for register PC. */
32178cab
MS
854
855CORE_ADDR
515630c5 856regcache_read_pc (struct regcache *regcache)
32178cab 857{
61a1198a
UW
858 struct gdbarch *gdbarch = get_regcache_arch (regcache);
859
32178cab
MS
860 CORE_ADDR pc_val;
861
61a1198a
UW
862 if (gdbarch_read_pc_p (gdbarch))
863 pc_val = gdbarch_read_pc (gdbarch, regcache);
cde9ea48 864 /* Else use per-frame method on get_current_frame. */
214e098a 865 else if (gdbarch_pc_regnum (gdbarch) >= 0)
cde9ea48 866 {
61a1198a 867 ULONGEST raw_val;
3e8c568d 868 regcache_cooked_read_unsigned (regcache,
214e098a 869 gdbarch_pc_regnum (gdbarch),
3e8c568d 870 &raw_val);
214e098a 871 pc_val = gdbarch_addr_bits_remove (gdbarch, raw_val);
cde9ea48
AC
872 }
873 else
515630c5
UW
874 internal_error (__FILE__, __LINE__,
875 _("regcache_read_pc: Unable to find PC"));
32178cab
MS
876 return pc_val;
877}
878
32178cab 879void
515630c5 880regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
32178cab 881{
61a1198a
UW
882 struct gdbarch *gdbarch = get_regcache_arch (regcache);
883
61a1198a
UW
884 if (gdbarch_write_pc_p (gdbarch))
885 gdbarch_write_pc (gdbarch, regcache, pc);
214e098a 886 else if (gdbarch_pc_regnum (gdbarch) >= 0)
3e8c568d 887 regcache_cooked_write_unsigned (regcache,
214e098a 888 gdbarch_pc_regnum (gdbarch), pc);
61a1198a
UW
889 else
890 internal_error (__FILE__, __LINE__,
515630c5 891 _("regcache_write_pc: Unable to update PC"));
edb3359d
DJ
892
893 /* Writing the PC (for instance, from "load") invalidates the
894 current frame. */
895 reinit_frame_cache ();
32178cab
MS
896}
897
32178cab 898
705152c5
MS
899static void
900reg_flush_command (char *command, int from_tty)
901{
902 /* Force-flush the register cache. */
903 registers_changed ();
904 if (from_tty)
a3f17187 905 printf_filtered (_("Register cache flushed.\n"));
705152c5
MS
906}
907
af030b9a
AC
908static void
909dump_endian_bytes (struct ui_file *file, enum bfd_endian endian,
910 const unsigned char *buf, long len)
911{
912 int i;
913 switch (endian)
914 {
915 case BFD_ENDIAN_BIG:
916 for (i = 0; i < len; i++)
917 fprintf_unfiltered (file, "%02x", buf[i]);
918 break;
919 case BFD_ENDIAN_LITTLE:
920 for (i = len - 1; i >= 0; i--)
921 fprintf_unfiltered (file, "%02x", buf[i]);
922 break;
923 default:
e2e0b3e5 924 internal_error (__FILE__, __LINE__, _("Bad switch"));
af030b9a
AC
925 }
926}
927
928enum regcache_dump_what
929{
b59ff9d5 930 regcache_dump_none, regcache_dump_raw, regcache_dump_cooked, regcache_dump_groups
af030b9a
AC
931};
932
933static void
934regcache_dump (struct regcache *regcache, struct ui_file *file,
935 enum regcache_dump_what what_to_dump)
936{
937 struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
b59ff9d5 938 struct gdbarch *gdbarch = regcache->descr->gdbarch;
af030b9a
AC
939 int regnum;
940 int footnote_nr = 0;
941 int footnote_register_size = 0;
942 int footnote_register_offset = 0;
943 int footnote_register_type_name_null = 0;
944 long register_offset = 0;
123a958e 945 unsigned char buf[MAX_REGISTER_SIZE];
af030b9a
AC
946
947#if 0
af030b9a
AC
948 fprintf_unfiltered (file, "nr_raw_registers %d\n",
949 regcache->descr->nr_raw_registers);
950 fprintf_unfiltered (file, "nr_cooked_registers %d\n",
951 regcache->descr->nr_cooked_registers);
952 fprintf_unfiltered (file, "sizeof_raw_registers %ld\n",
953 regcache->descr->sizeof_raw_registers);
954 fprintf_unfiltered (file, "sizeof_raw_register_valid_p %ld\n",
955 regcache->descr->sizeof_raw_register_valid_p);
f57d151a 956 fprintf_unfiltered (file, "gdbarch_num_regs %d\n",
214e098a 957 gdbarch_num_regs (gdbarch));
f57d151a 958 fprintf_unfiltered (file, "gdbarch_num_pseudo_regs %d\n",
214e098a 959 gdbarch_num_pseudo_regs (gdbarch));
af030b9a
AC
960#endif
961
962 gdb_assert (regcache->descr->nr_cooked_registers
214e098a
UW
963 == (gdbarch_num_regs (gdbarch)
964 + gdbarch_num_pseudo_regs (gdbarch)));
af030b9a
AC
965
966 for (regnum = -1; regnum < regcache->descr->nr_cooked_registers; regnum++)
967 {
968 /* Name. */
969 if (regnum < 0)
970 fprintf_unfiltered (file, " %-10s", "Name");
971 else
972 {
214e098a 973 const char *p = gdbarch_register_name (gdbarch, regnum);
af030b9a
AC
974 if (p == NULL)
975 p = "";
976 else if (p[0] == '\0')
977 p = "''";
978 fprintf_unfiltered (file, " %-10s", p);
979 }
980
981 /* Number. */
982 if (regnum < 0)
983 fprintf_unfiltered (file, " %4s", "Nr");
984 else
985 fprintf_unfiltered (file, " %4d", regnum);
986
987 /* Relative number. */
988 if (regnum < 0)
989 fprintf_unfiltered (file, " %4s", "Rel");
214e098a 990 else if (regnum < gdbarch_num_regs (gdbarch))
af030b9a
AC
991 fprintf_unfiltered (file, " %4d", regnum);
992 else
f57d151a 993 fprintf_unfiltered (file, " %4d",
214e098a 994 (regnum - gdbarch_num_regs (gdbarch)));
af030b9a
AC
995
996 /* Offset. */
997 if (regnum < 0)
998 fprintf_unfiltered (file, " %6s ", "Offset");
999 else
1000 {
1001 fprintf_unfiltered (file, " %6ld",
1002 regcache->descr->register_offset[regnum]);
a7e3c2ad 1003 if (register_offset != regcache->descr->register_offset[regnum]
d3b22ed5
AC
1004 || (regnum > 0
1005 && (regcache->descr->register_offset[regnum]
1006 != (regcache->descr->register_offset[regnum - 1]
1007 + regcache->descr->sizeof_register[regnum - 1])))
1008 )
af030b9a
AC
1009 {
1010 if (!footnote_register_offset)
1011 footnote_register_offset = ++footnote_nr;
1012 fprintf_unfiltered (file, "*%d", footnote_register_offset);
1013 }
1014 else
1015 fprintf_unfiltered (file, " ");
1016 register_offset = (regcache->descr->register_offset[regnum]
1017 + regcache->descr->sizeof_register[regnum]);
1018 }
1019
1020 /* Size. */
1021 if (regnum < 0)
1022 fprintf_unfiltered (file, " %5s ", "Size");
1023 else
01e1877c
AC
1024 fprintf_unfiltered (file, " %5ld",
1025 regcache->descr->sizeof_register[regnum]);
af030b9a
AC
1026
1027 /* Type. */
b59ff9d5
AC
1028 {
1029 const char *t;
1030 if (regnum < 0)
1031 t = "Type";
1032 else
1033 {
1034 static const char blt[] = "builtin_type";
1035 t = TYPE_NAME (register_type (regcache->descr->gdbarch, regnum));
1036 if (t == NULL)
1037 {
1038 char *n;
1039 if (!footnote_register_type_name_null)
1040 footnote_register_type_name_null = ++footnote_nr;
b435e160 1041 n = xstrprintf ("*%d", footnote_register_type_name_null);
b59ff9d5
AC
1042 make_cleanup (xfree, n);
1043 t = n;
1044 }
1045 /* Chop a leading builtin_type. */
1046 if (strncmp (t, blt, strlen (blt)) == 0)
1047 t += strlen (blt);
1048 }
1049 fprintf_unfiltered (file, " %-15s", t);
1050 }
1051
1052 /* Leading space always present. */
1053 fprintf_unfiltered (file, " ");
af030b9a
AC
1054
1055 /* Value, raw. */
1056 if (what_to_dump == regcache_dump_raw)
1057 {
1058 if (regnum < 0)
1059 fprintf_unfiltered (file, "Raw value");
1060 else if (regnum >= regcache->descr->nr_raw_registers)
1061 fprintf_unfiltered (file, "<cooked>");
1062 else if (!regcache_valid_p (regcache, regnum))
1063 fprintf_unfiltered (file, "<invalid>");
1064 else
1065 {
1066 regcache_raw_read (regcache, regnum, buf);
1067 fprintf_unfiltered (file, "0x");
0d20ae72 1068 dump_endian_bytes (file,
214e098a 1069 gdbarch_byte_order (gdbarch), buf,
01e1877c 1070 regcache->descr->sizeof_register[regnum]);
af030b9a
AC
1071 }
1072 }
1073
1074 /* Value, cooked. */
1075 if (what_to_dump == regcache_dump_cooked)
1076 {
1077 if (regnum < 0)
1078 fprintf_unfiltered (file, "Cooked value");
1079 else
1080 {
1081 regcache_cooked_read (regcache, regnum, buf);
1082 fprintf_unfiltered (file, "0x");
0d20ae72 1083 dump_endian_bytes (file,
214e098a 1084 gdbarch_byte_order (gdbarch), buf,
01e1877c 1085 regcache->descr->sizeof_register[regnum]);
af030b9a
AC
1086 }
1087 }
1088
b59ff9d5
AC
1089 /* Group members. */
1090 if (what_to_dump == regcache_dump_groups)
1091 {
1092 if (regnum < 0)
1093 fprintf_unfiltered (file, "Groups");
1094 else
1095 {
b59ff9d5 1096 const char *sep = "";
6c7d17ba
AC
1097 struct reggroup *group;
1098 for (group = reggroup_next (gdbarch, NULL);
1099 group != NULL;
1100 group = reggroup_next (gdbarch, group))
b59ff9d5 1101 {
6c7d17ba 1102 if (gdbarch_register_reggroup_p (gdbarch, regnum, group))
b59ff9d5 1103 {
6c7d17ba 1104 fprintf_unfiltered (file, "%s%s", sep, reggroup_name (group));
b59ff9d5
AC
1105 sep = ",";
1106 }
1107 }
1108 }
1109 }
1110
af030b9a
AC
1111 fprintf_unfiltered (file, "\n");
1112 }
1113
1114 if (footnote_register_size)
1115 fprintf_unfiltered (file, "*%d: Inconsistent register sizes.\n",
1116 footnote_register_size);
1117 if (footnote_register_offset)
1118 fprintf_unfiltered (file, "*%d: Inconsistent register offsets.\n",
1119 footnote_register_offset);
1120 if (footnote_register_type_name_null)
1121 fprintf_unfiltered (file,
1122 "*%d: Register type's name NULL.\n",
1123 footnote_register_type_name_null);
1124 do_cleanups (cleanups);
1125}
1126
1127static void
1128regcache_print (char *args, enum regcache_dump_what what_to_dump)
1129{
1130 if (args == NULL)
28c38f10 1131 regcache_dump (get_current_regcache (), gdb_stdout, what_to_dump);
af030b9a
AC
1132 else
1133 {
724b958c 1134 struct cleanup *cleanups;
af030b9a
AC
1135 struct ui_file *file = gdb_fopen (args, "w");
1136 if (file == NULL)
e2e0b3e5 1137 perror_with_name (_("maintenance print architecture"));
724b958c 1138 cleanups = make_cleanup_ui_file_delete (file);
28c38f10 1139 regcache_dump (get_current_regcache (), file, what_to_dump);
724b958c 1140 do_cleanups (cleanups);
af030b9a
AC
1141 }
1142}
1143
1144static void
1145maintenance_print_registers (char *args, int from_tty)
1146{
1147 regcache_print (args, regcache_dump_none);
1148}
1149
1150static void
1151maintenance_print_raw_registers (char *args, int from_tty)
1152{
1153 regcache_print (args, regcache_dump_raw);
1154}
1155
1156static void
1157maintenance_print_cooked_registers (char *args, int from_tty)
1158{
1159 regcache_print (args, regcache_dump_cooked);
1160}
1161
b59ff9d5
AC
1162static void
1163maintenance_print_register_groups (char *args, int from_tty)
1164{
1165 regcache_print (args, regcache_dump_groups);
1166}
1167
b9362cc7
AC
1168extern initialize_file_ftype _initialize_regcache; /* -Wmissing-prototype */
1169
32178cab
MS
1170void
1171_initialize_regcache (void)
1172{
030f20e1 1173 regcache_descr_handle = gdbarch_data_register_post_init (init_regcache_descr);
705152c5 1174
f4c5303c 1175 observer_attach_target_changed (regcache_observer_target_changed);
5231c1fd 1176 observer_attach_thread_ptid_changed (regcache_thread_ptid_changed);
f4c5303c 1177
705152c5 1178 add_com ("flushregs", class_maintenance, reg_flush_command,
1bedd215 1179 _("Force gdb to flush its register cache (maintainer command)"));
39f77062 1180
1a966eab
AC
1181 add_cmd ("registers", class_maintenance, maintenance_print_registers, _("\
1182Print the internal register configuration.\n\
1183Takes an optional file parameter."), &maintenanceprintlist);
af030b9a 1184 add_cmd ("raw-registers", class_maintenance,
1a966eab
AC
1185 maintenance_print_raw_registers, _("\
1186Print the internal register configuration including raw values.\n\
1187Takes an optional file parameter."), &maintenanceprintlist);
af030b9a 1188 add_cmd ("cooked-registers", class_maintenance,
1a966eab
AC
1189 maintenance_print_cooked_registers, _("\
1190Print the internal register configuration including cooked values.\n\
1191Takes an optional file parameter."), &maintenanceprintlist);
b59ff9d5 1192 add_cmd ("register-groups", class_maintenance,
1a966eab
AC
1193 maintenance_print_register_groups, _("\
1194Print the internal register configuration including each register's group.\n\
1195Takes an optional file parameter."),
af030b9a
AC
1196 &maintenanceprintlist);
1197
32178cab 1198}
This page took 0.872419 seconds and 4 git commands to generate.