public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Missing thread events for remote targets
@ 2023-10-11 12:53 Andrew Burgess
  2023-10-11 12:53 ` [PATCH 1/2] gdb: call update_thread_list for $_inferior_thread_count function Andrew Burgess
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrew Burgess @ 2023-10-11 12:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

I noticed that in some situations we are missing thread events ('new
thead' and 'thread exited') when using a remote target.  The second
patch in this series addresses this issue.

While writing the test for this case I discovered that
$_inferior_thread_count doesn't always give the correct value when
using remote targets, so the first patch addresses this issue.

---

Andrew Burgess (2):
  gdb: call update_thread_list for $_inferior_thread_count function
  gdb: call update_thread_list after completing an inferior call

 gdb/infcall.c                                 |   7 +
 gdb/testsuite/gdb.threads/inf-thr-count.c     |  80 ++++++++
 gdb/testsuite/gdb.threads/inf-thr-count.exp   | 175 ++++++++++++++++
 .../gdb.threads/infcall-thread-announce.c     | 192 ++++++++++++++++++
 .../gdb.threads/infcall-thread-announce.exp   |  71 +++++++
 gdb/thread.c                                  |   2 +
 6 files changed, 527 insertions(+)
 create mode 100644 gdb/testsuite/gdb.threads/inf-thr-count.c
 create mode 100644 gdb/testsuite/gdb.threads/inf-thr-count.exp
 create mode 100644 gdb/testsuite/gdb.threads/infcall-thread-announce.c
 create mode 100644 gdb/testsuite/gdb.threads/infcall-thread-announce.exp


base-commit: f6ca448ab70c52e923b7010aecdf7be9c0d4d4fc
-- 
2.25.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] gdb: call update_thread_list for $_inferior_thread_count function
  2023-10-11 12:53 [PATCH 0/2] Missing thread events for remote targets Andrew Burgess
@ 2023-10-11 12:53 ` Andrew Burgess
  2023-10-11 12:53 ` [PATCH 2/2] gdb: call update_thread_list after completing an inferior call Andrew Burgess
  2023-11-08 13:30 ` [PATCH 0/2] Missing thread events for remote targets Andrew Burgess
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Burgess @ 2023-10-11 12:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

I noticed that sometimes the value returned by $_inferior_thread_count
can become out of sync with the actual thread count of the inferior,
and will disagree with the number of threads reported by 'info
threads'.  This commit fixes this issue.

The cause of the problem is that 'info threads' includes a call to
update_thread_list, this can be seen in print_thread_info_1 in
thread.c, while $_inferior_thread_count doesn't include a similar
call, see the function inferior_thread_count_make_value also in
thread.c.

Of course, this is only a problem when GDB is running on a target that
relies on update_thread_list calls to learn about new threads,
e.g. remote or extended-remote targets.  Native targets generally
learn about new threads as soon as they appear and will not have this
problem.

I ran into this issue when writing a test for the next commit which
uses inferior function calls to add an remove threads from an
inferior.  But for testing I've made use of non-stop mode and
asynchronous inferior execution; by reading the inferior state I can
know when a new thread has been created, at which point I can print
$_inferior_thread_count while the inferior is still running.  This is
important, if I stop the inferior then GDB will pass through an
update_thread_list call in the normal stop code, which will
synchronise the thread list, after which $_inferior_thread_count will
report the correct value.

With this change in place $_inferior_thread_count is now correct.
---
 gdb/testsuite/gdb.threads/inf-thr-count.c   |  80 +++++++++
 gdb/testsuite/gdb.threads/inf-thr-count.exp | 175 ++++++++++++++++++++
 gdb/thread.c                                |   2 +
 3 files changed, 257 insertions(+)
 create mode 100644 gdb/testsuite/gdb.threads/inf-thr-count.c
 create mode 100644 gdb/testsuite/gdb.threads/inf-thr-count.exp

