aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat
diff options
context:
space:
mode:
authorKamil Rytarowski <n54@gmx.com>2020-09-02 19:21:19 +0200
committerKamil Rytarowski <n54@gmx.com>2020-09-10 15:38:57 +0200
commit1ccb2c170cea50671f7aa00eb6a2be2a33ea24a5 (patch)
tree77a08db565b1ddc3f1dcf7c0ca893d329e9b5e33 /gdb/nat
parentfeedfcc77379667e4af19e266abc00072e2d262d (diff)
downloadbinutils-1ccb2c170cea50671f7aa00eb6a2be2a33ea24a5.zip
binutils-1ccb2c170cea50671f7aa00eb6a2be2a33ea24a5.tar.gz
binutils-1ccb2c170cea50671f7aa00eb6a2be2a33ea24a5.tar.bz2
Add a common utility function to read and write siginfo_t in inferior
gdb/ChangeLog: * netbsd-nat.h (netbsd_nat::qxfer_siginfo): Add. * netbsd-nat.c (netbsd_nat::qxfer_siginfo): Likewise.
Diffstat (limited to 'gdb/nat')
-rw-r--r--gdb/nat/netbsd-nat.c29
-rw-r--r--gdb/nat/netbsd-nat.h10
2 files changed, 39 insertions, 0 deletions
diff --git a/gdb/nat/netbsd-nat.c b/gdb/nat/netbsd-nat.c
index d805b89..41b67cb 100644
--- a/gdb/nat/netbsd-nat.c
+++ b/gdb/nat/netbsd-nat.c
@@ -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;
+}
+
}
diff --git a/gdb/nat/netbsd-nat.h b/gdb/nat/netbsd-nat.h
index 6472cc5..d77119b 100644
--- a/gdb/nat/netbsd-nat.h
+++ b/gdb/nat/netbsd-nat.h
@@ -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