This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] regression: Quit should not ask with core (PR 12071)
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Cc: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Date: Wed, 29 Sep 2010 16:04:17 +0100
- Subject: Re: [patch] regression: Quit should not ask with core (PR 12071)
- References: <20100929144316.GA16519@host1.dyn.jankratochvil.net>
On Wednesday 29 September 2010 15:43:16, Jan Kratochvil wrote:
> @@ -467,7 +467,7 @@ have_live_inferiors (void)
> multiple target interfaces. */
> if (have_inferiors ())
> for (t = current_target.beneath; t != NULL; t = t->beneath)
> - if (t->to_stratum == process_stratum)
> + if (t->to_stratum == process_stratum && t->to_has_execution (t))
> return 1;
This is about the same as removing the loop and calling "target_has_execution".
But, that wouldn't be correct either, because the to_has_execution depends
on the inferior selected (see default_child_has_execution). So, for example,
if you have two inferiors in your gdb session, one of them is running as
a process, while the other is still just a pseudo-inferior / file_stratum
inferior yet, and you have the latter selected as current, your patch
will make that have-live-inferiors check still return 0, while there _is_
one live inferior.
The quickest fix is to iterate over all inferiors, and in turn, switch to
the iterated inferior, and check target_has_execution. In pseudo-C:
int
have_live_inferiors (void)
{
struct inferior *inf;
foreach (inf in inferiors)
{
thread = any_thread_of_inferior (inf);
if (thread)
{
switch_to_thread (thread->ptid);
if (target_has_execution)
return 1;
}
}
return 0;
}
Want to give that a try?
--
Pedro Alves