gdbserver: turn target ops 'read_memory' and 'write_memory' into methods
gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn process_stratum_target's read_memory and write_memory ops into methods of process_target. * target.h (struct process_stratum_target): Remove the target ops. (class process_target): Add the target ops. Update the derived classes and callers below. * linux-aarch32-low.cc (arm_breakpoint_at): Update. * linux-aarch64-low.cc (aarch64_breakpoint_at): Update. * linux-arm-low.cc (arm_sigreturn_next_pc): Update. (arm_get_syscall_trapinfo): Update. * linux-cris-low.cc (cris_breakpoint_at): Update. * linux-crisv32-low.cc (cris_breakpoint_at): Update. * linux-m32r-low.cc (m32r_breakpoint_at): Update. * linux-mips-low.cc (mips_breakpoint_at): Update. * linux-nios2-low.cc (nios2_breakpoint_at): Update. * linux-ppc-low.cc (ppc_breakpoint_at): Update. * linux-sh-low.cc (sh_breakpoint_at): Update. * linux-sparc-low.cc (sparc_fill_gregset_to_stack): Update. (sparc_store_gregset_from_stack): Update. (sparc_breakpoint_at): Update. * linux-tic6x-low.cc (tic6x_breakpoint_at): Update. * linux-tile-low.cc (tile_breakpoint_at): Update. * linux-x86-low.cc (x86_breakpoint_at): Update. * linux-xtensa-low.cc (xtensa_breakpoint_at): Update. * mem-brea.cc (insert_memory_breakpoint): Update. (validate_inserted_breakpoint): Update. * target.cc (read_inferior_memory): Update. (target_write_memory): Update. * linux-low.cc (linux_target_ops): Update. (linux_read_memory): Make a wrapper around the read_memory target op call. (linux_process_target::read_memory): Rename from linux_read_memory. (linux_write_memory): Turn into ... (linux_process_target::write_memory): ... this. * linux-low.h (class linux_process_target): Update. * lynx-low.cc (lynx_target_ops): Update. (lynx_read_memory): Turn into ... (lynx_process_target::read_memory): ... this. (lynx_write_memory): Turn into ... (lynx_process_target::write_memory): ... this. * lynx-low.h (class lynx_process_target): Update. * nto-low.cc (nto_target_ops): Update. (nto_read_memory): Turn into ... (nto_process_target::read_memory): ... this. (nto_write_memory): Turn into ... (nto_process_target::write_memory): ... this. * nto-low.h (class nto_process_target): Update. * win32-low.cc (win32_target_ops): Update. (win32_read_inferior_memory): Turn into ... (win32_process_target::read_memory): ... this. (win32_write_inferior_memory): Turn into ... (win32_process_target::write_memory): ... this. * win32-low.h (class win32_process_target): Update.
This commit is contained in:
parent
79b4408780
commit
e2558df32b
@ -1,3 +1,61 @@
|
||||
2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
|
||||
|
||||
Turn process_stratum_target's read_memory and write_memory
|
||||
ops into methods of process_target.
|
||||
|
||||
* target.h (struct process_stratum_target): Remove the target ops.
|
||||
(class process_target): Add the target ops.
|
||||
|
||||
Update the derived classes and callers below.
|
||||
|
||||
* linux-aarch32-low.cc (arm_breakpoint_at): Update.
|
||||
* linux-aarch64-low.cc (aarch64_breakpoint_at): Update.
|
||||
* linux-arm-low.cc (arm_sigreturn_next_pc): Update.
|
||||
(arm_get_syscall_trapinfo): Update.
|
||||
* linux-cris-low.cc (cris_breakpoint_at): Update.
|
||||
* linux-crisv32-low.cc (cris_breakpoint_at): Update.
|
||||
* linux-m32r-low.cc (m32r_breakpoint_at): Update.
|
||||
* linux-mips-low.cc (mips_breakpoint_at): Update.
|
||||
* linux-nios2-low.cc (nios2_breakpoint_at): Update.
|
||||
* linux-ppc-low.cc (ppc_breakpoint_at): Update.
|
||||
* linux-sh-low.cc (sh_breakpoint_at): Update.
|
||||
* linux-sparc-low.cc (sparc_fill_gregset_to_stack): Update.
|
||||
(sparc_store_gregset_from_stack): Update.
|
||||
(sparc_breakpoint_at): Update.
|
||||
* linux-tic6x-low.cc (tic6x_breakpoint_at): Update.
|
||||
* linux-tile-low.cc (tile_breakpoint_at): Update.
|
||||
* linux-x86-low.cc (x86_breakpoint_at): Update.
|
||||
* linux-xtensa-low.cc (xtensa_breakpoint_at): Update.
|
||||
* mem-brea.cc (insert_memory_breakpoint): Update.
|
||||
(validate_inserted_breakpoint): Update.
|
||||
* target.cc (read_inferior_memory): Update.
|
||||
(target_write_memory): Update.
|
||||
* linux-low.cc (linux_target_ops): Update.
|
||||
(linux_read_memory): Make a wrapper around the read_memory target
|
||||
op call.
|
||||
(linux_process_target::read_memory): Rename from linux_read_memory.
|
||||
(linux_write_memory): Turn into ...
|
||||
(linux_process_target::write_memory): ... this.
|
||||
* linux-low.h (class linux_process_target): Update.
|
||||
* lynx-low.cc (lynx_target_ops): Update.
|
||||
(lynx_read_memory): Turn into ...
|
||||
(lynx_process_target::read_memory): ... this.
|
||||
(lynx_write_memory): Turn into ...
|
||||
(lynx_process_target::write_memory): ... this.
|
||||
* lynx-low.h (class lynx_process_target): Update.
|
||||
* nto-low.cc (nto_target_ops): Update.
|
||||
(nto_read_memory): Turn into ...
|
||||
(nto_process_target::read_memory): ... this.
|
||||
(nto_write_memory): Turn into ...
|
||||
(nto_process_target::write_memory): ... this.
|
||||
* nto-low.h (class nto_process_target): Update.
|
||||
* win32-low.cc (win32_target_ops): Update.
|
||||
(win32_read_inferior_memory): Turn into ...
|
||||
(win32_process_target::read_memory): ... this.
|
||||
(win32_write_inferior_memory): Turn into ...
|
||||
(win32_process_target::write_memory): ... this.
|
||||
* win32-low.h (class win32_process_target): Update.
|
||||
|
||||
2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
|
||||
|
||||
Turn process_stratum_target's prepare_to_access_memory and
|
||||
|
@ -192,13 +192,13 @@ arm_breakpoint_at (CORE_ADDR where)
|
||||
/* Thumb mode. */
|
||||
unsigned short insn;
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn, 2);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn, 2);
|
||||
if (insn == thumb_breakpoint)
|
||||
return 1;
|
||||
|
||||
if (insn == thumb2_breakpoint[0])
|
||||
{
|
||||
(*the_target->read_memory) (where + 2, (unsigned char *) &insn, 2);
|
||||
the_target->pt->read_memory (where + 2, (unsigned char *) &insn, 2);
|
||||
if (insn == thumb2_breakpoint[1])
|
||||
return 1;
|
||||
}
|
||||
@ -208,7 +208,7 @@ arm_breakpoint_at (CORE_ADDR where)
|
||||
/* ARM mode. */
|
||||
unsigned long insn;
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn, 4);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
|
||||
if (insn == arm_abi_breakpoint)
|
||||
return 1;
|
||||
|
||||
|
@ -192,8 +192,8 @@ aarch64_breakpoint_at (CORE_ADDR where)
|
||||
{
|
||||
gdb_byte insn[aarch64_breakpoint_len];
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn,
|
||||
aarch64_breakpoint_len);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn,
|
||||
aarch64_breakpoint_len);
|
||||
if (memcmp (insn, aarch64_breakpoint, aarch64_breakpoint_len) == 0)
|
||||
return 1;
|
||||
|
||||
|
@ -779,15 +779,15 @@ arm_sigreturn_next_pc (struct regcache *regcache, int svc_number,
|
||||
gdb_assert (svc_number == __NR_sigreturn || svc_number == __NR_rt_sigreturn);
|
||||
|
||||
collect_register_by_name (regcache, "sp", &sp);
|
||||
(*the_target->read_memory) (sp, (unsigned char *) &sp_data, 4);
|
||||
the_target->pt->read_memory (sp, (unsigned char *) &sp_data, 4);
|
||||
|
||||
pc_offset = arm_linux_sigreturn_next_pc_offset
|
||||
(sp, sp_data, svc_number, __NR_sigreturn == svc_number ? 1 : 0);
|
||||
|
||||
(*the_target->read_memory) (sp + pc_offset, (unsigned char *) &next_pc, 4);
|
||||
the_target->pt->read_memory (sp + pc_offset, (unsigned char *) &next_pc, 4);
|
||||
|
||||
/* Set IS_THUMB according the CPSR saved on the stack. */
|
||||
(*the_target->read_memory) (sp + pc_offset + 4, (unsigned char *) &cpsr, 4);
|
||||
the_target->pt->read_memory (sp + pc_offset + 4, (unsigned char *) &cpsr, 4);
|
||||
*is_thumb = ((cpsr & CPSR_T) != 0);
|
||||
|
||||
return next_pc;
|
||||
@ -939,7 +939,7 @@ arm_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
|
||||
|
||||
collect_register_by_name (regcache, "pc", &pc);
|
||||
|
||||
if ((*the_target->read_memory) (pc - 4, (unsigned char *) &insn, 4))
|
||||
if (the_target->pt->read_memory (pc - 4, (unsigned char *) &insn, 4))
|
||||
*sysno = UNKNOWN_SYSCALL;
|
||||
else
|
||||
{
|
||||
|
@ -76,8 +76,8 @@ cris_breakpoint_at (CORE_ADDR where)
|
||||
{
|
||||
unsigned short insn;
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn,
|
||||
cris_breakpoint_len);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn,
|
||||
cris_breakpoint_len);
|
||||
if (insn == cris_breakpoint)
|
||||
return 1;
|
||||
|
||||
|
@ -72,8 +72,8 @@ cris_breakpoint_at (CORE_ADDR where)
|
||||
{
|
||||
unsigned short insn;
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn,
|
||||
cris_breakpoint_len);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn,
|
||||
cris_breakpoint_len);
|
||||
if (insn == cris_breakpoint)
|
||||
return 1;
|
||||
|
||||
|
@ -5709,11 +5709,20 @@ linux_process_target::store_registers (regcache *regcache, int regno)
|
||||
}
|
||||
|
||||
|
||||
/* Copy LEN bytes from inferior's memory starting at MEMADDR
|
||||
to debugger memory starting at MYADDR. */
|
||||
/* A wrapper for the read_memory target op. */
|
||||
|
||||
static int
|
||||
linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
|
||||
{
|
||||
return the_target->pt->read_memory (memaddr, myaddr, len);
|
||||
}
|
||||
|
||||
/* Copy LEN bytes from inferior's memory starting at MEMADDR
|
||||
to debugger memory starting at MYADDR. */
|
||||
|
||||
int
|
||||
linux_process_target::read_memory (CORE_ADDR memaddr,
|
||||
unsigned char *myaddr, int len)
|
||||
{
|
||||
int pid = lwpid_of (current_thread);
|
||||
PTRACE_XFER_TYPE *buffer;
|
||||
@ -5801,8 +5810,9 @@ linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
|
||||
memory at MEMADDR. On failure (cannot write to the inferior)
|
||||
returns the value of errno. Always succeeds if LEN is zero. */
|
||||
|
||||
static int
|
||||
linux_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
|
||||
int
|
||||
linux_process_target::write_memory (CORE_ADDR memaddr,
|
||||
const unsigned char *myaddr, int len)
|
||||
{
|
||||
int i;
|
||||
/* Round starting address down to longword boundary. */
|
||||
@ -7359,8 +7369,6 @@ linux_get_hwcap2 (int wordsize)
|
||||
static linux_process_target the_linux_target;
|
||||
|
||||
static process_stratum_target linux_target_ops = {
|
||||
linux_read_memory,
|
||||
linux_write_memory,
|
||||
linux_look_up_symbols,
|
||||
linux_request_interrupt,
|
||||
linux_read_auxv,
|
||||
|
@ -299,6 +299,12 @@ public:
|
||||
int prepare_to_access_memory () override;
|
||||
|
||||
void done_accessing_memory () override;
|
||||
|
||||
int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
|
||||
int len) override;
|
||||
|
||||
int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
|
||||
int len) override;
|
||||
};
|
||||
|
||||
#define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
|
||||
|
@ -70,8 +70,8 @@ m32r_breakpoint_at (CORE_ADDR where)
|
||||
{
|
||||
unsigned short insn;
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn,
|
||||
m32r_breakpoint_len);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn,
|
||||
m32r_breakpoint_len);
|
||||
if (insn == m32r_breakpoint)
|
||||
return 1;
|
||||
|
||||
|
@ -302,7 +302,7 @@ mips_breakpoint_at (CORE_ADDR where)
|
||||
{
|
||||
unsigned int insn;
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn, 4);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
|
||||
if (insn == mips_breakpoint)
|
||||
return 1;
|
||||
|
||||
|
@ -131,12 +131,12 @@ nios2_breakpoint_at (CORE_ADDR where)
|
||||
|
||||
/* For R2, first check for the 2-byte CDX trap.n breakpoint encoding. */
|
||||
#if defined(__nios2_arch__) && __nios2_arch__ == 2
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn, 2);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn, 2);
|
||||
if (insn == CDX_BREAKPOINT)
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn, 4);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
|
||||
if (insn == nios2_breakpoint)
|
||||
return 1;
|
||||
return 0;
|
||||
|
@ -277,7 +277,7 @@ ppc_breakpoint_at (CORE_ADDR where)
|
||||
{
|
||||
unsigned int insn;
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn, 4);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
|
||||
if (insn == ppc_breakpoint)
|
||||
return 1;
|
||||
/* If necessary, recognize more trap instructions here. GDB only uses
|
||||
|
@ -76,7 +76,7 @@ sh_breakpoint_at (CORE_ADDR where)
|
||||
{
|
||||
unsigned short insn;
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn, 2);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn, 2);
|
||||
if (insn == sh_breakpoint)
|
||||
return 1;
|
||||
|
||||
|
@ -133,7 +133,7 @@ sparc_fill_gregset_to_stack (struct regcache *regcache, const void *buf)
|
||||
for (i = l0_regno; i <= i7_regno; i++)
|
||||
{
|
||||
collect_register (regcache, i, tmp_reg_buf);
|
||||
(*the_target->write_memory) (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
|
||||
the_target->pt->write_memory (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
|
||||
addr += sizeof (tmp_reg_buf);
|
||||
}
|
||||
}
|
||||
@ -184,7 +184,7 @@ sparc_store_gregset_from_stack (struct regcache *regcache, const void *buf)
|
||||
|
||||
for (i = l0_regno; i <= i7_regno; i++)
|
||||
{
|
||||
(*the_target->read_memory) (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
|
||||
the_target->pt->read_memory (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
|
||||
supply_register (regcache, i, tmp_reg_buf);
|
||||
addr += sizeof (tmp_reg_buf);
|
||||
}
|
||||
@ -242,7 +242,7 @@ sparc_breakpoint_at (CORE_ADDR where)
|
||||
{
|
||||
unsigned char insn[INSN_SIZE];
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) insn, sizeof (insn));
|
||||
the_target->pt->read_memory (where, (unsigned char *) insn, sizeof (insn));
|
||||
|
||||
if (memcmp (sparc_breakpoint, insn, sizeof (insn)) == 0)
|
||||
return 1;
|
||||
|
@ -241,7 +241,7 @@ tic6x_breakpoint_at (CORE_ADDR where)
|
||||
{
|
||||
unsigned int insn;
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn, 4);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
|
||||
if (insn == tic6x_breakpoint)
|
||||
return 1;
|
||||
|
||||
|
@ -85,7 +85,7 @@ tile_breakpoint_at (CORE_ADDR where)
|
||||
{
|
||||
uint64_t insn;
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn, 8);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn, 8);
|
||||
if (insn == tile_breakpoint)
|
||||
return 1;
|
||||
|
||||
|
@ -515,7 +515,7 @@ x86_breakpoint_at (CORE_ADDR pc)
|
||||
{
|
||||
unsigned char c;
|
||||
|
||||
(*the_target->read_memory) (pc, &c, 1);
|
||||
the_target->pt->read_memory (pc, &c, 1);
|
||||
if (c == 0xCC)
|
||||
return 1;
|
||||
|
||||
|
@ -207,8 +207,8 @@ xtensa_breakpoint_at (CORE_ADDR where)
|
||||
{
|
||||
unsigned long insn;
|
||||
|
||||
(*the_target->read_memory) (where, (unsigned char *) &insn,
|
||||
xtensa_breakpoint_len);
|
||||
the_target->pt->read_memory (where, (unsigned char *) &insn,
|
||||
xtensa_breakpoint_len);
|
||||
return memcmp((char *) &insn,
|
||||
xtensa_breakpoint, xtensa_breakpoint_len) == 0;
|
||||
}
|
||||
|
@ -638,8 +638,9 @@ lynx_process_target::store_registers (regcache *regcache, int regno)
|
||||
|
||||
/* Implement the read_memory target_ops method. */
|
||||
|
||||
static int
|
||||
lynx_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
|
||||
int
|
||||
lynx_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
|
||||
int len)
|
||||
{
|
||||
/* On LynxOS, memory reads needs to be performed in chunks the size
|
||||
of int types, and they should also be aligned accordingly. */
|
||||
@ -671,8 +672,9 @@ lynx_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
|
||||
|
||||
/* Implement the write_memory target_ops method. */
|
||||
|
||||
static int
|
||||
lynx_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
|
||||
int
|
||||
lynx_process_target::write_memory (CORE_ADDR memaddr,
|
||||
const unsigned char *myaddr, int len)
|
||||
{
|
||||
/* On LynxOS, memory writes needs to be performed in chunks the size
|
||||
of int types, and they should also be aligned accordingly. */
|
||||
@ -694,7 +696,7 @@ lynx_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
|
||||
{
|
||||
/* We need to read the memory at this address in order to preserve
|
||||
the data that we are not overwriting. */
|
||||
lynx_read_memory (addr, (unsigned char *) &buf, xfer_size);
|
||||
read_memory (addr, (unsigned char *) &buf, xfer_size);
|
||||
if (errno)
|
||||
return errno;
|
||||
}
|
||||
@ -727,8 +729,6 @@ static lynx_process_target the_lynx_target;
|
||||
/* The LynxOS target_ops vector. */
|
||||
|
||||
static process_stratum_target lynx_target_ops = {
|
||||
lynx_read_memory,
|
||||
lynx_write_memory,
|
||||
NULL, /* look_up_symbols */
|
||||
lynx_request_interrupt,
|
||||
NULL, /* read_auxv */
|
||||
|
@ -81,6 +81,12 @@ public:
|
||||
void fetch_registers (regcache *regcache, int regno) override;
|
||||
|
||||
void store_registers (regcache *regcache, int regno) override;
|
||||
|
||||
int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
|
||||
int len) override;
|
||||
|
||||
int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
|
||||
int len) override;
|
||||
};
|
||||
|
||||
/* The inferior's target description. This is a global because the
|
||||
|
@ -380,8 +380,8 @@ insert_memory_breakpoint (struct raw_breakpoint *bp)
|
||||
{
|
||||
memcpy (bp->old_data, buf, bp_size (bp));
|
||||
|
||||
err = (*the_target->write_memory) (bp->pc, bp_opcode (bp),
|
||||
bp_size (bp));
|
||||
err = the_target->pt->write_memory (bp->pc, bp_opcode (bp),
|
||||
bp_size (bp));
|
||||
if (err != 0)
|
||||
{
|
||||
if (debug_threads)
|
||||
@ -1857,7 +1857,7 @@ validate_inserted_breakpoint (struct raw_breakpoint *bp)
|
||||
gdb_assert (bp->raw_type == raw_bkpt_type_sw);
|
||||
|
||||
buf = (unsigned char *) alloca (bp_size (bp));
|
||||
err = (*the_target->read_memory) (bp->pc, buf, bp_size (bp));
|
||||
err = the_target->pt->read_memory (bp->pc, buf, bp_size (bp));
|
||||
if (err || memcmp (buf, bp_opcode (bp), bp_size (bp)) != 0)
|
||||
{
|
||||
/* Tag it as gone. */
|
||||
|
@ -706,8 +706,9 @@ nto_process_target::store_registers (regcache *regcache, int regno)
|
||||
|
||||
Return 0 on success -1 otherwise. */
|
||||
|
||||
static int
|
||||
nto_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
|
||||
int
|
||||
nto_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
|
||||
int len)
|
||||
{
|
||||
TRACE ("%s memaddr:0x%08lx, len:%d\n", __func__, memaddr, len);
|
||||
|
||||
@ -725,8 +726,9 @@ nto_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
|
||||
|
||||
Return 0 on success -1 otherwise. */
|
||||
|
||||
static int
|
||||
nto_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
|
||||
int
|
||||
nto_process_target::write_memory (CORE_ADDR memaddr,
|
||||
const unsigned char *myaddr, int len)
|
||||
{
|
||||
int len_written;
|
||||
|
||||
@ -941,8 +943,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
|
||||
static nto_process_target the_nto_target;
|
||||
|
||||
static process_stratum_target nto_target_ops = {
|
||||
nto_read_memory,
|
||||
nto_write_memory,
|
||||
NULL, /* nto_look_up_symbols */
|
||||
nto_request_interrupt,
|
||||
nto_read_auxv,
|
||||
|
@ -71,6 +71,12 @@ public:
|
||||
void fetch_registers (regcache *regcache, int regno) override;
|
||||
|
||||
void store_registers (regcache *regcache, int regno) override;
|
||||
|
||||
int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
|
||||
int len) override;
|
||||
|
||||
int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
|
||||
int len) override;
|
||||
};
|
||||
|
||||
/* The inferior's target description. This is a global because the
|
||||
|
@ -120,7 +120,7 @@ int
|
||||
read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
|
||||
{
|
||||
int res;
|
||||
res = (*the_target->read_memory) (memaddr, myaddr, len);
|
||||
res = the_target->pt->read_memory (memaddr, myaddr, len);
|
||||
check_mem_read (memaddr, myaddr, len);
|
||||
return res;
|
||||
}
|
||||
@ -151,7 +151,7 @@ target_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
|
||||
update it. */
|
||||
gdb::byte_vector buffer (myaddr, myaddr + len);
|
||||
check_mem_write (memaddr, buffer.data (), myaddr, len);
|
||||
return (*the_target->write_memory) (memaddr, buffer.data (), len);
|
||||
return the_target->pt->write_memory (memaddr, buffer.data (), len);
|
||||
}
|
||||
|
||||
ptid_t
|
||||
|
@ -70,25 +70,6 @@ class process_target;
|
||||
shared code. */
|
||||
struct process_stratum_target
|
||||
{
|
||||
/* Read memory from the inferior process. This should generally be
|
||||
called through read_inferior_memory, which handles breakpoint shadowing.
|
||||
|
||||
Read LEN bytes at MEMADDR into a buffer at MYADDR.
|
||||
|
||||
Returns 0 on success and errno on failure. */
|
||||
|
||||
int (*read_memory) (CORE_ADDR memaddr, unsigned char *myaddr, int len);
|
||||
|
||||
/* Write memory to the inferior process. This should generally be
|
||||
called through target_write_memory, which handles breakpoint shadowing.
|
||||
|
||||
Write LEN bytes from the buffer at MYADDR to MEMADDR.
|
||||
|
||||
Returns 0 on success and errno on failure. */
|
||||
|
||||
int (*write_memory) (CORE_ADDR memaddr, const unsigned char *myaddr,
|
||||
int len);
|
||||
|
||||
/* Query GDB for the values of any symbols we're interested in.
|
||||
This function is called whenever we receive a "qSymbols::"
|
||||
query, which corresponds to every time more symbols (might)
|
||||
@ -478,6 +459,24 @@ public:
|
||||
|
||||
/* Undo the effects of prepare_to_access_memory. */
|
||||
virtual void done_accessing_memory ();
|
||||
|
||||
/* Read memory from the inferior process. This should generally be
|
||||
called through read_inferior_memory, which handles breakpoint shadowing.
|
||||
|
||||
Read LEN bytes at MEMADDR into a buffer at MYADDR.
|
||||
|
||||
Returns 0 on success and errno on failure. */
|
||||
virtual int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
|
||||
int len) = 0;
|
||||
|
||||
/* Write memory to the inferior process. This should generally be
|
||||
called through target_write_memory, which handles breakpoint shadowing.
|
||||
|
||||
Write LEN bytes from the buffer at MYADDR to MEMADDR.
|
||||
|
||||
Returns 0 on success and errno on failure. */
|
||||
virtual int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
|
||||
int len) = 0;
|
||||
};
|
||||
|
||||
extern process_stratum_target *the_target;
|
||||
|
@ -1676,8 +1676,9 @@ win32_process_target::store_registers (regcache *regcache, int regno)
|
||||
/* Read memory from the inferior process. This should generally be
|
||||
called through read_inferior_memory, which handles breakpoint shadowing.
|
||||
Read LEN bytes at MEMADDR into a buffer at MYADDR. */
|
||||
static int
|
||||
win32_read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
|
||||
int
|
||||
win32_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
|
||||
int len)
|
||||
{
|
||||
return child_xfer_memory (memaddr, (char *) myaddr, len, 0, 0) != len;
|
||||
}
|
||||
@ -1686,9 +1687,9 @@ win32_read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
|
||||
called through write_inferior_memory, which handles breakpoint shadowing.
|
||||
Write LEN bytes from the buffer at MYADDR to MEMADDR.
|
||||
Returns 0 on success and errno on failure. */
|
||||
static int
|
||||
win32_write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
|
||||
int len)
|
||||
int
|
||||
win32_process_target::write_memory (CORE_ADDR memaddr,
|
||||
const unsigned char *myaddr, int len)
|
||||
{
|
||||
return child_xfer_memory (memaddr, (char *) myaddr, len, 1, 0) != len;
|
||||
}
|
||||
@ -1837,8 +1838,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
|
||||
static win32_process_target the_win32_target;
|
||||
|
||||
static process_stratum_target win32_target_ops = {
|
||||
win32_read_inferior_memory,
|
||||
win32_write_inferior_memory,
|
||||
NULL, /* lookup_symbols */
|
||||
win32_request_interrupt,
|
||||
NULL, /* read_auxv */
|
||||
|
@ -130,6 +130,12 @@ public:
|
||||
void fetch_registers (regcache *regcache, int regno) override;
|
||||
|
||||
void store_registers (regcache *regcache, int regno) override;
|
||||
|
||||
int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
|
||||
int len) override;
|
||||
|
||||
int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
|
||||
int len) override;
|
||||
};
|
||||
|
||||
/* Retrieve the context for this thread, if not already retrieved. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user