Re: [PATCH 1/8] Switch to current thread before finish_step_over

Pedro Alves
2016-05-24T15:59:31Z

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