Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Aditya Vidyadhar Kamath <akamath996@gmail.com>
To: ulrich.weigand@de.ibm.com, simon.marchi@polymtl.ca, tom@tromey.com
Cc: gdb-patches@sourceware.org, Aditya.Kamath1@ibm.com,
	sangamesh.swamy@in.ibm.com,
	Aditya Vidyadhar Kamath <aditya.kamath1@ibm.com>
Subject: [PATCH 2/3][RFC] Batch getthrds() calls in get_signaled_thread
Date: Wed, 16 Sep 2026 17:16:06 +0530	[thread overview]
Message-ID: <20260916114603.17488-4-akamath996@gmail.com> (raw)

From: Aditya Vidyadhar Kamath <aditya.kamath1@ibm.com>

The original code called getthrds() with a count of 1, fetching one
kernel thread descriptor per syscall.  With N threads in the process
that costs N syscalls per stop just to find the signaled thread.

Change to fetch GETTHRDS_BATCH (64) descriptors per call and scan
the batch in a loop.  This reduces the syscall count from O(N) to
O(N/64).

Also done the benchmark here who results are pasted below. To analyse
where time is being spent. For now, this patch request for comment/draft and will
remove the same and this paragraph from the commit message after
feedback.

==========
Benchmark C code
// cat ../bench_next.c
/* Spawns NUM_THREADS worker threads that spin, then steps through
   10 assignments in do_steps() so GDB can time each next.

   Also tests two scenarios from the bug report:
     1. "next" over a call that spawns a thread (spawn_thread_here()).
     2. A background thread exits while "next" is in progress
        (exit_thread_here()).  */
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>

#ifndef NUM_THREADS
#define NUM_THREADS 3
#endif

static volatile int keep_running = 1;
static volatile int extra_thread_started = 0;

static void *
worker (void *arg)
{
  while (keep_running)
    sched_yield ();
  return NULL;
}

/* Thread that exits on its own after signalling it has started.  */
static void *
short_lived (void *arg)
{
  extra_thread_started = 1;
  return NULL;
}

/* GDB will "next" over this call -- a new thread is spawned inside.  */
static void
spawn_thread_here (void)
{
  pthread_t t;
  pthread_create (&t, NULL, short_lived, NULL);
  pthread_join (t, NULL);
}

/* GDB will "next" over this call -- the short-lived background thread
   is in the process of exiting while we step.  */
static void
exit_thread_here (void)
{
  /* Just a visible marker so GDB can stop here.  */
  volatile int x = 42;
  (void)x;
}

void
do_steps (void)
{
  volatile int a = 1;
  volatile int b = 2;
  volatile int c = a + b;
  volatile int d = c * 2;
  volatile int e = d - a;
  volatile int f = e + c;
  volatile int g = f / 2;
  volatile int h = g + 1;
  volatile int i2 = h * h;
  volatile int j = i2 - b;
  (void)j;
}

int
main (void)
{
  pthread_t threads[NUM_THREADS];
  pthread_t bg;
  int i;

  /* Start background spinning threads.  */
  for (i = 0; i < NUM_THREADS; i++)
    pthread_create (&threads[i], NULL, worker, NULL);

  /* Next over a call that spawns a thread */
  spawn_thread_here ();

  /* Next while a background thread is exiting
     Launch a thread that exits quickly; "next" through exit_thread_here()
     while that exit is in flight.  */
  pthread_create (&bg, NULL, short_lived, NULL);
  exit_thread_here ();
  pthread_join (bg, NULL);

  do_steps ();

  keep_running = 0;
  for (i = 0; i < NUM_THREADS; i++)
    pthread_join (threads[i], NULL);

  return 0;
}
============
Benchmark GDB code:

// cat ../bench_next.gdb 
set pagination off
set confirm off
maintenance set per-command time on

# Scenario 1: next over a call that spawns a thread
break spawn_thread_here
run
next

# Scenario 2: next while a background thread is exiting
break exit_thread_here
continue
next

break do_steps
continue

next
next
next
next
next
next
next
next
next
next

quit

