From ac740bc7a9103a561329ebf7aa05ff31bcab2267 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Mon, 1 Sep 2014 22:48:40 +0100 Subject: Reset errno before PTRACE_PEEKUSER for MIPS DSP_CONTROL PTRACE_PEEKUSER can return -1, which is usually used to determine whether a system call has reported an error, so errno must be used alone to determine whether an error occurred. However errno isn't modified by a successful system call so it must be reset to a known value (0) before the syscall call. Add the missing errno reset when reading the DSP_CONTROL register in the native MIPS Linux backend and the MIPS gdbserver backend. gdb/: * mips-linux-nat.c (mips_linux_read_description): Reset errno to 0 prior to reading DSP_CONTROL with PTRACE_PEEKUSER ptrace call. gdb/gdbserver/: * linux-mips-low.c (mips_read_description): Reset errno to 0 prior to reading DSP_CONTROL with PTRACE_PEEKUSER ptrace call. --- gdb/mips-linux-nat.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gdb/mips-linux-nat.c') diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c index 88faa1e..ffc8411 100644 --- a/gdb/mips-linux-nat.c +++ b/gdb/mips-linux-nat.c @@ -439,6 +439,7 @@ mips_linux_read_description (struct target_ops *ops) if (tid == 0) tid = ptid_get_pid (inferior_ptid); + errno = 0; ptrace (PTRACE_PEEKUSER, tid, DSP_CONTROL, 0); switch (errno) { -- cgit v1.1