From: Lancelot SIX <Lancelot.Six@amd.com>
To: Simon Marchi <simark@simark.ca>, gdb-patches@sourceware.org
Cc: lsix@lancelotsix.com
Subject: Re: [PATCH v4] gdb/gcore: interrupt all threads before generating the corefile
Date: Tue, 10 Jan 2023 14:40:37 +0000 [thread overview]
Message-ID: <0539ed3a-3163-981f-3b82-1ac31fad8b3a@amd.com> (raw)
In-Reply-To: <9c70aa6a-2a00-a985-c080-33d086597ee7@simark.ca>
Hi,
Thanks for the review!
>> + bool all_stop_was_running = false;
>> + if (exists_non_stop_target ())
>> + stop_all_threads ("generating coredump", inf);
>> + else
>> + {
>> + all_stop_was_running = any_thread_of_inferior (inf)->executing ();
> I'm wondering what happens if you call this while the inferior is doing
> an in-line step over, with one thread resumed and the others stopped. I
> think the others will have executing == false, so could you fall on one
> that isn't executing?
I am not entirely sure about those cases, but you might be right. I
could explicitly check all threads:
for (thread_info *t : all_non_exited_threads (inf->process_target (),
ptid_t (inf->pid))
all_stop_was_running |= t->executing ();
I'll do that in next revision.
>> +
>> +# This testcase checks that when in non-stop mode with some threads running
>> +# the gcore command can interrupt all threads, generate a core dump and
>> +# restart threads as required.
>> +
>
> Please add a short comment explaining the goal of this test.
>
There is one just above, but I recon it can be improved.
>> +standard_testfile
>> +
>> +if { [prepare_for_testing "failed to prepare" \
>> + ${testfile} ${srcfile} {pthreads debug}] } {
>> + return
>> +}
>
> prepare_for_testing starts GDB, but it gets restarted below anyway. Use
> build_executable to avoid the unnecessary spawn.
>
I will do that for next revision.
>> +
>> +save_vars { GDBFLAGS } {
>> + append GDBFLAGS " -ex \"set non-stop on\""
>> + clean_restart ${binfile}
>> +}
>> +
>> +set lineno [gdb_get_line_number "Break here"]
>> +if { ![runto $lineno] } {
>> + return
>> +}
>> +
>> +# We should be stopped in thread 1 while thread 2 is running.
>> +gdb_test_sequence "info threads" "info threads" {
>> + {Id\s+Target Id\s+Frame}
>> + {\*\s+1[^\n]*\n}
>> + {\s+2\s+[^\n]*\(running\)[^\n]*\n}
>> +}
>> +
>> +set th1_pc ""
>> +gdb_test_multiple "p/x \$pc" "fetch thread 1 PC" {
>> + -wrap -re "$::decimal = ($::hex)" {
>> + set th1_pc $expect_out(1,string)
>> + pass $gdb_test_name
>> + }
>
> Could that use get_hexadecimal_valueof?
>
Probably yes. I will use this also.
> Simon
>
Thanks,
Lancelot.
next prev parent reply other threads:[~2023-01-10 14:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 14:12 Lancelot SIX
2022-12-06 15:03 ` Eli Zaretskii
2023-01-04 11:15 ` [PING] " Lancelot SIX
2023-01-06 21:27 ` Simon Marchi
2023-01-10 14:40 ` Lancelot SIX [this message]
2023-01-30 16:33 ` Lancelot SIX
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=0539ed3a-3163-981f-3b82-1ac31fad8b3a@amd.com \
--to=lancelot.six@amd.com \
--cc=gdb-patches@sourceware.org \
--cc=lsix@lancelotsix.com \
--cc=simark@simark.ca \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).