===============
# cd /current_gdb && time /current_gdb/binutils-gdb/gdb/gdb -batch -x bench_next.gdb ./bench_next_bin 2>&1 | grep -E "^(real|user|sys)|volatile int
|pd_update total|sync_thread|pthdb_session"
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "pd_update total": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "pd_update total": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.146, user 0.081, sys 0.085, user+sys 0.166, 14.5 % CPU
Time for "pd_update total": wall 1.146, user 0.081, sys 0.085, user+sys 0.166, 14.5 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.025, user 0.092, sys 0.092, user+sys 0.184, 18.0 % CPU
Time for "pd_update total": wall 1.025, user 0.092, sys 0.092, user+sys 0.184, 18.0 % CPU
25        volatile int a = 1;
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.962, user 0.098, sys 0.095, user+sys 0.193, 20.1 % CPU
Time for "pd_update total": wall 0.962, user 0.098, sys 0.095, user+sys 0.193, 20.1 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.965, user 0.098, sys 0.094, user+sys 0.192, 19.9 % CPU
Time for "pd_update total": wall 0.965, user 0.098, sys 0.094, user+sys 0.192, 19.9 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.954, user 0.098, sys 0.094, user+sys 0.192, 20.1 % CPU
Time for "pd_update total": wall 0.954, user 0.098, sys 0.094, user+sys 0.192, 20.1 % CPU
26        volatile int b = 2;
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.949, user 0.098, sys 0.094, user+sys 0.192, 20.2 % CPU
Time for "pd_update total": wall 0.949, user 0.098, sys 0.094, user+sys 0.192, 20.2 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.957, user 0.098, sys 0.094, user+sys 0.192, 20.1 % CPU
Time for "pd_update total": wall 0.957, user 0.098, sys 0.094, user+sys 0.192, 20.1 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.033, user 0.101, sys 0.098, user+sys 0.199, 19.3 % CPU
Time for "pd_update total": wall 1.033, user 0.101, sys 0.098, user+sys 0.199, 19.3 % CPU
27        volatile int c = a + b;
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.031, user 0.101, sys 0.098, user+sys 0.199, 19.3 % CPU
Time for "pd_update total": wall 1.031, user 0.101, sys 0.098, user+sys 0.199, 19.3 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.028, user 0.100, sys 0.098, user+sys 0.198, 19.3 % CPU
Time for "pd_update total": wall 1.028, user 0.100, sys 0.098, user+sys 0.198, 19.3 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.996, user 0.100, sys 0.098, user+sys 0.198, 19.9 % CPU
Time for "pd_update total": wall 0.996, user 0.100, sys 0.098, user+sys 0.198, 19.9 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.000, user 0.098, sys 0.098, user+sys 0.196, 19.6 % CPU
Time for "pd_update total": wall 1.001, user 0.098, sys 0.098, user+sys 0.196, 19.6 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.998, user 0.098, sys 0.098, user+sys 0.196, 19.6 % CPU
Time for "pd_update total": wall 0.998, user 0.098, sys 0.098, user+sys 0.196, 19.6 % CPU
28        volatile int d = c * 2;
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.999, user 0.098, sys 0.098, user+sys 0.196, 19.6 % CPU
Time for "pd_update total": wall 0.999, user 0.098, sys 0.098, user+sys 0.196, 19.6 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.001, user 0.099, sys 0.098, user+sys 0.197, 19.7 % CPU
Time for "pd_update total": wall 1.001, user 0.099, sys 0.098, user+sys 0.197, 19.7 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.969, user 0.100, sys 0.095, user+sys 0.195, 20.1 % CPU
Time for "pd_update total": wall 0.969, user 0.100, sys 0.095, user+sys 0.195, 20.1 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.980, user 0.099, sys 0.096, user+sys 0.195, 19.9 % CPU
Time for "pd_update total": wall 0.980, user 0.099, sys 0.096, user+sys 0.195, 19.9 % CPU
29        volatile int e = d - a;
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.984, user 0.100, sys 0.096, user+sys 0.196, 19.9 % CPU
Time for "pd_update total": wall 0.984, user 0.100, sys 0.096, user+sys 0.196, 19.9 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.094, user 0.098, sys 0.094, user+sys 0.192, 17.6 % CPU
Time for "pd_update total": wall 1.094, user 0.099, sys 0.094, user+sys 0.193, 17.6 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.019, user 0.106, sys 0.097, user+sys 0.203, 19.9 % CPU
Time for "pd_update total": wall 1.019, user 0.106, sys 0.097, user+sys 0.203, 19.9 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.002, user 0.106, sys 0.096, user+sys 0.202, 20.2 % CPU
Time for "pd_update total": wall 1.002, user 0.106, sys 0.096, user+sys 0.202, 20.2 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.003, user 0.105, sys 0.096, user+sys 0.201, 20.0 % CPU
Time for "pd_update total": wall 1.003, user 0.105, sys 0.096, user+sys 0.201, 20.0 % CPU
30        volatile int f = e + c;
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.011, user 0.106, sys 0.097, user+sys 0.203, 20.1 % CPU
Time for "pd_update total": wall 1.011, user 0.106, sys 0.097, user+sys 0.203, 20.1 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.010, user 0.107, sys 0.096, user+sys 0.203, 20.1 % CPU
Time for "pd_update total": wall 1.010, user 0.107, sys 0.096, user+sys 0.203, 20.1 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.026, user 0.110, sys 0.096, user+sys 0.206, 20.1 % CPU
Time for "pd_update total": wall 1.026, user 0.110, sys 0.096, user+sys 0.206, 20.1 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.200, user 0.090, sys 0.085, user+sys 0.175, 14.6 % CPU
Time for "pd_update total": wall 1.201, user 0.090, sys 0.085, user+sys 0.175, 14.6 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.212, user 0.090, sys 0.091, user+sys 0.181, 14.9 % CPU
Time for "pd_update total": wall 1.212, user 0.090, sys 0.091, user+sys 0.181, 14.9 % CPU
31        volatile int g = f / 2;
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 0.993, user 0.103, sys 0.096, user+sys 0.199, 20.0 % CPU
Time for "pd_update total": wall 0.993, user 0.103, sys 0.096, user+sys 0.199, 20.0 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.258, user 0.079, sys 0.082, user+sys 0.161, 12.8 % CPU
Time for "pd_update total": wall 1.258, user 0.079, sys 0.082, user+sys 0.161, 12.8 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.255, user 0.080, sys 0.081, user+sys 0.161, 12.8 % CPU
Time for "pd_update total": wall 1.255, user 0.080, sys 0.081, user+sys 0.161, 12.8 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.259, user 0.080, sys 0.081, user+sys 0.161, 12.8 % CPU
Time for "pd_update total": wall 1.259, user 0.080, sys 0.081, user+sys 0.161, 12.8 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.264, user 0.080, sys 0.082, user+sys 0.162, 12.8 % CPU
Time for "pd_update total": wall 1.265, user 0.080, sys 0.082, user+sys 0.162, 12.8 % CPU
32        volatile int h = g + 1;
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.261, user 0.079, sys 0.083, user+sys 0.162, 12.8 % CPU
Time for "pd_update total": wall 1.261, user 0.079, sys 0.083, user+sys 0.162, 12.8 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.232, user 0.076, sys 0.081, user+sys 0.157, 12.7 % CPU
Time for "pd_update total": wall 1.232, user 0.076, sys 0.081, user+sys 0.157, 12.7 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.250, user 0.078, sys 0.083, user+sys 0.161, 12.9 % CPU
Time for "pd_update total": wall 1.250, user 0.078, sys 0.083, user+sys 0.161, 12.9 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.258, user 0.080, sys 0.084, user+sys 0.164, 13.0 % CPU
Time for "pd_update total": wall 1.258, user 0.080, sys 0.084, user+sys 0.164, 13.0 % CPU
33        volatile int i2 = h * h;
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.276, user 0.082, sys 0.082, user+sys 0.164, 12.9 % CPU
Time for "pd_update total": wall 1.276, user 0.082, sys 0.082, user+sys 0.164, 12.9 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.271, user 0.083, sys 0.081, user+sys 0.164, 12.9 % CPU
Time for "pd_update total": wall 1.271, user 0.083, sys 0.081, user+sys 0.164, 12.9 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.280, user 0.079, sys 0.086, user+sys 0.165, 12.9 % CPU
Time for "pd_update total": wall 1.280, user 0.079, sys 0.086, user+sys 0.165, 12.9 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.211, user 0.075, sys 0.081, user+sys 0.156, 12.9 % CPU
Time for "pd_update total": wall 1.211, user 0.075, sys 0.081, user+sys 0.156, 12.9 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.264, user 0.077, sys 0.086, user+sys 0.163, 12.9 % CPU
Time for "pd_update total": wall 1.264, user 0.077, sys 0.086, user+sys 0.163, 12.9 % CPU
34        volatile int j = i2 - b;
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.240, user 0.078, sys 0.081, user+sys 0.159, 12.8 % CPU
Time for "pd_update total": wall 1.240, user 0.078, sys 0.081, user+sys 0.159, 12.8 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.256, user 0.078, sys 0.082, user+sys 0.160, 12.7 % CPU
Time for "pd_update total": wall 1.257, user 0.078, sys 0.082, user+sys 0.160, 12.7 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.267, user 0.078, sys 0.082, user+sys 0.160, 12.6 % CPU
Time for "pd_update total": wall 1.267, user 0.078, sys 0.082, user+sys 0.160, 12.6 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.254, user 0.079, sys 0.081, user+sys 0.160, 12.8 % CPU
Time for "pd_update total": wall 1.255, user 0.079, sys 0.081, user+sys 0.160, 12.7 % CPU
Time for "pthdb_session_update": wall 0.000, user 0.000, sys 0.000, user+sys 0.000, NaNQ % CPU
Time for "sync_threadlists": wall 1.257, user 0.078, sys 0.082, user+sys 0.160, 12.7 % CPU
Time for "pd_update total": wall 1.257, user 0.078, sys 0.082, user+sys 0.160, 12.7 % CPU