diff --git a/gdb/testsuite/gdb.threads/inf-thr-count.c b/gdb/testsuite/gdb.threads/inf-thr-count.c
new file mode 100644
index 00000000000..48855041319
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/inf-thr-count.c
@@ -0,0 +1,80 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2023 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <pthread.h>
+#include <assert.h>
+#include <unistd.h>
+
+/* Set to 0 by GDB to cause the inferior to drop out of a spin loop.  */
+volatile int spin = 1;
+
+/* Set by the inferior to communicate to GDB what stage of the test we are
+   in.  Initially 0, but set to 1 once a new thread has been created.  Then
+   set to 2 once the extra thread has exited.  */
+volatile int stage = 0;
+
+/* New thread worker function.  Just spins until GDB tells it to exit.  */
+void *
+thread_func (void *arg)
+{
+  assert (arg == NULL);
+
+  stage = 1;
+
+  while (spin)
+    sleep (1);
+
+  return NULL;
+}
+
+/* Somewhere to place a breakpoint.  */
+void
+breakpt ()
+{
+  /* Nothing.  */
+}
+
+/* Create a new test that spins until GDB tells it to exit.  Then, once the
+   new thread has exited, this thread spins until GDB tells us to exit.  */
+int
+main ()
+{
+  alarm (600);
+
+  breakpt ();
+
+  pthread_t thr;
+  int res;
+
+  res = pthread_create (&thr, NULL, thread_func, NULL);
+  assert (res == 0);
+
+  void *retval;
+  res = pthread_join (thr, &retval);
+  assert (res == 0);
+
+  spin = 1;
+  stage = 2;
+
+  while (spin)
+    sleep (1);
+
+  breakpt ();
+
+  return 0;
+}
+
diff --git a/gdb/testsuite/gdb.threads/inf-thr-count.exp b/gdb/testsuite/gdb.threads/inf-thr-count.exp
new file mode 100644
index 00000000000..8cfbf66d902
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/inf-thr-count.exp
@@ -0,0 +1,175 @@
+# Copyright 2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the $_inferior_thread_count convenience variable will
+# correctly update its value without passing through a normal stop
+# event.
+#
+# When GDB is using a remote (or extended-remote) target, GDB only
+# learns about changes to the thread list be explicitly querying the
+# target.  This is done as part of a normal stop, but there are some
+# situations where the thread list can change, but GDB doesn't pass
+# through a normal stop.
+#
+# For example, when the target is running asynchronously in non-stop
+# mode; in this case GDB can query the thread list without the target
+# ever stopping.
+#
+# Or after an inferior function call.
+#
+# The solution is to ensure that $_inferior_thread_count explicitly
+# queries the target to update the thread list.  This test checks that
+# this is done.
+
+standard_testfile
+
+if {[build_executable "failed to prepare" $testfile $srcfile \
+	 {debug pthreads}] == -1} {
+    return -1
+}
+
+# Start GDB.  Ensure we are in non-stop mode as we need to read from
+# the inferior while it is running.
+save_vars {GDBFLAGS} {
+    append GDBFLAGS " -ex \"set non-stop on\""
+    clean_restart $binfile
+}
+
+if ![runto_main] {
+    return -1
+}
+
+gdb_breakpoint breakpt
+gdb_continue_to_breakpoint "first breakpt call"
+
+# Check we can see a single thread to begin with.
+gdb_test "p \$_inferior_thread_count" \
+    "^\\\$$::decimal = 1" \
+    "only one thread in \$_inferior_thread_count"
+
+# We don't want thread events, it makes it harder to match GDB's
+# output.
+gdb_test_no_output "set print thread-events off"
+
+# Continue the program in the background.
+set test "continue&"
+gdb_test_multiple "continue&" $test {
+    -re "Continuing\\.\r\n$gdb_prompt " {
+	pass $test
+    }
+}
+
+# Read the 'stage' flag from the inferior.  This is initially 0, but
+# will be set to 1 once the extra thread has been created, and then 2
+# once the extra thread has exited.
+#
+# We catch the case where we can't read from the inferior while the
+# inferior is running, this happens if the target hasn't entered
+# non-stop mode like we asked.  In this case we interrupt the inferior
+# and bail.
+#
+# Otherwise, if we can read from the inferior we try at most 10 times
+# to read the flag (with a 1 second delay after each read).  If the
+# flag isn't set after this then we bail.  The inferior is either very
+# slow, or the thread hasn't started for some reason.
+proc wait_for_stage { num } {
+    set failure_count 0
+    set cmd "print /d stage"
+    set stage_flag 0
+    gdb_test_multiple "$cmd" "wait for 'stage' flag to be $num" {
+	-re -wrap "^Cannot execute this command while the target is running\\.\r\nUse the \"interrupt\" command to stop the target\r\nand then try again\\." {
+	    fail "$gdb_test_name (can't read asynchronously)"
+	    gdb_test_no_output "interrupt"
+
+	    gdb_test_multiple "" "wait for thread to stop" {
+		-re "Thread .* received signal .*" {
+		    pass $gdb_test_name
+		    gdb_test "p 1 + 2" " = 3"
+		}
+	    }
+	}
+
+	-re -wrap "^\\$\[0-9\]* = (\[-\]*\[0-9\]*).*" {
+	    set stage_flag $expect_out(1,string)
+	    if {$stage_flag != $num} {
+		set stage_flag 0
+		incr failure_count
+		if { $failure_count < 10 } {
+		    sleep 1
+		    send_gdb "$cmd\n"
+		    exp_continue
+		}
+		fail $gdb_test_name
+	    } else {
+		pass $gdb_test_name
+	    }
+	}
+    }
+
+    return $stage_flag
+}
+
+# Wait until we can see that the extra thread has been created.
+if {![wait_for_stage 1]} {
+    unresolved "failed to see thread start"
+    return -1
+}
+
+
+if {[target_info exists gdb_protocol]
+    && ([target_info gdb_protocol] == "remote"
+	|| [target_info gdb_protocol] == "extended-remote")} {
+    set new_thread_re "\\\[New Thread \[^\r\n\]+\\\]\r\n"
+    set exit_thread_re "\\\[Thread \[^\r\n\]+ exited\\\]\r\n"
+} else {
+    set new_thread_re ""
+    set exit_thread_re ""
+}
+
+# This is the test we actually care about.  Check that the
+# $_inferior_thread_count convenience variable shows the correct
+# thread count; the new thread should be visible.
+gdb_test "with print thread-events on -- p \$_inferior_thread_count" \
+    "^${new_thread_re}\\\$$::decimal = 2" \
+    "second thread visible in \$_inferior_thread_count"
+
+# Set a variable in the inferior, this will cause the second thread to
+# exit.
+gdb_test_no_output "set variable spin = 0" \
+    "set 'spin' flag to allow worker thread to exit"
+
+# Wait until the extra thread has exited.
+if {![wait_for_stage 2]} {
+    unresolved "failed to see thread start"
+    return -1
+}
+
+# Check that the second thread has gone away.
+gdb_test "with print thread-events on -- p \$_inferior_thread_count" \
+    "^${exit_thread_re}\\\$$::decimal = 1" \
+    "back to one thread visible in \$_inferior_thread_count"
+
+# Set a variable in the inferior, this will cause the second thread to
+# exit.
+gdb_test_no_output "set variable spin = 0" \
+    "set 'spin' flag to allow main thread to exit"
+
+# When the second thread exits, the main thread joins with it, and
+# then proceeds to hit the breakpt function again.
+gdb_test_multiple "" "wait for main thread to stop" {
+    -re "Thread 1 \[^\r\n\]+ hit Breakpoint $decimal, breakpt \\(\\)\[^\r\n\]+\r\n\[^\r\n\]+\r\n" {
+	pass $gdb_test_name
+    }
+}
diff --git a/gdb/thread.c b/gdb/thread.c
index c8145da59bc..0660589abbf 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -2183,6 +2183,8 @@ inferior_thread_count_make_value (struct gdbarch *gdbarch,
 {
   int int_val = 0;
 
+  update_thread_list ();
+
   if (inferior_ptid != null_ptid)
     int_val = current_inferior ()->non_exited_threads ().size ();
 
-- 
2.25.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] gdb: call update_thread_list after completing an inferior call
  2023-10-11 12:53 [PATCH 0/2] Missing thread events for remote targets Andrew Burgess
  2023-10-11 12:53 ` [PATCH 1/2] gdb: call update_thread_list for $_inferior_thread_count function Andrew Burgess
@ 2023-10-11 12:53 ` Andrew Burgess
  2023-11-08 13:30 ` [PATCH 0/2] Missing thread events for remote targets Andrew Burgess
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Burgess @ 2023-10-11 12:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

I noticed that if GDB is using a remote or extended-remote target,
then, if an inferior call caused a new thread to appear, or for an
existing thread to exit, then these events are not reported to the
user.

The problem is that for these targets GDB relies on a call to
update_thread_list to learn about changes to the inferior's thread
list.

If GDB doesn't pass through the normal stop code then GDB will not
call update_thread_list, and so will not report changes in the thread
list.

This commit adds an additional update_thread_list call, after which
thread events are correctly reported.
---
 gdb/infcall.c                                 |   7 +
 .../gdb.threads/infcall-thread-announce.c     | 192 ++++++++++++++++++
 .../gdb.threads/infcall-thread-announce.exp   |  71 +++++++
 3 files changed, 270 insertions(+)
 create mode 100644 gdb/testsuite/gdb.threads/infcall-thread-announce.c
 create mode 100644 gdb/testsuite/gdb.threads/infcall-thread-announce.exp

diff --git a/gdb/infcall.c b/gdb/infcall.c
index 0f9ad34bbb4..e62c2205808 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -1388,6 +1388,13 @@ call_function_by_hand_dummy (struct value *function,
 
     gdb::observers::inferior_call_post.notify (call_thread_ptid, funaddr);
 
+
+    /* As the inferior call failed, we are about to throw an error, which
+       will be caught and printed somewhere else in GDB.  We want new threads
+       to be printed before the error message, otherwise it looks odd; the
+       threads appear after GDB has reported a stop.  */
+    update_thread_list ();
+
     if (call_thread->state != THREAD_EXITED)
       {
 	/* The FSM should still be the same.  */
diff --git a/gdb/testsuite/gdb.threads/infcall-thread-announce.c b/gdb/testsuite/gdb.threads/infcall-thread-announce.c
new file mode 100644
index 00000000000..2ed246c7662
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/infcall-thread-announce.c
@@ -0,0 +1,192 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2023 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <pthread.h>
+
+/* Test can create at most this number of extra threads.  */
+#define MAX_THREADS 3
+
+/* For convenience.  */
+#define FALSE 0
+#define TRUE (!FALSE)
+
+/* Controls a thread created by this test.  */
+struct thread_descriptor
+{
+  /* The pthread handle.  Not valid unless STARTED is true.  */
+  pthread_t thr;
+
+  /* This field is set to TRUE when a thread has been created, otherwise,
+     is false.  */
+  int started;
+
+  /* A condition variable and mutex, used for synchronising between the
+     worker thread and the main thread.  */
+  pthread_cond_t cond;
+  pthread_mutex_t mutex;
+};
+
+/* Keep track of worker threads.  */
+struct thread_descriptor threads[MAX_THREADS];
+
+/* Worker thread function.  Doesn't do much.  Synchronise with the main
+   thread, mark the thread as started, and then block waiting for the main
+   thread.  Once the main thread wakes us, this thread exits.
+
+   ARG is a thread_descriptor shared with the main thread.  */
+
+void *
+thread_function (void *arg)
+{
+  int res;
+  struct thread_descriptor *thread = (struct thread_descriptor *) arg;
+
+  /* Acquire the thread's lock.  Initially the main thread holds this lock,
+     but releases it when the main thread enters a pthread_cond_wait.  */
+  res = pthread_mutex_lock (&thread->mutex);
+  assert (res == 0);
+
+  /* Mark the thread as started.  */
+  thread->started = TRUE;
+
+  /* Signal the main thread to tell it we are started.  The main thread
+     will still be blocked though as we hold the thread's lock.  */
+  res = pthread_cond_signal (&thread->cond);
+  assert (res == 0);
+
+  /* Now wait until the main thread tells us to exit.  By entering this
+     pthread_cond_wait we release the lock, which allows the main thread to
+     resume.  */
+  res = pthread_cond_wait (&thread->cond, &thread->mutex);
+  assert (res == 0);
+
+  /* The main thread woke us up.  We reacquired the thread lock as we left
+     the pthread_cond_wait, so release the lock now.  */
+  res = pthread_mutex_unlock (&thread->mutex);
+  assert (res == 0);
+
+  return NULL;
+}
+
+/* Start a new thread within the global THREADS array.  Return true if a
+   new thread was started, otherwise return false.  */
+
+int
+start_thread ()
+{
+  int idx, res;
+
+  for (idx = 0; idx < MAX_THREADS; ++idx)
+    if (!threads[idx].started)
+      break;
+
+  if (idx == MAX_THREADS)
+    return FALSE;
+
+  /* Acquire the thread lock before starting the new thread.  */
+  res = pthread_mutex_lock (&threads[idx].mutex);
+  assert (res == 0);
+
+  /* Start the new thread.  */
+  res = pthread_create (&threads[idx].thr, NULL,
+			thread_function, &threads[idx]);
+  assert (res == 0);
+
+  /* Unlock and wait.  The thread signals us once it is ready.  */
+  res = pthread_cond_wait (&threads[idx].cond, &threads[idx].mutex);
+  assert (res == 0);
+
+  /* The worker thread is now blocked in a pthread_cond_wait and we
+     reacquired the lock as we left our own pthread_cond_wait above.  */
+  res = pthread_mutex_unlock (&threads[idx].mutex);
+  assert (res == 0);
+
+  return TRUE;
+}
+
+/* Stop a thread from within the global THREADS array.  Return true if a
+   thread was stopped, otherwise return false.  */
+int
+stop_thread ()
+{
+  /* Look for a thread that is started.  */
+  for (int idx = 0; idx < MAX_THREADS; ++idx)
+    if (threads[idx].started)
+      {
+	int res;
+
+	/* Grab the thread lock.  */
+	res = pthread_mutex_lock (&threads[idx].mutex);
+	assert (res == 0);
+
+	/* Signal the worker thread, this wakes it up, but it can't exit
+	   until it acquires the thread lock, which we currently hold.  */
+	res = pthread_cond_signal (&threads[idx].cond);
+	assert (res == 0);
+
+	/* Release the thread lock, this allows the worker thread to exit.  */
+	res = pthread_mutex_unlock (&threads[idx].mutex);
+	assert (res == 0);
+
+	/* Now wait for the thread to exit.  */
+	void *retval;
+	res = pthread_join (threads[idx].thr, &retval);
+	assert (res == 0);
+	assert (retval == NULL);
+
+	/* Now the thread has exited, mark it as no longer started.  */
+	assert (threads[idx].started);
+	threads[idx].started = FALSE;
+
+	return TRUE;
+      }
+
+  return FALSE;
+}
+
+void
+init_descriptor_array ()
+{
+  for (int i = 0; i < MAX_THREADS; ++i)
+    {
+      int res;
+
+      threads[i].started = FALSE;
+      res = pthread_cond_init (&threads[i].cond, NULL);
+      assert (res == 0);
+      res = pthread_mutex_init (&threads[i].mutex, NULL);
+      assert (res == 0);
+    }
+}
+
+void
+breakpt ()
+{
+  /* Nothing.  */
+}
+
+int
+main ()
+{
+  init_descriptor_array ();
+  breakpt ();
+  start_thread ();
+  stop_thread ();
+  breakpt ();
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.threads/infcall-thread-announce.exp b/gdb/testsuite/gdb.threads/infcall-thread-announce.exp
new file mode 100644
index 00000000000..f480b435f21
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/infcall-thread-announce.exp
@@ -0,0 +1,71 @@
+# Copyright 2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that thread creation and thread exit events are correctly
+# announced when a thread starts, or exits, as a result of an inferior
+# function call from GDB.
+
+standard_testfile
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] == -1} {
+    return -1
+}
+
+if ![runto_main] {
+    return -1
+}
+
+gdb_breakpoint breakpt
+gdb_continue_to_breakpoint "first breakpt call"
+
+set thr_count 1
+
+proc check_thread_count { adjustment } {
+    incr ::thr_count $adjustment
+
+    gdb_test "p \$_inferior_thread_count" \
+	"^\\\$$::decimal = $::thr_count"
+}
+
+with_test_prefix "starting threads" {
+    gdb_test "call (void) start_thread()" \
+	"\\\[New Thread \[^\r\n\]+\\\]" \
+	"start a new thread, return value discarded"
+    check_thread_count +1
+
+    foreach_with_prefix call_type { print call } {
+	gdb_test "$call_type start_thread()" \
+	    "\\\[New Thread \[^\r\n\]+\\\]\r\n\\\$$decimal = 1" \
+	    "start another new thread"
+	check_thread_count +1
+    }
+}
+
+with_test_prefix "stopping threads" {
+    gdb_test "call (void) stop_thread()" \
+	"\\\[Thread \[^\r\n\]+ exited\\\]" \
+	"stop a thread, return value discarded"
+    check_thread_count -1
+
+    foreach_with_prefix call_type { print call } {
+	gdb_test "$call_type stop_thread()" \
+	    "\\\[Thread \[^\r\n\]+ exited\\\]\r\n\\\$$decimal = 1" \
+	    "stop another thread"
+	check_thread_count -1
+    }
+}
+
+gdb_continue_to_breakpoint "second breakpt call"
+gdb_continue_to_end
-- 
2.25.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Missing thread events for remote targets
  2023-10-11 12:53 [PATCH 0/2] Missing thread events for remote targets Andrew Burgess
  2023-10-11 12:53 ` [PATCH 1/2] gdb: call update_thread_list for $_inferior_thread_count function Andrew Burgess
  2023-10-11 12:53 ` [PATCH 2/2] gdb: call update_thread_list after completing an inferior call Andrew Burgess
@ 2023-11-08 13:30 ` Andrew Burgess
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Burgess @ 2023-11-08 13:30 UTC (permalink / raw)
  To: gdb-patches

Andrew Burgess <aburgess@redhat.com> writes:

> I noticed that in some situations we are missing thread events ('new
> thead' and 'thread exited') when using a remote target.  The second
> patch in this series addresses this issue.
>
> While writing the test for this case I discovered that
> $_inferior_thread_count doesn't always give the correct value when
> using remote targets, so the first patch addresses this issue.

I've gone ahead and pushed this series.

Thanks,
Andrew

>
> ---
>
> Andrew Burgess (2):
>   gdb: call update_thread_list for $_inferior_thread_count function
>   gdb: call update_thread_list after completing an inferior call
>
>  gdb/infcall.c                                 |   7 +
>  gdb/testsuite/gdb.threads/inf-thr-count.c     |  80 ++++++++
>  gdb/testsuite/gdb.threads/inf-thr-count.exp   | 175 ++++++++++++++++
>  .../gdb.threads/infcall-thread-announce.c     | 192 ++++++++++++++++++
>  .../gdb.threads/infcall-thread-announce.exp   |  71 +++++++
>  gdb/thread.c                                  |   2 +
>  6 files changed, 527 insertions(+)
>  create mode 100644 gdb/testsuite/gdb.threads/inf-thr-count.c
>  create mode 100644 gdb/testsuite/gdb.threads/inf-thr-count.exp
>  create mode 100644 gdb/testsuite/gdb.threads/infcall-thread-announce.c
>  create mode 100644 gdb/testsuite/gdb.threads/infcall-thread-announce.exp
>
>
> base-commit: f6ca448ab70c52e923b7010aecdf7be9c0d4d4fc
> -- 
> 2.25.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-08 13:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-11 12:53 [PATCH 0/2] Missing thread events for remote targets Andrew Burgess
2023-10-11 12:53 ` [PATCH 1/2] gdb: call update_thread_list for $_inferior_thread_count function Andrew Burgess
2023-10-11 12:53 ` [PATCH 2/2] gdb: call update_thread_list after completing an inferior call Andrew Burgess
2023-11-08 13:30 ` [PATCH 0/2] Missing thread events for remote targets Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).