]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdbserver:prepare_access_memory: pick another thread
authorPedro Alves <palves@redhat.com>
Mon, 30 Nov 2015 16:05:26 +0000 (16:05 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 30 Nov 2015 18:44:51 +0000 (18:44 +0000)
commita67a9faef0e32886c83611cc7a0ba61e91123063
tree77dcebf790baccc6f857afc13da9ee36ada47a76
parentf2faf941ae49653ff6e1485adfee299313d47c91
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.
gdb/gdbserver/ChangeLog
gdb/gdbserver/mem-break.c
gdb/gdbserver/target.c
gdb/gdbserver/target.h