From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107791 invoked by alias); 27 Nov 2015 10:55:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 107772 invoked by uid 89); 27 Nov 2015 10:55:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f45.google.com Received: from mail-pa0-f45.google.com (HELO mail-pa0-f45.google.com) (209.85.220.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 27 Nov 2015 10:55:05 +0000 Received: by padhx2 with SMTP id hx2so112338103pad.1 for ; Fri, 27 Nov 2015 02:55:03 -0800 (PST) X-Received: by 10.66.144.103 with SMTP id sl7mr52456579pab.3.1448621703391; Fri, 27 Nov 2015 02:55:03 -0800 (PST) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id n88sm33280070pfb.26.2015.11.27.02.55.00 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 27 Nov 2015 02:55:02 -0800 (PST) From: Yao Qi To: gdb-patches@sourceware.org Cc: palves@redhat.com, simon.marchi@ericsson.com Subject: Move threads out of jumppad without single step Date: Fri, 27 Nov 2015 10:55:00 -0000 Message-ID: <86zixzvhj1.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00580.txt.bz2 Hi Pedro, Can we move threads out of jumppad without using single step? I mean, supposing GDBserver can compute the next PCs of the instruction on which fast tracepoint is set, GDBserver can insert breakpoints at the next PCs of the instruction fast tracepoint is set on, and resume the thread which is in jumppad. In the recent discussion about ARM fast tracepoint support, I pointed out that missing hardware single step may be a showstopper to ARM fast tracepoint support, but Simon wants to convince me that we can have a non-perfect fast tracepoint support on ARM with software single step. After I think about the possible issues of using software single step, I don't have any outcomes, but I wonder why do we need to single step thread out of jumppad? Here is my understanding, in the jumppad, the instructions are like, saved registers spin lock call gdb_collect spin unlock restore registers <----- [1] relocated instructions jump back If PC is within the range above, GDBserver needs to move the thread out. GDBserver can single step instructions one by one until PC is out of this range, but we have an optimization here that GDBserver can insert breakpoint and resume rather than single step one by one if PC doesn't point to the relocated instructions yet [1]. Afterwards, GDBserver will single step, but there aren't many instructions. Unless I miss something, the code comments explain why do we move threads out of jumppad, but they do *not* explain why do we move threads out of jumppad in this way. IMO, the reason is that instructions before [1] are sequentially executed (except call gdb_collect), but instructions after [1] may not. We can safely insert breakpoint on [1], and thread must hit the breakpoint. However, the original instruction on which the fast tracepoint is set may be a branch instruction, so the relocated instructions may jump back to the target address. At the moment we add fast tracepoint support (for x86), we rely on hardware single step so that we don't have to compute the next PCs (that is also the reason why qRelocInsn packet was added). Now, the situation in GDBserver changed a little bit, as GDBserver will be able to accurately compute the next PCs. Under this assumption, GDBserver can compute the next PCs of the original instruction, and set breakpoints there when threads are in jumppad. In this way, we don't need to single step thread out jumppad at all for targets which support software single step in GDBserver. --=20 Yao (=E9=BD=90=E5=B0=A7)