diff options
author | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2020-02-17 16:11:53 +0100 |
---|---|---|
committer | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2020-02-20 17:35:05 +0100 |
commit | e2558df32b83c2e3b41829d46c0b3d09732d7176 (patch) | |
tree | bca1d3be31edd11a17b7e9c0055cce0beac4ec43 /gdbserver | |
parent | 79b4408780b27eeb60de7f3fe10bc654dddcf067 (diff) | |
download | gdb-e2558df32b83c2e3b41829d46c0b3d09732d7176.zip gdb-e2558df32b83c2e3b41829d46c0b3d09732d7176.tar.gz gdb-e2558df32b83c2e3b41829d46c0b3d09732d7176.tar.bz2 |
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.
Diffstat (limited to 'gdbserver')
-rw-r--r-- | gdbserver/ChangeLog | 58 | ||||
-rw-r--r-- | gdbserver/linux-aarch32-low.cc | 6 | ||||
-rw-r--r-- | gdbserver/linux-aarch64-low.cc | 4 | ||||
-rw-r--r-- | gdbserver/linux-arm-low.cc | 8 | ||||
-rw-r--r-- | gdbserver/linux-cris-low.cc | 4 | ||||
-rw-r--r-- | gdbserver/linux-crisv32-low.cc | 4 | ||||
-rw-r--r-- | gdbserver/linux-low.cc | 20 | ||||
-rw-r--r-- | gdbserver/linux-low.h | 6 | ||||
-rw-r--r-- | gdbserver/linux-m32r-low.cc | 4 | ||||
-rw-r--r-- | gdbserver/linux-mips-low.cc | 2 | ||||
-rw-r--r-- | gdbserver/linux-nios2-low.cc | 4 | ||||
-rw-r--r-- | gdbserver/linux-ppc-low.cc | 2 | ||||
-rw-r--r-- | gdbserver/linux-sh-low.cc | 2 | ||||
-rw-r--r-- | gdbserver/linux-sparc-low.cc | 6 | ||||
-rw-r--r-- | gdbserver/linux-tic6x-low.cc | 2 | ||||
-rw-r--r-- | gdbserver/linux-tile-low.cc | 2 | ||||
-rw-r--r-- | gdbserver/linux-x86-low.cc | 2 | ||||
-rw-r--r-- | gdbserver/linux-xtensa-low.cc | 4 | ||||
-rw-r--r-- | gdbserver/lynx-low.cc | 14 | ||||
-rw-r--r-- | gdbserver/lynx-low.h | 6 | ||||
-rw-r--r-- | gdbserver/mem-break.cc | 6 | ||||
-rw-r--r-- | gdbserver/nto-low.cc | 12 | ||||
-rw-r--r-- | gdbserver/nto-low.h | 6 | ||||
-rw-r--r-- | gdbserver/target.cc | 4 | ||||
-rw-r--r-- | gdbserver/target.h | 37 | ||||
-rw-r--r-- | gdbserver/win32-low.cc | 13 | ||||
-rw-r--r-- | gdbserver/win32-low.h | 6 |
27 files changed, 166 insertions, 78 deletions
diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog index d41539b..3617c1b 100644 --- a/gdbserver/ChangeLog +++ b/gdbserver/ChangeLog @@ -1,5 +1,63 @@ 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 done_accessing_memory ops into methods of process_target. diff --git a/gdbserver/linux-aarch32-low.cc b/gdbserver/linux-aarch32-low.cc index c6a7024..41e018a 100644 --- a/gdbserver/linux-aarch32-low.cc +++ b/gdbserver/linux-aarch32-low.cc @@ -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; diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 961fd5b..97117f0 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -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; diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc index 9f046c0..e7cc119 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -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 { diff --git a/gdbserver/linux-cris-low.cc b/gdbserver/linux-cris-low.cc index 8ea5af9..6a4e8b1 100644 --- a/gdbserver/linux-cris-low.cc +++ b/gdbserver/linux-cris-low.cc @@ -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; diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc index facb5c5..fe12624 100644 --- a/gdbserver/linux-crisv32-low.cc +++ b/gdbserver/linux-crisv32-low.cc @@ -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; diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 6f408ad..1a790e5 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -5709,12 +5709,21 @@ 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; CORE_ADDR addr; @@ -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, diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index 2b7b357..b8b1014 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -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))) diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc index c52e816..8fe8389 100644 --- a/gdbserver/linux-m32r-low.cc +++ b/gdbserver/linux-m32r-low.cc @@ -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; diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc index f94e141..cb7eb53 100644 --- a/gdbserver/linux-mips-low.cc +++ b/gdbserver/linux-mips-low.cc @@ -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; diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc index bfc5aee..6e5d308 100644 --- a/gdbserver/linux-nios2-low.cc +++ b/gdbserver/linux-nios2-low.cc @@ -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; diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc index 5d8d67b..93b3511 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -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 diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc index abe71ff..06ce811 100644 --- a/gdbserver/linux-sh-low.cc +++ b/gdbserver/linux-sh-low.cc @@ -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; diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc index cfa76c0..b0b6c96 100644 --- a/gdbserver/linux-sparc-low.cc +++ b/gdbserver/linux-sparc-low.cc @@ -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; diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc index 51a31c7..b57f8c5 100644 --- a/gdbserver/linux-tic6x-low.cc +++ b/gdbserver/linux-tic6x-low.cc @@ -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; diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc index cd85e94..baee93a 100644 --- a/gdbserver/linux-tile-low.cc +++ b/gdbserver/linux-tile-low.cc @@ -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; diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index 09ec22f..cb2d3f5 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -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; diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc index 83af11e..31e7bad 100644 --- a/gdbserver/linux-xtensa-low.cc +++ b/gdbserver/linux-xtensa-low.cc @@ -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; } diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc index e243764..eb5147d 100644 --- a/gdbserver/lynx-low.cc +++ b/gdbserver/lynx-low.cc @@ -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 */ diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h index ea6cf00..9036eb3 100644 --- a/gdbserver/lynx-low.h +++ b/gdbserver/lynx-low.h @@ -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 diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc index 1b6f236..43a07c39 100644 --- a/gdbserver/mem-break.cc +++ b/gdbserver/mem-break.cc @@ -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. */ diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc index 36bd40c..d56f247 100644 --- a/gdbserver/nto-low.cc +++ b/gdbserver/nto-low.cc @@ -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, diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h index f630360..0f4bb43 100644 --- a/gdbserver/nto-low.h +++ b/gdbserver/nto-low.h @@ -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 diff --git a/gdbserver/target.cc b/gdbserver/target.cc index f88e9fa..49302f6 100644 --- a/gdbserver/target.cc +++ b/gdbserver/target.cc @@ -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 diff --git a/gdbserver/target.h b/gdbserver/target.h index e89ddbb..ead4a61 100644 --- a/gdbserver/target.h +++ b/gdbserver/target.h @@ -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; diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index 4a8e64d..ef0d603 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -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 */ diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h index ff3659f..0ecb2f8 100644 --- a/gdbserver/win32-low.h +++ b/gdbserver/win32-low.h @@ -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. */ |