This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[patch] fix the bug of conflict of -c and -x option
- From: Lai Jiangshan <laijs at cn dot fujitsu dot com>
- To: systemtap at sourceware dot org
- Date: Mon, 20 Aug 2007 16:23:23 +0900
- Subject: [patch] fix the bug of conflict of -c and -x option
hi, all
using the following command to test target(), we can find that
the return value of target() is the pid of "readlink /proc/self",
but not 1234 as expected. Obviously, the -c and -x options are
conflict! pid specified by -x option will be overwritten if the -c
option is also specified.
$ stap -c "readlink /proc/self" -x 1234 -e 'probe begin{printf("target()=%d\n",target())}'
19681
target()=19681
the man page of stap says nothing about the conflict of -c and -x.
I think it will be better if the following patch can be applied.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
diff -Nur systemtap-20070818/main.cxx systemtap-20070818-new/main.cxx
--- systemtap-20070818/main.cxx 2007-08-15 00:29:40.000000000 +0900
+++ systemtap-20070818-new/main.cxx 2007-08-20 14:24:36.000000000 +0900
@@ -448,6 +448,12 @@
usage (s, 1);
}
+ if((s.cmd != "") && (s.target_pid))
+ {
+ cerr << "You can't specify -c and -x options together." <<endl;
+ usage (s, 1);
+ }
+
if (s.last_pass > 4 && release_changed)
{
if (s.verbose)
diff -Nur systemtap-20070818/runtime/staprun/common.c systemtap-20070818-new/runtime/staprun/common.c
--- systemtap-20070818/runtime/staprun/common.c 2007-08-15 00:23:59.000000000 +0900
+++ systemtap-20070818-new/runtime/staprun/common.c 2007-08-20 14:44:16.000000000 +0900
@@ -104,6 +104,11 @@
"option only has an effect when the module is inserted.\n");
usage(argv[0]);
}
+
+ if (target_cmd && target_pid) {
+ err("You can't specify the '-c' and '-x' options together.\n");
+ usage(argv[0]);
+ }
}
void usage(char *prog)