From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31773 invoked by alias); 21 May 2008 02:54:32 -0000 Received: (qmail 31764 invoked by uid 22791); 21 May 2008 02:54:31 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.25) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 21 May 2008 02:54:06 +0000 Received: from kahikatea.snap.net.nz (141.60.255.123.dynamic.snap.net.nz [123.255.60.141]) by viper.snap.net.nz (Postfix) with ESMTP id 513D93D9E34 for ; Wed, 21 May 2008 14:53:58 +1200 (NZST) Received: by kahikatea.snap.net.nz (Postfix, from userid 1000) id 2B4018FC6D; Wed, 21 May 2008 14:53:55 +1200 (NZST) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18483.36546.101715.670386@kahikatea.snap.net.nz> Date: Wed, 21 May 2008 06:13:00 -0000 To: gdb-patches@sources.redhat.com Subject: [PATCH] Another annotation for threads X-Mailer: VM 7.19 under Emacs 22.2.50.2 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-05/txt/msg00620.txt.bz2 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 * annotate.c (annotate_thread_changed): New function. * thread.c (thread_command) : Use it. * infrun.c (normal_stop): Use it. 2008-05-21 Nick Roberts * annotate.texinfo (Multi-threaded Apps): Add entry for thread-changed annotation. 2008-05-21 Nick Roberts * 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