From: Simon Marchi <simark@simark.ca>
To: Lancelot SIX <lancelot.six@amd.com>, gdb-patches@sourceware.org
Cc: lsix@lancelotsix.com
Subject: Re: [PATCH v4] gdb/gcore: interrupt all threads before generating the corefile
Date: Fri, 6 Jan 2023 16:27:22 -0500 [thread overview]
Message-ID: <9c70aa6a-2a00-a985-c080-33d086597ee7@simark.ca> (raw)
In-Reply-To: <20221206141248.2485033-1-lancelot.six@amd.com>
> @@ -131,6 +132,28 @@ gcore_command (const char *args, int from_tty)
> if (!target_has_execution ())
> noprocess ();
>
> + scoped_restore_current_thread restore_current_thread;
> + scoped_disable_commit_resumed disable_commit_resume ("generating coredump");
> + struct inferior *inf = current_inferior ();
> + scoped_finish_thread_state finish_state (inf->process_target (),
> + ptid_t (inf->pid));
> +
> + 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?
What if we are in all-stop, but we resumed with schedlock on?
Note that I'd be fine with merging the patch without considering those
cases, since it's clearly an improvement already.
> diff --git a/gdb/testsuite/gdb.base/gcore-nonstop.exp b/gdb/testsuite/gdb.base/gcore-nonstop.exp
> new file mode 100644
> index 00000000000..4a240eb0872
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/gcore-nonstop.exp
> @@ -0,0 +1,77 @@
> +# Copyright 2022 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/>.
> +
> +# 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.
> +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.
> +
> +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?
Simon
next prev parent reply other threads:[~2023-01-06 21:27 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 [this message]
2023-01-10 14:40 ` Lancelot SIX
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=9c70aa6a-2a00-a985-c080-33d086597ee7@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=lancelot.six@amd.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).