From patchwork Mon Sep 1 16:29:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 2618 X-Patchwork-Delegate: macro@orcam.me.uk Received: (qmail 4931 invoked by alias); 1 Sep 2014 16:31:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 4912 invoked by uid 89); 1 Sep 2014 16:31:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 01 Sep 2014 16:31:01 +0000 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id 31B6883CAE158 for ; Mon, 1 Sep 2014 17:30:54 +0100 (IST) Received: from LEMAIL01.le.imgtec.org (192.168.152.62) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 1 Sep 2014 17:30:57 +0100 Received: from jhogan-linux.le.imgtec.org (192.168.154.101) by LEMAIL01.le.imgtec.org (192.168.152.62) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 1 Sep 2014 17:30:56 +0100 From: James Hogan To: CC: James Hogan Subject: [PATCH] Reset errno before PTRACE_PEEKUSER for MIPS DSP_CONTROL Date: Mon, 1 Sep 2014 17:29:56 +0100 Message-ID: <1409588996-14779-1-git-send-email-james.hogan@imgtec.com> MIME-Version: 1.0 X-IsSubscribed: yes 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/ChangeLog | 5 +++++ gdb/gdbserver/ChangeLog | 5 +++++ gdb/gdbserver/linux-mips-low.c | 1 + gdb/mips-linux-nat.c | 1 + 4 files changed, 12 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8963878eb8ca..e4004d96cac8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-09-01 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-01 Maciej W. Rozycki * varobj.c (_initialize_varobj): Move to the end of file. diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index caa243da5d7d..2d292b92875f 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2014-09-01 James Hogan + + * linux-mips-low.c (mips_read_description): Reset errno to 0 prior to + reading DSP_CONTROL with PTRACE_PEEKUSER ptrace call. + 2014-08-29 Gary Benson * server.h (setjmp.h): Do not include. diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c index 1b2160b35371..377284be5422 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 88faa1edf692..ffc8411ca3bc 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) {