This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Newbie: Access stack avriables in a kernel module
- From: "Wolfram Gettert" <wolfram dot gettert at mixed-mode dot de>
- To: systemtap at sources dot redhat dot com
- Date: Wed, 25 Aug 2010 16:40:03 +0200 (CEST)
- Subject: Newbie: Access stack avriables in a kernel module
- Reply-to: wolfram dot gettert at mixed-mode dot de
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=%u, res=%i, return=%i\n", probefunc(),$arg, $res,
$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=0;
struct mplex_dev *mplex=filp->private_data;
PRINTK_DEBUG("entering mplex_fop_ioctl(), minor=%i\n",
MINOR(mplex->cdev.dev));
/* Check that there is no IOCTL() confict */
if ((_IOC_TYPE(cmd) != 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=%u\n", MINOR(mplex->cdev.dev),
mplex->priv1);
return mplex->priv1;
break;
case MIOTPRIV1:
mplex->priv1=arg;
break;
default:
return -ENOTTY;
}
return res;
}
The ouput I get from stap is:
Call mplex_fop_ioctl arg=10, res=96, return=0
Call mplex_fop_ioctl arg=20, res=96, return=0
Call mplex_fop_ioctl arg=30, res=96, return=0
Call mplex_fop_ioctl arg=40, res=96, return=0
Call mplex_fop_ioctl arg=40, res=96, return=10
Call mplex_fop_ioctl arg=40, res=96, return=20
Call mplex_fop_ioctl arg=40, res=96, return=30
Call mplex_fop_ioctl arg=40, res=96, return=40
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