From patchwork Tue Apr 7 15:52:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 6073 Received: (qmail 93374 invoked by alias); 7 Apr 2015 15:52:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 93326 invoked by uid 89); 7 Apr 2015 15:52:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f173.google.com Received: from mail-pd0-f173.google.com (HELO mail-pd0-f173.google.com) (209.85.192.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 07 Apr 2015 15:52:13 +0000 Received: by pdbnk13 with SMTP id nk13so83116774pdb.0 for ; Tue, 07 Apr 2015 08:52:12 -0700 (PDT) X-Received: by 10.66.137.2 with SMTP id qe2mr37403245pab.77.1428421932153; Tue, 07 Apr 2015 08:52:12 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id u8sm6893859pdj.46.2015.04.07.08.52.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Apr 2015 08:52:11 -0700 (PDT) From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 2/2] Honour software single step in fallback of displaced stepping Date: Tue, 7 Apr 2015 16:52:05 +0100 Message-Id: <1428421925-18025-3-git-send-email-qiyaoltc@gmail.com> In-Reply-To: <1428421925-18025-1-git-send-email-qiyaoltc@gmail.com> References: <1428421925-18025-1-git-send-email-qiyaoltc@gmail.com> X-IsSubscribed: yes From: Yao Qi 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 * 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",