From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 5 03:23:06 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EBCB6350; Thu, 5 Mar 2015 03:23:06 +0000 (UTC) Received: from mail-yk0-x22a.google.com (mail-yk0-x22a.google.com [IPv6:2607:f8b0:4002:c07::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A4A5BF6D; Thu, 5 Mar 2015 03:23:06 +0000 (UTC) Received: by ykq142 with SMTP id 142so1727040ykq.2; Wed, 04 Mar 2015 19:23:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=OmPakgf1T4C2vqMRCHN3lQ0ZsZrgn2q+cSfliDElBNU=; b=Y9EbMUnt1sjzUTG1YeT2V8RTcdKQjID4rBS9R1kxnR1uwRONGTGVV+sHJhQ5f930Uq aJ+kMWEDmZMb7fX6Sc4Uf9bgPRVKvRKEEC8xDetVWKAnTj6VW1q1Tdyrmd5V4UuKRATR i55IVXZfS8ea2HHTHmxX6zSC+p2gwlBU+TVv0+OJtdlrlKiFiYSuGUswGAlMpJCbVgK+ EdVebuyeyiZFli1MX7VrXF3FMr1Jeuya/mVUvpMnLNrDuEzl8i1b62jO9jc7cGC4Ce1I iFf1/uEB/pQWS+8TqtiQS/xujr9YCxSDpydi6McmBotmGxuxKSBlTpRlVo+lhZyL5xi+ R+SA== X-Received: by 10.236.11.40 with SMTP id 28mr5411903yhw.14.1425525785790; Wed, 04 Mar 2015 19:23:05 -0800 (PST) Received: from muskytusk ([104.236.250.12]) by mx.google.com with ESMTPSA id 69sm4704242yhd.15.2015.03.04.19.23.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Mar 2015 19:23:03 -0800 (PST) Sender: Mark Johnston Date: Thu, 5 Mar 2015 03:22:27 +0000 From: Mark Johnston To: Navdeep Parhar Subject: Re: ddb breakpoints and dtraceall.ko Message-ID: <20150305032046.GA66171@muskytusk> References: <54F7B053.7060004@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54F7B053.7060004@FreeBSD.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Mar 2015 03:23:07 -0000 On Wed, Mar 04, 2015 at 05:24:35PM -0800, Navdeep Parhar wrote: > Breakpoints in ddb don't seem to work if dtraceall.ko is loaded. I'm > able to set a breakpoint but the kernel doesn't enter the debugger when > it should. Note that this is with dtraceall.ko loaded only, there are > no active DTrace probes. Unloading dtraceall.ko fixes the problem. > > Anyone else see this too? Hi Navdeep, Looks like this is an artifact of the way that DTrace hooks into the breakpoint handler. When the DTrace hooks are installed, a breakpoint results in a call to dtrace_invop(), which in turn calls fbt_invop(), which looks for a matching DTrace probe based on the trap address. If you place a breakpoint on the beginning of a function and a corresponding fbt probe exists, fbt_invop() will find a match and handle it, so DDB never sees the trap. My immediate thought was to add a "probe enabled" flag to struct fbt_probe, but I don't see a good way to avoid races: if a probe fires but is disabled before the thread gets to fbt_invop(), we'll wind up in kdb_trap(). We could try using an IPI to ensure synchronization, which I think would work on amd64 since breakpoint traps are handled with interrupts disabled, but I'm not sure whether that could be easily made to work on all arches. Then again, I'm not sure whether arches (arm, powerpc) have this problem in the first place, since they may use an illegal instruction rather than a breakpoint to trigger a DTrace probe.