summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <pedro@codesourcery.com>2008-08-18 22:35:16 +0000
committerPedro Alves <pedro@codesourcery.com>2008-08-18 22:35:16 +0000
commit4ea5edc9147e10b0a1716571facf177294f75a51 (patch)
tree7e1831aa6a22145db082d2fe566166a158b807f9
parent29f4dd7bf0e85c26b7702da5ecda035a27a96c9d (diff)
downloadgdb-4ea5edc9147e10b0a1716571facf177294f75a51.tar.gz
2008-08-18 Pedro Alves <pedro@codesourcery.com>
gdb/doc/ * observer.texi (thread_ptid_changed): New. gdb/ * gdbthread.h (thread_change_ptid): Declare. * infrun.c (infrun_thread_ptid_changed): New. (_initialize_infrun): Attach infrun_thread_ptid_changed to the thread_ptid_changed observer. * regcache.c (regcache_thread_ptid_changed): New. (_initialize_regcache): Attach regcache_thread_ptid_changed to the thread_ptid_changed observer. * thread.c (thread_change_ptid): New.
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/doc/ChangeLog4
-rw-r--r--gdb/doc/observer.texi4
-rw-r--r--gdb/gdbthread.h3
-rw-r--r--gdb/infrun.c26
-rw-r--r--gdb/regcache.c11
-rw-r--r--gdb/thread.c9
7 files changed, 68 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bf32587e2b8..e02205bc8e4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2008-08-18 Pedro Alves <pedro@codesourcery.com>
+
+ * gdbthread.h (thread_change_ptid): Declare.
+ * infrun.c (infrun_thread_ptid_changed): New.
+ (_initialize_infrun): Attach infrun_thread_ptid_changed to the
+ thread_ptid_changed observer.
+ * regcache.c (regcache_thread_ptid_changed): New.
+ (_initialize_regcache): Attach regcache_thread_ptid_changed to the
+ thread_ptid_changed observer.
+ * thread.c (thread_change_ptid): New.
+
2008-08-18 Tom Tromey <tromey@redhat.com>
* symfile.c (reread_symbols): Update.
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index cc8ef9be456..e048b90be25 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2008-08-18 Pedro Alves <pedro@codesourcery.com>
+
+ * observer.texi (thread_ptid_changed): New.
+
2008-08-18 Luis Machado <luisgpm@br.ibm.com>
* doc/gdb.texinfo (PowerPC): Mention Extended FPR's for POWER7.
diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index 8d1db1423c7..3e10c5f17bf 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -175,3 +175,7 @@ The current architecture has changed. The argument @var{newarch} is
a pointer to the new architecture.
@end deftypefun
+@deftypefun void thread_ptid_changed (ptid_t @var{old_ptid}, ptid_t @var{new_ptid})
+The thread's ptid has changed. The @var{old_ptid} parameter specifies
+the old value, and @var{new_ptid} specifies the new value.
+@end deftypefun
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 780ec251c76..6696017d0a0 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -151,6 +151,9 @@ extern struct thread_info *find_thread_pid (ptid_t ptid);
/* Find thread by GDB user-visible thread number. */
struct thread_info *find_thread_id (int num);
+/* Change the ptid of thread OLD_PTID to NEW_PTID. */
+void thread_change_ptid (ptid_t old_ptid, ptid_t new_ptid);
+
/* Iterator function to call a user-provided callback function
once for each known thread. */
typedef int (*thread_callback_func) (struct thread_info *, void *);
diff --git a/gdb/infrun.c b/gdb/infrun.c
index de7de790710..19b3229abc0 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -865,6 +865,30 @@ displaced_step_fixup (ptid_t event_ptid, enum target_signal signal)
}
}
+/* Update global variables holding ptids to hold NEW_PTID if they were
+ holding OLD_PTID. */
+static void
+infrun_thread_ptid_changed (ptid_t old_ptid, ptid_t new_ptid)
+{
+ struct displaced_step_request *it;
+
+ if (ptid_equal (inferior_ptid, old_ptid))
+ inferior_ptid = new_ptid;
+
+ if (ptid_equal (singlestep_ptid, old_ptid))
+ singlestep_ptid = new_ptid;
+
+ if (ptid_equal (displaced_step_ptid, old_ptid))
+ displaced_step_ptid = new_ptid;
+
+ if (ptid_equal (deferred_step_ptid, old_ptid))
+ deferred_step_ptid = new_ptid;
+
+ for (it = displaced_step_request_queue; it; it = it->next)
+ if (ptid_equal (it->ptid, old_ptid))
+ it->ptid = new_ptid;
+}
+
/* Resuming. */
@@ -4855,4 +4879,6 @@ breakpoints, even if such is supported by the target."),
inferior_ptid = null_ptid;
target_last_wait_ptid = minus_one_ptid;
displaced_step_ptid = null_ptid;
+
+ observer_attach_thread_ptid_changed (infrun_thread_ptid_changed);
}
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 199b626a1a7..616a6f71817 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -453,6 +453,16 @@ regcache_observer_target_changed (struct target_ops *target)
registers_changed ();
}
+/* Update global variables old ptids to hold NEW_PTID if they were
+ holding OLD_PTID. */
+static void
+regcache_thread_ptid_changed (ptid_t old_ptid, ptid_t new_ptid)
+{
+ if (current_regcache != NULL
+ && ptid_equal (current_regcache->ptid, old_ptid))
+ current_regcache->ptid = new_ptid;
+}
+
/* Low level examining and depositing of registers.
The caller is responsible for making sure that the inferior is
@@ -1134,6 +1144,7 @@ _initialize_regcache (void)
regcache_descr_handle = gdbarch_data_register_post_init (init_regcache_descr);
observer_attach_target_changed (regcache_observer_target_changed);
+ observer_attach_thread_ptid_changed (regcache_thread_ptid_changed);
add_com ("flushregs", class_maintenance, reg_flush_command,
_("Force gdb to flush its register cache (maintainer command)"));
diff --git a/gdb/thread.c b/gdb/thread.c
index f90606ce690..15da5b6239e 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -589,6 +589,15 @@ prune_threads (void)
}
void
+thread_change_ptid (ptid_t old_ptid, ptid_t new_ptid)
+{
+ struct thread_info * tp = find_thread_pid (old_ptid);
+ tp->ptid = new_ptid;
+
+ observer_notify_thread_ptid_changed (old_ptid, new_ptid);
+}
+
+void
set_running (ptid_t ptid, int running)
{
struct thread_info *tp;