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 >