* [Bug kprobes/15675] New: A misusing of function @module_kallsyms_on_each_symbo cause the stap generated module can not resolve the module symbols.
@ 2013-06-25 2:09 yangwen at huawei dot com
2013-06-25 2:11 ` [Bug kprobes/15675] A misusing of function @kallsyms_on_each_symbo " yangwen at huawei dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: yangwen at huawei dot com @ 2013-06-25 2:09 UTC (permalink / raw)
To: systemtap
http://sourceware.org/bugzilla/show_bug.cgi?id=15675
Bug ID: 15675
Summary: A misusing of function @module_kallsyms_on_each_symbo
cause the stap generated module can not resolve the
module symbols.
Product: systemtap
Version: unspecified
Status: NEW
Severity: critical
Priority: P2
Component: kprobes
Assignee: systemtap at sourceware dot org
Reporter: yangwen at huawei dot com
/* Summary:
* A misusing of function @module_kallsyms_on_each_symbol
* cause the stap generated module can not resolve the
* module symbols.
* */
/* 1. Supporse we use stap on the following script to probe
* the 'FuncA' in module named 'ModA'
* */
probe kprobe.module("ModA").function ("FuncA") {
printf("Wen Test: cache:readCache called, task:%s pid:%d\n",
execname(), pid())
}
/* 2. The stap command will generate the following 3 pieces of
* codes to resolve the symbol referenced above
* */
stap_dwarfless_probes[] = {
{ .symbol_string="ModA:FuncA", .probe=(&stap_probes[1]), },
};
{
int p = 0;
for (i = 0; i < 1; i++) {
struct stap_dwarfless_probe *sdp = & stap_dwarfless_probes[i];
if (! sdp->address)
p++;
}
kallsyms_on_each_symbol(kprobe_resolve, &p);
}
static int kprobe_resolve(void *data, const char *name,
struct module *owner,
unsigned long val) {
int i;
int *p = (int *) data;
for (i=0; i<1 && *p > 0; i++) {
struct stap_dwarfless_probe *sdp = & stap_dwarfless_probes[i];
if (! sdp->address)
if (strcmp(sdp->symbol_string, name) == 0) {
sdp->address = val;
(*p)--;
}
}
return (p > 0) ? 0 : -1;
}
/* 3. In the generated function 'kprobe_resolve (a callback function for
* kallsyms_on_each_symbol), it compares the sdp->symbol_string--in this
* expamle it's "ModA:FuncA"--with the second parameter @name of
kprobe_resolve.
*
* The expr 'if (strcmp(sdp->symbol_string, name) == 0)' NEVER evals TRUE,
because
* the kernel does NOT merge the module name with the symbol name to give the
parameter
* @name, the @name parameter always contain ONLY the symbol name.
*
* The kprobe_resolve should compare module name and symbol name respectively.
* It maybe looks like this:
* */
static int kprobe_resolve(void *data, const char *name,
struct module *owner,
unsigned long val) {
int i;
int *p = (int *) data;
for (i=0; i<1 && *p > 0; i++) {
struct stap_dwarfless_probe *sdp = & stap_dwarfless_probes[i];
if (! sdp->address) {
const char * colon;
if ((colon = strchr(sdp->symbol_string, ':')) && owner) {
if ((strlen(owner->name) == (colon - sdp->symbol_string)) &&
(strncmp(sdp->symbol_string, owner->name, colon -
sdp->symbol_string) == 0) &&
(strcmp(colon + 1, name) == 0)) {
sdp->address = val;
(*p)--;
}
} else {
if (strcmp(sdp->symbol_string, name) == 0) {
sdp->address = val;
(*p)--;
}
}
}
}
return (p > 0) ? 0 : -1;
}
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug kprobes/15675] A misusing of function @kallsyms_on_each_symbo cause the stap generated module can not resolve the module symbols.
2013-06-25 2:09 [Bug kprobes/15675] New: A misusing of function @module_kallsyms_on_each_symbo cause the stap generated module can not resolve the module symbols yangwen at huawei dot com
@ 2013-06-25 2:11 ` yangwen at huawei dot com
2013-06-25 18:45 ` [Bug kprobes/15675] 'kprobe.module("foo").function("bar")' probes do not work dsmith at redhat dot com
2013-06-25 18:51 ` dsmith at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: yangwen at huawei dot com @ 2013-06-25 2:11 UTC (permalink / raw)
To: systemtap
http://sourceware.org/bugzilla/show_bug.cgi?id=15675
ywen <yangwen at huawei dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|A misusing of function |A misusing of function
|@module_kallsyms_on_each_sy |@kallsyms_on_each_symbo
|mbo cause the stap |cause the stap generated
|generated module can not |module can not resolve the
|resolve the module symbols. |module symbols.
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug kprobes/15675] 'kprobe.module("foo").function("bar")' probes do not work
2013-06-25 2:09 [Bug kprobes/15675] New: A misusing of function @module_kallsyms_on_each_symbo cause the stap generated module can not resolve the module symbols yangwen at huawei dot com
2013-06-25 2:11 ` [Bug kprobes/15675] A misusing of function @kallsyms_on_each_symbo " yangwen at huawei dot com
@ 2013-06-25 18:45 ` dsmith at redhat dot com
2013-06-25 18:51 ` dsmith at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: dsmith at redhat dot com @ 2013-06-25 18:45 UTC (permalink / raw)
To: systemtap
http://sourceware.org/bugzilla/show_bug.cgi?id=15675
David Smith <dsmith at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dsmith at redhat dot com
Summary|A misusing of function |'kprobe.module("foo").funct
|@kallsyms_on_each_symbo |ion("bar")' probes do not
|cause the stap generated |work
|module can not resolve the |
|module symbols. |
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug kprobes/15675] 'kprobe.module("foo").function("bar")' probes do not work
2013-06-25 2:09 [Bug kprobes/15675] New: A misusing of function @module_kallsyms_on_each_symbo cause the stap generated module can not resolve the module symbols yangwen at huawei dot com
2013-06-25 2:11 ` [Bug kprobes/15675] A misusing of function @kallsyms_on_each_symbo " yangwen at huawei dot com
2013-06-25 18:45 ` [Bug kprobes/15675] 'kprobe.module("foo").function("bar")' probes do not work dsmith at redhat dot com
@ 2013-06-25 18:51 ` dsmith at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: dsmith at redhat dot com @ 2013-06-25 18:51 UTC (permalink / raw)
To: systemtap
http://sourceware.org/bugzilla/show_bug.cgi?id=15675
David Smith <dsmith at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #1 from David Smith <dsmith at redhat dot com> ---
This problem is now fixed. I took your suggested code changes and made the
systemtap translator emit code like that in the following commit:
=====
commit 8c2728197442816189a94f3f241186bcf6cb245a
Author: Yang Wen <yangwen@huawei.com>
Date: Tue Jun 25 13:40:29 2013 -0500
Fix PR15675 by making 'probe kprobe.module("foo").function("bar") work.
* tapsets.cxx (kprobe_derived_probe_group::emit_module_decls): Fix emitted
kprobe_resolve() to lookup "module:function" symbols correctly.
====
I then wondered why we hadn't seen this before. It was because we never tested
it. So, after fixing bug #10395 to fix the kmodule.exp testcase, I added a new
test to that testcase to test probing 'kprobe.module("foo").function("bar")':
====
commit 5039ed9600735c3b2fc23068f5c15282639ad042
Author: David Smith <dsmith@redhat.com>
Date: Tue Jun 25 13:43:58 2013 -0500
Add a new test for probing 'kprobe.module("foo").function("bar") (PR15675).
* testsuite/systemtap.base/kprobe_module.stp: Add new test for
'kprobe.module("foo").function("bar")'.
* testsuite/systemtap.base/kmodule.exp: Run new kprobe_module.stp test.
====
Thanks for the code fix.
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-25 18:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-25 2:09 [Bug kprobes/15675] New: A misusing of function @module_kallsyms_on_each_symbo cause the stap generated module can not resolve the module symbols yangwen at huawei dot com
2013-06-25 2:11 ` [Bug kprobes/15675] A misusing of function @kallsyms_on_each_symbo " yangwen at huawei dot com
2013-06-25 18:45 ` [Bug kprobes/15675] 'kprobe.module("foo").function("bar")' probes do not work dsmith at redhat dot com
2013-06-25 18:51 ` dsmith at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).