From: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "palves@redhat.com" <palves@redhat.com>
Subject: RE: [PATCH v7 5/5] gdb/infrun: handle already-exited threads when attempting to stop
Date: Wed, 22 Apr 2020 16:07:15 +0000 [thread overview]
Message-ID: <SN6PR11MB289323E8CA25B502E67856C1C4D20@SN6PR11MB2893.namprd11.prod.outlook.com> (raw)
In-Reply-To: <e540fa513347a44c1ae4fc4aa41b506098ad97d8.1587563226.git.tankut.baris.aktemur@intel.com>
On Wednesday, April 22, 2020 5:01 PM, Aktemur, Tankut Baris wrote:
> diff --git a/gdb/infrun.c b/gdb/infrun.c
> index 167d50ff3ab..93169269553 100644
> --- a/gdb/infrun.c
> +++ b/gdb/infrun.c
> @@ -4781,7 +4781,47 @@ stop_all_threads (void)
> {
> int need_wait = 0;
>
> - update_thread_list ();
> + for (inferior *inf : all_non_exited_inferiors ())
> + {
Sorry. There is a 'switch_to_inferior_no_thread (inf);', here.
> + update_thread_list ();
> +
> + /* After updating the thread list, it's possible to end
> + up with pid != 0 but no threads, if the inf's process
> + has exited but we have not processed that event yet.
> + The exit event must be waiting somewhere in the queue
> + to be processed. Silently add a thread so that we do
> + a wait_one() below to pick the pending event. */
> +
> + bool has_threads = false;
> + for (thread_info *tp ATTRIBUTE_UNUSED
> + : inf->non_exited_threads ())
> + {
> + has_threads = true;
> + break;
> + }
> +
> + if (has_threads)
> + continue;
> +
> + ptid_t ptid (inf->pid, inf->pid, 0);
> +
> + /* Re-surrect the thread, if not physically deleted.
> + Add a new one otherwise. */
> + thread_info *t = find_thread_ptid (inf->process_target (), ptid);
> + gdb_assert (t == nullptr || t->state == THREAD_EXITED);
> +
> + if (debug_infrun)
> + fprintf_unfiltered (gdb_stdlog, "infrun: stop_all_threads,"
> + " inf (pid %d): %s a thread", inf->pid,
> + (t == nullptr)
> + ? "adding" : "resurrecting");
> +
> + if (t == nullptr)
> + t = add_thread_silent (inf->process_target (), ptid);
> +
> + set_executing (inf->process_target (), ptid, true);
> + t->state = THREAD_STOPPED;
> + }
Thanks.
-Baris
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
next prev parent reply other threads:[~2020-04-22 16:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1587563226.git.tankut.baris.aktemur@intel.com>
2020-04-22 15:00 ` [PATCH v7 3/5] gdb/remote: do not delete a thread if it has a pending exit event Tankut Baris Aktemur
2020-05-04 14:43 ` Pedro Alves
2020-05-04 15:33 ` Aktemur, Tankut Baris
2020-05-13 14:20 ` Pedro Alves
2020-04-22 15:00 ` [PATCH v7 5/5] gdb/infrun: handle already-exited threads when attempting to stop Tankut Baris Aktemur
2020-04-22 16:07 ` Aktemur, Tankut Baris [this message]
2020-05-03 15:38 ` Aktemur, Tankut Baris
2020-05-13 21:15 ` Pedro Alves
2020-05-14 8:50 ` Aktemur, Tankut Baris
2020-05-14 11:32 ` Pedro Alves
2020-05-14 11:42 ` Aktemur, Tankut Baris
2020-05-14 11:25 ` Pedro Alves
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=SN6PR11MB289323E8CA25B502E67856C1C4D20@SN6PR11MB2893.namprd11.prod.outlook.com \
--to=tankut.baris.aktemur@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.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