Add a common utility function to read and write siginfo_t in inferior
authorKamil Rytarowski <n54@gmx.com>
Wed, 2 Sep 2020 17:21:19 +0000 (19:21 +0200)
committerKamil Rytarowski <n54@gmx.com>
Thu, 10 Sep 2020 13:38:57 +0000 (15:38 +0200)
gdb/ChangeLog:

        * netbsd-nat.h (netbsd_nat::qxfer_siginfo): Add.
        * netbsd-nat.c (netbsd_nat::qxfer_siginfo): Likewise.

gdb/ChangeLog
gdb/nat/netbsd-nat.c
gdb/nat/netbsd-nat.h

index 41bd6998bb96a3f69ec87c43fd305ae7b2556794..ecf8e37f58b9995d54eccde0496fcb33f30cc14e 100644 (file)
@@ -1,3 +1,8 @@
+2020-09-10  Kamil Rytarowski  <n54@gmx.com>
+
+       * netbsd-nat.h (netbsd_nat::qxfer_siginfo): Add.
+       * netbsd-nat.c (netbsd_nat::qxfer_siginfo): Likewise.
+
 2020-09-10  Kamil Rytarowski  <n54@gmx.com>
 
        * netbsd-nat.h (netbsd_nat::enable_proc_events): Add.
index d805b892404e2d3dc0e67bd9573bcad8cc96c523..41b67cb72fcff49f29abccd24ad6ae4e88f6e119 100644 (file)
@@ -181,4 +181,33 @@ enable_proc_events (pid_t pid)
     perror_with_name (("ptrace"));
 }
 
+/* See netbsd-nat.h.  */
+
+int
+qxfer_siginfo (pid_t pid, const char *annex, unsigned char *readbuf,
+              unsigned const char *writebuf, CORE_ADDR offset, int len)
+{
+  ptrace_siginfo_t psi;
+
+  if (offset > sizeof (siginfo_t))
+    return -1;
+
+  if (ptrace (PT_GET_SIGINFO, pid, &psi, sizeof (psi)) == -1)
+    return -1;
+
+  if (offset + len > sizeof (siginfo_t))
+    len = sizeof (siginfo_t) - offset;
+
+  if (readbuf != NULL)
+    memcpy (readbuf, ((gdb_byte *) &psi.psi_siginfo) + offset, len);
+  else
+    {
+      memcpy (((gdb_byte *) &psi.psi_siginfo) + offset, writebuf, len);
+
+      if (ptrace (PT_SET_SIGINFO, pid, &psi, sizeof (psi)) == -1)
+       return -1;
+    }
+  return len;
+}
+
 }
index 6472cc56da41dcd84696ab87cc2b5bc98c315f22..d77119bb86237be0f6ae49a3b65bb3cf4240cb2f 100644 (file)
@@ -57,6 +57,16 @@ extern void for_each_thread (pid_t pid,
    traced.  */
 
 extern void enable_proc_events (pid_t pid);
+
+/* Implement reading and writing of inferior's siginfo_t specified by PID.
+   Returns -1 on failure and the number of bytes on a successful transfer.
+
+   This function assumes internally that the queried process is stopped and
+   traced.  */
+
+extern int qxfer_siginfo (pid_t pid, const char *annex, unsigned char *readbuf,
+                         unsigned const char *writebuf, CORE_ADDR offset,
+                         int len);
 }
 
 #endif
This page took 0.031736 seconds and 4 git commands to generate.