gdbserver: turn target ops 'read_memory' and 'write_memory' into methods
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Mon, 17 Feb 2020 15:11:53 +0000 (16:11 +0100)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 20 Feb 2020 16:35:05 +0000 (17:35 +0100)
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.

27 files changed:
gdbserver/ChangeLog
gdbserver/linux-aarch32-low.cc
gdbserver/linux-aarch64-low.cc
gdbserver/linux-arm-low.cc
gdbserver/linux-cris-low.cc
gdbserver/linux-crisv32-low.cc
gdbserver/linux-low.cc
gdbserver/linux-low.h
gdbserver/linux-m32r-low.cc
gdbserver/linux-mips-low.cc
gdbserver/linux-nios2-low.cc
gdbserver/linux-ppc-low.cc
gdbserver/linux-sh-low.cc
gdbserver/linux-sparc-low.cc
gdbserver/linux-tic6x-low.cc
gdbserver/linux-tile-low.cc
gdbserver/linux-x86-low.cc
gdbserver/linux-xtensa-low.cc
gdbserver/lynx-low.cc
gdbserver/lynx-low.h
gdbserver/mem-break.cc
gdbserver/nto-low.cc
gdbserver/nto-low.h
gdbserver/target.cc
gdbserver/target.h
gdbserver/win32-low.cc
gdbserver/win32-low.h

index d41539bc81866771f141c531a7783ad3e2703dcf..3617c1ba214eafe89e254d0744c77da46be61cf5 100644 (file)
@@ -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
index c6a70249d3bbb35adc13c1540d959634140a8daa..41e018ab528dba9b6f386fb053674ea74cddba53 100644 (file)
@@ -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;
 
index 961fd5b3cc41c708d7acfe3c03639e287330bbb7..97117f05780a378cbbf88e33e9e06d4f063adc08 100644 (file)
@@ -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;
 
index 9f046c098bf1cc067919fa26aa260d942fbdf870..e7cc119685740017b2e4ee8d76b77ad7f1b20e80 100644 (file)
@@ -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
        {
index 8ea5af92e31523324e2eef070ddda47f3dd390f7..6a4e8b1946a01cf46842addb4b8b1d68c9051572 100644 (file)
@@ -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;
 
index facb5c5c274be16e091ea16ff6d154472dfa89f9..fe12624c3b657307a878884fb7acfc27a7ac3498 100644 (file)
@@ -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;
 
index 6f408ad9333657d4ad9f52d82ba15098d5556a47..1a790e5eae913ef417fa5559daa67e9b9548379d 100644 (file)
@@ -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,
index 2b7b357ba674fa542313ef7a5ffc1db4b143d749..b8b10143dec5721344f3216b435be9bd85bf39b2 100644 (file)
@@ -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)))
index c52e816e341d8b0ff0fc8784132409553d6def27..8fe8389618fa75806c4e2e01b6ea2e3198b10293 100644 (file)
@@ -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;
 
index f94e141be79ffcd472a65f752adef14bb30ba1df..cb7eb53e3ebf81d258f01f2912f2d20d189d2f6e 100644 (file)
@@ -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;
 
index bfc5aee165d284e0202e3f6c52bd1873f7b05413..6e5d3084dad4172be9ef17508c6d47a898b85727 100644 (file)
@@ -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;
index 5d8d67bec2fbdc10b1054f916fd4af80adf1a826..93b3511a2e116c58ca580bef29c8cf3a8b08eed1 100644 (file)
@@ -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
index abe71ff4766b9898097bad88e7ab08c67147fd5a..06ce8118ebff01eb34597c80a5d6ed370039207c 100644 (file)
@@ -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;
 
index cfa76c0b8e65223eaaa0506b13f18a5c01b08017..b0b6c96b3de5352a46d756306d97c9dffe154aab 100644 (file)
@@ -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;
index 51a31c7876a248a221fdc034d175714461f3d738..b57f8c57710796d76c08075f08cfa788fe412963 100644 (file)
@@ -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;
 
index cd85e945a46e3b422402a286aa36115f87201832..baee93a5c24cfe64fe5e579bbddd3d5d9b4d5df6 100644 (file)
@@ -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;
 
index 09ec22ff678f314dcab0d0e35652e0728139ce1a..cb2d3f5958077cd14978d1914594483dc4b72156 100644 (file)
@@ -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;
 
index 83af11e11dc7bcba8bb591d2d328c01e11c2ec50..31e7bad36b814cf6a7b4afacca0d35fc14aaba57 100644 (file)
@@ -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;
 }
index e243764a863330013370eb2f43670c0f6f14121e..eb5147d907b0f3350719f3f4cd9d982c95019ad9 100644 (file)
@@ -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 */
index ea6cf008f5b134a84a656e9dab8c957725a35248..9036eb3eff0deae9f72aa7726d3d7ad7d6fa10a3 100644 (file)
@@ -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
index 1b6f236581465f7d4907f03724b15ce556a49f62..43a07c390d1b7a142753058975b023853e22d12f 100644 (file)
@@ -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.  */
index 36bd40c20d8571571923564faca8cf6ee35c430e..d56f247acb4155cebc12e2878cb432734ab324de 100644 (file)
@@ -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,
index f630360a2f43007447c0ee0e98d552b129edb054..0f4bb434483fa5b74840c879ce3a005a9e01bd02 100644 (file)
@@ -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
index f88e9faf19163ce95194e986d67a5904e3901dc6..49302f61dfb3657fd122f38004c945a2f48387f8 100644 (file)
@@ -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
index e89ddbb0048fa63c699677cdbcc6f1745ad655c5..ead4a613e906934799113486c4802597c1bffcdf 100644 (file)
@@ -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;
index 4a8e64d11aeb11308cd595ea2356f6f29d032479..ef0d6035e93a090ea59346286b0c2080129587d7 100644 (file)
@@ -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 */
index ff3659f6dabac6213c3c0348382a5f22dcab9b85..0ecb2f8ebb5a54fd190ced673863788da297d47a 100644 (file)
@@ -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.  */
This page took 0.047555 seconds and 4 git commands to generate.