Add "thread-exited" annotation

Message ID 87d0l8pzdz.fsf@gmail.com
State New, archived
Headers

Commit Message

Amos Bird April 26, 2019, 3:19 p.m. UTC
  This patch adds "thread-exited" annotation so that annotation 
based clients like cgdb could currently handle thread exit.

--
Amos Bird
amosbird@gmail.com
  

Comments

Tom Tromey April 30, 2019, 3:45 p.m. UTC | #1
>>>>> "Amos" == Amos Bird <amosbird@gmail.com> 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  <amosbird@gmail.com>
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
  

Patch

From 890aa5099b92b5c05bd03b1084926460f6aa0d7a Mon Sep 17 00:00:00 2001
From: Amos Bird <amosbird@gmail.com>
Date: Fri, 26 Apr 2019 23:09:11 +0800
Subject: [PATCH] Add "thread-exit" annotation.

---
 gdb/ChangeLog  |  5 +++++
 gdb/annotate.c | 12 ++++++++++++
 2 files changed, 17 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  <amosbird@gmail.com>
+
+	* annotate.c (annotate_thread_exited): Add "thread-exited"
+	annotation.
+
 2019-04-25  Keith Seitz  <keiths@redhat.com>
 
 	PR c++/24367
diff --git a/gdb/annotate.c b/gdb/annotate.c
index 97cb4c8855..b3a7343a5a 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -241,6 +241,17 @@  annotate_thread_changed (void)
     }
 }
 
+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 +606,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);
 }
-- 
2.21.0