From patchwork Tue Apr 30 17:09:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Bird X-Patchwork-Id: 32469 Received: (qmail 84839 invoked by alias); 30 Apr 2019 17:09:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 84830 invoked by uid 89); 30 Apr 2019 17:09:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Spam-Relays-External:209.85.214.193, H*RU:209.85.214.193, hits, HX-Received:141 X-HELO: mail-pl1-f193.google.com Received: from mail-pl1-f193.google.com (HELO mail-pl1-f193.google.com) (209.85.214.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 30 Apr 2019 17:09:47 +0000 Received: by mail-pl1-f193.google.com with SMTP id y3so6186594plp.0 for ; Tue, 30 Apr 2019 10:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=s5wpqUc2RumsybOehlIFKyGE1zAOMio/iJzt3VBu+rQ=; b=olPd3kBTRybaBRc9rYcgU/3J4H5Kz1K8uQyXQBPHLlyROFJWmZKKW9FnJpeMcqOcmr 6GkRoAXyQFzPn+7uhUgUaNBE1O5IzzzaMQLuggJFk6+zUtupRs/DgM9l5hOVxR9KEvGv f7kpnVwsPaMpKjUZDL7IgI+zf5Ad30BXzndAed3C2uhQ48z0xvLlbkMG0oPXlNYajd6B S63IBls7W3s9k38bxNk7vmEllhCRwZBg7ztxf8lYqeC04ao/QVepUu9GSeZ/xHmyK7ms tBXrhrhvUttOB9wed8cfhhZGI3VmFRC5Bivor5XdgXKvPZAnBJJ8ipSOTD+RcKQ7V/Hn Mr+g== Return-Path: Received: from localhost ([168.235.105.19]) by smtp.gmail.com with ESMTPSA id v82sm85991980pfa.170.2019.04.30.10.09.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Apr 2019 10:09:44 -0700 (PDT) References: <87d0l8pzdz.fsf@gmail.com> <87ef5j33au.fsf@tromey.com> User-agent: mu4e 1.1.0; emacs 27.0.50 From: Amos Bird To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Add "thread-exited" annotation In-reply-to: <87ef5j33au.fsf@tromey.com> Date: Wed, 01 May 2019 01:09:57 +0800 Message-ID: <87ftpzo1wa.fsf@gmail.com> MIME-Version: 1.0 Patch updated. Tom Tromey writes: >>>>>> "Amos" == Amos Bird writes: > > Amos> This patch adds "thread-exited" annotation so that > annotation based > Amos> clients like cgdb could currently handle thread exit. > > I sort of wish that all clients would just use MI, but ... > > Amos> +2019-04-26 Amos Bird > Amos> + > Amos> + * annotate.c (annotate_thread_exited): Add > "thread-exited" > Amos> + annotation. > > The patch itself is fine (just some nits), but a change like > this > requires a documentation update (and probably NEWS as well) and > a test > case. > > > Amos> +void > Amos> +annotate_thread_exited (struct thread_info *t, int > silent) > Amos> +{ > > New functions should have an intro comment. Also, this function > should > be "static". > > Tom --- Amos Bird amosbird@gmail.com From b910b30abba42992bec4a011cc13c6eb1f20a43a Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Fri, 26 Apr 2019 23:09:11 +0800 Subject: [PATCH] Add "thread-exit" annotation. --- gdb/ChangeLog | 5 +++++ gdb/NEWS | 2 ++ gdb/annotate.c | 14 ++++++++++++++ gdb/doc/ChangeLog | 5 +++++ gdb/doc/annotate.texinfo | 5 +++++ gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/annota1.exp | 9 +++++++++ 7 files changed, 45 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e0120e7743..849ed30731 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-04-26 Amos Bird + + * annotate.c (annotate_thread_exited): Add "thread-exited" + annotation. + 2019-04-25 Keith Seitz PR c++/24367 diff --git a/gdb/NEWS b/gdb/NEWS index 5309a8f923..df5f836bac 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,8 @@ *** Changes since GDB 8.3 +* 'thread-exited' event is now available in the old annotations interface + * New built-in convenience variables $_gdb_major and $_gdb_minor provide the GDB version. They are handy for conditionally using features available only in or since specific GDB versions, in diff --git a/gdb/annotate.c b/gdb/annotate.c index 97cb4c8855..af804ddd1f 100644 --- a/gdb/annotate.c +++ b/gdb/annotate.c @@ -241,6 +241,19 @@ annotate_thread_changed (void) } } +/* Emit notification on thread exit. */ + +static void +annotate_thread_exited (struct thread_info *t, int silent) +{ + if (annotation_level > 1) + { + printf_filtered(("\n\032\032thread-exited," + "id=\"%d\",group-id=\"i%d\"\n"), + t->global_num, t->inf->num); + } +} + void annotate_field_begin (struct type *type) { @@ -595,4 +608,5 @@ _initialize_annotate (void) gdb::observers::breakpoint_created.attach (breakpoint_changed); gdb::observers::breakpoint_deleted.attach (breakpoint_changed); gdb::observers::breakpoint_modified.attach (breakpoint_changed); + gdb::observers::thread_exit.attach (annotate_thread_exited); } diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index ba152329d7..79b837aac6 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2019-04-26 Amos Bird + + * annotate.texinfo (Multi-threaded Apps): Add entry for thread-exited + annotation. + 2019-04-22 Pedro Alves * gdb.texinfo (Reverse Execution): Mention and xref process record diff --git a/gdb/doc/annotate.texinfo b/gdb/doc/annotate.texinfo index b85b759f9a..38978f3ccc 100644 --- a/gdb/doc/annotate.texinfo +++ b/gdb/doc/annotate.texinfo @@ -836,6 +836,11 @@ 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. +@findex thread-exited@r{, annotation} +@item ^Z^Zthread-exited + +This annotation is issued once for each thread that is exited. + @end table @node GNU Free Documentation License diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 9b0725a033..169b5b8dce 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-04-26 Amos Bird + + * gdb.base/annota1.exp (thread_switch): Test for thread-exited + annotation. + 2019-04-25 Keith Seitz PR c++/24367 diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp index 5237bc9715..032cd2ecde 100644 --- a/gdb/testsuite/gdb.base/annota1.exp +++ b/gdb/testsuite/gdb.base/annota1.exp @@ -492,8 +492,17 @@ proc thread_switch {} { } } +proc thread_exit {} { + gdb_test_multiple "call (void)pthread_exit()" "thread exit" { + -re ".*\032\032thread-exited.*" { + pass "thread exit" + } + } +} + thread_test thread_switch +thread_exit # restore the original prompt for the rest of the testsuite -- 2.21.0