From: Nick Roberts <nickrob@snap.net.nz>
To: gdb-patches@sources.redhat.com
Subject: [PATCH] Another annotation for threads
Date: Wed, 21 May 2008 06:13:00 -0000 [thread overview]
Message-ID: <18483.36546.101715.670386@kahikatea.snap.net.nz> (raw)
This is a patch for another annotation, this time for thread changes. It
follows an earlier patch (not committed) for notifying thread changes in MI
using observers. In that patch thread changes were notified in two places:
normal_stop in infrun.c and do_captured_thread_select in thread.c. Here
normal_stop is used but the second call has been moved to thread_command so
that temporary thread changes in commands like "info thread", "-var-update" etc
aren't reported.
In the doc patch, I've used @r{, annotation} with findex but I don't know what
all this does as annotate.texinfo doesn't appear to have a function index.
If this patch is OK, I will submit a similar one for MI using an observer.
--
Nick http://www.inet.net.nz/~nickrob
2008-05-21 Nick Roberts <nickrob@snap.net.nz>
* annotate.c (annotate_thread_changed): New function.
* thread.c (thread_command) : Use it.
* infrun.c (normal_stop): Use it.
2008-05-21 Nick Roberts <nickrob@snap.net.nz>
* annotate.texinfo (Multi-threaded Apps): Add entry for thread-changed
annotation.
2008-05-21 Nick Roberts <nickrob@snap.net.nz>
* gdb.base/annota1.exp (thread_switch): Test for thread-changed
annotation.
--- annotate.c.~1.16.~ 2008-05-17 10:27:23.000000000 +1200
+++ annotate.c 2008-05-21 10:25:51.000000000 +1200
@@ -243,6 +243,15 @@ annotate_new_thread (void)
}
void
+annotate_thread_changed (void)
+{
+ if (annotation_level > 1)
+ {
+ printf_unfiltered (("\n\032\032thread-changed\n"));
+ }
+}
+
+void
annotate_field_begin (struct type *type)
{
if (annotation_level == 2)
--- thread.c.~1.70.~ 2008-05-17 20:02:16.000000000 +1200
+++ thread.c 2008-05-21 10:55:29.000000000 +1200
@@ -738,6 +738,7 @@ thread_command (char *tidstr, int from_t
return;
}
+ annotate_thread_changed ();
gdb_thread_select (uiout, tidstr, NULL);
}
--- infrun.c.~1.277.~ 2008-05-08 16:32:23.000000000 +1200
+++ infrun.c 2008-05-21 10:26:59.000000000 +1200
@@ -3605,6 +3605,7 @@ normal_stop (void)
target_terminal_ours_for_output ();
printf_filtered (_("[Switching to %s]\n"),
target_pid_to_str (inferior_ptid));
+ annotate_thread_changed ();
previous_inferior_ptid = inferior_ptid;
}
--- annotate.texinfo.~1.9.~ 2008-05-21 13:53:53.000000000 +1200
+++ annotate.texinfo 2008-05-21 14:14:18.000000000 +1200
@@ -825,17 +825,24 @@ depend on the language).
@chapter Multi-threaded Applications
@cindex annotations for multi-threaded apps
-@findex new-thread@r{, annotation}
-The following annotation reports that the application being debugged is
-multi-threaded.
+The following annotations report thread related changes of state.
-@smallexample
-^Z^Znew-thread
-@end smallexample
+@table @code
+@findex new-thread@r{, annotation}
+@item ^Z^Znew-thread
This annotation is issued once for each thread that is created apart from
the main thread, which is not reported.
+@findex thread-changed@r{, annotation}
+@item ^Z^Zthread-changed
+
+The selected thread has changed. This may occur at the request of the
+user with the @code{thread} command, or as a result of execution,
+e.g., another thread hits a breakpoint.
+
+@end table
+
@raisesections
@include fdl.texi
@lowersections
--- annota1.exp.~1.30.~ 2008-05-20 18:48:14.000000000 +1200
+++ annota1.exp 2008-05-21 13:51:11.000000000 +1200
@@ -527,7 +527,18 @@ proc thread_test {} {
}
}
+proc thread_switch {} {
+ send_gdb "thread 1\n"
+ gdb_expect {
+ -re ".*\032\032thread-changed" {
+ pass "thread switch"
+ }
+ timeout { fail "thread switch (timeout)" }
+ }
+}
+
thread_test
+thread_switch
# restore the original prompt for the rest of the testsuite
next reply other threads:[~2008-05-21 2:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-21 6:13 Nick Roberts [this message]
2008-05-21 8:54 ` Eli Zaretskii
2008-06-05 19:30 ` Daniel Jacobowitz
2008-06-05 21:20 ` Nick Roberts
2008-06-05 21:26 ` Daniel Jacobowitz
2008-06-05 22:02 ` Joel Brobecker
2008-06-06 1:03 ` Nick Roberts
2008-06-06 6:59 ` Joel Brobecker
2008-06-06 0:50 ` Nick Roberts
2008-06-06 1:06 ` Tom Tromey
2008-06-06 2:30 ` Daniel Jacobowitz
2008-06-06 2:44 ` Tom Tromey
2008-06-06 2:39 ` Pedro Alves
2008-06-06 3:00 ` Nick Roberts
2008-06-06 11:44 ` Daniel Jacobowitz
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=18483.36546.101715.670386@kahikatea.snap.net.nz \
--to=nickrob@snap.net.nz \
--cc=gdb-patches@sources.redhat.com \
/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