real    0m52.611s
user    0m5.930s
sys     0m8.012s
---
 gdb/aix-thread.c | 60 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 43 insertions(+), 17 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index aa14f8ff045..2355f87db54 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -44,6 +44,7 @@
 #include "inferior.h"
 #include "regcache.h"
 #include "cli/cli-cmds.h"
+#include "maint.h"
 #include "ppc-tdep.h"
 #include "observable.h"
 #include "objfiles.h"
@@ -706,30 +707,35 @@ state2str (pthdb_state_t state)
     }
 }
 
+/* Number of thread descriptors to fetch per getthrds() call.
+   Fetching in batches reduces syscall overhead to one call per
+   GETTHRDS_BATCH threads.  */
+constexpr int GETTHRDS_BATCH = 64;
+
 /* Search through the list of all kernel threads for the thread
-   that has stopped on a SIGTRAP signal, and return its TID.
+   that has stopped on a signal, and return its TID.
    Return 0 if none found.  */
 
 static pthdb_tid_t
 get_signaled_thread (int pid)
 {
-  struct thrdsinfo64 thrinf;
+  struct thrdsinfo64 thrinf[GETTHRDS_BATCH];
   tid_t ktid = 0;
 
-  while (1)
-    {
-      if (getthrds (pid, &thrinf,
-		    sizeof (thrinf), &ktid, 1) != 1)
-	break;
+  scoped_time_it time_it ("get_signaled_thread");
 
+  for (int count;
+       (count = getthrds (pid, thrinf, sizeof (thrinf[0]), &ktid,
+			  GETTHRDS_BATCH)) > 0;)
+    {
       /* We also need to keep in mind Trap and interrupt or any
 	 signal that needs to be handled in pd_update ().  */
-
-      if (thrinf.ti_cursig)
-	return thrinf.ti_tid;
+      for (int i = 0; i < count; i++)
+	if (thrinf[i].ti_cursig)
+	  return thrinf[i].ti_tid;
     }
 
-  /* Didn't find any thread stopped on a SIGTRAP signal.  */
+  /* Didn't find any thread stopped on a signal.  */
   return 0;
 }
 
@@ -763,18 +769,30 @@ sync_threadlists (pid_t pid)
 
   for (cmd = PTHDB_LIST_FIRST;; cmd = PTHDB_LIST_NEXT)
     {
-      status = pthdb_pthread (data->pd_session, &pdtid, cmd);
+      {
+	scoped_time_it time_it ("pthdb_pthread");
+	status = pthdb_pthread (data->pd_session, &pdtid, cmd);
+      }
       if (status != PTHDB_SUCCESS || pdtid == PTHDB_INVALID_PTHREAD)
 	break;
 
-      status = pthdb_pthread_ptid (data->pd_session, pdtid, &pthid);
+      {
+	scoped_time_it time_it ("pthdb_pthread_ptid");
+	status = pthdb_pthread_ptid (data->pd_session, pdtid, &pthid);
+      }
       if (status != PTHDB_SUCCESS || pthid == PTHDB_INVALID_PTID)
 	continue;
 
-      status = pthdb_pthread_tid (data->pd_session, pdtid, &tid);
+      {
+	scoped_time_it time_it ("pthdb_pthread_tid");
+	status = pthdb_pthread_tid (data->pd_session, pdtid, &tid);
+      }
       ptid_t ptid (pid, tid, pthid);
 
-      status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+      {
+	scoped_time_it time_it ("pthdb_pthread_state");
+	status = pthdb_pthread_state (data->pd_session, pdtid, &state);
+      }
       in_queue_threads.insert (pdtid);
 
       /* If this thread has reported and exited, do not add it again.  */
@@ -853,7 +871,12 @@ pd_update (pid_t pid)
   if (!data->pd_active)
     return ptid_t (pid);
 
-  status = pthdb_session_update (data->pd_session);
+  scoped_time_it total_time_it ("pd_update total");
+
+  {
+    scoped_time_it time_it ("pthdb_session_update");
+    status = pthdb_session_update (data->pd_session);
+  }
   if (status != PTHDB_SUCCESS)
     return ptid_t (pid);
 
@@ -861,7 +884,10 @@ pd_update (pid_t pid)
      and not core files since list of threads never change for core
      files.  */
   if (target_has_execution ())
-    sync_threadlists (pid);
+    {
+      scoped_time_it time_it ("sync_threadlists");
+      sync_threadlists (pid);
+    }
 
   /* Define "current thread" as one that just received a trap signal.  */
 
-- 
2.51.2


                 reply	other threads:[~2026-09-16 11:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260916114603.17488-4-akamath996@gmail.com \
    --to=akamath996@gmail.com \
    --cc=Aditya.Kamath1@ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    --cc=simon.marchi@polymtl.ca \
    --cc=tom@tromey.com \
    --cc=ulrich.weigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox