Re: RFC: fix crash when inferior exits during "continue"

Pedro Alves
2012-02-16T11:44:33Z

On 02/15/2012 08:13 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> Pedro> and the current thread disappears while the user is typing,
> Pedro> the command ends up being applied to a random thread, which is
> Pedro> not good.
>
> This makes sense to me if the user entered a background command.
> But why not switch if the last command was a foreground command?

Yes, agreed. The lame reason is that the original non-stop work didn't
care that much about the CLI (and there's no foreground in MI), and I
have an old TODO item for that, that I never got around to. :-P

> What do you think of the appended?

> diff --git a/gdb/testsuite/gdb.base/inferior-died.c b/gdb/testsuite/gdb.base/inferior-died.c
> new file mode 100644
> index 0000000..66227cf
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/inferior-died.c

> +#include <stdio.h>

Doesn't look necessary.

> static void
> @@ -1095,6 +1096,8 @@ do_restore_current_thread_cleanup (void *arg)
> set_current_inferior (find_inferior_id (old->inf_id));
> }
>
> + current_inferior ()->removable = old->was_removable;

This is unnecessary. restore_current_thread_cleanup_dtor
is called when either you run or discard the cleanup.

Otherwise looks good. Thanks.

--
Pedro Alves