This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/2] Avoid step-over infinite loop in GDBServer
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Antoine Tremblay <antoine dot tremblay at ericsson dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Wed, 22 Feb 2017 10:15:24 +0000
- Subject: Re: [PATCH 2/2] Avoid step-over infinite loop in GDBServer
- Authentication-results: sourceware.org; auth=none
- References: <20161129120702.9490-1-antoine.tremblay@ericsson.com> <20161129120702.9490-2-antoine.tremblay@ericsson.com>
On Tue, Nov 29, 2016 at 12:07 PM, Antoine Tremblay
<antoine.tremblay@ericsson.com> wrote:
> Before this patch, GDBServer always executed a step-over if it found a
> thread that needed one.
>
> This could be a problem in a situation exposed by non-stop-fair-events.exp
> where the code and the breakpoint placement is like so:
>
> instruction A : has a single-step breakpoint installed for thread 1 and 2
> instruction B : has a single-step breakpoint installed for thread 3
> and is a branch to A.
>
Is instruction B following instruction A? Is it like
.L1:
nop
b .L1
> In this particular case:
>
> - GDBServer stops on instruction A in thread 1.
> - Deletes thread 1 single-step breakpoint.
> - Starts a step-over of thread 1 to step-over the thread 2 breakpoint.
> - GDBServer finishes a step-over and is at instruction B.
> - GDBserver starts a step-over of thread 1 to step-over the thread 3
> breakpoint at instruction B.
Why does GDBserver starts a step-over again? is it because
need_step_over_p doing checks like this,
if (breakpoint_here (pc) || fast_tracepoint_jump_here (pc))
{
/* Don't step over a breakpoint that GDB expects to hit
though. If the condition is being evaluated on the target's side
and it evaluate to false, step over this breakpoint as well. */
if (gdb_breakpoint_here (pc)
&& gdb_condition_true_at_breakpoint (pc)
&& gdb_no_commands_at_breakpoint (pc))
{
if (debug_threads)
debug_printf ("Need step over [LWP %ld]? yes, but found"
" GDB breakpoint at 0x%s; skipping step over\n",
lwpid_of (thread), paddress (pc));
current_thread = saved_thread;
return 0;
}
else
{
if (debug_threads)
debug_printf ("Need step over [LWP %ld]? yes, "
"found breakpoint at 0x%s\n",
lwpid_of (thread), paddress (pc));
/* We've found an lwp that needs stepping over --- return 1 so
that find_inferior stops looking. */
current_thread = saved_thread;
return 1;
}
}
there is a single step breakpoint on pc, and it is obviously not a
gdb breakpoint, so 1 is returned.
> - GDBServer stops on instuction A in thread 1.
> - GDBServer is now in an infinite loop.
>
I am wondering can we take the information that we've already step
over a breakpoint for thread A into need_step_over_p, if we see pc
is on another single step breakpoint for thread B, don't do step over.
--
Yao (齐尧)