From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9862 invoked by alias); 18 May 2008 09:11:54 -0000 Received: (qmail 9850 invoked by uid 22791); 18 May 2008 09:11:52 -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; Sun, 18 May 2008 09:11:25 +0000 Received: from kahikatea.snap.net.nz (204.61.255.123.dynamic.snap.net.nz [123.255.61.204]) by viper.snap.net.nz (Postfix) with ESMTP id 4A72A3DA3A8; Sun, 18 May 2008 21:11:17 +1200 (NZST) Received: by kahikatea.snap.net.nz (Postfix, from userid 1000) id 89B338FC6D; Sun, 18 May 2008 21:11:05 +1200 (NZST) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18479.62120.536436.427524@kahikatea.snap.net.nz> Date: Mon, 19 May 2008 12:39:00 -0000 To: Eli Zaretskii , brobecker@adacore.com, gdb-patches@sources.redhat.com Subject: Re: [PATCH] New annotation for threads In-Reply-To: <18478.48682.13900.951343@kahikatea.snap.net.nz> References: <18440.29531.916381.569346@kahikatea.snap.net.nz> <20080429023735.GD841@adacore.com> <18454.43094.168458.742737@kahikatea.snap.net.nz> <20080501181758.GD3801@adacore.com> <18458.21177.959458.278174@kahikatea.snap.net.nz> <20080501233703.GF3801@adacore.com> <18458.23326.25887.70597@kahikatea.snap.net.nz> <18478.48682.13900.951343@kahikatea.snap.net.nz> 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/msg00543.txt.bz2 > I plan to represent this patch with a test shortly... Here it is with documentation. This is pretty much what I submitted originally. Since then the new_thread observer has been moved to add_thread_silent and, as Daniel points out, might be called at other locations or change in the future. With the benefit of hindsight, I think these are good reasons not to use the observer for annotations. -- Nick http://www.inet.net.nz/~nickrob 2008-05-18 Nick Roberts * annotate.c (annotate_new_thread): New function for new-thread annotation. * annotate.h: (annotate_new_thread): New extern. * thread.c (add_thread_with_info): Use it. * Makefile.in (thread.o): Add dependency on annotate.h. 2008-05-18 Nick Roberts * gdb.base/annota1.exp: Test for new annotation. 2008-05-18 Nick Roberts * annotate.texinfo (Multi-threaded Apps): New node for new annotation. Index: annotate.c =================================================================== RCS file: /cvs/src/src/gdb/annotate.c,v retrieving revision 1.15 diff -p -u -r1.15 annotate.c --- annotate.c 1 Jan 2008 22:53:09 -0000 1.15 +++ annotate.c 18 May 2008 09:07:38 -0000 @@ -234,6 +234,15 @@ annotate_frames_invalid (void) } void +annotate_new_thread (void) +{ + if (annotation_level > 1) + { + printf_unfiltered (("\n\032\032new-thread\n")); + } +} + +void annotate_field_begin (struct type *type) { if (annotation_level == 2) Index: annotate.h =================================================================== RCS file: /cvs/src/src/gdb/annotate.h,v retrieving revision 1.9 diff -p -u -r1.9 annotate.h --- annotate.h 1 Jan 2008 22:53:09 -0000 1.9 +++ annotate.h 18 May 2008 09:07:38 -0000 @@ -43,6 +43,7 @@ extern void annotate_record (void); extern void annotate_breakpoints_table_end (void); extern void annotate_frames_invalid (void); +extern void annotate_new_thread (void); struct type; Index: thread.c =================================================================== RCS file: /cvs/src/src/gdb/thread.c,v retrieving revision 1.69 diff -p -u -r1.69 thread.c --- thread.c 9 May 2008 08:14:47 -0000 1.69 +++ thread.c 18 May 2008 09:07:39 -0000 @@ -40,6 +40,7 @@ #include #include "ui-out.h" #include "observer.h" +#include "annotate.h" /* Definition of struct thread_info exported to gdbthread.h */ @@ -141,7 +142,8 @@ add_thread_with_info (ptid_t ptid, struc if (print_thread_events) printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid)); - + + annotate_new_thread (); return result; } Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.1021 diff -p -u -r1.1021 Makefile.in --- Makefile.in 16 May 2008 12:51:21 -0000 1.1021 +++ Makefile.in 18 May 2008 09:07:41 -0000 @@ -2932,7 +2932,7 @@ target-memory.o: target-memory.c $(defs_ thread.o: thread.c $(defs_h) $(symtab_h) $(frame_h) $(inferior_h) \ $(environ_h) $(value_h) $(target_h) $(gdbthread_h) $(exceptions_h) \ $(command_h) $(gdbcmd_h) $(regcache_h) $(gdb_h) $(gdb_string_h) \ - $(ui_out_h) $(observer_h) + $(ui_out_h) $(observer_h) $(annotate_h) top.o: top.c $(defs_h) $(gdbcmd_h) $(call_cmds_h) $(cli_cmds_h) \ $(cli_script_h) $(cli_setshow_h) $(cli_decode_h) $(symtab_h) \ $(inferior_h) $(exceptions_h) $(target_h) $(breakpoint_h) \ Index: testsuite/gdb.base/annota1.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/annota1.exp,v retrieving revision 1.29 diff -p -u -r1.29 annota1.exp --- testsuite/gdb.base/annota1.exp 16 May 2008 12:48:08 -0000 1.29 +++ testsuite/gdb.base/annota1.exp 18 May 2008 09:07:42 -0000 @@ -490,6 +490,39 @@ if [ regexp "core not found" $exec_outpu } } +set testfile "watch_thread_num" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +set gdb_prompt $old_gdb_prompt + +if { ![get_compiler_info ${binfile}] && [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] == "" } { + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load ${binfile} + if { ![runto main] } then { + fail "run to main" + return + } + + set gdb_prompt \ + "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n" + + send_gdb "set annotate 2\n" + gdb_expect { + -re "set annotate 2\r\n$gdb_prompt$" {} + } + + send_gdb "next 2\n" + gdb_expect { + -re ".*\032\032new-thread" { + pass "new thread" + } + timeout { fail "new thread (timeout)" } + } +} + # restore the original prompt for the rest of the testsuite set gdb_prompt $old_gdb_prompt Index: doc/annotate.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/annotate.texinfo,v retrieving revision 1.7 diff -p -u -r1.7 annotate.texinfo --- doc/annotate.texinfo 20 Jan 2007 16:51:56 -0000 1.7 +++ doc/annotate.texinfo 18 May 2008 09:07:42 -0000 @@ -85,6 +85,7 @@ This is Edition @value{EDITION}, @value{ * Annotations for Running:: Whether the program is running, how it stopped, etc. * Source Annotations:: Annotations describing source code. +* Multi-threaded Apps:: An annotation that reports multi-threadedness. * GNU Free Documentation License:: @end menu @@ -820,6 +821,21 @@ source which is being displayed. @var{a followed by one or more lowercase hex digits (note that this does not depend on the language). +@node Multi-threaded Apps +@chapter Multi-threaded Applications +@cindex annotations for multi-threaded apps + +@findex new-thread +The following annotation reports that the application being debugged is +multi-threaded. + +@smallexample +^Z^Znew-thread +@end smallexample + +This annotation is issued once for each thread that is created apart from +the main thread, which is not reported. + @raisesections @include fdl.texi @lowersections