From: Aditya Kamath <Aditya.Kamath1@ibm.com>
To: Abhay Kandpal <abhay@linux.ibm.com>,
Aditya Vidyadhar Kamath <akamath996@gmail.com>,
Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
"simon.marchi@polymtl.ca" <simon.marchi@polymtl.ca>,
"tom@tromey.com" <tom@tromey.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
SANGAMESH MALLAYYA <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH v1][RFC] Speed up next/step while debugging multithreaded programs on AIX.
Date: Thu, 10 Sep 2026 10:15:08 +0000 [thread overview]
Message-ID: <LV8PR15MB64880A03BF7C3E96F79B4013D6BF2@LV8PR15MB6488.namprd15.prod.outlook.com> (raw)
In-Reply-To: <b78628da-05fa-4303-b824-fe6c993741c9@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 3571 bytes --]
Hi Abhay and community members,
Thank you very much for the feedback. Please see my comments below to your concerns and I am sending v2 of this patch after this soon.
>Doesn't a breakpoint stop also arrive as >TARGET_WAITKIND_STOPPED with GDB_SIGNAL_TRAP?
>get_signaled_thread() already looks for the thread stopped >on SIGTRAP to find the
>current thread, and that has to work at breakpoint stops >too, so I would expect
>a breakpoint hit to look the same as a single-step here.
>If so, breakpoint stops also get step_stop = true and skip >the sync
>The last_thread_count < 0 check only covers the first stop >after pd_activate().
After that first sync, >last_thread_count is >= 0 for the rest of the session
and >need_sync becomes just !step_stop. So from the second stop >onwards
a breakpoint hit skips the sync, and any threads >created since the previous
stop are missed.
You are right here. A user breakpoint hit, a software single-step completion, and the thread-creation stub breakpoint all arrive with exactly the same WAITKIND_STOPPED + GDB_SIGNAL_TRAP. The v1 version of this patch couldn't tell them apart, so step_stop was true for breakpoint hits too, and the sync was wrongly skipped. I checked this. I did not think in this angle and just thought about speeding up. Thanks for pointing it out. Yeah the benchmark will not point this out.
>resume() is already told whether GDB asked for a single >step, and it already
>has the aix_thread_variables pointer in hand. Could you >save the flag there
>and use it here instead of inferring it from the signal?
>/* aix_thread_target::resume (), after the existing
>data = get_thread_data_helper_for_ptid (ptid); */
>data->last_resume_step = step;
>/* in wait () */
>bool step_stop = (data->last_resume_step
>&& status->kind () == TARGET_WAITKIND_STOPPED
>&& status->sig () == GDB_SIGNAL_TRAP);
>That would also handle "next" over a function call, where GDB puts a temporary
>breakpoint at the return address and continues rather than single-stepping
>through the callee. resume() is called with step = 0 in that case, so the
>stop would correctly get a full sync even though the user typed "next”.
I like this idea but while implementing came across something else. On AIX rs6000_software_single_step() is registered as the architecture's next-PC provider. infrun.c's maybe_software_singlestep() calls it, which inserts breakpoints at the next instruction(s) and returns hw_step = false, so do_target_resume() always passes step=0. Saving that would have made last_resume_step always 0, killing the optimisation entirely.
In the debug log I saw every do_target_resume call showed step=0, even for next.
The right signal is whether software single-step breakpoints were inserted for the current thread at the time of the resume. That is what thread_has_single_step_breakpoints_set() reports, and it is set when and only when GDB is software-single-stepping through source lines.
So in resume() in v2 version of this patch you will see:
struct thread_info *tp = inferior_thread ();
data->last_resume_step = thread_has_single_step_breakpoints_set (tp);
This is 1 when GDB inserted single-step breakpoints which is a next/step resume, and 0 for any free continue or temporary-breakpoint resume. The wait() side then checks both last_resume_step and GDB_SIGNAL_TRAP — both must be true for the sync skip to apply.
Let me know your thoughts in the next version of this patch.
Have a nice day ahead.
Thank you and regards,
Aditya.
[-- Attachment #2: Type: text/html, Size: 15541 bytes --]
prev parent reply other threads:[~2026-09-10 10:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 5:43 Aditya Vidyadhar Kamath
2026-09-09 17:58 ` Abhay Kandpal
2026-09-10 10:15 ` Aditya Kamath [this message]
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=LV8PR15MB64880A03BF7C3E96F79B4013D6BF2@LV8PR15MB6488.namprd15.prod.outlook.com \
--to=aditya.kamath1@ibm.com \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=abhay@linux.ibm.com \
--cc=akamath996@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=sangamesh.swamy@in.ibm.com \
--cc=simon.marchi@polymtl.ca \
--cc=tom@tromey.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