mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Huang Shijie <shijie.huang@arm.com>
To: <akpm@linux-foundation.org>
Cc: <nd@arm.com>, <pmladek@suse.com>, <steve.capper@arm.com>,
	<linux-kernel@vger.kernel.org>,
	Huang Shijie <shijie.huang@arm.com>
Subject: [PATCH v2] kprobes: add a new module parameter
Date: Thu, 19 May 2016 09:40:47 +0800	[thread overview]
Message-ID: <1463622047-25734-1-git-send-email-shijie.huang@arm.com> (raw)
In-Reply-To: <20160518142713.a87ef65de5dd50d84c21d1e9@linux-foundation.org>

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@arm.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

  reply	other threads:[~2016-05-19  1:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-18  1:36 [PATCH 1/2] " Huang Shijie
2016-05-18  1:36 ` [PATCH 2/2] kprobes: print out the symbol name for the hooks Huang Shijie
2016-05-18 21:27 ` [PATCH 1/2] kprobes: add a new module parameter Andrew Morton
2016-05-19  1:40   ` Huang Shijie [this message]
2016-05-19  1:36 [PATCH v2] " Huang Shijie

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=1463622047-25734-1-git-send-email-shijie.huang@arm.com \
    --to=shijie.huang@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nd@arm.com \
    --cc=pmladek@suse.com \
    --cc=steve.capper@arm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®