This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Bail out of processing stop if hook-stop resumes target / changes context
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Yao Qi <qiyaoltc at gmail dot com>, gdb-patches at sourceware dot org
- Date: Thu, 27 Aug 2015 14:35:27 +0100
- Subject: Re: [PATCH] Bail out of processing stop if hook-stop resumes target / changes context
- Authentication-results: sourceware.org; auth=none
- References: <1439836415-22008-1-git-send-email-palves at redhat dot com> <86zj1n1ycy dot fsf at gmail dot com> <55DC8E2C dot 6010308 at redhat dot com>
Pedro Alves <palves@redhat.com> writes:
>>> - if (stop_command)
>>> - catch_errors (hook_stop_stub, stop_command,
>>> - "Error while running hook_stop:\n", RETURN_MASK_ALL);
>>> + if (stop_command != NULL)
>>> + {
>>> + struct stop_context *saved_context = save_stop_context ();
>>> + struct cleanup *old_chain
>>> + = make_cleanup (release_stop_context_cleanup, saved_context);
>>> +
>>> + catch_errors (hook_stop_stub, stop_command,
>>> + "Error while running hook_stop:\n", RETURN_MASK_ALL);
>>> +
>>> + /* If the stop hook resumes the target, then there's no point in
>>> + trying to notify about the previous stop; its context is
>>> + gone. Likewise if the command switches thread or inferior --
>>> + the observers would print a stop for the wrong
>>> + thread/inferior. */
>>> + if (stop_context_changed (saved_context))
>>> + {
>>> + do_cleanups (old_chain);
>>> + return 1;
>>> + }
>>> + do_cleanups (old_chain);
>>> + }
>>
>> I am wondering why don't we let interpreter in async to execute
>> stop_command, and we simply return here. In this way, we don't have to
>> know whether stop_command resumes the target or switches the thread.
>> Once there is no event from event loop, the target really stops and
>> hook-stop is already executed.
>
> Not sure I understood the suggestion -- I don't see how that would end
> up being different. If the hook-stop does "continue&", then we still need
> to know that the target was resumed. Likewise if the hook-stop just
> does "thread N" and thus switches to another thread -- there's no
> execution involved in that case so seems to me interpreter async/sync
> makes no difference.
I was thinking that why do we need stop_id or stop_context here. We can
let interpreter to execute hook-stop commands in an async way, and GDB
reads events out of event loop, until all events are consumed. In this
way, do we still need stop_id or stop_context?
--
Yao (éå)