This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 09/12] Make reinsert_breakpoint thread specific


On 06/02/2016 10:30 AM, Yao Qi wrote:
> V2: rewrite commit log to make it easy to read,
>     "id" -> "ptid",

Thanks.

> 
> This patch makes reinsert_breakpoint thread specific, which means we
> insert and remove reinsert_breakpoint breakpoints for a specific
> thread.  This motivation of this change is that I'll use
> reinsert_breakpoint for vCont;s on software single step target, so that
> GDBserver may insert one reinsert_breakpoint for one thread doing
> step-over, and insert one reinsert_breakpoint for another thread doing
> vCont;s.  After the operation of one thread is finished, GDBserver must
> remove reinsert_breakpoint for that thread only.
> 
> On the other hand, reinsert_breakpoint is used for step-over nowadays.
> GDBserver inserts reinsert_breakpoint, and wait only from the thread
> doing step-over.  After the step-over is done, GDBserver removes the
> reinsert_breakpoint.  If there is still any threads need step-over, do
> the same again until all threads are finished step-over.  In other words,
> reinsert_breakpoint is globally thread specific, but in an implicit way.
> It is natural to make it explicitly thread specific.
> 
> gdb/gdbserver:
> 
> 2016-05-20  Yao Qi  <yao.qi@linaro.org>
> 
> 	* mem-break.c (struct reinsert_breakpoint) <ptid>: New field.
> 	(set_reinsert_breakpoint): New parameter ptid.  Callers updated.
> 	(delete_reinsert_breakpoints): Likewise.
> 	(has_reinsert_breakpoints): Change parameter to thread.  Callers
> 	updated.
> 	(clone_one_breakpoint): Likewise.
> 	(uninsert_reinsert_breakpoints): Likewise.
> 	(reinsert_reinsert_breakpoints): Likewise.
> 	* mem-break.h (set_reinsert_breakpoint): Update declaration.
> 	(delete_reinsert_breakpoints): Likewise.
> 	(reinsert_reinsert_breakpoints): Likewise.
> 	(uninsert_reinsert_breakpoints): Likewise.
> 	(has_reinsert_breakpoints): Likewise.
> ---
>  gdb/gdbserver/linux-low.c | 25 +++++++++++--------------
>  gdb/gdbserver/mem-break.c | 44 +++++++++++++++++++++++++++++++-------------
>  gdb/gdbserver/mem-break.h | 23 ++++++++++++-----------
>  3 files changed, 54 insertions(+), 38 deletions(-)
> 
> diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
> index b0af178..414117b 100644
> --- a/gdb/gdbserver/linux-low.c
> +++ b/gdb/gdbserver/linux-low.c
> @@ -555,7 +555,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
>  		 hit it, so uninsert reinsert breakpoints from parent
>  		 (and child).  Once vfork child is done, reinsert
>  		 them back to parent.  */
> -	      uninsert_reinsert_breakpoints ();
> +	      uninsert_reinsert_breakpoints (ptid_of_lwp (event_lwp));
>  	      current_thread = saved_thread;

Would it work to pass down the thread pointer directly?

That would then allow pushing down the save current thread / restore
current thread juggling to uninsert_reinsert_breakpoints too.

>  	    }
>  
> @@ -597,11 +597,11 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
>  		 to access its memory without stopping all other threads
>  		 from other processes.  */
>  	      current_thread = child_thr;
> -	      delete_reinsert_breakpoints ();
> +	      delete_reinsert_breakpoints (ptid);
>  	      current_thread = saved_thread;

Likewise here, ptid is the child_thr's ptid here, I believe.

>  
> -	      gdb_assert (has_reinsert_breakpoints (parent_proc));
> -	      gdb_assert (!has_reinsert_breakpoints (child_proc));
> +	      gdb_assert (has_reinsert_breakpoints (event_thr));
> +	      gdb_assert (!has_reinsert_breakpoints (child_thr));
>  	    }
>  
>  	  /* Report the event.  */
> @@ -656,13 +656,12 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
>        if (event_lwp->bp_reinsert != 0 && can_software_single_step ())
>  	{
>  	  struct thread_info *saved_thread = current_thread;
> -	  struct process_info *proc = get_thread_process (event_thr);
>  
>  	  current_thread = event_thr;
> -	  reinsert_reinsert_breakpoints ();
> +	  reinsert_reinsert_breakpoints (ptid_of_lwp (event_lwp));
>  	  current_thread = saved_thread;

Ditto.  Etc.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]