[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1463622047-25734-1-git-send-email-shijie.huang@arm.com>
Date: Thu, 19 May 2016 09:40:47 +0800
From: Huang Shijie <shijie.huang@....com>
To: <akpm@...ux-foundation.org>
CC: <nd@....com>, <pmladek@...e.com>, <steve.capper@....com>,
<linux-kernel@...r.kernel.org>, Huang Shijie <shijie.huang@....com>
Subject: [PATCH v2] kprobes: add a new module parameter
This patch adds a new module parameter which can be used as the
symbol name. Without this patch, we can only test the "_do_fork" function
with this kernel module. With this patch, the module becomes more flexable,
we can test any functions with this module with:
#insmod kprobe_example.ko symbol="xxx"
Signed-off-by: Huang Shijie <shijie.huang@....com>
---
v1 -- > v2:
Add more comment for this patch.
---
samples/kprobes/kprobe_example.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c
index 727eb21..2bb190d 100644
--- a/samples/kprobes/kprobe_example.c
+++ b/samples/kprobes/kprobe_example.c
@@ -14,9 +14,13 @@
#include <linux/module.h>
#include <linux/kprobes.h>
+#define MAX_SYMBOL_LEN 64
+static char symbol[MAX_SYMBOL_LEN] = "_do_fork";
+module_param_string(symbol, symbol, sizeof(symbol), 0644);
+
/* For each probe you need to allocate a kprobe structure */
static struct kprobe kp = {
- .symbol_name = "_do_fork",
+ .symbol_name = symbol,
};
/* kprobe pre_handler: called just before the probed instruction is executed */
--
2.5.5
Powered by blists - more mailing lists