public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Antoine Tremblay <antoine.tremblay@ericsson.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH 2/2] Avoid step-over infinite loop in GDBServer
Date: Wed, 22 Feb 2017 10:15:00 -0000	[thread overview]
Message-ID: <CAH=s-PPoNi-kwciCbC+UGxx+M1E7M9JctTM+f3kONJjxJ+SwOA@mail.gmail.com> (raw)
In-Reply-To: <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 (齐尧)

  parent reply	other threads:[~2017-02-22 10:15 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29 12:07 [PATCH 1/2] This patch fixes GDBServer's run control for single stepping Antoine Tremblay
2016-11-29 12:07 ` [PATCH 2/2] Avoid step-over infinite loop in GDBServer Antoine Tremblay
2017-01-16 17:27   ` Antoine Tremblay
2017-01-18 16:31     ` Antoine Tremblay
2017-02-03 16:21   ` Pedro Alves
2017-02-17  3:39     ` Antoine Tremblay
2017-02-22 10:15   ` Yao Qi [this message]
2017-03-27 13:28     ` Antoine Tremblay
2016-11-29 12:12 ` [PATCH 1/2] This patch fixes GDBServer's run control for single stepping Antoine Tremblay
2017-01-16 17:28 ` Antoine Tremblay
2017-01-27 15:01 ` Yao Qi
2017-01-27 16:07   ` Antoine Tremblay
2017-01-27 17:01     ` Yao Qi
2017-01-27 18:24       ` Antoine Tremblay
2017-01-29 21:41         ` Yao Qi
2017-01-30 13:29           ` Antoine Tremblay
2017-02-03 16:13             ` Pedro Alves
2017-02-17  1:42               ` Antoine Tremblay
2017-02-17  2:05                 ` Pedro Alves
2017-02-17  3:06                   ` Antoine Tremblay
2017-02-17 22:19                     ` Yao Qi
2017-02-18  0:19                       ` Antoine Tremblay
2017-02-18 22:49                         ` Yao Qi
2017-02-19 19:40                           ` Antoine Tremblay
2017-02-19 20:31                             ` Antoine Tremblay
2017-03-29 12:41                           ` Antoine Tremblay
2017-03-29 14:11                             ` Antoine Tremblay
2017-03-29 17:54                               ` Antoine Tremblay
2017-03-30 16:06                             ` Yao Qi
2017-03-30 18:31                               ` Antoine Tremblay
2017-03-31 16:31                                 ` Yao Qi
2017-03-31 18:22                                   ` Antoine Tremblay
2017-04-03 12:41                                     ` Yao Qi
2017-04-03 13:18                                       ` Antoine Tremblay
2017-04-03 15:18                                         ` Yao Qi
2017-04-03 16:57                                           ` Antoine Tremblay
2017-02-16 22:32             ` Yao Qi
2017-02-17  2:17               ` Antoine Tremblay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH=s-PPoNi-kwciCbC+UGxx+M1E7M9JctTM+f3kONJjxJ+SwOA@mail.gmail.com' \
    --to=qiyaoltc@gmail.com \
    --cc=antoine.tremblay@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).