From owner-freebsd-dtrace@freebsd.org Sun Aug 2 18:55:37 2015 Return-Path: Delivered-To: freebsd-dtrace@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9D04B9B1134 for ; Sun, 2 Aug 2015 18:55:37 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pd0-x22d.google.com (mail-pd0-x22d.google.com [IPv6:2607:f8b0:400e:c02::22d]) (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 6B5F4135A for ; Sun, 2 Aug 2015 18:55:37 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by pdrg1 with SMTP id g1so64680240pdr.2 for ; Sun, 02 Aug 2015 11:55:36 -0700 (PDT) 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=8AjNWnNoM6HlTuKIxo27LirymQSizXhQeDqb6U5Clvo=; b=TXD+Az3mpWi0ILvOQZ8n4QB+m4NpPlMVnQ+PiUtX7ZzblXfiCKV4IjvbdNoUSd44kC 0CJmGYeloiqx+lzE3XGEI9z+lzaXK2fWVohuYsbsmi5bpBCYfiaRfTqJnNyKWtso9uXd +9MZzu8na+f4rxPaT9BFFa1SO2waOmE7wdUbshzU458mlIqMMFH9Hv8aO7mFF3CgHGbC ja+NJCUoTz1TuuDJvLlDxTMLHXiRrvj6THOwWdyeEb8YZgGjJsVE5bqnp1WYtiBBx8uO ovgg9E21oFL50xGejDChwckhL//XMaCZsj9VX+9Shl6vEwNhOI4vX4UGQg7dEEZyCJgQ Faiw== X-Received: by 10.70.1.102 with SMTP id 6mr28508294pdl.32.1438541736897; Sun, 02 Aug 2015 11:55:36 -0700 (PDT) Received: from raichu ([104.232.114.184]) by smtp.gmail.com with ESMTPSA id mk6sm15049409pab.9.2015.08.02.11.55.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Aug 2015 11:55:35 -0700 (PDT) Sender: Mark Johnston Date: Sun, 2 Aug 2015 11:55:33 -0700 From: Mark Johnston To: HeTak Cc: freebsd-dtrace@freebsd.org Subject: Re: How to get functions' local variables? Message-ID: <20150802185533.GC59626@raichu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Aug 2015 18:55:37 -0000 On Sun, Aug 02, 2015 at 10:22:39AM +0430, HeTak wrote: > Hi there, > > My question is: How I can check a function's local varibales' value using > dtrace? > > I'm a newbie in using dtrace and it's a bit weird for me..I went through > manuals and so, but did not get that. :( > > What I could find out is that via args, I can get functions' input > arguments. But I could not find out how I can check the value of a variable > which is defined inside my goal function's scope. Isn't this feature > available in Dtrace? No, DTrace doesn't support that feature. It can be approximated for userland programs using the PID provider, since that lets you effectively place breakpoints on arbitrary instructions, and using curthread->td_intr_frame, you can retrieve the register set of the interrupted thread. So if you could map a source line number and local variable name to a function offset and register (or stack offset), you should be able to retrieve the variable's value. But as far as I know, nothing exists to do this automatically. I'm not sure how hard it would be to write a program to use DWARF info to generate a D script which can retrieve a local variable's value. Seems like an interesting experiment? :) -Mark