From: James Hogan Date: Mon, 1 Sep 2014 21:48:40 +0000 (+0100) Subject: Reset errno before PTRACE_PEEKUSER for MIPS DSP_CONTROL X-Git-Tag: binutils-2_25~415 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ac740bc7a9103a561329ebf7aa05ff31bcab2267;p=external%2Fbinutils.git 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d416623..ad1a87b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-09-03 James Hogan + + * mips-linux-nat.c (mips_linux_read_description): Reset errno to 0 + prior to reading DSP_CONTROL with PTRACE_PEEKUSER ptrace call. + 2014-09-03 Sergio Durigan Junior PR python/16699 diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index a47ef49..3fb143c 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2014-09-03 James Hogan + + * linux-mips-low.c (mips_read_description): Reset errno to 0 prior + to reading DSP_CONTROL with PTRACE_PEEKUSER ptrace call. + 2014-09-03 Gary Benson * linux-x86-low.c (x86_linux_prepare_to_resume): Use diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c index 1b2160b..377284b 100644 --- a/gdb/gdbserver/linux-mips-low.c +++ b/gdb/gdbserver/linux-mips-low.c @@ -128,6 +128,7 @@ mips_read_description (void) { int pid = lwpid_of (current_inferior); + errno = 0; ptrace (PTRACE_PEEKUSER, pid, DSP_CONTROL, 0); switch (errno) { 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) {