Add current_regcache unit test
[deliverable/binutils-gdb.git] / gdb / regcache.c
CommitLineData
32178cab 1/* Cache and manage the values of registers for GDB, the GNU debugger.
3fadccb3 2
61baf725 3 Copyright (C) 1986-2017 Free Software Foundation, Inc.
32178cab
MS
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
32178cab
MS
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
32178cab
MS
19
20#include "defs.h"
32178cab
MS
21#include "inferior.h"
22#include "target.h"
23#include "gdbarch.h"
705152c5 24#include "gdbcmd.h"
4e052eda 25#include "regcache.h"
b59ff9d5 26#include "reggroups.h"
f4c5303c 27#include "observer.h"
c21236dc 28#include "remote.h"
d3eaaf66 29#include "valprint.h"
0b309272 30#include "regset.h"
32178cab
MS
31
32/*
33 * DATA STRUCTURE
34 *
35 * Here is the actual register cache.
36 */
37
3fadccb3 38/* Per-architecture object describing the layout of a register cache.
0df8b418 39 Computed once when the architecture is created. */
3fadccb3
AC
40
41struct gdbarch_data *regcache_descr_handle;
42
43struct regcache_descr
44{
45 /* The architecture this descriptor belongs to. */
46 struct gdbarch *gdbarch;
47
bb1db049
AC
48 /* The raw register cache. Each raw (or hard) register is supplied
49 by the target interface. The raw cache should not contain
50 redundant information - if the PC is constructed from two
d2f0b918 51 registers then those registers and not the PC lives in the raw
bb1db049 52 cache. */
3fadccb3
AC
53 int nr_raw_registers;
54 long sizeof_raw_registers;
ee99023e 55 long sizeof_raw_register_status;
3fadccb3 56
d138e37a
AC
57 /* The cooked register space. Each cooked register in the range
58 [0..NR_RAW_REGISTERS) is direct-mapped onto the corresponding raw
59 register. The remaining [NR_RAW_REGISTERS
02f60eae 60 .. NR_COOKED_REGISTERS) (a.k.a. pseudo registers) are mapped onto
d138e37a 61 both raw registers and memory by the architecture methods
02f60eae 62 gdbarch_pseudo_register_read and gdbarch_pseudo_register_write. */
d138e37a 63 int nr_cooked_registers;
067df2e5 64 long sizeof_cooked_registers;
ee99023e 65 long sizeof_cooked_register_status;
d138e37a 66
86d31898 67 /* Offset and size (in 8 bit bytes), of each register in the
d138e37a 68 register cache. All registers (including those in the range
99e42fd8
PA
69 [NR_RAW_REGISTERS .. NR_COOKED_REGISTERS) are given an
70 offset. */
3fadccb3 71 long *register_offset;
3fadccb3 72 long *sizeof_register;
3fadccb3 73
bb425013
AC
74 /* Cached table containing the type of each register. */
75 struct type **register_type;
3fadccb3
AC
76};
77
3fadccb3
AC
78static void *
79init_regcache_descr (struct gdbarch *gdbarch)
80{
81 int i;
82 struct regcache_descr *descr;
83 gdb_assert (gdbarch != NULL);
84
bb425013 85 /* Create an initial, zero filled, table. */
116f06ea 86 descr = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct regcache_descr);
3fadccb3 87 descr->gdbarch = gdbarch;
3fadccb3 88
d138e37a
AC
89 /* Total size of the register space. The raw registers are mapped
90 directly onto the raw register cache while the pseudo's are
3fadccb3 91 either mapped onto raw-registers or memory. */
214e098a
UW
92 descr->nr_cooked_registers = gdbarch_num_regs (gdbarch)
93 + gdbarch_num_pseudo_regs (gdbarch);
ee99023e
PA
94 descr->sizeof_cooked_register_status
95 = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
3fadccb3 96
bb425013 97 /* Fill in a table of register types. */
116f06ea 98 descr->register_type
3e43a32a
MS
99 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers,
100 struct type *);
bb425013 101 for (i = 0; i < descr->nr_cooked_registers; i++)
336a3131 102 descr->register_type[i] = gdbarch_register_type (gdbarch, i);
bb425013 103
bb1db049
AC
104 /* Construct a strictly RAW register cache. Don't allow pseudo's
105 into the register cache. */
214e098a 106 descr->nr_raw_registers = gdbarch_num_regs (gdbarch);
ee99023e 107 descr->sizeof_raw_register_status = gdbarch_num_regs (gdbarch);
bb1db049 108
067df2e5 109 /* Lay out the register cache.
3fadccb3 110
bb425013
AC
111 NOTE: cagney/2002-05-22: Only register_type() is used when
112 constructing the register cache. It is assumed that the
113 register's raw size, virtual size and type length are all the
114 same. */
3fadccb3
AC
115
116 {
117 long offset = 0;
123f5f96 118
116f06ea
AC
119 descr->sizeof_register
120 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
121 descr->register_offset
122 = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
99e42fd8
PA
123 for (i = 0; i < descr->nr_raw_registers; i++)
124 {
125 descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]);
126 descr->register_offset[i] = offset;
127 offset += descr->sizeof_register[i];
128 gdb_assert (MAX_REGISTER_SIZE >= descr->sizeof_register[i]);
129 }
130 /* Set the real size of the raw register cache buffer. */
131 descr->sizeof_raw_registers = offset;
132
133 for (; i < descr->nr_cooked_registers; i++)
3fadccb3 134 {
bb425013 135 descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]);
3fadccb3
AC
136 descr->register_offset[i] = offset;
137 offset += descr->sizeof_register[i];
123a958e 138 gdb_assert (MAX_REGISTER_SIZE >= descr->sizeof_register[i]);
3fadccb3 139 }
99e42fd8 140 /* Set the real size of the readonly register cache buffer. */
067df2e5 141 descr->sizeof_cooked_registers = offset;
3fadccb3
AC
142 }
143
3fadccb3
AC
144 return descr;
145}
146
147static struct regcache_descr *
148regcache_descr (struct gdbarch *gdbarch)
149{
19ba03f4
SM
150 return (struct regcache_descr *) gdbarch_data (gdbarch,
151 regcache_descr_handle);
3fadccb3
AC
152}
153
bb425013
AC
154/* Utility functions returning useful register attributes stored in
155 the regcache descr. */
156
157struct type *
158register_type (struct gdbarch *gdbarch, int regnum)
159{
160 struct regcache_descr *descr = regcache_descr (gdbarch);
123f5f96 161
bb425013
AC
162 gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
163 return descr->register_type[regnum];
164}
165
0ed04cce
AC
166/* Utility functions returning useful register attributes stored in
167 the regcache descr. */
168
08a617da
AC
169int
170register_size (struct gdbarch *gdbarch, int regnum)
171{
172 struct regcache_descr *descr = regcache_descr (gdbarch);
173 int size;
123f5f96 174
f57d151a 175 gdb_assert (regnum >= 0
214e098a
UW
176 && regnum < (gdbarch_num_regs (gdbarch)
177 + gdbarch_num_pseudo_regs (gdbarch)));
08a617da 178 size = descr->sizeof_register[regnum];
08a617da
AC
179 return size;
180}
181
8d689ee5
YQ
182/* See common/common-regcache.h. */
183
184int
185regcache_register_size (const struct regcache *regcache, int n)
186{
187 return register_size (get_regcache_arch (regcache), n);
188}
189
ef79d9a3
YQ
190regcache::regcache (gdbarch *gdbarch, address_space *aspace_,
191 bool readonly_p_)
192 : m_aspace (aspace_), m_readonly_p (readonly_p_)
3fadccb3 193{
ef79d9a3
YQ
194 gdb_assert (gdbarch != NULL);
195 m_descr = regcache_descr (gdbarch);
4621115f 196
ef79d9a3 197 if (m_readonly_p)
4621115f 198 {
ef79d9a3
YQ
199 m_registers = XCNEWVEC (gdb_byte, m_descr->sizeof_cooked_registers);
200 m_register_status = XCNEWVEC (signed char,
201 m_descr->sizeof_cooked_register_status);
4621115f
YQ
202 }
203 else
204 {
ef79d9a3
YQ
205 m_registers = XCNEWVEC (gdb_byte, m_descr->sizeof_raw_registers);
206 m_register_status = XCNEWVEC (signed char,
207 m_descr->sizeof_raw_register_status);
4621115f 208 }
ef79d9a3
YQ
209 m_ptid = minus_one_ptid;
210}
4621115f 211
deb1fa3e
YQ
212static enum register_status
213do_cooked_read (void *src, int regnum, gdb_byte *buf)
214{
215 struct regcache *regcache = (struct regcache *) src;
216
217 return regcache_cooked_read (regcache, regnum, buf);
218}
219
220regcache::regcache (readonly_t, const regcache &src)
221 : regcache (src.arch (), src.aspace (), true)
222{
223 gdb_assert (!src.m_readonly_p);
224 save (do_cooked_read, (void *) &src);
225}
226
ef79d9a3
YQ
227gdbarch *
228regcache::arch () const
229{
230 return m_descr->gdbarch;
231}
3fadccb3 232
ddaaf0fb
SM
233/* See regcache.h. */
234
235ptid_t
236regcache_get_ptid (const struct regcache *regcache)
237{
ef79d9a3 238 gdb_assert (!ptid_equal (regcache->ptid (), minus_one_ptid));
ddaaf0fb 239
ef79d9a3 240 return regcache->ptid ();
ddaaf0fb
SM
241}
242
99e42fd8
PA
243struct regcache *
244regcache_xmalloc (struct gdbarch *gdbarch, struct address_space *aspace)
245{
4621115f 246 return new regcache (gdbarch, aspace);
99e42fd8
PA
247}
248
3fadccb3
AC
249void
250regcache_xfree (struct regcache *regcache)
251{
252 if (regcache == NULL)
253 return;
4621115f
YQ
254
255 delete regcache;
3fadccb3
AC
256}
257
b9362cc7 258static void
36160dc4
AC
259do_regcache_xfree (void *data)
260{
19ba03f4 261 regcache_xfree ((struct regcache *) data);
36160dc4
AC
262}
263
264struct cleanup *
265make_cleanup_regcache_xfree (struct regcache *regcache)
266{
267 return make_cleanup (do_regcache_xfree, regcache);
268}
269
b94ade42
PL
270/* Cleanup routines for invalidating a register. */
271
272struct register_to_invalidate
273{
274 struct regcache *regcache;
275 int regnum;
276};
277
278static void
279do_regcache_invalidate (void *data)
280{
19ba03f4 281 struct register_to_invalidate *reg = (struct register_to_invalidate *) data;
b94ade42
PL
282
283 regcache_invalidate (reg->regcache, reg->regnum);
284}
285
286static struct cleanup *
287make_cleanup_regcache_invalidate (struct regcache *regcache, int regnum)
288{
289 struct register_to_invalidate* reg = XNEW (struct register_to_invalidate);
290
291 reg->regcache = regcache;
292 reg->regnum = regnum;
293 return make_cleanup_dtor (do_regcache_invalidate, (void *) reg, xfree);
294}
295
41d35cb0
MK
296/* Return REGCACHE's architecture. */
297
298struct gdbarch *
299get_regcache_arch (const struct regcache *regcache)
300{
ef79d9a3 301 return regcache->arch ();
41d35cb0
MK
302}
303
6c95b8df
PA
304struct address_space *
305get_regcache_aspace (const struct regcache *regcache)
306{
ef79d9a3 307 return regcache->aspace ();
6c95b8df
PA
308}
309
51b1fe4e
AC
310/* Return a pointer to register REGNUM's buffer cache. */
311
ef79d9a3
YQ
312gdb_byte *
313regcache::register_buffer (int regnum) const
51b1fe4e 314{
ef79d9a3 315 return m_registers + m_descr->register_offset[regnum];
51b1fe4e
AC
316}
317
2d28509a 318void
ef79d9a3
YQ
319regcache_save (struct regcache *regcache,
320 regcache_cooked_read_ftype *cooked_read, void *src)
2d28509a 321{
ef79d9a3
YQ
322 regcache->save (cooked_read, src);
323}
324
325void
326regcache::save (regcache_cooked_read_ftype *cooked_read,
327 void *src)
328{
329 struct gdbarch *gdbarch = m_descr->gdbarch;
2d522557 330 gdb_byte buf[MAX_REGISTER_SIZE];
2d28509a 331 int regnum;
123f5f96 332
2d28509a 333 /* The DST should be `read-only', if it wasn't then the save would
5602984a 334 end up trying to write the register values back out to the
2d28509a 335 target. */
ef79d9a3 336 gdb_assert (m_readonly_p);
2d28509a 337 /* Clear the dest. */
ef79d9a3
YQ
338 memset (m_registers, 0, m_descr->sizeof_cooked_registers);
339 memset (m_register_status, 0, m_descr->sizeof_cooked_register_status);
2d28509a 340 /* Copy over any registers (identified by their membership in the
f57d151a
UW
341 save_reggroup) and mark them as valid. The full [0 .. gdbarch_num_regs +
342 gdbarch_num_pseudo_regs) range is checked since some architectures need
5602984a 343 to save/restore `cooked' registers that live in memory. */
ef79d9a3 344 for (regnum = 0; regnum < m_descr->nr_cooked_registers; regnum++)
2d28509a
AC
345 {
346 if (gdbarch_register_reggroup_p (gdbarch, regnum, save_reggroup))
347 {
05d1431c 348 enum register_status status = cooked_read (src, regnum, buf);
123f5f96 349
05d1431c 350 if (status == REG_VALID)
ef79d9a3 351 memcpy (register_buffer (regnum), buf,
05d1431c
PA
352 register_size (gdbarch, regnum));
353 else
5602984a 354 {
05d1431c
PA
355 gdb_assert (status != REG_UNKNOWN);
356
ef79d9a3 357 memset (register_buffer (regnum), 0,
5602984a 358 register_size (gdbarch, regnum));
5602984a 359 }
ef79d9a3 360 m_register_status[regnum] = status;
2d28509a
AC
361 }
362 }
363}
364
ef79d9a3
YQ
365void
366regcache::restore (struct regcache *src)
2d28509a 367{
ef79d9a3 368 struct gdbarch *gdbarch = m_descr->gdbarch;
2d28509a 369 int regnum;
123f5f96 370
5602984a
AC
371 /* The dst had better not be read-only. If it is, the `restore'
372 doesn't make much sense. */
ef79d9a3
YQ
373 gdb_assert (!m_readonly_p);
374 gdb_assert (src->m_readonly_p);
2d28509a 375 /* Copy over any registers, being careful to only restore those that
f57d151a
UW
376 were both saved and need to be restored. The full [0 .. gdbarch_num_regs
377 + gdbarch_num_pseudo_regs) range is checked since some architectures need
5602984a 378 to save/restore `cooked' registers that live in memory. */
ef79d9a3 379 for (regnum = 0; regnum < m_descr->nr_cooked_registers; regnum++)
2d28509a 380 {
5602984a 381 if (gdbarch_register_reggroup_p (gdbarch, regnum, restore_reggroup))
2d28509a 382 {
ef79d9a3
YQ
383 if (src->m_register_status[regnum] == REG_VALID)
384 cooked_write (regnum, src->register_buffer (regnum));
2d28509a
AC
385 }
386 }
387}
388
3fadccb3
AC
389void
390regcache_cpy (struct regcache *dst, struct regcache *src)
391{
3fadccb3 392 gdb_assert (src != NULL && dst != NULL);
ef79d9a3 393 gdb_assert (src->m_descr->gdbarch == dst->m_descr->gdbarch);
3fadccb3 394 gdb_assert (src != dst);
ef79d9a3 395 gdb_assert (src->m_readonly_p || dst->m_readonly_p);
6c95b8df 396
ef79d9a3 397 if (!src->m_readonly_p)
5602984a 398 regcache_save (dst, do_cooked_read, src);
ef79d9a3
YQ
399 else if (!dst->m_readonly_p)
400 dst->restore (src);
2d28509a 401 else
ef79d9a3 402 dst->cpy_no_passthrough (src);
3fadccb3
AC
403}
404
bd49952b
JK
405/* Copy/duplicate the contents of a register cache. Unlike regcache_cpy,
406 which is pass-through, this does not go through to the target.
407 Only values values already in the cache are transferred. The SRC and DST
408 buffers must not overlap. */
409
ef79d9a3
YQ
410void
411regcache::cpy_no_passthrough (struct regcache *src)
3fadccb3 412{
ef79d9a3
YQ
413 gdb_assert (src != NULL);
414 gdb_assert (src->m_descr->gdbarch == m_descr->gdbarch);
3fadccb3 415 /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough
ee99023e
PA
416 move of data into a thread's regcache. Doing this would be silly
417 - it would mean that regcache->register_status would be
418 completely invalid. */
ef79d9a3 419 gdb_assert (m_readonly_p && src->m_readonly_p);
6c95b8df 420
ef79d9a3
YQ
421 memcpy (m_registers, src->m_registers,
422 m_descr->sizeof_cooked_registers);
423 memcpy (m_register_status, src->m_register_status,
424 m_descr->sizeof_cooked_register_status);
3fadccb3
AC
425}
426
427struct regcache *
428regcache_dup (struct regcache *src)
429{
deb1fa3e 430 return new regcache (regcache::readonly, *src);
3fadccb3
AC
431}
432
39181896 433enum register_status
ee99023e 434regcache_register_status (const struct regcache *regcache, int regnum)
3fadccb3
AC
435{
436 gdb_assert (regcache != NULL);
ef79d9a3
YQ
437 return regcache->get_register_status (regnum);
438}
439
440enum register_status
441regcache::get_register_status (int regnum) const
442{
6ed7ea50 443 gdb_assert (regnum >= 0);
ef79d9a3
YQ
444 if (m_readonly_p)
445 gdb_assert (regnum < m_descr->nr_cooked_registers);
6ed7ea50 446 else
ef79d9a3 447 gdb_assert (regnum < m_descr->nr_raw_registers);
6ed7ea50 448
ef79d9a3 449 return (enum register_status) m_register_status[regnum];
3fadccb3
AC
450}
451
9c5ea4d9
UW
452void
453regcache_invalidate (struct regcache *regcache, int regnum)
454{
455 gdb_assert (regcache != NULL);
ef79d9a3 456 regcache->invalidate (regnum);
9c5ea4d9
UW
457}
458
ef79d9a3
YQ
459void
460regcache::invalidate (int regnum)
461{
462 gdb_assert (regnum >= 0);
463 gdb_assert (!m_readonly_p);
464 gdb_assert (regnum < m_descr->nr_raw_registers);
465 m_register_status[regnum] = REG_UNKNOWN;
466}
9c5ea4d9 467
3fadccb3 468/* Global structure containing the current regcache. */
3fadccb3 469
5ebd2499 470/* NOTE: this is a write-through cache. There is no "dirty" bit for
32178cab
MS
471 recording if the register values have been changed (eg. by the
472 user). Therefore all registers must be written back to the
473 target when appropriate. */
474
c2250ad1 475struct regcache_list
594f7785 476{
c2250ad1
UW
477 struct regcache *regcache;
478 struct regcache_list *next;
479};
480
481static struct regcache_list *current_regcache;
482
483struct regcache *
e2d96639
YQ
484get_thread_arch_aspace_regcache (ptid_t ptid, struct gdbarch *gdbarch,
485 struct address_space *aspace)
c2250ad1
UW
486{
487 struct regcache_list *list;
488 struct regcache *new_regcache;
594f7785 489
c2250ad1 490 for (list = current_regcache; list; list = list->next)
ef79d9a3 491 if (ptid_equal (list->regcache->ptid (), ptid)
c2250ad1
UW
492 && get_regcache_arch (list->regcache) == gdbarch)
493 return list->regcache;
594f7785 494
4621115f 495 new_regcache = new regcache (gdbarch, aspace, false);
ef79d9a3 496 new_regcache->set_ptid (ptid);
e2d96639 497
8d749320 498 list = XNEW (struct regcache_list);
e2d96639
YQ
499 list->regcache = new_regcache;
500 list->next = current_regcache;
501 current_regcache = list;
502
503 return new_regcache;
504}
505
506struct regcache *
507get_thread_arch_regcache (ptid_t ptid, struct gdbarch *gdbarch)
508{
509 struct address_space *aspace;
510
b78974c3
PA
511 /* For the benefit of "maint print registers" & co when debugging an
512 executable, allow dumping the regcache even when there is no
513 thread selected (target_thread_address_space internal-errors if
514 no address space is found). Note that normal user commands will
515 fail higher up on the call stack due to no
516 target_has_registers. */
517 aspace = (ptid_equal (null_ptid, ptid)
518 ? NULL
519 : target_thread_address_space (ptid));
520
e2d96639 521 return get_thread_arch_aspace_regcache (ptid, gdbarch, aspace);
594f7785
UW
522}
523
c2250ad1
UW
524static ptid_t current_thread_ptid;
525static struct gdbarch *current_thread_arch;
526
527struct regcache *
528get_thread_regcache (ptid_t ptid)
529{
530 if (!current_thread_arch || !ptid_equal (current_thread_ptid, ptid))
531 {
532 current_thread_ptid = ptid;
533 current_thread_arch = target_thread_architecture (ptid);
534 }
535
536 return get_thread_arch_regcache (ptid, current_thread_arch);
537}
538
539struct regcache *
540get_current_regcache (void)
594f7785
UW
541{
542 return get_thread_regcache (inferior_ptid);
543}
32178cab 544
361c8ade
GB
545/* See common/common-regcache.h. */
546
547struct regcache *
548get_thread_regcache_for_ptid (ptid_t ptid)
549{
550 return get_thread_regcache (ptid);
551}
32178cab 552
f4c5303c
OF
553/* Observer for the target_changed event. */
554
2c0b251b 555static void
f4c5303c
OF
556regcache_observer_target_changed (struct target_ops *target)
557{
558 registers_changed ();
559}
560
5231c1fd
PA
561/* Update global variables old ptids to hold NEW_PTID if they were
562 holding OLD_PTID. */
563static void
564regcache_thread_ptid_changed (ptid_t old_ptid, ptid_t new_ptid)
565{
c2250ad1
UW
566 struct regcache_list *list;
567
568 for (list = current_regcache; list; list = list->next)
ef79d9a3
YQ
569 if (ptid_equal (list->regcache->ptid (), old_ptid))
570 list->regcache->set_ptid (new_ptid);
5231c1fd
PA
571}
572
32178cab
MS
573/* Low level examining and depositing of registers.
574
575 The caller is responsible for making sure that the inferior is
576 stopped before calling the fetching routines, or it will get
577 garbage. (a change from GDB version 3, in which the caller got the
578 value from the last stop). */
579
580/* REGISTERS_CHANGED ()
581
582 Indicate that registers may have changed, so invalidate the cache. */
583
584void
e66408ed 585registers_changed_ptid (ptid_t ptid)
32178cab 586{
e66408ed 587 struct regcache_list *list, **list_link;
c2250ad1 588
e66408ed
PA
589 list = current_regcache;
590 list_link = &current_regcache;
591 while (list)
c2250ad1 592 {
ef79d9a3 593 if (ptid_match (list->regcache->ptid (), ptid))
e66408ed
PA
594 {
595 struct regcache_list *dead = list;
596
597 *list_link = list->next;
598 regcache_xfree (list->regcache);
599 list = *list_link;
600 xfree (dead);
601 continue;
602 }
603
604 list_link = &list->next;
605 list = *list_link;
c2250ad1 606 }
32178cab 607
c34fd852 608 if (ptid_match (current_thread_ptid, ptid))
041274d8
PA
609 {
610 current_thread_ptid = null_ptid;
611 current_thread_arch = NULL;
612 }
32178cab 613
c34fd852 614 if (ptid_match (inferior_ptid, ptid))
041274d8
PA
615 {
616 /* We just deleted the regcache of the current thread. Need to
617 forget about any frames we have cached, too. */
618 reinit_frame_cache ();
619 }
620}
c2250ad1 621
041274d8
PA
622void
623registers_changed (void)
624{
625 registers_changed_ptid (minus_one_ptid);
a5d9d57d 626
32178cab
MS
627 /* Force cleanup of any alloca areas if using C alloca instead of
628 a builtin alloca. This particular call is used to clean up
629 areas allocated by low level target code which may build up
630 during lengthy interactions between gdb and the target before
631 gdb gives control to the user (ie watchpoints). */
632 alloca (0);
32178cab
MS
633}
634
8e368124
AH
635void
636regcache_raw_update (struct regcache *regcache, int regnum)
61a0eb5b 637{
8e368124 638 gdb_assert (regcache != NULL);
ef79d9a3
YQ
639
640 regcache->raw_update (regnum);
641}
642
643void
644regcache::raw_update (int regnum)
645{
646 gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
8e368124 647
3fadccb3
AC
648 /* Make certain that the register cache is up-to-date with respect
649 to the current thread. This switching shouldn't be necessary
650 only there is still only one target side register cache. Sigh!
651 On the bright side, at least there is a regcache object. */
8e368124 652
ef79d9a3 653 if (!m_readonly_p && get_register_status (regnum) == REG_UNKNOWN)
3fadccb3 654 {
ef79d9a3 655 target_fetch_registers (this, regnum);
788c8b10
PA
656
657 /* A number of targets can't access the whole set of raw
658 registers (because the debug API provides no means to get at
659 them). */
ef79d9a3
YQ
660 if (m_register_status[regnum] == REG_UNKNOWN)
661 m_register_status[regnum] = REG_UNAVAILABLE;
3fadccb3 662 }
8e368124
AH
663}
664
665enum register_status
666regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf)
ef79d9a3
YQ
667{
668 return regcache->raw_read (regnum, buf);
669}
670
671enum register_status
672regcache::raw_read (int regnum, gdb_byte *buf)
8e368124
AH
673{
674 gdb_assert (buf != NULL);
ef79d9a3 675 raw_update (regnum);
05d1431c 676
ef79d9a3
YQ
677 if (m_register_status[regnum] != REG_VALID)
678 memset (buf, 0, m_descr->sizeof_register[regnum]);
05d1431c 679 else
ef79d9a3
YQ
680 memcpy (buf, register_buffer (regnum),
681 m_descr->sizeof_register[regnum]);
05d1431c 682
ef79d9a3 683 return (enum register_status) m_register_status[regnum];
61a0eb5b
AC
684}
685
05d1431c 686enum register_status
28fc6740 687regcache_raw_read_signed (struct regcache *regcache, int regnum, LONGEST *val)
ef79d9a3
YQ
688{
689 gdb_assert (regcache != NULL);
690 return regcache->raw_read_signed (regnum, val);
691}
692
693enum register_status
694regcache::raw_read_signed (int regnum, LONGEST *val)
28fc6740 695{
2d522557 696 gdb_byte *buf;
05d1431c 697 enum register_status status;
123f5f96 698
ef79d9a3
YQ
699 gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
700 buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);
701 status = raw_read (regnum, buf);
05d1431c
PA
702 if (status == REG_VALID)
703 *val = extract_signed_integer
ef79d9a3
YQ
704 (buf, m_descr->sizeof_register[regnum],
705 gdbarch_byte_order (m_descr->gdbarch));
05d1431c
PA
706 else
707 *val = 0;
708 return status;
28fc6740
AC
709}
710
05d1431c 711enum register_status
28fc6740
AC
712regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
713 ULONGEST *val)
ef79d9a3
YQ
714{
715 gdb_assert (regcache != NULL);
716 return regcache->raw_read_unsigned (regnum, val);
717}
718
719
720enum register_status
721regcache::raw_read_unsigned (int regnum, ULONGEST *val)
28fc6740 722{
2d522557 723 gdb_byte *buf;
05d1431c 724 enum register_status status;
123f5f96 725
ef79d9a3
YQ
726 gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
727 buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);
728 status = raw_read (regnum, buf);
05d1431c
PA
729 if (status == REG_VALID)
730 *val = extract_unsigned_integer
ef79d9a3
YQ
731 (buf, m_descr->sizeof_register[regnum],
732 gdbarch_byte_order (m_descr->gdbarch));
05d1431c
PA
733 else
734 *val = 0;
735 return status;
28fc6740
AC
736}
737
c00dcbe9
MK
738void
739regcache_raw_write_signed (struct regcache *regcache, int regnum, LONGEST val)
ef79d9a3
YQ
740{
741 gdb_assert (regcache != NULL);
742 regcache->raw_write_signed (regnum, val);
743}
744
745void
746regcache::raw_write_signed (int regnum, LONGEST val)
c00dcbe9 747{
7c543f7b 748 gdb_byte *buf;
123f5f96 749
ef79d9a3
YQ
750 gdb_assert (regnum >=0 && regnum < m_descr->nr_raw_registers);
751 buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);
752 store_signed_integer (buf, m_descr->sizeof_register[regnum],
753 gdbarch_byte_order (m_descr->gdbarch), val);
754 raw_write (regnum, buf);
c00dcbe9
MK
755}
756
757void
758regcache_raw_write_unsigned (struct regcache *regcache, int regnum,
759 ULONGEST val)
ef79d9a3
YQ
760{
761 gdb_assert (regcache != NULL);
762 regcache->raw_write_unsigned (regnum, val);
763}
764
765void
766regcache::raw_write_unsigned (int regnum, ULONGEST val)
c00dcbe9 767{
7c543f7b 768 gdb_byte *buf;
123f5f96 769
ef79d9a3
YQ
770 gdb_assert (regnum >=0 && regnum < m_descr->nr_raw_registers);
771 buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);
772 store_unsigned_integer (buf, m_descr->sizeof_register[regnum],
773 gdbarch_byte_order (m_descr->gdbarch), val);
774 raw_write (regnum, buf);
c00dcbe9
MK
775}
776
9fd15b2e
YQ
777LONGEST
778regcache_raw_get_signed (struct regcache *regcache, int regnum)
779{
780 LONGEST value;
781 enum register_status status;
782
783 status = regcache_raw_read_signed (regcache, regnum, &value);
784 if (status == REG_UNAVAILABLE)
785 throw_error (NOT_AVAILABLE_ERROR,
786 _("Register %d is not available"), regnum);
787 return value;
788}
789
05d1431c 790enum register_status
2d522557 791regcache_cooked_read (struct regcache *regcache, int regnum, gdb_byte *buf)
ef79d9a3
YQ
792{
793 return regcache->cooked_read (regnum, buf);
794}
795
796enum register_status
797regcache::cooked_read (int regnum, gdb_byte *buf)
68365089 798{
d138e37a 799 gdb_assert (regnum >= 0);
ef79d9a3
YQ
800 gdb_assert (regnum < m_descr->nr_cooked_registers);
801 if (regnum < m_descr->nr_raw_registers)
802 return raw_read (regnum, buf);
803 else if (m_readonly_p
804 && m_register_status[regnum] != REG_UNKNOWN)
05d1431c
PA
805 {
806 /* Read-only register cache, perhaps the cooked value was
807 cached? */
ef79d9a3
YQ
808 if (m_register_status[regnum] == REG_VALID)
809 memcpy (buf, register_buffer (regnum),
810 m_descr->sizeof_register[regnum]);
05d1431c 811 else
ef79d9a3 812 memset (buf, 0, m_descr->sizeof_register[regnum]);
05d1431c 813
ef79d9a3 814 return (enum register_status) m_register_status[regnum];
05d1431c 815 }
ef79d9a3 816 else if (gdbarch_pseudo_register_read_value_p (m_descr->gdbarch))
3543a589
TT
817 {
818 struct value *mark, *computed;
819 enum register_status result = REG_VALID;
820
821 mark = value_mark ();
822
ef79d9a3
YQ
823 computed = gdbarch_pseudo_register_read_value (m_descr->gdbarch,
824 this, regnum);
3543a589
TT
825 if (value_entirely_available (computed))
826 memcpy (buf, value_contents_raw (computed),
ef79d9a3 827 m_descr->sizeof_register[regnum]);
3543a589
TT
828 else
829 {
ef79d9a3 830 memset (buf, 0, m_descr->sizeof_register[regnum]);
3543a589
TT
831 result = REG_UNAVAILABLE;
832 }
833
834 value_free_to_mark (mark);
835
836 return result;
837 }
d138e37a 838 else
ef79d9a3 839 return gdbarch_pseudo_register_read (m_descr->gdbarch, this,
05d1431c 840 regnum, buf);
61a0eb5b
AC
841}
842
3543a589
TT
843struct value *
844regcache_cooked_read_value (struct regcache *regcache, int regnum)
ef79d9a3
YQ
845{
846 return regcache->cooked_read_value (regnum);
847}
848
849struct value *
850regcache::cooked_read_value (int regnum)
3543a589
TT
851{
852 gdb_assert (regnum >= 0);
ef79d9a3 853 gdb_assert (regnum < m_descr->nr_cooked_registers);
3543a589 854
ef79d9a3
YQ
855 if (regnum < m_descr->nr_raw_registers
856 || (m_readonly_p && m_register_status[regnum] != REG_UNKNOWN)
857 || !gdbarch_pseudo_register_read_value_p (m_descr->gdbarch))
3543a589
TT
858 {
859 struct value *result;
860
ef79d9a3 861 result = allocate_value (register_type (m_descr->gdbarch, regnum));
3543a589
TT
862 VALUE_LVAL (result) = lval_register;
863 VALUE_REGNUM (result) = regnum;
864
865 /* It is more efficient in general to do this delegation in this
866 direction than in the other one, even though the value-based
867 API is preferred. */
ef79d9a3
YQ
868 if (cooked_read (regnum,
869 value_contents_raw (result)) == REG_UNAVAILABLE)
3543a589
TT
870 mark_value_bytes_unavailable (result, 0,
871 TYPE_LENGTH (value_type (result)));
872
873 return result;
874 }
875 else
ef79d9a3
YQ
876 return gdbarch_pseudo_register_read_value (m_descr->gdbarch,
877 this, regnum);
3543a589
TT
878}
879
05d1431c 880enum register_status
a378f419
AC
881regcache_cooked_read_signed (struct regcache *regcache, int regnum,
882 LONGEST *val)
ef79d9a3
YQ
883{
884 gdb_assert (regcache != NULL);
885 return regcache->cooked_read_signed (regnum, val);
886}
887
888enum register_status
889regcache::cooked_read_signed (int regnum, LONGEST *val)
a378f419 890{
05d1431c 891 enum register_status status;
2d522557 892 gdb_byte *buf;
123f5f96 893
ef79d9a3
YQ
894 gdb_assert (regnum >= 0 && regnum < m_descr->nr_cooked_registers);
895 buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);
896 status = cooked_read (regnum, buf);
05d1431c
PA
897 if (status == REG_VALID)
898 *val = extract_signed_integer
ef79d9a3
YQ
899 (buf, m_descr->sizeof_register[regnum],
900 gdbarch_byte_order (m_descr->gdbarch));
05d1431c
PA
901 else
902 *val = 0;
903 return status;
a378f419
AC
904}
905
05d1431c 906enum register_status
a378f419
AC
907regcache_cooked_read_unsigned (struct regcache *regcache, int regnum,
908 ULONGEST *val)
ef79d9a3
YQ
909{
910 gdb_assert (regcache != NULL);
911 return regcache->cooked_read_unsigned (regnum, val);
912}
913
914enum register_status
915regcache::cooked_read_unsigned (int regnum, ULONGEST *val)
a378f419 916{
05d1431c 917 enum register_status status;
2d522557 918 gdb_byte *buf;
123f5f96 919
ef79d9a3
YQ
920 gdb_assert (regnum >= 0 && regnum < m_descr->nr_cooked_registers);
921 buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);
922 status = cooked_read (regnum, buf);
05d1431c
PA
923 if (status == REG_VALID)
924 *val = extract_unsigned_integer
ef79d9a3
YQ
925 (buf, m_descr->sizeof_register[regnum],
926 gdbarch_byte_order (m_descr->gdbarch));
05d1431c
PA
927 else
928 *val = 0;
929 return status;
a378f419
AC
930}
931
a66a9c23
AC
932void
933regcache_cooked_write_signed (struct regcache *regcache, int regnum,
934 LONGEST val)
ef79d9a3
YQ
935{
936 gdb_assert (regcache != NULL);
937 regcache->cooked_write_signed (regnum, val);
938}
939
940void
941regcache::cooked_write_signed (int regnum, LONGEST val)
a66a9c23 942{
7c543f7b 943 gdb_byte *buf;
123f5f96 944
ef79d9a3
YQ
945 gdb_assert (regnum >=0 && regnum < m_descr->nr_cooked_registers);
946 buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);
947 store_signed_integer (buf, m_descr->sizeof_register[regnum],
948 gdbarch_byte_order (m_descr->gdbarch), val);
949 cooked_write (regnum, buf);
a66a9c23
AC
950}
951
952void
953regcache_cooked_write_unsigned (struct regcache *regcache, int regnum,
954 ULONGEST val)
ef79d9a3
YQ
955{
956 gdb_assert (regcache != NULL);
957 regcache->cooked_write_unsigned (regnum, val);
958}
959
960void
961regcache::cooked_write_unsigned (int regnum, ULONGEST val)
a66a9c23 962{
7c543f7b 963 gdb_byte *buf;
123f5f96 964
ef79d9a3
YQ
965 gdb_assert (regnum >=0 && regnum < m_descr->nr_cooked_registers);
966 buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);
967 store_unsigned_integer (buf, m_descr->sizeof_register[regnum],
968 gdbarch_byte_order (m_descr->gdbarch), val);
969 cooked_write (regnum, buf);
a66a9c23
AC
970}
971
20aa2c60
PA
972/* See regcache.h. */
973
974void
975regcache_raw_set_cached_value (struct regcache *regcache, int regnum,
976 const gdb_byte *buf)
977{
ef79d9a3
YQ
978 regcache->raw_set_cached_value (regnum, buf);
979}
980
981void
982regcache::raw_set_cached_value (int regnum, const gdb_byte *buf)
983{
984 memcpy (register_buffer (regnum), buf,
985 m_descr->sizeof_register[regnum]);
986 m_register_status[regnum] = REG_VALID;
20aa2c60
PA
987}
988
61a0eb5b 989void
2d522557
AC
990regcache_raw_write (struct regcache *regcache, int regnum,
991 const gdb_byte *buf)
ef79d9a3
YQ
992{
993 gdb_assert (regcache != NULL && buf != NULL);
994 regcache->raw_write (regnum, buf);
995}
996
997void
998regcache::raw_write (int regnum, const gdb_byte *buf)
61a0eb5b 999{
3e00d44f 1000 struct cleanup *old_chain;
594f7785 1001
ef79d9a3
YQ
1002 gdb_assert (buf != NULL);
1003 gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
1004 gdb_assert (!m_readonly_p);
3fadccb3 1005
3fadccb3
AC
1006 /* On the sparc, writing %g0 is a no-op, so we don't even want to
1007 change the registers array if something writes to this register. */
ef79d9a3 1008 if (gdbarch_cannot_store_register (arch (), regnum))
3fadccb3
AC
1009 return;
1010
3fadccb3 1011 /* If we have a valid copy of the register, and new value == old
0df8b418 1012 value, then don't bother doing the actual store. */
ef79d9a3
YQ
1013 if (get_register_status (regnum) == REG_VALID
1014 && (memcmp (register_buffer (regnum), buf,
1015 m_descr->sizeof_register[regnum]) == 0))
3fadccb3
AC
1016 return;
1017
ef79d9a3
YQ
1018 target_prepare_to_store (this);
1019 raw_set_cached_value (regnum, buf);
b94ade42
PL
1020
1021 /* Register a cleanup function for invalidating the register after it is
1022 written, in case of a failure. */
ef79d9a3 1023 old_chain = make_cleanup_regcache_invalidate (this, regnum);
b94ade42 1024
ef79d9a3 1025 target_store_registers (this, regnum);
594f7785 1026
b94ade42
PL
1027 /* The target did not throw an error so we can discard invalidating the
1028 register and restore the cleanup chain to what it was. */
3e00d44f 1029 discard_cleanups (old_chain);
61a0eb5b
AC
1030}
1031
68365089 1032void
2d522557
AC
1033regcache_cooked_write (struct regcache *regcache, int regnum,
1034 const gdb_byte *buf)
ef79d9a3
YQ
1035{
1036 regcache->cooked_write (regnum, buf);
1037}
1038
1039void
1040regcache::cooked_write (int regnum, const gdb_byte *buf)
68365089 1041{
d138e37a 1042 gdb_assert (regnum >= 0);
ef79d9a3
YQ
1043 gdb_assert (regnum < m_descr->nr_cooked_registers);
1044 if (regnum < m_descr->nr_raw_registers)
1045 raw_write (regnum, buf);
d138e37a 1046 else
ef79d9a3 1047 gdbarch_pseudo_register_write (m_descr->gdbarch, this,
d8124050 1048 regnum, buf);
61a0eb5b
AC
1049}
1050
06c0b04e
AC
1051/* Perform a partial register transfer using a read, modify, write
1052 operation. */
1053
1054typedef void (regcache_read_ftype) (struct regcache *regcache, int regnum,
1055 void *buf);
1056typedef void (regcache_write_ftype) (struct regcache *regcache, int regnum,
1057 const void *buf);
1058
ef79d9a3
YQ
1059enum register_status
1060regcache::xfer_part (int regnum, int offset, int len, void *in,
1061 const void *out,
1062 enum register_status (*read) (struct regcache *regcache,
1063 int regnum,
1064 gdb_byte *buf),
1065 void (*write) (struct regcache *regcache, int regnum,
1066 const gdb_byte *buf))
1067{
1068 struct gdbarch *gdbarch = arch ();
9890e433 1069 gdb_byte *reg = (gdb_byte *) alloca (register_size (gdbarch, regnum));
123f5f96 1070
ef79d9a3
YQ
1071 gdb_assert (offset >= 0 && offset <= m_descr->sizeof_register[regnum]);
1072 gdb_assert (len >= 0 && offset + len <= m_descr->sizeof_register[regnum]);
06c0b04e
AC
1073 /* Something to do? */
1074 if (offset + len == 0)
05d1431c 1075 return REG_VALID;
0df8b418 1076 /* Read (when needed) ... */
06c0b04e
AC
1077 if (in != NULL
1078 || offset > 0
ef79d9a3 1079 || offset + len < m_descr->sizeof_register[regnum])
06c0b04e 1080 {
05d1431c
PA
1081 enum register_status status;
1082
06c0b04e 1083 gdb_assert (read != NULL);
ef79d9a3 1084 status = read (this, regnum, reg);
05d1431c
PA
1085 if (status != REG_VALID)
1086 return status;
06c0b04e 1087 }
0df8b418 1088 /* ... modify ... */
06c0b04e
AC
1089 if (in != NULL)
1090 memcpy (in, reg + offset, len);
1091 if (out != NULL)
1092 memcpy (reg + offset, out, len);
1093 /* ... write (when needed). */
1094 if (out != NULL)
1095 {
1096 gdb_assert (write != NULL);
ef79d9a3 1097 write (this, regnum, reg);
06c0b04e 1098 }
05d1431c
PA
1099
1100 return REG_VALID;
06c0b04e
AC
1101}
1102
05d1431c 1103enum register_status
06c0b04e 1104regcache_raw_read_part (struct regcache *regcache, int regnum,
2d522557 1105 int offset, int len, gdb_byte *buf)
06c0b04e 1106{
ef79d9a3
YQ
1107 return regcache->raw_read_part (regnum, offset, len, buf);
1108}
123f5f96 1109
ef79d9a3
YQ
1110enum register_status
1111regcache::raw_read_part (int regnum, int offset, int len, gdb_byte *buf)
1112{
1113 gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
1114 return xfer_part (regnum, offset, len, buf, NULL,
1115 regcache_raw_read, regcache_raw_write);
06c0b04e
AC
1116}
1117
1118void
1119regcache_raw_write_part (struct regcache *regcache, int regnum,
2d522557 1120 int offset, int len, const gdb_byte *buf)
06c0b04e 1121{
ef79d9a3
YQ
1122 regcache->raw_write_part (regnum, offset, len, buf);
1123}
123f5f96 1124
ef79d9a3
YQ
1125void
1126regcache::raw_write_part (int regnum, int offset, int len,
1127 const gdb_byte *buf)
1128{
1129 gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
1130 xfer_part (regnum, offset, len, NULL, buf, regcache_raw_read,
1131 regcache_raw_write);
06c0b04e
AC
1132}
1133
05d1431c 1134enum register_status
06c0b04e 1135regcache_cooked_read_part (struct regcache *regcache, int regnum,
2d522557 1136 int offset, int len, gdb_byte *buf)
06c0b04e 1137{
ef79d9a3
YQ
1138 return regcache->cooked_read_part (regnum, offset, len, buf);
1139}
123f5f96 1140
ef79d9a3
YQ
1141
1142enum register_status
1143regcache::cooked_read_part (int regnum, int offset, int len, gdb_byte *buf)
1144{
1145 gdb_assert (regnum >= 0 && regnum < m_descr->nr_cooked_registers);
1146 return xfer_part (regnum, offset, len, buf, NULL,
1147 regcache_cooked_read, regcache_cooked_write);
06c0b04e
AC
1148}
1149
1150void
1151regcache_cooked_write_part (struct regcache *regcache, int regnum,
2d522557 1152 int offset, int len, const gdb_byte *buf)
06c0b04e 1153{
ef79d9a3
YQ
1154 regcache->cooked_write_part (regnum, offset, len, buf);
1155}
123f5f96 1156
ef79d9a3
YQ
1157void
1158regcache::cooked_write_part (int regnum, int offset, int len,
1159 const gdb_byte *buf)
1160{
1161 gdb_assert (regnum >= 0 && regnum < m_descr->nr_cooked_registers);
1162 xfer_part (regnum, offset, len, NULL, buf,
1163 regcache_cooked_read, regcache_cooked_write);
06c0b04e 1164}
32178cab 1165
a16d75cc 1166/* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE. */
9a661b68
MK
1167
1168void
6618125d 1169regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
ef79d9a3
YQ
1170{
1171 gdb_assert (regcache != NULL);
1172 regcache->raw_supply (regnum, buf);
1173}
1174
1175void
1176regcache::raw_supply (int regnum, const void *buf)
9a661b68
MK
1177{
1178 void *regbuf;
1179 size_t size;
1180
ef79d9a3
YQ
1181 gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
1182 gdb_assert (!m_readonly_p);
9a661b68 1183
ef79d9a3
YQ
1184 regbuf = register_buffer (regnum);
1185 size = m_descr->sizeof_register[regnum];
9a661b68
MK
1186
1187 if (buf)
ee99023e
PA
1188 {
1189 memcpy (regbuf, buf, size);
ef79d9a3 1190 m_register_status[regnum] = REG_VALID;
ee99023e 1191 }
9a661b68 1192 else
ee99023e
PA
1193 {
1194 /* This memset not strictly necessary, but better than garbage
1195 in case the register value manages to escape somewhere (due
1196 to a bug, no less). */
1197 memset (regbuf, 0, size);
ef79d9a3 1198 m_register_status[regnum] = REG_UNAVAILABLE;
ee99023e 1199 }
9a661b68
MK
1200}
1201
f81fdd35
AH
1202/* Supply register REGNUM with zeroed value to REGCACHE. This is not the same
1203 as calling raw_supply with NULL (which will set the state to
1204 unavailable). */
1205
1206void
1207regcache::raw_supply_zeroed (int regnum)
1208{
1209 void *regbuf;
1210 size_t size;
1211
1212 gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
1213 gdb_assert (!m_readonly_p);
1214
1215 regbuf = register_buffer (regnum);
1216 size = m_descr->sizeof_register[regnum];
1217
1218 memset (regbuf, 0, size);
1219 m_register_status[regnum] = REG_VALID;
1220}
1221
9a661b68
MK
1222/* Collect register REGNUM from REGCACHE and store its contents in BUF. */
1223
1224void
6618125d 1225regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf)
ef79d9a3
YQ
1226{
1227 gdb_assert (regcache != NULL && buf != NULL);
1228 regcache->raw_collect (regnum, buf);
1229}
1230
1231void
1232regcache::raw_collect (int regnum, void *buf) const
9a661b68
MK
1233{
1234 const void *regbuf;
1235 size_t size;
1236
ef79d9a3
YQ
1237 gdb_assert (buf != NULL);
1238 gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
9a661b68 1239
ef79d9a3
YQ
1240 regbuf = register_buffer (regnum);
1241 size = m_descr->sizeof_register[regnum];
9a661b68
MK
1242 memcpy (buf, regbuf, size);
1243}
1244
0b309272
AA
1245/* Transfer a single or all registers belonging to a certain register
1246 set to or from a buffer. This is the main worker function for
1247 regcache_supply_regset and regcache_collect_regset. */
1248
ef79d9a3
YQ
1249void
1250regcache::transfer_regset (const struct regset *regset,
1251 struct regcache *out_regcache,
1252 int regnum, const void *in_buf,
1253 void *out_buf, size_t size) const
0b309272
AA
1254{
1255 const struct regcache_map_entry *map;
1256 int offs = 0, count;
1257
19ba03f4
SM
1258 for (map = (const struct regcache_map_entry *) regset->regmap;
1259 (count = map->count) != 0;
1260 map++)
0b309272
AA
1261 {
1262 int regno = map->regno;
1263 int slot_size = map->size;
1264
1265 if (slot_size == 0 && regno != REGCACHE_MAP_SKIP)
ef79d9a3 1266 slot_size = m_descr->sizeof_register[regno];
0b309272
AA
1267
1268 if (regno == REGCACHE_MAP_SKIP
1269 || (regnum != -1
1270 && (regnum < regno || regnum >= regno + count)))
1271 offs += count * slot_size;
1272
1273 else if (regnum == -1)
1274 for (; count--; regno++, offs += slot_size)
1275 {
1276 if (offs + slot_size > size)
1277 break;
1278
1279 if (out_buf)
ef79d9a3 1280 raw_collect (regno, (gdb_byte *) out_buf + offs);
0b309272 1281 else
ef79d9a3
YQ
1282 out_regcache->raw_supply (regno, in_buf
1283 ? (const gdb_byte *) in_buf + offs
1284 : NULL);
0b309272
AA
1285 }
1286 else
1287 {
1288 /* Transfer a single register and return. */
1289 offs += (regnum - regno) * slot_size;
1290 if (offs + slot_size > size)
1291 return;
1292
1293 if (out_buf)
ef79d9a3 1294 raw_collect (regnum, (gdb_byte *) out_buf + offs);
0b309272 1295 else
ef79d9a3
YQ
1296 out_regcache->raw_supply (regnum, in_buf
1297 ? (const gdb_byte *) in_buf + offs
1298 : NULL);
0b309272
AA
1299 return;
1300 }
1301 }
1302}
1303
1304/* Supply register REGNUM from BUF to REGCACHE, using the register map
1305 in REGSET. If REGNUM is -1, do this for all registers in REGSET.
1306 If BUF is NULL, set the register(s) to "unavailable" status. */
1307
1308void
1309regcache_supply_regset (const struct regset *regset,
1310 struct regcache *regcache,
1311 int regnum, const void *buf, size_t size)
1312{
ef79d9a3
YQ
1313 regcache->supply_regset (regset, regnum, buf, size);
1314}
1315
1316void
1317regcache::supply_regset (const struct regset *regset,
1318 int regnum, const void *buf, size_t size)
1319{
1320 transfer_regset (regset, this, regnum, buf, NULL, size);
0b309272
AA
1321}
1322
1323/* Collect register REGNUM from REGCACHE to BUF, using the register
1324 map in REGSET. If REGNUM is -1, do this for all registers in
1325 REGSET. */
1326
1327void
1328regcache_collect_regset (const struct regset *regset,
1329 const struct regcache *regcache,
1330 int regnum, void *buf, size_t size)
1331{
ef79d9a3
YQ
1332 regcache->collect_regset (regset, regnum, buf, size);
1333}
1334
1335void
1336regcache::collect_regset (const struct regset *regset,
1337 int regnum, void *buf, size_t size) const
1338{
1339 transfer_regset (regset, NULL, regnum, NULL, buf, size);
0b309272
AA
1340}
1341
193cb69f 1342
515630c5 1343/* Special handling for register PC. */
32178cab
MS
1344
1345CORE_ADDR
515630c5 1346regcache_read_pc (struct regcache *regcache)
32178cab 1347{
61a1198a
UW
1348 struct gdbarch *gdbarch = get_regcache_arch (regcache);
1349
32178cab
MS
1350 CORE_ADDR pc_val;
1351
61a1198a
UW
1352 if (gdbarch_read_pc_p (gdbarch))
1353 pc_val = gdbarch_read_pc (gdbarch, regcache);
cde9ea48 1354 /* Else use per-frame method on get_current_frame. */
214e098a 1355 else if (gdbarch_pc_regnum (gdbarch) >= 0)
cde9ea48 1356 {
61a1198a 1357 ULONGEST raw_val;
123f5f96 1358
05d1431c
PA
1359 if (regcache_cooked_read_unsigned (regcache,
1360 gdbarch_pc_regnum (gdbarch),
1361 &raw_val) == REG_UNAVAILABLE)
1362 throw_error (NOT_AVAILABLE_ERROR, _("PC register is not available"));
1363
214e098a 1364 pc_val = gdbarch_addr_bits_remove (gdbarch, raw_val);
cde9ea48
AC
1365 }
1366 else
515630c5
UW
1367 internal_error (__FILE__, __LINE__,
1368 _("regcache_read_pc: Unable to find PC"));
32178cab
MS
1369 return pc_val;
1370}
1371
32178cab 1372void
515630c5 1373regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
32178cab 1374{
61a1198a
UW
1375 struct gdbarch *gdbarch = get_regcache_arch (regcache);
1376
61a1198a
UW
1377 if (gdbarch_write_pc_p (gdbarch))
1378 gdbarch_write_pc (gdbarch, regcache, pc);
214e098a 1379 else if (gdbarch_pc_regnum (gdbarch) >= 0)
3e8c568d 1380 regcache_cooked_write_unsigned (regcache,
214e098a 1381 gdbarch_pc_regnum (gdbarch), pc);
61a1198a
UW
1382 else
1383 internal_error (__FILE__, __LINE__,
515630c5 1384 _("regcache_write_pc: Unable to update PC"));
edb3359d
DJ
1385
1386 /* Writing the PC (for instance, from "load") invalidates the
1387 current frame. */
1388 reinit_frame_cache ();
32178cab
MS
1389}
1390
ed771251 1391void
ef79d9a3 1392regcache::debug_print_register (const char *func, int regno)
ed771251 1393{
ef79d9a3 1394 struct gdbarch *gdbarch = arch ();
ed771251
AH
1395
1396 fprintf_unfiltered (gdb_stdlog, "%s ", func);
1397 if (regno >= 0 && regno < gdbarch_num_regs (gdbarch)
1398 && gdbarch_register_name (gdbarch, regno) != NULL
1399 && gdbarch_register_name (gdbarch, regno)[0] != '\0')
1400 fprintf_unfiltered (gdb_stdlog, "(%s)",
1401 gdbarch_register_name (gdbarch, regno));
1402 else
1403 fprintf_unfiltered (gdb_stdlog, "(%d)", regno);
1404 if (regno >= 0 && regno < gdbarch_num_regs (gdbarch))
1405 {
1406 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1407 int size = register_size (gdbarch, regno);
ef79d9a3 1408 gdb_byte *buf = register_buffer (regno);
ed771251
AH
1409
1410 fprintf_unfiltered (gdb_stdlog, " = ");
1411 for (int i = 0; i < size; i++)
1412 {
1413 fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
1414 }
1415 if (size <= sizeof (LONGEST))
1416 {
1417 ULONGEST val = extract_unsigned_integer (buf, size, byte_order);
1418
1419 fprintf_unfiltered (gdb_stdlog, " %s %s",
1420 core_addr_to_string_nz (val), plongest (val));
1421 }
1422 }
1423 fprintf_unfiltered (gdb_stdlog, "\n");
1424}
32178cab 1425
705152c5
MS
1426static void
1427reg_flush_command (char *command, int from_tty)
1428{
1429 /* Force-flush the register cache. */
1430 registers_changed ();
1431 if (from_tty)
a3f17187 1432 printf_filtered (_("Register cache flushed.\n"));
705152c5
MS
1433}
1434
ef79d9a3
YQ
1435void
1436regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
af030b9a
AC
1437{
1438 struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
ef79d9a3 1439 struct gdbarch *gdbarch = m_descr->gdbarch;
af030b9a
AC
1440 int regnum;
1441 int footnote_nr = 0;
1442 int footnote_register_size = 0;
1443 int footnote_register_offset = 0;
1444 int footnote_register_type_name_null = 0;
1445 long register_offset = 0;
e362b510 1446 gdb_byte buf[MAX_REGISTER_SIZE];
af030b9a
AC
1447
1448#if 0
af030b9a 1449 fprintf_unfiltered (file, "nr_raw_registers %d\n",
ef79d9a3 1450 m_descr->nr_raw_registers);
af030b9a 1451 fprintf_unfiltered (file, "nr_cooked_registers %d\n",
ef79d9a3 1452 m_descr->nr_cooked_registers);
af030b9a 1453 fprintf_unfiltered (file, "sizeof_raw_registers %ld\n",
ef79d9a3 1454 m_descr->sizeof_raw_registers);
ee99023e 1455 fprintf_unfiltered (file, "sizeof_raw_register_status %ld\n",
ef79d9a3 1456 m_descr->sizeof_raw_register_status);
f57d151a 1457 fprintf_unfiltered (file, "gdbarch_num_regs %d\n",
214e098a 1458 gdbarch_num_regs (gdbarch));
f57d151a 1459 fprintf_unfiltered (file, "gdbarch_num_pseudo_regs %d\n",
214e098a 1460 gdbarch_num_pseudo_regs (gdbarch));
af030b9a
AC
1461#endif
1462
ef79d9a3 1463 gdb_assert (m_descr->nr_cooked_registers
214e098a
UW
1464 == (gdbarch_num_regs (gdbarch)
1465 + gdbarch_num_pseudo_regs (gdbarch)));
af030b9a 1466
ef79d9a3 1467 for (regnum = -1; regnum < m_descr->nr_cooked_registers; regnum++)
af030b9a
AC
1468 {
1469 /* Name. */
1470 if (regnum < 0)
1471 fprintf_unfiltered (file, " %-10s", "Name");
1472 else
1473 {
214e098a 1474 const char *p = gdbarch_register_name (gdbarch, regnum);
123f5f96 1475
af030b9a
AC
1476 if (p == NULL)
1477 p = "";
1478 else if (p[0] == '\0')
1479 p = "''";
1480 fprintf_unfiltered (file, " %-10s", p);
1481 }
1482
1483 /* Number. */
1484 if (regnum < 0)
1485 fprintf_unfiltered (file, " %4s", "Nr");
1486 else
1487 fprintf_unfiltered (file, " %4d", regnum);
1488
1489 /* Relative number. */
1490 if (regnum < 0)
1491 fprintf_unfiltered (file, " %4s", "Rel");
214e098a 1492 else if (regnum < gdbarch_num_regs (gdbarch))
af030b9a
AC
1493 fprintf_unfiltered (file, " %4d", regnum);
1494 else
f57d151a 1495 fprintf_unfiltered (file, " %4d",
214e098a 1496 (regnum - gdbarch_num_regs (gdbarch)));
af030b9a
AC
1497
1498 /* Offset. */
1499 if (regnum < 0)
1500 fprintf_unfiltered (file, " %6s ", "Offset");
1501 else
1502 {
1503 fprintf_unfiltered (file, " %6ld",
ef79d9a3
YQ
1504 m_descr->register_offset[regnum]);
1505 if (register_offset != m_descr->register_offset[regnum]
d3b22ed5 1506 || (regnum > 0
ef79d9a3
YQ
1507 && (m_descr->register_offset[regnum]
1508 != (m_descr->register_offset[regnum - 1]
1509 + m_descr->sizeof_register[regnum - 1])))
d3b22ed5 1510 )
af030b9a
AC
1511 {
1512 if (!footnote_register_offset)
1513 footnote_register_offset = ++footnote_nr;
1514 fprintf_unfiltered (file, "*%d", footnote_register_offset);
1515 }
1516 else
1517 fprintf_unfiltered (file, " ");
ef79d9a3
YQ
1518 register_offset = (m_descr->register_offset[regnum]
1519 + m_descr->sizeof_register[regnum]);
af030b9a
AC
1520 }
1521
1522 /* Size. */
1523 if (regnum < 0)
1524 fprintf_unfiltered (file, " %5s ", "Size");
1525 else
ef79d9a3 1526 fprintf_unfiltered (file, " %5ld", m_descr->sizeof_register[regnum]);
af030b9a
AC
1527
1528 /* Type. */
b59ff9d5
AC
1529 {
1530 const char *t;
123f5f96 1531
b59ff9d5
AC
1532 if (regnum < 0)
1533 t = "Type";
1534 else
1535 {
1536 static const char blt[] = "builtin_type";
123f5f96 1537
ef79d9a3 1538 t = TYPE_NAME (register_type (arch (), regnum));
b59ff9d5
AC
1539 if (t == NULL)
1540 {
1541 char *n;
123f5f96 1542
b59ff9d5
AC
1543 if (!footnote_register_type_name_null)
1544 footnote_register_type_name_null = ++footnote_nr;
b435e160 1545 n = xstrprintf ("*%d", footnote_register_type_name_null);
b59ff9d5
AC
1546 make_cleanup (xfree, n);
1547 t = n;
1548 }
1549 /* Chop a leading builtin_type. */
61012eef 1550 if (startswith (t, blt))
b59ff9d5
AC
1551 t += strlen (blt);
1552 }
1553 fprintf_unfiltered (file, " %-15s", t);
1554 }
1555
1556 /* Leading space always present. */
1557 fprintf_unfiltered (file, " ");
af030b9a
AC
1558
1559 /* Value, raw. */
1560 if (what_to_dump == regcache_dump_raw)
1561 {
1562 if (regnum < 0)
1563 fprintf_unfiltered (file, "Raw value");
ef79d9a3 1564 else if (regnum >= m_descr->nr_raw_registers)
af030b9a 1565 fprintf_unfiltered (file, "<cooked>");
ef79d9a3 1566 else if (get_register_status (regnum) == REG_UNKNOWN)
af030b9a 1567 fprintf_unfiltered (file, "<invalid>");
ef79d9a3 1568 else if (get_register_status (regnum) == REG_UNAVAILABLE)
ee99023e 1569 fprintf_unfiltered (file, "<unavailable>");
af030b9a
AC
1570 else
1571 {
ef79d9a3 1572 raw_read (regnum, buf);
d3eaaf66 1573 print_hex_chars (file, buf,
ef79d9a3 1574 m_descr->sizeof_register[regnum],
d3eaaf66 1575 gdbarch_byte_order (gdbarch));
af030b9a
AC
1576 }
1577 }
1578
1579 /* Value, cooked. */
1580 if (what_to_dump == regcache_dump_cooked)
1581 {
1582 if (regnum < 0)
1583 fprintf_unfiltered (file, "Cooked value");
1584 else
1585 {
05d1431c
PA
1586 enum register_status status;
1587
ef79d9a3 1588 status = cooked_read (regnum, buf);
05d1431c
PA
1589 if (status == REG_UNKNOWN)
1590 fprintf_unfiltered (file, "<invalid>");
1591 else if (status == REG_UNAVAILABLE)
1592 fprintf_unfiltered (file, "<unavailable>");
1593 else
d3eaaf66 1594 print_hex_chars (file, buf,
ef79d9a3 1595 m_descr->sizeof_register[regnum],
d3eaaf66 1596 gdbarch_byte_order (gdbarch));
af030b9a
AC
1597 }
1598 }
1599
b59ff9d5
AC
1600 /* Group members. */
1601 if (what_to_dump == regcache_dump_groups)
1602 {
1603 if (regnum < 0)
1604 fprintf_unfiltered (file, "Groups");
1605 else
1606 {
b59ff9d5 1607 const char *sep = "";
6c7d17ba 1608 struct reggroup *group;
123f5f96 1609
6c7d17ba
AC
1610 for (group = reggroup_next (gdbarch, NULL);
1611 group != NULL;
1612 group = reggroup_next (gdbarch, group))
b59ff9d5 1613 {
6c7d17ba 1614 if (gdbarch_register_reggroup_p (gdbarch, regnum, group))
b59ff9d5 1615 {
3e43a32a
MS
1616 fprintf_unfiltered (file,
1617 "%s%s", sep, reggroup_name (group));
b59ff9d5
AC
1618 sep = ",";
1619 }
1620 }
1621 }
1622 }
1623
c21236dc
PA
1624 /* Remote packet configuration. */
1625 if (what_to_dump == regcache_dump_remote)
1626 {
1627 if (regnum < 0)
1628 {
1629 fprintf_unfiltered (file, "Rmt Nr g/G Offset");
1630 }
ef79d9a3 1631 else if (regnum < m_descr->nr_raw_registers)
c21236dc
PA
1632 {
1633 int pnum, poffset;
1634
ef79d9a3 1635 if (remote_register_number_and_offset (arch (), regnum,
c21236dc
PA
1636 &pnum, &poffset))
1637 fprintf_unfiltered (file, "%7d %11d", pnum, poffset);
1638 }
1639 }
1640
af030b9a
AC
1641 fprintf_unfiltered (file, "\n");
1642 }
1643
1644 if (footnote_register_size)
1645 fprintf_unfiltered (file, "*%d: Inconsistent register sizes.\n",
1646 footnote_register_size);
1647 if (footnote_register_offset)
1648 fprintf_unfiltered (file, "*%d: Inconsistent register offsets.\n",
1649 footnote_register_offset);
1650 if (footnote_register_type_name_null)
1651 fprintf_unfiltered (file,
1652 "*%d: Register type's name NULL.\n",
1653 footnote_register_type_name_null);
1654 do_cleanups (cleanups);
1655}
1656
1657static void
1658regcache_print (char *args, enum regcache_dump_what what_to_dump)
1659{
1660 if (args == NULL)
ef79d9a3 1661 get_current_regcache ()->dump (gdb_stdout, what_to_dump);
af030b9a
AC
1662 else
1663 {
d7e74731 1664 stdio_file file;
123f5f96 1665
d7e74731 1666 if (!file.open (args, "w"))
e2e0b3e5 1667 perror_with_name (_("maintenance print architecture"));
ef79d9a3 1668 get_current_regcache ()->dump (&file, what_to_dump);
af030b9a
AC
1669 }
1670}
1671
1672static void
1673maintenance_print_registers (char *args, int from_tty)
1674{
1675 regcache_print (args, regcache_dump_none);
1676}
1677
1678static void
1679maintenance_print_raw_registers (char *args, int from_tty)
1680{
1681 regcache_print (args, regcache_dump_raw);
1682}
1683
1684static void
1685maintenance_print_cooked_registers (char *args, int from_tty)
1686{
1687 regcache_print (args, regcache_dump_cooked);
1688}
1689
b59ff9d5
AC
1690static void
1691maintenance_print_register_groups (char *args, int from_tty)
1692{
1693 regcache_print (args, regcache_dump_groups);
1694}
1695
c21236dc
PA
1696static void
1697maintenance_print_remote_registers (char *args, int from_tty)
1698{
1699 regcache_print (args, regcache_dump_remote);
1700}
1701
8248946c
YQ
1702#if GDB_SELF_TEST
1703#include "selftest.h"
1704
1705namespace selftests {
1706
1707/* Return the number of elements in current_regcache. */
1708
1709static size_t
1710current_regcache_size ()
1711{
1712 size_t i = 0;
1713 for (auto list = current_regcache; list; list = list->next)
1714 i++;
1715
1716 return i;
1717}
1718
1719static void
1720current_regcache_test (void)
1721{
1722 /* It is empty at the start. */
1723 SELF_CHECK (current_regcache_size () == 0);
1724
1725 ptid_t ptid1 (1), ptid2 (2), ptid3 (3);
1726
1727 /* Get regcache from ptid1, a new regcache is added to
1728 current_regcache. */
1729 regcache *regcache = get_thread_arch_aspace_regcache (ptid1,
1730 target_gdbarch (),
1731 NULL);
1732
1733 SELF_CHECK (regcache != NULL);
1734 SELF_CHECK (regcache->ptid () == ptid1);
1735 SELF_CHECK (current_regcache_size () == 1);
1736
1737 /* Get regcache from ptid2, a new regcache is added to
1738 current_regcache. */
1739 regcache = get_thread_arch_aspace_regcache (ptid2,
1740 target_gdbarch (),
1741 NULL);
1742 SELF_CHECK (regcache != NULL);
1743 SELF_CHECK (regcache->ptid () == ptid2);
1744 SELF_CHECK (current_regcache_size () == 2);
1745
1746 /* Get regcache from ptid3, a new regcache is added to
1747 current_regcache. */
1748 regcache = get_thread_arch_aspace_regcache (ptid3,
1749 target_gdbarch (),
1750 NULL);
1751 SELF_CHECK (regcache != NULL);
1752 SELF_CHECK (regcache->ptid () == ptid3);
1753 SELF_CHECK (current_regcache_size () == 3);
1754
1755 /* Get regcache from ptid2 again, nothing is added to
1756 current_regcache. */
1757 regcache = get_thread_arch_aspace_regcache (ptid2,
1758 target_gdbarch (),
1759 NULL);
1760 SELF_CHECK (regcache != NULL);
1761 SELF_CHECK (regcache->ptid () == ptid2);
1762 SELF_CHECK (current_regcache_size () == 3);
1763
1764 /* Mark ptid2 is changed, so regcache of ptid2 should be removed from
1765 current_regcache. */
1766 registers_changed_ptid (ptid2);
1767 SELF_CHECK (current_regcache_size () == 2);
1768}
1769
1770} // namespace selftests
1771#endif /* GDB_SELF_TEST */
1772
b9362cc7
AC
1773extern initialize_file_ftype _initialize_regcache; /* -Wmissing-prototype */
1774
32178cab
MS
1775void
1776_initialize_regcache (void)
1777{
3e43a32a
MS
1778 regcache_descr_handle
1779 = gdbarch_data_register_post_init (init_regcache_descr);
705152c5 1780
f4c5303c 1781 observer_attach_target_changed (regcache_observer_target_changed);
5231c1fd 1782 observer_attach_thread_ptid_changed (regcache_thread_ptid_changed);
f4c5303c 1783
705152c5 1784 add_com ("flushregs", class_maintenance, reg_flush_command,
1bedd215 1785 _("Force gdb to flush its register cache (maintainer command)"));
39f77062 1786
3e43a32a
MS
1787 add_cmd ("registers", class_maintenance, maintenance_print_registers,
1788 _("Print the internal register configuration.\n"
1789 "Takes an optional file parameter."), &maintenanceprintlist);
af030b9a 1790 add_cmd ("raw-registers", class_maintenance,
3e43a32a
MS
1791 maintenance_print_raw_registers,
1792 _("Print the internal register configuration "
1793 "including raw values.\n"
1794 "Takes an optional file parameter."), &maintenanceprintlist);
af030b9a 1795 add_cmd ("cooked-registers", class_maintenance,
3e43a32a
MS
1796 maintenance_print_cooked_registers,
1797 _("Print the internal register configuration "
1798 "including cooked values.\n"
1799 "Takes an optional file parameter."), &maintenanceprintlist);
b59ff9d5 1800 add_cmd ("register-groups", class_maintenance,
3e43a32a
MS
1801 maintenance_print_register_groups,
1802 _("Print the internal register configuration "
1803 "including each register's group.\n"
1804 "Takes an optional file parameter."),
af030b9a 1805 &maintenanceprintlist);
c21236dc
PA
1806 add_cmd ("remote-registers", class_maintenance,
1807 maintenance_print_remote_registers, _("\
1808Print the internal register configuration including each register's\n\
1809remote register number and buffer offset in the g/G packets.\n\
1810Takes an optional file parameter."),
1811 &maintenanceprintlist);
8248946c
YQ
1812#if GDB_SELF_TEST
1813 register_self_test (selftests::current_regcache_test);
1814#endif
32178cab 1815}
This page took 1.72616 seconds and 4 git commands to generate.