aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/mem-break.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-11-30 16:05:26 +0000
committerPedro Alves <palves@redhat.com>2015-11-30 18:44:51 +0000
commita67a9faef0e32886c83611cc7a0ba61e91123063 (patch)
tree77dcebf790baccc6f857afc13da9ee36ada47a76 /gdb/gdbserver/mem-break.c
parentf2faf941ae49653ff6e1485adfee299313d47c91 (diff)
downloadgdb-a67a9faef0e32886c83611cc7a0ba61e91123063.zip
gdb-a67a9faef0e32886c83611cc7a0ba61e91123063.tar.gz
gdb-a67a9faef0e32886c83611cc7a0ba61e91123063.tar.bz2
gdbserver:prepare_access_memory: pick another thread
Say GDB wants to access the inferior process's memory. The current remote general thread is 3, but GDB's switched to thread 2. Because both threads are of the same process, GDB skips making the remote thread be thread 2 as well (sending an Hg packet) before accessing memory (remote.c:set_general_process). However, if thread 3 has exited meanwhile, thread 3 no longer exists on the server and gdbserver points current_thread to NULL. The result is the memory access fails, even through the process still exists. Fix this by making prepare_to_access memory select the thread to access memory through. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * mem-break.c (check_gdb_bp_preconditions): Remove current_thread check. (set_gdb_breakpoint): If prepare_to_access_memory fails, set *ERR to -1. * target.c (struct thread_search): New structure. (thread_search_callback): New function. (prev_general_thread): New global. (prepare_to_access_memory, done_accessing_memory): New functions. * target.h (prepare_to_access_memory, done_accessing_memory): Replace macros with function declarations.
Diffstat (limited to 'gdb/gdbserver/mem-break.c')
-rw-r--r--gdb/gdbserver/mem-break.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c
index c808a84..11c21db 100644
--- a/gdb/gdbserver/mem-break.c
+++ b/gdb/gdbserver/mem-break.c
@@ -1023,13 +1023,8 @@ check_gdb_bp_preconditions (char z_type, int *err)
*err = 1;
return 0;
}
- else if (current_thread == NULL)
- {
- *err = -1;
- return 0;
- }
- else
- return 1;
+
+ return 1;
}
/* See mem-break.h. This is a wrapper for set_gdb_breakpoint_1 that
@@ -1047,9 +1042,11 @@ set_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind, int *err)
access memory. */
if (z_type == Z_PACKET_SW_BP)
{
- *err = prepare_to_access_memory ();
- if (*err != 0)
- return NULL;
+ if (prepare_to_access_memory () != 0)
+ {
+ *err = -1;
+ return NULL;
+ }
}
bp = set_gdb_breakpoint_1 (z_type, addr, kind, err);