aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/target.h
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/target.h
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/target.h')
-rw-r--r--gdb/gdbserver/target.h14
1 files changed, 4 insertions, 10 deletions
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index 8903da5..a09ba2f 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -651,17 +651,11 @@ int start_non_stop (int nonstop);
ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
int connected_wait);
-#define prepare_to_access_memory() \
- (the_target->prepare_to_access_memory \
- ? (*the_target->prepare_to_access_memory) () \
- : 0)
+/* Prepare to read or write memory from the inferior process. See the
+ corresponding target_ops methods for more details. */
-#define done_accessing_memory() \
- do \
- { \
- if (the_target->done_accessing_memory) \
- (*the_target->done_accessing_memory) (); \
- } while (0)
+int prepare_to_access_memory (void);
+void done_accessing_memory (void);
#define target_core_of_thread(ptid) \
(the_target->core_of_thread ? (*the_target->core_of_thread) (ptid) \