From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30992 invoked by alias); 25 Aug 2010 14:40:19 -0000 Received: (qmail 30981 invoked by uid 22791); 25 Aug 2010 14:40:17 -0000 X-SWARE-Spam-Status: No, hits=0.7 required=5.0 tests=AWL,BAYES_00,RCVD_NUMERIC_HELO X-Spam-Check-By: sourceware.org Received: from miraculix.pixel.de (HELO miraculix.pixel.de) (145.253.133.146) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Aug 2010 14:40:11 +0000 Received: from encryptix.pixel.de ([145.253.132.16]) by miraculix.pixel.de with smtp (Exim 4.69) (envelope-from ) id 1OoH96-00044A-2x for systemtap@sources.redhat.com; Wed, 25 Aug 2010 16:40:08 +0200 Received: from encryptix.pixel.de (localhost [127.0.0.1]) by encryptix.pixel.de (Postfix) with ESMTP id 0CEE08E43D8 for ; Wed, 25 Aug 2010 16:40:03 +0200 (CEST) Received: from denkdirnix.pixel.de (unknown [145.253.132.60]) by encryptix.pixel.de (Postfix) with ESMTP id 07D308E43BB for ; Wed, 25 Aug 2010 16:40:03 +0200 (CEST) Received: from denkdirnix (denkdirnix.netexpress.de [145.253.132.60]) by denkdirnix.pixel.de (Postfix) with ESMTP id 2A553A72CE for ; Wed, 25 Aug 2010 16:40:03 +0200 (CEST) Received: from 145.253.132.220 (145.253.132.220) by denkdirnix (F-Secure/fsigk_smtp/403/denkdirnix); Wed, 25 Aug 2010 16:40:03 +0200 (CEST) Received: from 145.253.132.179 (SquirrelMail authenticated user wge) by intern.netexpress.de with HTTP; Wed, 25 Aug 2010 16:40:03 +0200 (CEST) Message-ID: <40610.145.253.132.179.1282747203.squirrel@intern.netexpress.de> Date: Wed, 25 Aug 2010 14:40:00 -0000 Subject: Newbie: Access stack avriables in a kernel module From: "Wolfram Gettert" To: systemtap@sources.redhat.com Reply-To: wolfram.gettert@mixed-mode.de User-Agent: SquirrelMail/1.4.4 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-TBoneOriginalFrom: "Wolfram Gettert" X-TBoneOriginalTo: systemtap@sources.redhat.com X-TBoneDomainSigned: false X-SA-Exim-Scanned: No (on miraculix.pixel.de); SAEximRunCond expanded to false Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2010-q3/txt/msg00297.txt.bz2 Hi all, I am quite new to Systemtap. I have read the tutorial. Now I am trying to do some examples on my own. I like to access some variables inside a kernel module. I understand that with $xxx in the probe I can access a variable xxx in the kernel module. I have managed that for static int variable of the module. Now, I want to a access a parameter in a function of the kernel module. I created the following probe: probe module("mplex").function("mplex_fop_ioctl").return { printf("Call %s arg=3D%u, res=3D%i, return=3D%i\n", probefunc(),$arg, $re= s, $return) } The code of the function in the kernel is: static int mplex_fop_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { int res=3D0; struct mplex_dev *mplex=3Dfilp->private_data; PRINTK_DEBUG("entering mplex_fop_ioctl(), minor=3D%i\n", MINOR(mplex->cdev.dev)); /* Check that there is no IOCTL() confict */ if ((_IOC_TYPE(cmd) !=3D MPLEX_IOC_MAGIC) || (_IOC_NR(cmd) > MPLEX_IOC_MAXNR)) { PRINTK_ERR("inappropriate ioctl() for device\n"); return -ENOTTY; } PRINTK_INFO("cmd: %i", cmd); switch (cmd) { case MIOQPRIV1: PRINTK_INFO("*mp: %p\n", mplex); PRINTK_INFO("minor: %u, priv1=3D%u\n", MINOR(mplex->cdev.dev), mplex->priv1); return mplex->priv1; break; case MIOTPRIV1: mplex->priv1=3Darg; break; default: return -ENOTTY; } return res; } The ouput I get from stap is: Call mplex_fop_ioctl arg=3D10, res=3D96, return=3D0 Call mplex_fop_ioctl arg=3D20, res=3D96, return=3D0 Call mplex_fop_ioctl arg=3D30, res=3D96, return=3D0 Call mplex_fop_ioctl arg=3D40, res=3D96, return=3D0 Call mplex_fop_ioctl arg=3D40, res=3D96, return=3D10 Call mplex_fop_ioctl arg=3D40, res=3D96, return=3D20 Call mplex_fop_ioctl arg=3D40, res=3D96, return=3D30 Call mplex_fop_ioctl arg=3D40, res=3D96, return=3D40 The values of arg and return are Ok. But as you see in the code of the function above, res is initialized with 0. But the probe prints another value. Why? Is it bug? Have I missunderstood something? Thanks for any comment on that. I am using SystemTap translator/driver (version 1.0/0.143 Debian version 1.0-2) on a x86 2.6.32-24-generic #41-Ubuntu SMP. Wolfram