+2017-09-29 Pedro Alves <palves@redhat.com>
+
+ * linux-low.c (handle_extended_wait): Pass parent thread instead
+ of process to thread_db_notice_clone.
+ * linux-low.h (thread_db_notice_clone): Replace parent process
+ parameter with parent thread parameter.
+ * thread-db.c (find_one_thread): Add comment.
+ (thread_db_notice_clone): Replace parent process parameter with
+ parent thread parameter. Temporarily switch to the parent thread.
+
2017-09-26 Sergio Durigan Junior <sergiodj@redhat.com>
* gdbthread.h: Include "common-gdbthread.h".
new_lwp->status_pending = status;
}
- thread_db_notice_clone (get_thread_process (event_thr), ptid);
+ thread_db_notice_clone (event_thr, ptid);
/* Don't report the event. */
return 1;
both the clone and the parent should be stopped. This function does
whatever is required have the clone under thread_db's control. */
-void thread_db_notice_clone (struct process_info *proc, ptid_t lwp);
+void thread_db_notice_clone (struct thread_info *parent_thr, ptid_t child_ptid);
bool thread_db_thread_handle (ptid_t ptid, gdb_byte **handle, int *handle_len);
#include "nat/gdb_thread_db.h"
#include "gdb_vecs.h"
#include "nat/linux-procfs.h"
+#include "common/scoped_restore.h"
#ifndef USE_LIBTHREAD_DB_DIRECTLY
#include <dlfcn.h>
}
#endif
+/* Get thread info about PTID, accessing memory via the current
+ thread. */
+
static int
find_one_thread (ptid_t ptid)
{
/* See linux-low.h. */
void
-thread_db_notice_clone (struct process_info *proc, ptid_t ptid)
+thread_db_notice_clone (struct thread_info *parent_thr, ptid_t child_ptid)
{
- struct thread_db *thread_db = proc->priv->thread_db;
+ process_info *parent_proc = get_thread_process (parent_thr);
+ struct thread_db *thread_db = parent_proc->priv->thread_db;
/* If the thread layer isn't initialized, return. It may just
be that the program uses clone, but does not use libthread_db. */
if (thread_db == NULL || !thread_db->all_symbols_looked_up)
return;
- if (!find_one_thread (ptid))
+ /* find_one_thread calls into libthread_db which accesses memory via
+ the current thread. Temporarily switch to a thread we know is
+ stopped. */
+ scoped_restore restore_current_thread
+ = make_scoped_restore (¤t_thread, parent_thr);
+
+ if (!find_one_thread (child_ptid))
warning ("Cannot find thread after clone.\n");
}