public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] Honour software single step in fallback of displaced stepping
Date: Tue, 07 Apr 2015 15:52:00 -0000	[thread overview]
Message-ID: <1428421925-18025-3-git-send-email-qiyaoltc@gmail.com> (raw)
In-Reply-To: <1428421925-18025-1-git-send-email-qiyaoltc@gmail.com>

From: Yao Qi <yao.qi@linaro.org>

Hi,
When I run gdb.threads/non-stop-fair-events.exp on arm-linux target,
I see the following error in the log,

  displaced: breakpoint is gone: Thread 22518, step(1)^M
  Sending packet: $vCont;s:p57f3.57f6#9d...
  gdb/gdbserver/linux-low.c:3686: A problem internal to GDBserver has been detected.^M
  linux_resume_one_lwp_throw: Assertion `step == 0' failed.

GDB sends vCont;s by mistake, and GDBserver fails on assert.  GDB
doesn't consider software single step in infrun.c:displaced_step_fixup,

	  /* Go back to what we were trying to do.  */
	  step = currently_stepping (tp);

	  if (debug_displaced)
	    fprintf_unfiltered (gdb_stdlog,
				"displaced: breakpoint is gone: %s, step(%d)\n",
				target_pid_to_str (tp->ptid), step);

	  target_resume (ptid, step, GDB_SIGNAL_0);

The patch is to let GDB consider software single step here.  It fixes
fails in gdb.threads/non-stop-fair-events.exp on arm.

gdb:

2015-04-02  Yao Qi  <yao.qi@linaro.org>

	* infrun.c (maybe_software_singlestep): Declare.
	(displaced_step_fixup): Call maybe_software_singlestep.
---
 gdb/infrun.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index f5faa0a..f4bbf67 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -100,6 +100,8 @@ static void insert_step_resume_breakpoint_at_caller (struct frame_info *);
 
 static void insert_longjmp_resume_breakpoint (struct gdbarch *, CORE_ADDR);
 
+static int maybe_software_singlestep (struct gdbarch *gdbarch, CORE_ADDR pc);
+
 /* When set, stop the 'step' command if we enter a function which has
    no line number information.  The normal behavior is that we step
    over such function.  */
@@ -1847,6 +1849,7 @@ displaced_step_fixup (ptid_t event_ptid, enum gdb_signal signal)
       regcache = get_thread_regcache (ptid);
       actual_pc = regcache_read_pc (regcache);
       aspace = get_regcache_aspace (regcache);
+      gdbarch = get_regcache_arch (regcache);
 
       if (breakpoint_here_p (aspace, actual_pc))
 	{
@@ -1857,8 +1860,6 @@ displaced_step_fixup (ptid_t event_ptid, enum gdb_signal signal)
 
 	  displaced_step_prepare (ptid);
 
-	  gdbarch = get_regcache_arch (regcache);
-
 	  if (debug_displaced)
 	    {
 	      CORE_ADDR actual_pc = regcache_read_pc (regcache);
@@ -1891,6 +1892,9 @@ displaced_step_fixup (ptid_t event_ptid, enum gdb_signal signal)
 	  /* Go back to what we were trying to do.  */
 	  step = currently_stepping (tp);
 
+	  if (step)
+	    step = maybe_software_singlestep (gdbarch, actual_pc);
+
 	  if (debug_displaced)
 	    fprintf_unfiltered (gdb_stdlog,
 				"displaced: breakpoint is gone: %s, step(%d)\n",
-- 
1.9.1

  reply	other threads:[~2015-04-07 15:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 15:52 [PATCH 0/2] " Yao Qi
2015-04-07 15:52 ` Yao Qi [this message]
2015-04-07 15:52 ` [PATCH 1/2] [gdbserver] assert on step if !can_hardware_single_step Yao Qi
2015-04-07 17:09   ` Pedro Alves
2015-04-07 16:59 ` [PATCH 0/2] Honour software single step in fallback of displaced stepping Pedro Alves
2015-04-08  9:51   ` Yao Qi
2015-04-16 12:00     ` Yao Qi
2015-04-16 12:02       ` Pedro Alves
2015-04-16 13:01         ` Yao Qi

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=1428421925-18025-3-git-send-email-qiyaoltc@gmail.com \
    --to=qiyaoltc@gmail.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).