From: Hien Nguyen <hien@us.ibm.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 2.6.12-rc1-mm3] [2/2] kprobes += function-return probes - example: probing arbitrary functions
Date: Tue, 29 Mar 2005 14:29:36 -0800 [thread overview]
Message-ID: <4249D6D0.9080300@us.ibm.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 463 bytes --]
Also include here is a test module
The testrprobe.ko is a generic test module. One could use this module to
insert an exit probe to any function in the kernel.
For example :
insmod test_rprobe.ko <entryaddr=address for func entry>
or use the included loadtestrprobe.sh script
./loadtestrprobe.sh <function name>
One good example is to see what kind of page fault is encountered
./loadtestrprobe.sh handle_mm_fault
Signed-off-by: hien Nguyen <hien@us.ibm.com>
[-- Attachment #2: testrprobe.c --]
[-- Type: text/x-csrc, Size: 1072 bytes --]
#include <linux/module.h>
#include <linux/kprobes.h>
static unsigned long entryaddr;
module_param(entryaddr, ulong, 0);
MODULE_PARM_DESC(addr,
"\nfunction entry address.\n");
int inst_test_erprobe (void)
{
jprobe_return();
return 0;
}
int rp_handler(struct retprobe_instance *ri, struct pt_regs *regs)
{
printk("rprobe handler: p->addr=0x%p, ret=0x%lx\n", ri->rp->kprobe->addr, regs->eax);
return 0;
}
static struct jprobe jp = {
.entry = (kprobe_opcode_t *) inst_test_erprobe,
};
static struct retprobe rp = {
.handler = rp_handler,
.maxactive = 1,
.nmissed = 0
};
static int init_testrp(void)
{
if (entryaddr == 0 ) {
printk("Need to input an function entry address as parameter.\n");
return -EINVAL;
}
jp.kp.addr = (kprobe_opcode_t *) entryaddr;
register_jretprobe(&jp, &rp);
printk("exit probe init: instrumentation is enabled...\n");
return 0;
}
static void cleanup_testrp(void)
{
unregister_jprobe(&jp);
printk("exit probe cleanup.\n");
}
module_init(init_testrp);
module_exit(cleanup_testrp);
MODULE_LICENSE("GPL");
[-- Attachment #3: loadtestrprobe.sh --]
[-- Type: application/x-shellscript, Size: 194 bytes --]
reply other threads:[~2005-03-29 22:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4249D6D0.9080300@us.ibm.com \
--to=hien@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.