[PATCH] Implement backend dispatch table

Stan Cox scox at redhat.com
Thu Apr 27 18:27:36 UTC 2017


This is an implementation of the previously mentioned backend dispatch 
table idea.       This patch isolates the backend specific functionality 
by creating a dispatch table for backend specific entrypoints; which  
can be overridden by the backend. Most of the dispatch entries default 
to the current functionality and the calls change from xxx() to 
backend.xxx().  Some entries (argument handling and initialization 
primarily) add functionality specific to the backend.  This patch 
enables a backend, e.g. gdbserver, to be added to strace with no change 
to frontend functionality.   The change should be general enough to 
allow for future additional backends (dyninst?)  The patch is large but 
much of it is mechanical replacement.

Add backend interface to allow for multiple backends.

* defs.h (struct backend): New.  Struct of entrypoints that dispatch to
    backend routines.  Change all callers of umoven, umovestr, getfdpath,
    test_ptrace_seize, startup_child, detach, trace, to use backend
    equivalent.

* strace.c (startup_attach): Call backend.startup_attach.
    (prog_pid_check, handle_arg):  New.
    (init): Initialize backend dispatch table.  Call
    backend.handle_arg, backend.prog_pid_check, backend.verify_args,
    backend.start_init, and backend.end_init.

* syscall.c (get_regs):  Call backend.get_regs.
    (get_scno):  Call backend.get_scno


diff --git a/defs.h b/defs.h
index 5b81647..3168a9f 100644
--- a/defs.h
+++ b/defs.h
@@ -289,6 +289,36 @@ struct tcb {
  #define filtered(tcp)    ((tcp)->flags & TCB_FILTERED)
  #define hide_log(tcp)    ((tcp)->flags & TCB_HIDE_LOG)

+/* Backend Dispatch Table */
+struct backend {
+    void (*detach) (struct tcb *tcp);
+    bool (*end_init) (void);
+    void (*get_regs) (pid_t pid);
+    int (*get_scno) (struct tcb *tcp);
+    int (*getfdpath) (struct tcb *tcp, int fd, char *buf, unsigned 
bufsize);
+    bool (*handle_arg) (char arg);
+        bool (*prog_pid_check) (char *exec_name, int pid);
+    bool (*start_init) (void);
+    void (*startup_attach) (struct tcb *tcp);
+    void (*startup_child) (char **argv);
+    void (*test_ptrace_seize) (void);
+    bool (*trace) (void);
+    int (*umoven) (struct tcb *const tcp, kernel_ulong_t addr, unsigned 
int len,
+           void *const our_addr);
+    int (*umovestr) (struct tcb *const tcp, kernel_ulong_t addr, 
unsigned int len, char *laddr);
+    int (*upeek_) (int pid, unsigned long off, kernel_ulong_t *res);
+    int (*upoke_) (int pid, unsigned long off, kernel_ulong_t val);
+    bool(*verify_args) (char *username, bool daemon, unsigned int 
*follow_fork);
+} backend;
+
+
+extern int upeek(int pid, unsigned long, kernel_ulong_t *);
+extern int upoke(int pid, unsigned long, kernel_ulong_t);
+
+#define upeek(pid,off,res) backend.upeek_(pid, off, res)
+#define upoke(pid,off,val) backend.upoke_(pid, off, val)
+#define pr
+
  #include "xlat.h"

  extern const struct xlat addrfams[];
@@ -445,10 +475,8 @@ static inline int set_tcb_priv_ulong(struct tcb 
*tcp, unsigned long val)
      return set_tcb_priv_data(tcp, (void *) val, 0);
  }

-extern int
-umoven(struct tcb *tcp, kernel_ulong_t addr, unsigned int len, void 
*laddr);
  #define umove(pid, addr, objp)    \
