This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/8] Switch to current thread before finish_step_over
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>, gdb-patches at sourceware dot org
- Date: Tue, 24 May 2016 16:59:27 +0100
- Subject: Re: [PATCH 1/8] Switch to current thread before finish_step_over
- Authentication-results: sourceware.org; auth=none
- References: <1463757161-25850-1-git-send-email-yao dot qi at linaro dot org> <1463757161-25850-2-git-send-email-yao dot qi at linaro dot org>
On 05/20/2016 04:12 PM, Yao Qi wrote:
> This patch switched current_thread to the step we are doing step-over
s/to the step/to the thread/
> @@ -4741,7 +4749,13 @@ complete_ongoing_step_over (void)
>
> lwp = find_lwp_pid (step_over_bkpt);
> if (lwp != NULL)
> - finish_step_over (lwp);
> + {
> + struct thread_info *saved_thread = current_thread;
> +
> + current_thread = get_lwp_thread (lwp);
> + finish_step_over (lwp);
> + current_thread = saved_thread;
> + }
So the pattern should be that if a function takes a thread/lwp
parameter, then it should work with that, instead of relying on
the global state. So I think that it should be finish_step_over
itself that switches the current thread, because it is an implementation
detail of finish_step_over that is calls into functions that rely
on the global current thread. Putting the save/restore there
should make it more obvious why it's needed.
Thanks,
Pedro Alves