aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
diff options
context:
space:
mode:
authorKamil Rytarowski <n54@gmx.com>2020-10-07 05:57:52 +0200
committerKamil Rytarowski <n54@gmx.com>2020-10-07 14:52:25 +0200
commit91e5e8db334b9a87c54f03982dfa0c88e3c9d7a1 (patch)
treea46f4667d6dd8c4b099d0c06b9884c39d9c1bb56 /gdbserver
parent9529c852664bbfc64f3ccda6abd81fc1aced6f16 (diff)
downloadfsf-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 'gdbserver')
-rw-r--r--gdbserver/ChangeLog5
-rw-r--r--gdbserver/netbsd-low.cc61
2 files changed, 7 insertions, 59 deletions
diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog
index 1571719..1709f3f 100644
--- a/gdbserver/ChangeLog
+++ b/gdbserver/ChangeLog
@@ -1,5 +1,10 @@
2020-10-07 Kamil Rytarowski <n54@gmx.com>
+ * netbsd-low.cc (netbsd_process_target::read_memory)
+ (netbsd_process_target::write_memory): Update.
+
+2020-10-07 Kamil Rytarowski <n54@gmx.com>
+
* netbsd-aarch64-low.cc: Add.
* Makefile.in (SFILES): Register "netbsd-aarch64-low.c".
* configure.srv: Add aarch64*-*-netbsd*.
diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc
index 7bec55a..e5ea823 100644
--- a/gdbserver/netbsd-low.cc
+++ b/gdbserver/netbsd-low.cc
@@ -556,36 +556,8 @@ int
netbsd_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
int size)
{
- struct ptrace_io_desc io;
- io.piod_op = PIOD_READ_D;
- io.piod_len = size;
-
pid_t pid = current_process ()->pid;
-
- int bytes_read = 0;
-
- if (size == 0)
- {
- /* Zero length write always succeeds. */
- return 0;
- }
- do
- {
- io.piod_offs = (void *)(memaddr + bytes_read);
- io.piod_addr = myaddr + bytes_read;
-
- int rv = ptrace (PT_IO, pid, &io, 0);
- if (rv == -1)
- return errno;
- if (io.piod_len == 0)
- return 0;
-
- bytes_read += io.piod_len;
- io.piod_len = size - bytes_read;
- }
- while (bytes_read < size);
-
- return 0;
+ return netbsd_nat::read_memory (pid, myaddr, memaddr, size, nullptr);
}
/* Implement the write_memory target_ops method. */
@@ -594,37 +566,8 @@ int
netbsd_process_target::write_memory (CORE_ADDR memaddr,
const unsigned char *myaddr, int size)
{
- struct ptrace_io_desc io;
- io.piod_op = PIOD_WRITE_D;
- io.piod_len = size;
-
pid_t pid = current_process ()->pid;
-
- int bytes_written = 0;
-
- if (size == 0)
- {
- /* Zero length write always succeeds. */
- return 0;
- }
-
- do
- {
- io.piod_addr = (void *)(myaddr + bytes_written);
- io.piod_offs = (void *)(memaddr + bytes_written);
-
- int rv = ptrace (PT_IO, pid, &io, 0);
- if (rv == -1)
- return errno;
- if (io.piod_len == 0)
- return 0;
-
- bytes_written += io.piod_len;
- io.piod_len = size - bytes_written;
- }
- while (bytes_written < size);
-
- return 0;
+ return netbsd_nat::write_memory (pid, myaddr, memaddr, size, nullptr);
}
/* Implement the request_interrupt target_ops method. */