gdbserver/libthread_db: Don't ignore memory reading failures
authorPedro Alves <palves@redhat.com>
Fri, 29 Sep 2017 11:33:41 +0000 (12:33 +0100)
committerPedro Alves <palves@redhat.com>
Fri, 29 Sep 2017 12:10:39 +0000 (13:10 +0100)
If we had this in place before, then the regression fixed by the
previous commit would have been been visible is all test runs.  E.g.:

  Running src/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp ...
  FAIL: gdb.threads/multi-create-ns-info-thr.exp: continue to breakpoint 6

Debugging manually we'd see this:
  gdbserver: Cannot get thread handle for LWP 1467: generic error

Instead of:
  gdbserver: PID mismatch!  Expected 27472, got 27471

which is misleading - gdbserver didn't 27471, that was stale stack
data from previous function invocations.

gdb/gdbserver/ChangeLog:
2017-09-29  Pedro Alves  <palves@redhat.com>

* proc-service.c (ps_pdread): Return PS_ERR if reading memory
fails.

gdb/gdbserver/ChangeLog
gdb/gdbserver/proc-service.c

index f27451da2f9b3301eb3f4ba044bdfdb5ef41d46f..0dbcae266224a23db47af8c5fc9c6d7941f90d35 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-29  Pedro Alves  <palves@redhat.com>
+
+       * proc-service.c (ps_pdread): Return PS_ERR if reading memory
+       fails.
+
 2017-09-29  Pedro Alves  <palves@redhat.com>
 
        * linux-low.c (handle_extended_wait): Pass parent thread instead
index 98d6acda0a9f9bc20e608ed7cbe48f6c98abfb8e..5b058fdeb09f16f748f10f4d0c4a8a11e7f4e3cf 100644 (file)
@@ -80,7 +80,8 @@ ps_err_e
 ps_pdread (gdb_ps_prochandle_t ph, psaddr_t addr,
           gdb_ps_read_buf_t buf, gdb_ps_size_t size)
 {
-  read_inferior_memory ((uintptr_t) addr, (gdb_byte *) buf, size);
+  if (read_inferior_memory ((uintptr_t) addr, (gdb_byte *) buf, size) != 0)
+    return PS_ERR;
   return PS_OK;
 }