From patchwork Mon Sep 1 21:48:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 2620 X-Patchwork-Delegate: macro@orcam.me.uk Received: (qmail 21822 invoked by alias); 1 Sep 2014 21:48:57 -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 21805 invoked by uid 89); 1 Sep 2014 21:48:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 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 21:48:55 +0000 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id 10BE17EBA53A6; Mon, 1 Sep 2014 22:48:49 +0100 (IST) Received: from KLMAIL02.kl.imgtec.org (10.40.60.222) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 1 Sep 2014 22:48:52 +0100 Received: from LEMAIL01.le.imgtec.org (192.168.152.62) by klmail02.kl.imgtec.org (10.40.60.222) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 1 Sep 2014 22:48:52 +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 22:48:51 +0100 From: James Hogan To: CC: "Maciej W. Rozycki" , James Hogan Subject: [PATCH v2] Reset errno before PTRACE_PEEKUSER for MIPS DSP_CONTROL Date: Mon, 1 Sep 2014 22:48:40 +0100 Message-ID: <1409608120-23991-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. --- Changes in v2: - Wrap ChangeLog entries to 74 columns (Maciej W. Rozycki). --- 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..e9e3f9e734e6 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..2fa9ec74c08a 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) {