int byte_order,
int byte_order_for_code,
int has_thumb2_breakpoint,
- struct regcache *regcache)
+ reg_buffer_common *regcache)
{
self->ops = ops;
self->byte_order = byte_order;
{
int byte_order = self->byte_order;
int byte_order_for_code = self->byte_order_for_code;
+ reg_buffer_common *regcache = self->regcache;
CORE_ADDR pc = regcache_read_pc (self->regcache);
unsigned long pc_val = ((unsigned long) pc) + 4; /* PC after prefetch */
unsigned short inst1;
CORE_ADDR nextpc = pc + 2; /* Default is next instruction. */
ULONGEST status, itstate;
- struct regcache *regcache = self->regcache;
std::vector<CORE_ADDR> next_pcs;
nextpc = MAKE_THUMB_ADDR (nextpc);
unsigned long this_instr = 0;
unsigned long status;
CORE_ADDR nextpc;
- struct regcache *regcache = self->regcache;
- CORE_ADDR pc = regcache_read_pc (self->regcache);
+ reg_buffer_common *regcache = self->regcache;
+ CORE_ADDR pc = regcache_read_pc (regcache);
std::vector<CORE_ADDR> next_pcs;
pc_val = (unsigned long) pc;
/* Forward declaration. */
struct arm_get_next_pcs;
+struct reg_buffer_common;
/* get_next_pcs operations. */
struct arm_get_next_pcs_ops
not. */
int has_thumb2_breakpoint;
/* Registry cache. */
- struct regcache *regcache;
+ reg_buffer_common *regcache;
};
/* Initialize arm_get_next_pcs. */
int byte_order,
int byte_order_for_code,
int has_thumb2_breakpoint,
- struct regcache *regcache);
+ reg_buffer_common *regcache);
/* Find the next possible PCs after the current instruction executes. */
std::vector<CORE_ADDR> arm_get_next_pcs (struct arm_get_next_pcs *self);
/* See arm.h. */
unsigned long
-shifted_reg_val (struct regcache *regcache, unsigned long inst,
+shifted_reg_val (reg_buffer_common *regcache, unsigned long inst,
int carry, unsigned long pc_val, unsigned long status_reg)
{
unsigned long res, shift;
((CORE_ADDR) (((unsigned long) (addr)) + 8 + (sbits (instr, 0, 23) << 2)))
/* Forward declaration. */
-struct regcache;
+struct reg_buffer_common;
/* Return the size in bytes of the complete Thumb instruction whose
first halfword is INST1. */
/* Decode shifted register value. */
-unsigned long shifted_reg_val (struct regcache *regcache,
+unsigned long shifted_reg_val (reg_buffer_common *regcache,
unsigned long inst,
int carry,
unsigned long pc_val,
arm_linux_get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self)
{
CORE_ADDR next_pc = 0;
- CORE_ADDR pc = regcache_read_pc (self->regcache);
- int is_thumb = arm_is_thumb (self->regcache);
+ regcache *regcache
+ = gdb::checked_static_cast<struct regcache *> (self->regcache);
+ CORE_ADDR pc = regcache_read_pc (regcache);
+ int is_thumb = arm_is_thumb (regcache);
ULONGEST svc_number = 0;
if (is_thumb)
}
else
{
- struct gdbarch *gdbarch = self->regcache->arch ();
+ struct gdbarch *gdbarch = regcache->arch ();
enum bfd_endian byte_order_for_code =
gdbarch_byte_order_for_code (gdbarch);
unsigned long this_instr =
{
/* SIGRETURN or RT_SIGRETURN may affect the arm thumb mode, so
update IS_THUMB. */
- next_pc = arm_linux_sigreturn_next_pc (self->regcache, svc_number,
- &is_thumb);
+ next_pc = arm_linux_sigreturn_next_pc (regcache, svc_number, &is_thumb);
}
/* Addresses for calling Thumb functions have the bit 0 set. */
arm_get_next_pcs_addr_bits_remove (struct arm_get_next_pcs *self,
CORE_ADDR val)
{
- return gdbarch_addr_bits_remove (self->regcache->arch (), val);
+ return gdbarch_addr_bits_remove
+ (gdb::checked_static_cast<regcache *> (self->regcache)->arch (), val);
}
/* Wrapper over syscall_next_pc for use in get_next_pcs. */
int
arm_get_next_pcs_is_thumb (struct arm_get_next_pcs *self)
{
- return arm_is_thumb (self->regcache);
+ return arm_is_thumb (gdb::checked_static_cast<regcache *> (self->regcache));
}
/* single_step() is called just before we want to resume the inferior,
alignment = AARCH64_HWP_ALIGNMENT;
else
{
- struct regcache *regcache
- = get_thread_regcache_for_ptid (ptid);
+ reg_buffer_common *regcache = get_thread_regcache_for_ptid (ptid);
/* Set alignment to 2 only if the current process is 32-bit,
since thumb instruction can be 2-byte aligned. Otherwise, set
struct perf_event_sample sample;
size_t read = 0;
struct btrace_block block = { 0, 0 };
- struct regcache *regcache;
gdb_assert (begin <= start);
gdb_assert (start <= end);
/* The first block ends at the current pc. */
- regcache = get_thread_regcache_for_ptid (tinfo->ptid);
+ reg_buffer_common *regcache = get_thread_regcache_for_ptid (tinfo->ptid);
block.end = regcache_read_pc (regcache);
/* The buffer may contain a partial record as its last entry (i.e. when the
/* See gdbsupport/common-regcache.h. */
int
-regcache_register_size (const struct regcache *regcache, int n)
+regcache_register_size (const reg_buffer_common *regcache, int n)
{
- return register_size (regcache->arch (), n);
+ return register_size
+ (gdb::checked_static_cast<const struct regcache *> (regcache)->arch (), n);
}
reg_buffer::reg_buffer (gdbarch *gdbarch, bool has_pseudo)
/* See gdbsupport/common-regcache.h. */
-struct regcache *
+reg_buffer_common *
get_thread_regcache_for_ptid (ptid_t ptid)
{
/* This function doesn't take a process_stratum_target parameter
}
enum register_status
-regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
+regcache_raw_read_unsigned (reg_buffer_common *regcache, int regnum,
ULONGEST *val)
{
gdb_assert (regcache != NULL);
- return regcache->raw_read (regnum, val);
+ return gdb::checked_static_cast<struct regcache *> (regcache)->raw_read
+ (regnum, val);
}
void
/* Special handling for register PC. */
CORE_ADDR
-regcache_read_pc (struct regcache *regcache)
+regcache_read_pc (reg_buffer_common *reg_buf)
{
+ regcache *regcache = gdb::checked_static_cast<struct regcache *> (reg_buf);
struct gdbarch *gdbarch = regcache->arch ();
CORE_ADDR pc_val;
/* See gdbsupport/common-regcache.h. */
CORE_ADDR
-regcache_read_pc_protected (regcache *regcache)
+regcache_read_pc_protected (reg_buffer_common *regcache)
{
CORE_ADDR pc;
try
#include "linux-aarch32-low.h"
#include "linux-aarch32-tdesc.h"
#include "linux-arm-tdesc.h"
+#include "gdbsupport/gdb-checked-static-cast.h"
#include <sys/uio.h>
/* Don't include elf.h if linux/elf.h got included by gdb_proc_service.h.
CORE_ADDR pc = regcache_read_pc (self->regcache);
int is_thumb = arm_is_thumb_mode ();
ULONGEST svc_number = 0;
- struct regcache *regcache = self->regcache;
+ regcache *regcache
+ = gdb::checked_static_cast<struct regcache *> (self->regcache);
if (is_thumb)
{
#include "gdbthread.h"
#include "tdesc.h"
#include "gdbsupport/rsp-low.h"
+#include "gdbsupport/gdb-checked-static-cast.h"
+
#ifndef IN_PROCESS_AGENT
struct regcache *
/* See gdbsupport/common-regcache.h. */
-struct regcache *
+reg_buffer_common *
get_thread_regcache_for_ptid (ptid_t ptid)
{
return get_thread_regcache (find_thread_ptid (ptid), 1);
/* See gdbsupport/common-regcache.h. */
int
-regcache_register_size (const struct regcache *regcache, int n)
+regcache_register_size (const reg_buffer_common *regcache, int n)
{
- return register_size (regcache->tdesc, n);
+ return register_size
+ (gdb::checked_static_cast<const struct regcache *> (regcache)->tdesc, n);
}
static unsigned char *
}
enum register_status
-regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
+regcache_raw_read_unsigned (reg_buffer_common *reg_buf, int regnum,
ULONGEST *val)
{
int size;
+ regcache *regcache = gdb::checked_static_cast<struct regcache *> (reg_buf);
gdb_assert (regcache != NULL);
/* Special handling for register PC. */
CORE_ADDR
-regcache_read_pc (struct regcache *regcache)
+regcache_read_pc (reg_buffer_common *regcache)
{
- return the_target->read_pc (regcache);
+ return the_target->read_pc
+ (gdb::checked_static_cast<struct regcache *> (regcache));
}
void
/* Return the register's value or throw if it's not available. */
ULONGEST
-regcache_raw_get_unsigned (struct regcache *regcache, int regnum)
+regcache_raw_get_unsigned (reg_buffer_common *regcache, int regnum)
{
ULONGEST value;
enum register_status status;
#ifndef COMMON_COMMON_REGCACHE_H
#define COMMON_COMMON_REGCACHE_H
+struct reg_buffer_common;
+
/* This header is a stopgap until we have an independent regcache. */
enum register_status : signed char
thread specified by PTID. This function must be provided by
the client. */
-extern struct regcache *get_thread_regcache_for_ptid (ptid_t ptid);
+extern reg_buffer_common *get_thread_regcache_for_ptid (ptid_t ptid);
/* Return the size of register numbered N in REGCACHE. This function
must be provided by the client. */
-extern int regcache_register_size (const struct regcache *regcache, int n);
+extern int regcache_register_size (const reg_buffer_common *regcache, int n);
/* Read the PC register. This function must be provided by the
client. */
-extern CORE_ADDR regcache_read_pc (struct regcache *regcache);
+extern CORE_ADDR regcache_read_pc (reg_buffer_common *regcache);
/* Read the PC register. If PC cannot be read, return 0.
This is a wrapper around 'regcache_read_pc'. */
-extern CORE_ADDR regcache_read_pc_protected (regcache *regcache);
+extern CORE_ADDR regcache_read_pc_protected (reg_buffer_common *regcache);
/* Read a raw register into a unsigned integer. */
-extern enum register_status regcache_raw_read_unsigned
- (struct regcache *regcache, int regnum, ULONGEST *val);
+extern enum register_status
+regcache_raw_read_unsigned (reg_buffer_common *regcache, int regnum,
+ ULONGEST *val);
-ULONGEST regcache_raw_get_unsigned (struct regcache *regcache, int regnum);
+ULONGEST regcache_raw_get_unsigned (reg_buffer_common *regcache, int regnum);
struct reg_buffer_common
{