2008-08-18 Pedro Alves <pedro@codesourcery.com>
authorPedro Alves <palves@redhat.com>
Mon, 18 Aug 2008 22:35:17 +0000 (22:35 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 18 Aug 2008 22:35:17 +0000 (22:35 +0000)
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.

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/observer.texi
gdb/gdbthread.h
gdb/infrun.c
gdb/regcache.c
gdb/thread.c

index bf32587e2b84466ba08208337e66c97da862a18f..e02205bc8e4025783b08bbefaa9d0255ca7f07d6 100644 (file)
@@ -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.
index cc8ef9be4561b868e646a9f801ac9fcf97797891..e048b90be25fbc09dba18498a7fe86d2e3f1d9e2 100644 (file)
@@ -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.
index 8d1db1423c7b653b0b3007883879a3db684ab9a9..3e10c5f17bf4a03528a05e9172d1867ae7563a4c 100644 (file)
@@ -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
index 780ec251c76310477e869bc5b74397061f8c99a7..6696017d0a02d623594c2ec8365920bb1a641465 100644 (file)
@@ -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 *);
index de7de790710ce92e43372dc245e07ac1be8932ee..19b3229abc07f2c452b658c132cdda0a51b0e2c6 100644 (file)
@@ -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;
+}
+
 \f
 /* 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);
 }
index 199b626a1a722f500cd97997d802b18e3277dbf6..616a6f71817f786f745cdae148b340693b4674fa 100644 (file)
@@ -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)"));
index f90606ce6904c6bc266f0c68520827a30050f695..15da5b6239e8580d2a60686d82ba17f79f65d10b 100644 (file)
@@ -588,6 +588,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)
 {
This page took 0.057343 seconds and 4 git commands to generate.