Reset errno before PTRACE_PEEKUSER for MIPS DSP_CONTROL
authorJames Hogan <james.hogan@imgtec.com>
Mon, 1 Sep 2014 21:48:40 +0000 (22:48 +0100)
committerMaciej W. Rozycki <macro@codesourcery.com>
Wed, 3 Sep 2014 21:09:10 +0000 (22:09 +0100)
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
gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-mips-low.c
gdb/mips-linux-nat.c

index d4166233495dc2bc592fa14d2e1b3f9a5f0df9bb..ad1a87b78214d87b1309e0dd809f307a11162589 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-03  James Hogan  <james.hogan@imgtec.com>
+
+       * 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  <sergiodj@redhat.com>
 
        PR python/16699
index a47ef49229336ea10f7e3f1621c703921f2e696a..3fb143c2cb3ab126ab94afaef0dc8d677f6fb226 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-03  James Hogan  <james.hogan@imgtec.com>
+
+       * 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  <gbenson@redhat.com>
 
        * linux-x86-low.c (x86_linux_prepare_to_resume): Use
index 1b2160b35371cbec05818d3494299061f1436fac..377284be5422d0d2d9ed2601f725088331a4d916 100644 (file)
@@ -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)
        {
index 88faa1edf69200c9353e5914ea090aa2922c00f8..ffc8411ca3bcc3cf7f67c4031353ff35b4085da2 100644 (file)
@@ -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)
        {
This page took 0.037516 seconds and 4 git commands to generate.