From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6568 invoked by alias); 27 Oct 2011 20:29:21 -0000 Received: (qmail 6543 invoked by uid 22791); 27 Oct 2011 20:29:18 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,TW_BP,TW_EG X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Oct 2011 20:29:04 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=EU1-MAIL.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1RJWZT-0000pj-Ej from pedro_alves@mentor.com ; Thu, 27 Oct 2011 13:29:03 -0700 Received: from scottsdale.localnet ([172.16.63.104]) by EU1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 27 Oct 2011 21:29:01 +0100 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [patch, gdbserver] Uninsert bpkt when regular and fast tracepoint are set at the same address Date: Thu, 27 Oct 2011 21:23:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-11-generic; KDE/4.7.1; x86_64; ; ) Cc: Stan Shebs References: <4EA8C851.2080703@codesourcery.com> <4EA9A527.4030003@earthlink.net> In-Reply-To: <4EA9A527.4030003@earthlink.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201110272128.59083.pedro@codesourcery.com> X-IsSubscribed: yes 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 X-SW-Source: 2011-10/txt/msg00749.txt.bz2 On Thursday 27 October 2011 19:38:31, Stan Shebs wrote: > On 10/26/11 7:56 PM, Yao Qi wrote: > > Hi, > > I find a program will receive segv fault when I set a regular tracepoint > > and a fast tracepoint at the same address, start tracing and resume program. > > > > gdbserver has taken care of this situation in many places of the code, > > when uninserting breakpoint or fast tracepoint, write_inferior_memory is > > called to take care of layering breakpoints on top of fast tracepoints. > > However, it is not right to me. Here is an example to illustrate this > > problem. > > > > Supposing I set a regular tracepoint and a fast tracepoint on 0x080484fc, > > > > 0x080484fc<+3>: e8 f3 ff ff ff call 0x80484f4 > > > > During insertion, trap insn (for regular tracepoint) and jmp insn (for > > fast tracepoint) are inserted, and gdbserver takes care of them to make > > sure trap insn is *always* inserted on top of jmp insn. > > I'm looking at this and wondering, why are we inserting the fast > tracepoint jump insn at all? I think the way we do things currently is simpler. Consider: 1 - ftrace foo (5 bytes) 2 - tstart, installs fast tracepoint 3 - b foo, sets breakpoint (would remove the jmp?) 4 - del breakpoint $bkpt_foo (would re-insert insert the jmp?) If in 3 the answer is no, then we have to handle the jmp being inserted anyway. If it is yes, then, it looks like extra weird work. Same for step 4. This introduces unnecessary coupling between different "kinds" of breakpoints. As is, we think in terms of range of addresses we're writting to / reading from. > Shouldn't be it sufficient to let the trap handler do the work of both > slow and fast tracepoints at that location? > Since hitting the trap has > already put us on the slow path, there's not going to any noticeable > additional penalty for not going to the IPA and interpreting conditional > bytecodes instead of compiled ones, etc. We may not even need to sync > trace buffers (I'm not sure about that, code is tricky). That's actually kind of a separate issue, and we already do that. gdbserver/tracepoint.c has this comment: /* Presently, gdbserver doesn't run compiled conditions, only the IPA does. If the program stops at a fast tracepoint's address (e.g., due to a breakpoint, trap tracepoint, or stepping), gdbserver preemptively collect the fast tracepoint. Later, on resume, gdbserver steps over the fast tracepoint like it steps over breakpoints, so that the IPA doesn't see that fast tracepoint. This avoids double collects of fast tracepoints in that stopping scenario. Having gdbserver itself handle the fast tracepoint gives the user a consistent view of when fast or trap tracepoints are collected, compared to an alternative where only trap tracepoints are collected on stop, and fast tracepoints on resume. When a fast tracepoint is being processed by gdbserver, it is always the non-compiled condition expression that is used. */ -- Pedro Alves