From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: Re: [1/7] Register the main thread/task in fork-child.c
Date: Mon, 18 Aug 2008 22:41:00 -0000 [thread overview]
Message-ID: <200808182341.38872.pedro@codesourcery.com> (raw)
In-Reply-To: <200808082145.m78LjqWQ012096@brahms.sibelius.xs4all.nl>
[-- Attachment #1: Type: text/plain, Size: 374 bytes --]
On Friday 08 August 2008 22:45:52, Mark Kettenis wrote:
> The observer makes sense to me too. So the overall answer is yes!
Thanks!
I took the liberty of splitting this patch in two, as there
are other patches that are ready to be checked in, that
depended on thread_change_ptid, but which do not depend on
fork-child.c.
Attached is what I checked in.
--
Pedro Alves
[-- Attachment #2: thread_change_ptid.diff --]
[-- Type: text/x-diff, Size: 4944 bytes --]
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.
---
gdb/doc/observer.texi | 4 ++++
gdb/gdbthread.h | 3 +++
gdb/infrun.c | 26 ++++++++++++++++++++++++++
gdb/regcache.c | 11 +++++++++++
gdb/thread.c | 9 +++++++++
5 files changed, 53 insertions(+)
Index: src/gdb/doc/observer.texi
===================================================================
--- src.orig/gdb/doc/observer.texi 2008-08-18 23:19:58.000000000 +0100
+++ src/gdb/doc/observer.texi 2008-08-18 23:20:13.000000000 +0100
@@ -175,3 +175,7 @@ The current architecture has changed. T
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: src/gdb/gdbthread.h
===================================================================
--- src.orig/gdb/gdbthread.h 2008-08-18 23:19:58.000000000 +0100
+++ src/gdb/gdbthread.h 2008-08-18 23:20:13.000000000 +0100
@@ -151,6 +151,9 @@ extern struct thread_info *find_thread_p
/* 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: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c 2008-08-18 23:19:58.000000000 +0100
+++ src/gdb/infrun.c 2008-08-18 23:22:04.000000000 +0100
@@ -865,6 +865,30 @@ displaced_step_fixup (ptid_t event_ptid,
}
}
+/* 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 b
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: src/gdb/regcache.c
===================================================================
--- src.orig/gdb/regcache.c 2008-08-18 23:19:58.000000000 +0100
+++ src/gdb/regcache.c 2008-08-18 23:20:13.000000000 +0100
@@ -453,6 +453,16 @@ regcache_observer_target_changed (struct
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: src/gdb/thread.c
===================================================================
--- src.orig/gdb/thread.c 2008-08-18 23:19:58.000000000 +0100
+++ src/gdb/thread.c 2008-08-18 23:20:13.000000000 +0100
@@ -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;
next prev parent reply other threads:[~2008-08-18 22:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-08 1:33 Pedro Alves
2008-08-08 21:47 ` Mark Kettenis
2008-08-18 22:41 ` Pedro Alves [this message]
2008-08-18 22:44 ` Pedro Alves
2008-08-18 23:23 ` Daniel Jacobowitz
2008-08-18 23:30 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200808182341.38872.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox