[2/2] Enable range stepping for ARM on GDBServer

Message ID CAH=s-PN-T_VVrjF2tf71wD15mLALEHbd3Wy_DA2duDrFYnqXmQ@mail.gmail.com
State New, archived
Headers

Commit Message

Yao Qi Sept. 1, 2016, 4:44 p.m. UTC
  [sigh, I am testing my arm range stepping patches today...]

On Thu, Sep 1, 2016 at 4:59 PM, Pedro Alves <palves@redhat.com> wrote:
>>>
>>>> I'm sorry I can't be more helpful at the moment but I wanted to post
>>>> this issue before I have to leave for a while.
>>>
>>> Understood.  Does enabling range stepping unblock something else?
>>
>> It would unblock ARM tracepoints, as per Yao's requirements...
>
> Tracepoints make gdbserver single-step and then not report the event
> to gdb, so I do see the parallel with range-stepping.  Throwing
> while-stepping into the equation would make it even more clear.
>

Range-stepping makes gdbserver single-step and then not report the event
to gdb if thread pc is within the range.  It is similar to tracepoint, but much
simpler.

Both range-stepping and tracepoing needs to remove reinsert_breakpoint
when gdbserver gets an event but doesn't report it back to gdb.  However,
gdbserver doesn't do so now.  That is the reason I believe we need to
support range-stepping first, and I am working on this (but interrupted by
7.12 release).  The draft patch attached removes reinsert_breakpoint when
gdbserver gets an event but not to report it back to gdb.

Beside "removing reinsert_breakpoint on gdbserver internal event", we'd
better to think that "each backend unwinders don't have to worry about
unavailable data".  I posted a draft here
https://sourceware.org/ml/gdb-patches/2016-05/msg00060.html, I need
some review comments.  Pedro,
can you take a look?  This is not a hard requirement for ARM tracepoint
support.
  

Comments

Pedro Alves Sept. 1, 2016, 5:02 p.m. UTC | #1
On 09/01/2016 05:44 PM, Yao Qi wrote:

> Beside "removing reinsert_breakpoint on gdbserver internal event", we'd
> better to think that "each backend unwinders don't have to worry about
> unavailable data".  I posted a draft here
> https://sourceware.org/ml/gdb-patches/2016-05/msg00060.html, I need
> some review comments.  Pedro,
> can you take a look?  This is not a hard requirement for ARM tracepoint
> support.

I plan to, but there a few things still blocking 7.12 that I'd like to
clear first.

Thanks,
Pedro Alves
  
Antoine Tremblay Sept. 1, 2016, 5:05 p.m. UTC | #2
Yao Qi writes:

> [sigh, I am testing my arm range stepping patches today...]
>

Thanks for working on this :)

> On Thu, Sep 1, 2016 at 4:59 PM, Pedro Alves <palves@redhat.com> wrote:
>>>>
>>>>> I'm sorry I can't be more helpful at the moment but I wanted to post
>>>>> this issue before I have to leave for a while.
>>>>
>>>> Understood.  Does enabling range stepping unblock something else?
>>>
>>> It would unblock ARM tracepoints, as per Yao's requirements...
>>
>> Tracepoints make gdbserver single-step and then not report the event
>> to gdb, so I do see the parallel with range-stepping.  Throwing
>> while-stepping into the equation would make it even more clear.
>>
>
> Range-stepping makes gdbserver single-step and then not report the event
> to gdb if thread pc is within the range.  It is similar to tracepoint, but much
> simpler.
>
> Both range-stepping and tracepoing needs to remove reinsert_breakpoint
> when gdbserver gets an event but doesn't report it back to gdb.  However,
> gdbserver doesn't do so now.  That is the reason I believe we need to
> support range-stepping first, and I am working on this (but interrupted by
> 7.12 release).  The draft patch attached removes reinsert_breakpoint when
> gdbserver gets an event but not to report it back to gdb.
>

OK

> Beside "removing reinsert_breakpoint on gdbserver internal event", we'd
> better to think that "each backend unwinders don't have to worry about
> unavailable data".  I posted a draft here
> https://sourceware.org/ml/gdb-patches/2016-05/msg00060.html, I need
> some review comments.  Pedro,
> can you take a look?  This is not a hard requirement for ARM tracepoint
> support.

Thanks for not making this one a hard requirement!

Regards,
Antoine
  

Patch

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 45061ac..2f30bc1 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -3662,17 +3662,31 @@  linux_wait_1 (ptid_t ptid,
 	  (*the_low_target.set_pc) (regcache, event_child->stop_pc);
 	}
 
-      /* We may have finished stepping over a breakpoint.  If so,
-	 we've stopped and suspended all LWPs momentarily except the
-	 stepping one.  This is where we resume them all again.  We're
-	 going to keep waiting, so use proceed, which handles stepping
-	 over the next breakpoint.  */
-      if (debug_threads)
-	debug_printf ("proceeding all threads.\n");
-
       if (step_over_finished)
-	unsuspend_all_lwps (event_child);
+	{
+	  /* If we have finished stepping over a breakpoint, we've
+	     stopped and suspended all LWPs momentarily except the
+	     stepping one.  This is where we resume them all again.
+	     We're going to keep waiting, so use proceed, which
+	     handles stepping over the next breakpoint.  */
+	  unsuspend_all_lwps (event_child);
+	}
+      else
+	{
+	  /* Remove the singlestep breakpoints if any.  Note that
+	     there isn't singlestep breakpoint if we finished stepping
+	     over.  */
+	  if (can_software_single_step ()
+	      && has_reinsert_breakpoints (current_thread))
+	    {
+	      stop_all_lwps (0, event_child);
+	      delete_reinsert_breakpoints (current_thread);
+	      unstop_all_lwps (0, event_child);
+	    }
+	}
 
+      if (debug_threads)
+	debug_printf ("proceeding all threads.\n");
       proceed_all_lwps ();
       return ignore_event (ourstatus);
     }