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: 46838 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DF394214BA for ; Tue, 7 Apr 2015 15:52:46 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf13878762lbc.1 for ; Tue, 07 Apr 2015 08:52:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results; bh=VaNwy4DpNZNrF0kIrIJIidYsCTNdJDzaKCdFKZ8LBfY=; b=Y9P9MipAQBMElv0/BsqYoD7d7nCIa6OGI5KPaTwt8K9yXXXVdjSKfBcWJSigWTwWUb qjUTdPdB7n/I5saLkc66OKpqmeRlsWn9zcy5wxzgwvZcQmKLdocpf6BPnvSU2Iqu+MS/ YN+v3WXJhnK+InSTppvs0s7vhwI1+j+5t3nf9nrhQOJxv16/quS8yuoXh1IW7ME0Bk/a NFPdQGep6gB1TE7N0lqcb/jUNeSVCvZX7oFzsf8ogdaizr819BmVZqeuoHfpaoeWslzJ TtruIdNxGXfbvbFfiZQEAZMg+kECmKD2eBN7PzBZ2mzT2ofRZFvYlUyFHTqCccaMg8VX Lzow== X-Gm-Message-State: ALoCoQnTrhrmB834lgA75wQt0hjHwi0rNVKfx8Fy4QpgR9+2LyOTqxUDAZxqTJIioLNSXR0/+Vzz X-Received: by 10.180.97.68 with SMTP id dy4mr607314wib.0.1428421965870; Tue, 07 Apr 2015 08:52:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.1 with SMTP id n1ls54865laa.87.gmail; Tue, 07 Apr 2015 08:52:45 -0700 (PDT) X-Received: by 10.152.238.7 with SMTP id vg7mr13451174lac.3.1428421965718; Tue, 07 Apr 2015 08:52:45 -0700 (PDT) Received: from mail-lb0-x22b.google.com (mail-lb0-x22b.google.com. [2a00:1450:4010:c04::22b]) by mx.google.com with ESMTPS id q8si6396501laq.28.2015.04.07.08.52.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Apr 2015 08:52:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22b as permitted sender) client-ip=2a00:1450:4010:c04::22b; Received: by lbbuc2 with SMTP id uc2so42635869lbb.2 for ; Tue, 07 Apr 2015 08:52:45 -0700 (PDT) X-Received: by 10.152.23.70 with SMTP id k6mr18468500laf.76.1428421965468; Tue, 07 Apr 2015 08:52:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp509161lbt; Tue, 7 Apr 2015 08:52:44 -0700 (PDT) X-Received: by 10.66.55.68 with SMTP id q4mr37950325pap.71.1428421963592; Tue, 07 Apr 2015 08:52:43 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id fb1si7828314pab.35.2015.04.07.08.52.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Apr 2015 08:52:43 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-return-121645-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 93374 invoked by alias); 7 Apr 2015 15:52:22 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 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 X-Original-Sender: qiyaoltc@gmail.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22b as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com X-Google-Group-Id: 836684582541 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",