-    umoven((pid), (addr), sizeof(*(objp)), (void *) (objp))
+    backend.umoven((pid), (addr), sizeof(*(objp)), (void *) (objp))

  extern int
  umoven_or_printaddr(struct tcb *tcp, kernel_ulong_t addr,
@@ -463,9 +491,6 @@ umoven_or_printaddr_ignore_syserror(struct tcb *tcp, 
kernel_ulong_t addr,
  extern int
  umovestr(struct tcb *tcp, kernel_ulong_t addr, unsigned int len, char 
*laddr);

-extern int upeek(int pid, unsigned long, kernel_ulong_t *);
-extern int upoke(int pid, unsigned long, kernel_ulong_t);
-
  extern bool
  print_array(struct tcb *tcp,
          kernel_ulong_t start_addr,
diff --git a/desc.c b/desc.c
index 4882469..a9d9f72 100644
--- a/desc.c
+++ b/desc.c
@@ -147,7 +147,7 @@ decode_select(struct tcb *const tcp, const 
kernel_ulong_t *const args,
              int first = 1;

              addr = args[i+1];
-            if (!addr || !fds || umoven(tcp, addr, fdsize, fds) < 0)
+            if (!addr || !fds || backend.umoven(tcp, addr, fdsize, fds) 
< 0)
                  continue;
              for (j = 0;; j++) {
                  j = next_set_bit(fds, j, nfds);
diff --git a/dirent.c b/dirent.c
index 2ba6fe7..515ac89 100644
--- a/dirent.c
+++ b/dirent.c
@@ -100,7 +100,7 @@ SYS_FUNC(getdents)

      if (len) {
          buf = malloc(len);
-        if (!buf || umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
+        if (!buf || backend.umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
              printaddr(tcp->u_arg[1]);
              tprintf(", %u", count);
              free(buf);
diff --git a/dirent64.c b/dirent64.c
index 448a2f1..c09c394 100644
--- a/dirent64.c
+++ b/dirent64.c
@@ -68,7 +68,7 @@ SYS_FUNC(getdents64)

      if (len) {
          buf = malloc(len);
-        if (!buf || umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
+        if (!buf || backend.umoven(tcp, tcp->u_arg[1], len, buf) < 0) {
              printaddr(tcp->u_arg[1]);
              tprintf(", %u", count);
              free(buf);
diff --git a/dm.c b/dm.c
index a69077b..25e36cb 100644
--- a/dm.c
+++ b/dm.c
@@ -444,7 +444,7 @@ dm_known_ioctl(struct tcb *const tcp, const unsigned 
int code,
          ioc = alloca(sizeof(*ioc));
      }

-    if ((umoven(tcp, arg, offsetof(struct dm_ioctl, data), ioc) < 0) ||
+    if ((backend.umoven(tcp, arg, offsetof(struct dm_ioctl, data), ioc) 
< 0) ||
          (ioc->data_size < offsetof(struct dm_ioctl, data_size))) {
          if (entering(tcp))
              free(ioc);
diff --git a/execve.c b/execve.c
index 6e45b11..de2ae48 100644
--- a/execve.c
+++ b/execve.c
@@ -53,7 +53,7 @@ printargv(struct tcb *const tcp, kernel_ulong_t addr)
              char data[sizeof(kernel_ulong_t)];
          } cp;

-        if (umoven(tcp, addr, wordsize, cp.data)) {
+        if (backend.umoven(tcp, addr, wordsize, cp.data)) {
              if (sep == start_sep)
                  printaddr(addr);
              else
@@ -88,7 +88,7 @@ printargc(struct tcb *const tcp, kernel_ulong_t addr)
      char *cp = NULL;

      for (; addr; addr += current_wordsize, ++count) {
-        if (umoven(tcp, addr, current_wordsize, &cp)) {
+        if (backend.umoven(tcp, addr, current_wordsize, &cp)) {
              if (count) {
                  unterminated = true;
                  break;
diff --git a/file_handle.c b/file_handle.c
index f2f0b22..ea20aef 100644
--- a/file_handle.c
+++ b/file_handle.c
@@ -83,7 +83,7 @@ SYS_FUNC(name_to_handle_at)
                  tprintf(", handle_type=%d", h.handle_type);
                  if (h.handle_bytes > MAX_HANDLE_SZ)
                      h.handle_bytes = MAX_HANDLE_SZ;
-                if (!umoven(tcp, addr + sizeof(h), h.handle_bytes,
+                if (!backend.umoven(tcp, addr + sizeof(h), h.handle_bytes,
                          f_handle)) {
                      tprints(", f_handle=0x");
                      for (i = 0; i < h.handle_bytes; ++i)
@@ -120,7 +120,7 @@ SYS_FUNC(open_by_handle_at)
              h.handle_bytes, h.handle_type);
          if (h.handle_bytes > MAX_HANDLE_SZ)
              h.handle_bytes = MAX_HANDLE_SZ;
-        if (!umoven(tcp, addr + sizeof(h), h.handle_bytes, &f_handle)) {
+        if (!backend.umoven(tcp, addr + sizeof(h), h.handle_bytes, 
&f_handle)) {
              unsigned int i;

              tprints(", f_handle=0x");
diff --git a/ipc_shm.c b/ipc_shm.c
index c4bdb87..2c7906a 100644
--- a/ipc_shm.c
+++ b/ipc_shm.c
@@ -77,7 +77,7 @@ SYS_FUNC(shmat)
                  uint64_t r64;
                  uint32_t r32;
              } u;
-            if (umoven(tcp, tcp->u_arg[2], current_wordsize, &u) < 0)
+            if (backend.umoven(tcp, tcp->u_arg[2], current_wordsize, 
&u) < 0)
                  return RVAL_NONE;
              tcp->u_rval = (sizeof(u.r32) == current_wordsize)
                        ? u.r32 : u.r64;
diff --git a/linux/m68k/arch_sigreturn.c b/linux/m68k/arch_sigreturn.c
index b140268..b22a59f 100644
--- a/linux/m68k/arch_sigreturn.c
+++ b/linux/m68k/arch_sigreturn.c
@@ -14,7 +14,7 @@ arch_sigreturn(struct tcb *tcp)

      /* Fetch remaining words of signal mask, located immediately 
before.  */
      addr -= sizeof(mask) - sizeof(long);
-    if (umoven(tcp, addr, sizeof(mask) - sizeof(long), &mask[1]) < 0)
+    if (backend.umoven(tcp, addr, sizeof(mask) - sizeof(long), 
&mask[1]) < 0)
          return;

      tprintsigmask_addr("{mask=", mask);
diff --git a/linux/mips/get_syscall_args.c b/linux/mips/get_syscall_args.c
index ca2819b..30c54d7 100644
--- a/linux/mips/get_syscall_args.c
+++ b/linux/mips/get_syscall_args.c
@@ -15,7 +15,7 @@ get_syscall_args(struct tcb *tcp)
      tcp->u_arg[2] = mips_REG_A2;
      tcp->u_arg[3] = mips_REG_A3;
      if (tcp->s_ent->nargs > 4) {
-        if (umoven(tcp, mips_REG_SP + 4 * 4,
+        if (backend.umoven(tcp, mips_REG_SP + 4 * 4,
                 (tcp->s_ent->nargs - 4) * sizeof(tcp->u_arg[0]),
                 &tcp->u_arg[4]) < 0)
              return -1;
diff --git a/mem.c b/mem.c
index 40ed707..455bca6 100644
--- a/mem.c
+++ b/mem.c
@@ -275,7 +275,7 @@ SYS_FUNC(mincore)
          len = len / page_size + (len & page_mask ? 1 : 0);
          if (syserror(tcp) || !verbose(tcp) ||
              !tcp->u_arg[2] || !(vec = malloc(len)) ||
-            umoven(tcp, tcp->u_arg[2], len, vec) < 0)
+            backend.umoven(tcp, tcp->u_arg[2], len, vec) < 0)
              printaddr(tcp->u_arg[2]);
          else {
              unsigned long i;
diff --git a/msghdr.c b/msghdr.c
index 56ba549..f352871 100644
--- a/msghdr.c
+++ b/msghdr.c
@@ -269,7 +269,7 @@ decode_msg_control(struct tcb *const tcp, const 
kernel_ulong_t addr,
                     ? get_optmem_max() : in_control_len;
      unsigned int buf_len = control_len;
      char *buf = buf_len < cmsg_size ? NULL : malloc(buf_len);
-    if (!buf || umoven(tcp, addr, buf_len, buf) < 0) {
+    if (!buf || backend.umoven(tcp, addr, buf_len, buf) < 0) {
          printaddr(addr);
          free(buf);
          return;
diff --git a/pathtrace.c b/pathtrace.c
index 90974f4..6092a9e 100644
--- a/pathtrace.c
+++ b/pathtrace.c
@@ -58,7 +58,7 @@ upathmatch(struct tcb *const tcp, const kernel_ulong_t 
upath)
  {
      char path[PATH_MAX + 1];

-    return umovestr(tcp, upath, sizeof path, path) > 0 &&
+    return backend.umovestr(tcp, upath, sizeof path, path) > 0 &&
          pathmatch(path);
  }

@@ -69,7 +69,7 @@ static int
  fdmatch(struct tcb *tcp, int fd)
  {
      char path[PATH_MAX + 1];
-    int n = getfdpath(tcp, fd, path, sizeof(path));
+    int n = backend.getfdpath(tcp, fd, path, sizeof(path));

      return n >= 0 && pathmatch(path);
  }
@@ -290,7 +290,7 @@ pathtrace_match(struct tcb *tcp)
          for (i = 1; i <= 3; ++i) {
              if (args[i] == 0)
                  continue;
-            if (umoven(tcp, args[i], fdsize, fds) < 0) {
+            if (backend.umoven(tcp, args[i], fdsize, fds) < 0) {
                  continue;
              }
              for (j = 0;; j++) {
diff --git a/strace.c b/strace.c
index 4ee2d5d..ba3a297 100644
--- a/strace.c
+++ b/strace.c
@@ -157,7 +157,11 @@ unsigned os_release; /* generated from uname()'s 
u.release */
  static void detach(struct tcb *tcp);
  static void cleanup(void);
  static void interrupt(int sig);
+static bool trace (void);
  static sigset_t empty_set, blocked_set;
+int    umoven(struct tcb *const tcp, kernel_ulong_t addr, unsigned int len,
+        void *const our_addr);
+

  #ifdef HAVE_SIG_ATOMIC_T
  static volatile sig_atomic_t interrupted;
@@ -1132,6 +1136,11 @@ startup_attach(void)
          if (tcp->flags & TCB_ATTACHED)
              continue; /* no, we already attached it */

+        if (backend.startup_attach) {
+            backend.startup_attach(tcp);
+            continue;
+        }
+
          if (tcp->pid == parent_pid || tcp->pid == strace_tracer_pid) {
              errno = EPERM;
              perror_msg("attach: pid %d", tcp->pid);
@@ -1567,6 +1576,21 @@ get_os_release(void)
      return rel;
  }

+
+static bool
+prog_pid_check (char *exec_name, int nprocs)
+{
+    return exec_name || nprocs;
+}
+
+
+static bool
+handle_arg (char arg)
+{
+    return false;
+}
+
+
  /*
   * Initialization part of main() was eating much stack (~0.5k),
   * which was unused after init.
@@ -1584,6 +1608,23 @@ init(int argc, char *argv[])

      progname = argv[0] ? argv[0] : "strace";

+    backend.detach = detach;
+    backend.end_init = NULL;
+    backend.get_regs = NULL;
+    backend.get_scno = NULL;
+    backend.getfdpath = getfdpath;
+    backend.handle_arg = handle_arg;
+    backend.prog_pid_check = prog_pid_check;
+    backend.start_init = NULL;
+    backend.startup_attach = NULL;
+    backend.startup_child = startup_child;
+    backend.trace = trace;
+    backend.test_ptrace_seize = test_ptrace_seize;
+    backend.umoven = umoven;
+    backend.umovestr = umovestr;
+    backend.upeek_ = upeek;
+    backend.upoke_ = upoke;
+
      /* Make sure SIGCHLD has the default action so that waitpid
         definitely works without losing track of children.  The user
         should not have given us a bogus state to inherit, but he might
@@ -1730,7 +1771,8 @@ init(int argc, char *argv[])
                  error_opt_arg(c, optarg);
              break;
          default:
-            error_msg_and_help(NULL);
+            if (backend.handle_arg(c))
+                error_msg_and_help(NULL);
              break;
          }
      }
@@ -1741,7 +1783,7 @@ init(int argc, char *argv[])
      memset(acolumn_spaces, ' ', acolumn);
      acolumn_spaces[acolumn] = '\0';

-    if (!argv[0] && !nprocs) {
+    if (! backend.prog_pid_check(argv[0], nprocs)) {
          error_msg_and_help("must have PROG [ARGS] or -p PID");
      }

@@ -1752,6 +1794,9 @@ init(int argc, char *argv[])
      if (!followfork)
          followfork = optF;

+    if (backend.verify_args)
+        backend.verify_args(username, daemonized_tracer, &followfork);
+
      if (followfork >= 2 && cflag) {
          error_msg_and_help("(-c or -C) and -ff are mutually exclusive");
      }
@@ -1783,6 +1828,9 @@ init(int argc, char *argv[])
          tflag = 1;
      }

+    if (backend.start_init && backend.start_init() < 0)
+            error_msg_and_die("Cannot initialize backend on this target.");
+
  #ifdef USE_LIBUNWIND
      if (stack_trace_enabled) {
          unsigned int tcbi;
@@ -1819,7 +1867,7 @@ init(int argc, char *argv[])
                       PTRACE_O_TRACEVFORK;
      if (debug_flag)
          error_msg("ptrace_setoptions = %#x", ptrace_setoptions);
-    test_ptrace_seize();
+    backend.test_ptrace_seize();

      /*
       * Is something weird with our stdin and/or stdout -
@@ -1882,7 +1930,7 @@ init(int argc, char *argv[])
       * in the startup_child() mode we kill the spawned process anyway.
       */
      if (argv[0]) {
-        startup_child(argv);
+        backend.startup_child(argv);
      }

      sa.sa_handler = SIG_IGN;
@@ -1917,6 +1965,9 @@ init(int argc, char *argv[])
      if (nprocs != 0 || daemonized_tracer)
          startup_attach();

+    if (backend.end_init)
+        backend.end_init();
+
      /* Do we want pids printed in our -o OUTFILE?
       * -ff: no (every pid has its own file); or
       * -f: yes (there can be more pids in the future); or
@@ -1964,7 +2015,7 @@ cleanup(void)
              kill(tcp->pid, SIGCONT);
              kill(tcp->pid, fatal_sig);
          }
-        detach(tcp);
+        backend.detach(tcp);
      }
      if (cflag)
          call_summary(shared_log);
@@ -2325,7 +2376,7 @@ trace(void)
              if (tcp->flags & TCB_SKIP_DETACH_ON_FIRST_EXEC) {
                  tcp->flags &= ~TCB_SKIP_DETACH_ON_FIRST_EXEC;
              } else {
-                detach(tcp); /* do "-b execve" thingy */
+                backend.detach(tcp); /* do "-b execve" thingy */
                  return true;
              }
          }
@@ -2483,6 +2534,7 @@ restart_tracee:
      return true;
  }

+
  int
  main(int argc, char *argv[])
  {
@@ -2490,7 +2542,7 @@ main(int argc, char *argv[])

      exit_code = !nprocs;

-    while (trace())
+    while (backend.trace())
          ;

      cleanup();
diff --git a/syscall.c b/syscall.c
index 3e91880..9f041c4 100644
--- a/syscall.c
+++ b/syscall.c
@@ -365,7 +365,7 @@ decode_socket_subcall(struct tcb *tcp)
      const unsigned int nargs = sysent[scno].nargs;
      uint64_t buf[nargs];

-    if (umoven(tcp, tcp->u_arg[1], nargs * current_wordsize, buf) < 0)
+    if (backend.umoven(tcp, tcp->u_arg[1], nargs * current_wordsize, 
buf) < 0)
          return;

      tcp->scno = scno;
@@ -436,7 +436,7 @@ decode_mips_subcall(struct tcb *tcp)
       * see linux/mips/get_syscall_args.c
       */
      if (tcp->s_ent->nargs == MAX_ARGS) {
-        if (umoven(tcp,
+        if (backend.umoven(tcp,
                 mips_REG_SP + MAX_ARGS * sizeof(tcp->u_arg[0]),
                 sizeof(tcp->u_arg[0]),
                 &tcp->u_arg[MAX_ARGS - 1]) < 0)
@@ -1153,6 +1153,9 @@ ptrace_setregs(pid_t pid)
  static void
  get_regs(pid_t pid)
  {
+    if (backend.get_regs)
+        return backend.get_regs (pid);
+
  #undef USE_GET_SYSCALL_RESULT_REGS
  #ifdef ptrace_getregset_or_getregs

@@ -1230,7 +1233,11 @@ get_scno(struct tcb *tcp)
      if (get_regs_error)
          return -1;

-    int rc = arch_get_scno(tcp);
+    int rc;
+    if (backend.get_scno)
+        rc = backend.get_scno(tcp);
+    else
+        rc= arch_get_scno(tcp);
      if (rc != 1)
          return rc;

diff --git a/sysctl.c b/sysctl.c
index 3843693..22cb877 100644
--- a/sysctl.c
+++ b/sysctl.c
@@ -55,7 +55,7 @@ SYS_FUNC(sysctl)
      size = sizeof(int) * (unsigned long) info.nlen;
      name = (size / sizeof(int) != (unsigned long) info.nlen) ? NULL : 
malloc(size);
      if (name == NULL ||
-        umoven(tcp, (unsigned long) info.name, size, name) < 0) {
+        backend.umoven(tcp, (unsigned long) info.name, size, name) < 0) {
          free(name);
          if (entering(tcp))
              tprintf("{%p, %d, %p, %p, %p, %lu}",
diff --git a/sysmips.c b/sysmips.c
index af5ffba..17fc310 100644
--- a/sysmips.c
+++ b/sysmips.c
@@ -54,7 +54,7 @@ SYS_FUNC(sysmips)

          if (!verbose(tcp))
              break;
-        if (umovestr(tcp, tcp->u_arg[1], (__NEW_UTS_LEN + 1),
+        if (backend.umovestr(tcp, tcp->u_arg[1], (__NEW_UTS_LEN + 1),
                   nodename) < 0) {
              printaddr(tcp->u_arg[1]);
          } else {
diff --git a/upeek.c b/upeek.c
index 01a12d3..8f191c7 100644
--- a/upeek.c
+++ b/upeek.c
@@ -34,6 +34,8 @@
  #include "defs.h"
  #include "ptrace.h"

+#undef upeek
+
  int
  upeek(int pid, unsigned long off, kernel_ulong_t *res)
  {
diff --git a/upoke.c b/upoke.c
index dda0b8d..be4cea6 100644
--- a/upoke.c
+++ b/upoke.c
@@ -28,6 +28,8 @@
  #include "defs.h"
  #include "ptrace.h"

+#undef upoke
+
  int
  upoke(int pid, unsigned long off, kernel_ulong_t val)
  {
diff --git a/util.c b/util.c
index 9144efb..ca52411 100644
--- a/util.c
+++ b/util.c
@@ -597,7 +597,7 @@ void
  printfd(struct tcb *tcp, int fd)
  {
      char path[PATH_MAX + 1];
-    if (show_fd_path && getfdpath(tcp, fd, path, sizeof(path)) >= 0) {
+    if (show_fd_path && backend.getfdpath(tcp, fd, path, sizeof(path)) 
 >= 0) {
          static const char socket_prefix[] = "socket:[";
          const size_t socket_prefix_len = sizeof(socket_prefix) - 1;
          const size_t path_len = strlen(path);
@@ -855,7 +855,7 @@ printpathn(struct tcb *const tcp, const 
kernel_ulong_t addr, unsigned int n)
          n = sizeof path - 1;

      /* Fetch one byte more to find out whether path length > n. */
-    nul_seen = umovestr(tcp, addr, n + 1, path);
+    nul_seen = backend.umovestr(tcp, addr, n + 1, path);
      if (nul_seen < 0)
          printaddr(addr);
      else {
@@ -912,9 +912,9 @@ printstr_ex(struct tcb *const tcp, const 
kernel_ulong_t addr,
      if (size > len)
          size = len;
      if (style & QUOTE_0_TERMINATED)
-        rc = umovestr(tcp, addr, size, str);
+        rc = backend.umovestr(tcp, addr, size, str);
      else
-        rc = umoven(tcp, addr, size, str);
+        rc = backend.umoven(tcp, addr, size, str);

      if (rc < 0) {
          printaddr(addr);
@@ -971,7 +971,7 @@ dumpiov_upto(struct tcb *const tcp, const int len, 
const kernel_ulong_t addr,
          error_msg("Out of memory");
          return;
      }
-    if (umoven(tcp, addr, size, iov) >= 0) {
+    if (backend.umoven(tcp, addr, size, iov) >= 0) {
          for (i = 0; i < len; i++) {
              kernel_ulong_t iov_len = iov_iov_len(i);
              if (iov_len > data_size)
@@ -1021,7 +1021,7 @@ dumpstr(struct tcb *const tcp, const 
kernel_ulong_t addr, const int len)
          strsize = len + 16;
      }

-    if (umoven(tcp, addr, len, str) < 0)
+    if (backend.umoven(tcp, addr, len, str) < 0)
          return;

      /* Space-pad to 16 bytes */
@@ -1111,6 +1111,8 @@ vm_read_mem(const pid_t pid, void *const laddr,
   * move `len' bytes of data from process `pid'
   * at address `addr' to our space at `our_addr'
   */
+
+
  int
  umoven(struct tcb *const tcp, kernel_ulong_t addr, unsigned int len,
         void *const our_addr)
@@ -1221,12 +1223,13 @@ umoven(struct tcb *const tcp, kernel_ulong_t 
addr, unsigned int len,
      return 0;
  }

+
  int
  umoven_or_printaddr(struct tcb *const tcp, const kernel_ulong_t addr,
              const unsigned int len, void *const our_addr)
  {
      if (!addr || !verbose(tcp) || (exiting(tcp) && syserror(tcp)) ||
-        umoven(tcp, addr, len, our_addr) < 0) {
+        backend.umoven(tcp, addr, len, our_addr) < 0) {
          printaddr(addr);
          return -1;
      }
@@ -1239,7 +1242,7 @@ umoven_or_printaddr_ignore_syserror(struct tcb 
*const tcp,
                      const unsigned int len,
                      void *const our_addr)
  {
-    if (!addr || !verbose(tcp) || umoven(tcp, addr, len, our_addr) < 0) {
+    if (!addr || !verbose(tcp) || backend.umoven(tcp, addr, len, 
our_addr) < 0) {
          printaddr(addr);
          return -1;
      }





More information about the Strace-devel mailing list