From: Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org>
To: Lancelot SIX <lsix@lancelotsix.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCHv4 1/2] gdb: add some additional thread status debug output
Date: Fri, 22 Apr 2022 18:50:40 +0100 [thread overview]
Message-ID: <877d7hqa6n.fsf@redhat.com> (raw)
In-Reply-To: <20220421203458.cupeseh6bkpfbmpq@ubuntu.lan>
Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org> writes:
> Hi
>
> I just have some minor remarks on this patch. See below.
>
> On Thu, Apr 21, 2022 at 05:45:55PM +0100, Andrew Burgess via Gdb-patches wrote:
>> While working on this patch:
>>
>> https://sourceware.org/pipermail/gdb-patches/2022-January/185109.html
>>
>> I found it really useful to print the executing/resumed status of all
>> threads (or all threads in a particular inferior) at various
>> places (e.g. when a new inferior is started, when GDB attaches, etc).
>>
>> This debug was original part of the above patch, but I wanted to
>
> original -> originally ?
>
>> rewrite this as a separate patch and move the code into a new function
>> in infrun.h, which is what this patch does.
>>
>> Unless 'set debug infrun on' is in effect, then there should be no
>> user visible changes after this commit.
>> ---
>> gdb/infcmd.c | 19 ++++++++-----------
>> gdb/infrun.c | 3 +++
>> gdb/infrun.h | 26 ++++++++++++++++++++++++++
>> 3 files changed, 37 insertions(+), 11 deletions(-)
>>
>> diff --git a/gdb/infcmd.c b/gdb/infcmd.c
>> index 84eb6e5d79b..1beade2acec 100644
>> --- a/gdb/infcmd.c
>> +++ b/gdb/infcmd.c
>> @@ -238,6 +238,9 @@ post_create_inferior (int from_tty)
>> /* Be sure we own the terminal in case write operations are performed. */
>> target_terminal::ours_for_output ();
>>
>> + infrun_debug_show_threads ("threads in the newly created inferior",
>> + current_inferior ()->non_exited_threads ());
>> +
>> /* If the target hasn't taken care of this already, do it now.
>> Targets which need to access registers during to_open,
>> to_create_inferior, or to_attach should do it earlier; but many
>> @@ -454,6 +457,9 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how)
>> shouldn't refer to run_target again. */
>> run_target = NULL;
>>
>> + infrun_debug_show_threads ("immediately after create_process",
>> + current_inferior ()->non_exited_threads ());
>> +
>> /* We're starting off a new process. When we get out of here, in
>> non-stop mode, finish the state of all threads of that process,
>> but leave other threads alone, as they may be stopped in internal
>> @@ -2589,17 +2595,8 @@ attach_command (const char *args, int from_tty)
>> shouldn't refer to attach_target again. */
>> attach_target = NULL;
>>
>> - if (debug_infrun)
>> - {
>> - infrun_debug_printf ("immediately after attach:");
>> - for (thread_info *thread : inferior->non_exited_threads ())
>> - infrun_debug_printf (" thread %s, executing = %d, resumed = %d, "
>> - "state = %s",
>> - thread->ptid.to_string ().c_str (),
>> - thread->executing (),
>> - thread->resumed (),
>> - thread_state_string (thread->state));
>> - }
>> + infrun_debug_show_threads ("immediately after attach",
>> + current_inferior ()->non_exited_threads ());
>>
>> /* Enable async mode if it is supported by the target. */
>> if (target_can_async_p ())
>> diff --git a/gdb/infrun.c b/gdb/infrun.c
>> index c311240b78c..a814f5cbc2b 100644
>> --- a/gdb/infrun.c
>> +++ b/gdb/infrun.c
>> @@ -5043,6 +5043,9 @@ stop_all_threads (const char *reason, inferior *inf)
>> INFRUN_SCOPED_DEBUG_START_END ("reason=%s, inf=%d", reason,
>> inf != nullptr ? inf->num : -1);
>>
>> + infrun_debug_show_threads ("non-exited threads",
>> + all_non_exited_threads ());
>> +
>> scoped_restore_current_thread restore_thread;
>>
>> /* Enable thread events on relevant targets. */
>> diff --git a/gdb/infrun.h b/gdb/infrun.h
>> index 9685f3a9775..1421fa4050a 100644
>> --- a/gdb/infrun.h
>> +++ b/gdb/infrun.h
>> @@ -48,6 +48,32 @@ extern bool debug_infrun;
>> #define INFRUN_SCOPED_DEBUG_ENTER_EXIT \
>> scoped_debug_enter_exit (debug_infrun, "infrun")
>>
>> +/* A infrun debug helper routine to print out all the threads in the set
>> + THREADS (which should be a range type that returns thread_info*
>> + objects).
>> +
>> + The TITLE is a string that is printed before the list of threads.
>> +
>> + Output is only produced when 'set debug infrun on'. */
>> +
>> +template<typename ThreadRange>
>> +static inline void
>> +infrun_debug_show_threads (const char *title, ThreadRange threads)
>> +{
>> + if (debug_infrun)
>> + {
>> + infrun_debug_printf ("%s:", (title));
>
> I do not think the extra parens around title are necessary.
Thanks, I made these fixes locally.
Andrew
>
> Best,
> Lancelot
>
>> + for (thread_info *thread : threads)
>> + infrun_debug_printf (" thread %s, executing = %d, resumed = %d, "
>> + "state = %s",
>> + thread->ptid.to_string ().c_str (),
>> + thread->executing (),
>> + thread->resumed (),
>> + thread_state_string (thread->state));
>> + }
>> +}
>> +
>> +
>> /* Nonzero if we want to give control to the user when we're notified
>> of shared library events by the dynamic linker. */
>> extern int stop_on_solib_events;
>> --
>> 2.25.4
>>
next prev parent reply other threads:[~2022-04-22 17:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-30 20:03 [PATCH 0/3] Changes to thread state tracking Andrew Burgess
2021-08-30 20:03 ` [PATCH 1/3] gdb: make thread_info::executing private Andrew Burgess
2021-09-01 13:53 ` Simon Marchi via Gdb-patches
2021-09-07 11:46 ` Andrew Burgess
2021-08-30 20:03 ` [PATCH 2/3] gdb: make thread_suspend_state::stop_pc optional Andrew Burgess
2021-09-01 14:23 ` Simon Marchi via Gdb-patches
2021-09-07 13:21 ` Andrew Burgess
2021-09-07 14:10 ` Simon Marchi via Gdb-patches
2021-09-08 9:50 ` Andrew Burgess
2021-08-30 20:03 ` [PATCH 3/3] gdb: make thread_info executing and resumed state more consistent Andrew Burgess
2021-09-01 15:09 ` Simon Marchi via Gdb-patches
2021-09-22 11:21 ` Andrew Burgess
2021-09-23 17:14 ` Simon Marchi via Gdb-patches
2021-09-29 8:09 ` Andrew Burgess
2021-10-08 19:33 ` Simon Marchi via Gdb-patches
2022-01-13 18:34 ` [PATCHv3] " Andrew Burgess via Gdb-patches
2022-01-14 17:10 ` Simon Marchi via Gdb-patches
2022-02-24 15:52 ` Andrew Burgess via Gdb-patches
2022-03-03 19:42 ` Simon Marchi via Gdb-patches
2022-03-07 7:39 ` Aktemur, Tankut Baris via Gdb-patches
2022-03-30 9:19 ` Andrew Burgess via Gdb-patches
2022-04-21 16:45 ` [PATCHv4 0/2] Make " Andrew Burgess via Gdb-patches
2022-04-21 16:45 ` [PATCHv4 1/2] gdb: add some additional thread status debug output Andrew Burgess via Gdb-patches
2022-04-21 20:35 ` Lancelot SIX via Gdb-patches
2022-04-22 17:50 ` Andrew Burgess via Gdb-patches [this message]
2022-05-03 14:04 ` Andrew Burgess via Gdb-patches
2022-04-21 16:45 ` [PATCHv4 2/2] gdb: make thread_info executing and resumed state more consistent Andrew Burgess via Gdb-patches
2022-04-26 13:28 ` Nidal Faour via Gdb-patches
2022-08-08 11:04 ` [PATCHv4 0/2] Make " Craig Blackmore
2022-08-08 12:01 ` Andrew Burgess via Gdb-patches
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=877d7hqa6n.fsf@redhat.com \
--to=gdb-patches@sourceware.org \
--cc=aburgess@redhat.com \
--cc=lsix@lancelotsix.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