From owner-freebsd-dtrace@freebsd.org Sun Aug 2 05:53:21 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 AC45B9AFA4E for ; Sun, 2 Aug 2015 05:53:21 +0000 (UTC) (envelope-from hetakcoder@gmail.com) Received: from mail-wi0-x232.google.com (mail-wi0-x232.google.com [IPv6:2a00:1450:400c:c05::232]) (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 4A9411FF1 for ; Sun, 2 Aug 2015 05:53:21 +0000 (UTC) (envelope-from hetakcoder@gmail.com) Received: by wicmv11 with SMTP id mv11so99320944wic.0 for ; Sat, 01 Aug 2015 22:53:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=IfiDSJyllF5J+DI91udg4vUjkdJaGnlN68tZv69X5x8=; b=ZSUV/pJVq2LYT02L/nZ1f1wtFLOJQ8QPGzmz6fR8YqYpnkxaczZvaiI46LfcwnIwAf FskkcG4wiag1Je06onajmUDQnIk7L7i3xGL3dQ6Lh2pgMYnPjZt64VDEy0g8VsfIJrjM HIeHYo43t4tGZ5uTIayqcXWMlvQPXF6pYBhShbbHfTFJkWnWz18hxd4logeElDkoACPP faRPHmJqFS1IDvztuUneDNkqhLFkuetLG0Z7sQS2ImMnkcuHoXCtKuSS1xRzAICZSXtg 5rYUgXKsMgR6I5RYmw/0XSqqVGGvk85CHBjS4TAdNuN7hnxmclFR6lAVil+xRLcOoBpt 01eA== X-Received: by 10.180.39.163 with SMTP id q3mr22787912wik.82.1438494799417; Sat, 01 Aug 2015 22:53:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.68.233 with HTTP; Sat, 1 Aug 2015 22:52:39 -0700 (PDT) From: HeTak Date: Sun, 2 Aug 2015 10:22:39 +0430 Message-ID: Subject: How to get functions' local variables? To: freebsd-dtrace@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 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 05:53:21 -0000 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? Thanks :) --HeTaK 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 From owner-freebsd-dtrace@freebsd.org Mon Aug 3 05:33:52 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 C203B9B1C4A for ; Mon, 3 Aug 2015 05:33:52 +0000 (UTC) (envelope-from hetakcoder@gmail.com) Received: from mail-wi0-x22e.google.com (mail-wi0-x22e.google.com [IPv6:2a00:1450:400c:c05::22e]) (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 5E9F9952; Mon, 3 Aug 2015 05:33:52 +0000 (UTC) (envelope-from hetakcoder@gmail.com) Received: by wibxm9 with SMTP id xm9so98508564wib.1; Sun, 02 Aug 2015 22:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=piq9YvGtM7lG0Xm0LDBvpivl6JawIFNAUTVsbgrYfDk=; b=lY2ccpDB74HaJoSNallfC3BTrdc3CCI52k+ZjJE+3jqVPG7REWYtzEtsycikf25Hoi ozJNrjsxvRP5PU6XRmViSEOIkd3pKj/WTXqDFWsvV+WzlU7yyGYUVfXPjg/7dpR7vNaU 91m9yDtm3zATWBwMiTTzH4RWlXs3VJmp+uR+S26+7i3FLuDHUdU8Cj1qWQqB1fFoC9p5 Stjbj1D3eVbePkEqz9hmaH2o26I6RNtKc0XuaqzjSm1ctBa51rSkRZMqBTItT7LeJQi5 gRvqYYNWjo07d9r338a/1Oo4gJm1wVT3MCP36rLw9CnwQHFSfpgoVnDy4Xw7ZFCGF4xB JaMQ== X-Received: by 10.180.98.200 with SMTP id ek8mr31011018wib.38.1438580029679; Sun, 02 Aug 2015 22:33:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.164.98 with HTTP; Sun, 2 Aug 2015 22:33:10 -0700 (PDT) In-Reply-To: <20150802185533.GC59626@raichu> References: <20150802185533.GC59626@raichu> From: HeTak Date: Mon, 3 Aug 2015 10:03:10 +0430 Message-ID: Subject: Re: How to get functions' local variables? To: Mark Johnston Cc: freebsd-dtrace@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 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: Mon, 03 Aug 2015 05:33:52 -0000 Thank you for the answer, Mark :) It sounds kinda tricky to do so.. but maybe I give it a try ;) Cheerio HeTak On Sun, Aug 2, 2015 at 11:25 PM, Mark Johnston wrote: > 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 >