diff options
author | Kamil Rytarowski <n54@gmx.com> | 2020-10-07 05:57:52 +0200 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2020-10-07 14:52:25 +0200 |
commit | 91e5e8db334b9a87c54f03982dfa0c88e3c9d7a1 (patch) | |
tree | a46f4667d6dd8c4b099d0c06b9884c39d9c1bb56 /gdb/nbsd-nat.c | |
parent | 9529c852664bbfc64f3ccda6abd81fc1aced6f16 (diff) | |
download | fsf-binutils-gdb-91e5e8db334b9a87c54f03982dfa0c88e3c9d7a1.zip fsf-binutils-gdb-91e5e8db334b9a87c54f03982dfa0c88e3c9d7a1.tar.gz fsf-binutils-gdb-91e5e8db334b9a87c54f03982dfa0c88e3c9d7a1.tar.bz2 |
Add common write_memory and read_memory NetBSD routines
Instead of sharing the native-only code with all BSDs with slightly
different semantics of the kernels, share the NetBSD-only behavior beteen
the NetBSD native and gdbserver setup.
NetBSD does not differentiate the address space I and D in the
operations (contrary to OpenBSD). NetBSD handles EACCES that integrates
with NetBSD specific PaX MPROTECT error handling.
Add a verbose message in the native client that an operation could be
cancelled due to PaX MPROTECT setup.
gdb/ChangeLog:
* nat/netbsd-nat.c (write_memory, read_memory): Add.
* nat/netbsd-nat.h (write_memory, read_memory): Likewise.
* nbsd-nat.c (nbsd_nat_target::xfer_partial): Update.
gdbserver/ChangeLog:
* netbsd-low.cc (netbsd_process_target::read_memory)
(netbsd_process_target::write_memory): Update.
Diffstat (limited to 'gdb/nbsd-nat.c')
-rw-r--r-- | gdb/nbsd-nat.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c index 7a07fbf..46dcfac 100644 --- a/gdb/nbsd-nat.c +++ b/gdb/nbsd-nat.c @@ -764,6 +764,29 @@ nbsd_nat_target::xfer_partial (enum target_object object, *xfered_len = len; return TARGET_XFER_OK; } + case TARGET_OBJECT_MEMORY: + { + size_t xfered; + int res; + if (writebuf != nullptr) + res = netbsd_nat::write_memory (pid, writebuf, offset, len, &xfered); + else + res = netbsd_nat::read_memory (pid, readbuf, offset, len, &xfered); + if (res != 0) + { + if (res == EACCES) + fprintf_unfiltered (gdb_stderr, "Cannot %s process at %s (%s). " + "Is PaX MPROTECT active? See security(7), " + "sysctl(7), paxctl(8)\n", + (writebuf ? "write to" : "read from"), + pulongest (offset), safe_strerror (errno)); + return TARGET_XFER_E_IO; + } + if (xfered == 0) + return TARGET_XFER_EOF; + *xfered_len = (ULONGEST) xfered; + return TARGET_XFER_OK; + } default: return inf_ptrace_target::xfer_partial (object, annex, readbuf, writebuf, offset, |