+2007-11-12 Martin Hunt <hunt@redhat.com>
+
+ * systemtap.base/*.stp: Replace log() calls with
+ println() (or printf() if formatting would help.)
+ * systemtap.maps/*.stp: Ditto.
+ * systemtap.samples/*.stp: Ditto.
+ * systemtap.stress/*.stp: Ditto.
+
2007-11-09 Masami Hiramatsu <mhiramat@redhat.com>
PR3858
print("\n\n")
print_stack(bt)
print("\n\n")
- log("execname is \"" . execname() . "\"")
- log("pid is " . sprint(pid()))
- log("tid is " . sprint(tid()))
- log("pexecname is \"" . pexecname() . "\"")
- log("ppid is " . sprint(ppid()))
- log("uid is " . sprint(uid()))
- log("euid is " . sprint(euid()))
- log("gid is " . sprint(gid()))
- log("egid is " . sprint(egid()))
- log("pp is '" . pp() . "'")
+ printf("execname is %s\n", execname())
+ printf("pid is %d\n",pid())
+ printf("tid is %d\n", tid())
+ printf("pexecname is %s\n", pexecname())
+ printf("ppid is %d\n", ppid())
+ printf("uid is %d\n", uid())
+ printf("euid is %d\n", euid())
+ printf("gid is %d\n", gid())
+ printf("egid is %d\n", egid())
+ printf("pp is %s\n", pp())
}
probe kernel.function("uptime_read_proc") {
/*
* add.stp
*
- * Check the systemtap "addition" works
+ * Check that systemtap "addition" works
*/
global x3
probe begin
{
- log("systemtap starting probe")
+ println("systemtap starting probe")
x1 = 42; x2 = 53;
}
probe end
{
- log("systemtap ending probe")
+ println("systemtap ending probe")
x3 = x1 + x2;
if (x3 != 95 ) {
- log("systemtap test failure");
+ println("systemtap test failure")
} else {
- log("systemtap test success");
+ println("systemtap test success")
}
}
* Call with MAXMAPENTRIES << 100
*/
-probe begin { log("systemtap starting probe") }
-probe end { log("systemtap ending probe") }
+probe begin { println("systemtap starting probe") }
+probe end { println("systemtap ending probe") }
global a[100]
++bad
}
if (ok == 100 && bad == 0)
- log("systemtap test success")
+ println("systemtap test success")
else
printf("systemtap test failure - ok:%d, bad:%d\n", ok, bad)
}
* Check that ordering of begin/end probes works
*/
-probe begin { log("systemtap starting probe") }
-probe end { log("systemtap ending probe") }
+probe begin { println("systemtap starting probe") }
+probe end { println("systemtap ending probe") }
global beginstr, endstr
endstr .= "z"
if (beginstr == "abccde")
- log("systemtap test success")
+ println("systemtap test success")
else
printf("systemtap test failure - beginstr:%s != abccde\n", beginstr)
if (endstr == "vwxxyz")
- log("systemtap test success")
+ println("systemtap test success")
else
printf("systemtap test failure - endstr:%s != vwxxyz\n", endstr)
}
* Check that the deref mechanisms work correctly.
*/
-probe begin { log("systemtap starting probe") }
-probe end { log("systemtap ending probe") }
+probe begin { println("systemtap starting probe") }
+probe end { println("systemtap ending probe") }
probe end(1) {
log_test("kread u8", kread_u8())
function log_test(test:string, result:long) {
if (result)
- log("systemtap test success")
+ println("systemtap test success")
else
printf("systemtap test failure - %s\n", test)
}
# It's just an ordinary function that returns a 4-byte signed value,
# even on a 64-bit hosts.
probe kernel.function("sock_alloc_fd").return {
- log ($return < 0 ? "neg" : "pos")
+ println ($return < 0 ? "neg" : "pos")
}
probe timer.s (5) { exit () }
-probe begin { log ("start") }
\ No newline at end of file
+probe begin { println ("start") }
global count
global count2
-probe begin { log("systemtap starting probe") }
+probe begin { println("systemtap starting probe") }
probe kernel.function("schedule") { ++count; ++count2; }
probe end
{
- log("systemtap ending probe")
- log("count = " . sprint(count));
- log("count2 = " . sprint(count));
+ println("systemtap ending probe")
+ printf("count = %d\n", count)
+ printf("count2 = %d\n", count)
if ( count == count2) {
if ( (count-1) == count2 ) {
- log("systemtap test failure");
+ println("systemtap test failure");
} else {
- log("systemtap test success");
+ println("systemtap test success");
}
} else {
- log("systemtap test failure");
+ println("systemtap test failure");
}
}
probe begin
{
- log("systemtap starting probe")
+ println("systemtap starting probe")
}
probe kernel.function("schedule")
probe end
{
- log("systemtap ending probe")
- log("count = " . sprint(count));
- log("loop_count = " . sprint(loop_count));
+ println("systemtap ending probe")
+ printf("count = %d\n", count)
+ printf("loop_count = %d\n", loop_count)
if ( count * 10 == loop_count) {
- log("systemtap test success");
+ println("systemtap test success");
} else {
- log("systemtap test failure");
+ println("systemtap test failure");
}
}
* Check that global variables are initialized before all begin probes
*/
-probe begin { log("systemtap starting probe") }
-probe end { log("systemtap ending probe") }
+probe begin { println("systemtap starting probe") }
+probe end { println("systemtap ending probe") }
global gnum = 42
global gstr = "foobar"
probe end {
if (gnum_saved == 42)
- log("systemtap test success")
+ println("systemtap test success")
else
printf("systemtap test failure - gnum_saved:%d != 42\n", gnum_saved)
if (gstr_saved == "foobar")
- log("systemtap test success")
+ println("systemtap test success")
else
printf("systemtap test failure - gstr_saved:%s != foobar\n", gstr_saved)
}
* Check the systemtap if statement works
*/
-probe begin { log("systemtap starting probe") }
+probe begin { println("systemtap starting probe") }
probe end
{
- log("systemtap ending probe")
+ println("systemtap ending probe")
if (1) {
- log("systemtap test success");
+ println("systemtap test success");
} else {
- log("systemtap test failure");
+ println("systemtap test failure");
}
if (0) {
- log("systemtap test failure");
+ println("systemtap test failure");
} else {
- log("systemtap test success");
+ println("systemtap test success");
}
}
/*
* inc.stp
*
- * Check the systemtap ++ works
+ * Check that systemtap ++ works
*/
global x1
probe begin
{
- log("systemtap starting probe");
- x1 = 41;
+ println("systemtap starting probe")
+ x1 = 41
}
probe end
{
- log("systemtap ending probe");
- ++x1;
- if (x1 != 42 ) {
- log("systemtap test failure");
- } else {
- log("systemtap test success");
- }
+ println("systemtap ending probe")
+ x1++
+ if (x1 == 42) {
+ ++x1
+ if (x1 != 43 ) {
+ println("systemtap test failure")
+ } else {
+ println("systemtap test success")
+ }
+ } else
+ println("systemtap test failure")
}
probe begin
{
- log("systemtap starting probe")
+ println("systemtap starting probe")
}
probe kernel.function("schedule")
probe end
{
- log("systemtap ending probe")
- log("count = " . sprint(count));
+ println("systemtap ending probe")
+ printf("count = %d\n", count)
}
probe begin
{
- log("systemtap starting probe")
+ println("systemtap starting probe")
}
probe module("ext3").function("ext3_sync_file") ?,
probe end
{
- log("systemtap ending probe")
- log("count = " . sprint(count));
+ println("systemtap ending probe")
+ println("count = " . sprint(count));
}
/*
* logical_and.stp
*
- * Check the systemtap "logical and" works
+ * Check that systemtap "logical and" works
*/
global x1_0
probe begin
{
- log("systemtap starting probe")
+ println("systemtap starting probe")
x1_0 = 0; x2_1 = 1; x3_0 = 0; x4_1 = 1;
}
probe end
{
- log("systemtap ending probe")
+ println("systemtap ending probe")
if (x1_0 && x3_0 ) {
- log("systemtap test failure");
+ println("systemtap test failure");
} else {
- log("systemtap test success");
+ println("systemtap test success");
}
if (x2_1 && x3_0 ) {
- log("systemtap test failure");
+ println("systemtap test failure");
} else {
- log("systemtap test success");
+ println("systemtap test success");
}
if (x1_0 && x4_1 ) {
- log("systemtap test failure");
+ println("systemtap test failure");
} else {
- log("systemtap test success");
+ println("systemtap test success");
}
if (x2_1 && x4_1 ) {
- log("systemtap test success");
+ println("systemtap test success");
} else {
- log("systemtap test failure");
+ println("systemtap test failure");
}
}
/*
* neg.stp
*
- * Check the systemtap negation works
+ * Check that systemtap negation works
*/
global x2, x1
probe begin
{
- log("systemtap starting probe")
+ println("systemtap starting probe")
x1 = 0xaaaaaaaaaaaaaaaa
}
probe end
{
- log("systemtap ending probe")
- x2 = ~x1;
+ println("systemtap ending probe")
+ x2 = ~x1
if ( x2 != 0x5555555555555555 ) {
- log("systemtap test failure");
+ println("systemtap test failure")
} else {
- log("systemtap test success");
+ println("systemtap test success")
}
}
probe begin
{
- log("systemtap starting probe")
- s1 = "systemtap"
- s2 = "test"
- s3 = "success"
+ println("systemtap starting probe")
+ s1 = "systemtap"
+ s2 = "test"
+ s3 = "success"
}
probe end
{
- log("systemtap ending probe")
+ println("systemtap ending probe")
- print(s1, " ", s2, " ", s3, "\n")
- print(sprint(s1, " ", s2, " ", s3, "\n"))
+ print(s1, " ", s2, " ", s3, "\n")
+ print(sprint(s1, " ", s2, " ", s3, "\n"))
- println(s1, " ", s2, " ", s3)
- print(sprintln(s1, " ", s2, " ", s3))
+ println(s1, " ", s2, " ", s3)
+ print(sprintln(s1, " ", s2, " ", s3))
- printd(" ", s1, s2, s3 . "\n")
- print(sprintd(" ", s1, s2, s3 . "\n"))
+ printd(" ", s1, s2, s3 . "\n")
+ print(sprintd(" ", s1, s2, s3 . "\n"))
- printdln(" ", s1, s2, s3)
- print(sprintdln(" ", s1, s2, s3))
+ printdln(" ", s1, s2, s3)
+ print(sprintdln(" ", s1, s2, s3))
- // check that formatting characters get escaped correctly in the delimiter
- s = sprintd("%% % \\ \"", 1, 2, 3)
- if (s == "1%% % \\ \"2%% % \\ \"3")
- log("systemtap test success")
- else
- log("systemtap test failure")
+ // Check that formatting characters get escaped correctly
+ // in the delimiter.
+ s = sprintd("%% % \\ \"", 1, 2, 3)
+ if (s == "1%% % \\ \"2%% % \\ \"3")
+ println("systemtap test success")
+ else
+ println("systemtap test failure")
}
# These sys_ functions often display prologue sensitivity
probe syscall.read, syscall.write {
- log (name . argstr)
+ printf("%s (%s)\n", name, argstr)
if (num++ > 20) exit()
}
global num
probe begin
{
- log("systemtap starting probe")
+ println("systemtap starting probe")
}
probe end
{
- log("systemtap ending probe")
+ println("systemtap ending probe")
}
probe begin
{
- log("systemtap starting probe");
+ println("systemtap starting probe");
x1 = 0; x2 = 1; x3=30;
}
probe end
{
- log("systemtap ending probe")
+ println("systemtap ending probe")
x4 = x1 ? 9: 10;
x5 = x2 ? 99: 100;
x6 = x3 ? 999: 1000;
if (x4 != 10 ) {
- log("systemtap test failure");
+ println("systemtap test failure");
} else {
- log("systemtap test success");
+ println("systemtap test success");
}
if (x5 != 99 ) {
- log("systemtap test failure");
+ println("systemtap test failure");
} else {
- log("systemtap test success");
+ println("systemtap test success");
}
if (x6 != 999 ) {
- log("systemtap test failure");
+ println("systemtap test failure");
} else {
- log("systemtap test success");
+ println("systemtap test success");
}
}
# stap -DMAXERRORS=40
global sc
-probe begin { log(sprint(@count(sc))) }
+probe begin { println(@count(sc)) }
probe begin { print(@sum(sc)) }
probe begin { print(@max(sc)) }
probe begin { print(@min(sc)) }
probe begin { x=@hist_log(sc)[5]; print(x) }
global ry
-probe begin { log(sprint(@count(ry[4]))) }
+probe begin { println(@count(ry[4])) }
probe begin { print(@sum(ry[4])) }
probe begin { print(@max(ry[4])) }
probe begin { print(@min(ry[4])) }
probe begin
{
print("Print");
- log("Systemtap");
+ println("Systemtap");
warn("warning");
exit()
}
global foo, bar
probe begin {
- log ("foo=" . foo . " bar=" . sprint (bar+0 /* cast bar to integer */))
+ printf("foo=%s bar=%d\n", foo, bar)
exit ()
}
failures ++
result = "fail"
}
- log ("test " . (sprint (++testno)) . " [" . v . "]\t" . result)
+ println ("test " . (sprint (++testno)) . " [" . v . "]\t" . result)
}
function stest (v,n1,n2) {
failures ++
result = "fail"
}
- log ("test " . (sprint (++testno)) . " [" . v . "]\t" . result)
+ println ("test " . (sprint (++testno)) . " [" . v . "]\t" . result)
}
}
probe end {
- log ("passes: " . sprint(passes) . " failures: " . sprint(failures))
+ printf ("passes: %d failures: %d\n", passes, failures)
}
failures ++
result = "fail"
}
- log ("test " . (sprint (testno++)) . " [" . v . "]\t\t" . result)
+ printf ("test %d [%s]\t\t%s\n", testno++, v, result)
}
# Exactly the same as test() except it will magically work for strings.
failures ++
result = "fail"
}
- log ("test " . (sprint (testno++)) . " [" . v . "]\t\t" . result)
+ printf ("test %d [%s]\t\t%s\n", testno++, v, result)
}
}
probe end {
- print ("passes: " . sprint(passes))
- print (" failures: " . sprint(failures). "\n")
+ printf ("passes: %d failures: %d\n", passes, failures)
}
#! stap
global teststr
-probe begin { log("systemtap starting probe") }
+probe begin { println("systemtap starting probe") }
probe ioblock.request, ioblock.end {
teststr = sprintf("ioblock: %s\t%d\t%s\t%d\n", devname, sector,
bio_rw_str(rw), bio_rw_num(rw))
}
probe end {
- log("systemtap ending probe")
+ println("systemtap ending probe")
printf("%s", teststr)
}
write_bytes[execname()] += $count;
}
-probe begin { log( "starting probe" ); }
+probe begin { println( "starting probe" ); }
probe end {
foreach( name in names){
- log ("process: " . name);
+ printf ("process: %s\n", name);
if (opens[name])
- log( "opens n=" . sprint(opens[name]));
- if ( reads[name]){
+ printf ("opens=%d\n",opens[name])
+ if (reads[name]){
count = reads[name]; total=read_bytes[name];
- log("reads n, sum, avg=". sprint(count)
- . "," . sprint(total) . "," . sprint(total/count));
+ printf("reads=%d, sum=%d, avg=%d\n", count, total, total/count);
}
if (writes[name]){
count = writes[name]; total=write_bytes[name];
- log("writes n, sum, avg=". sprint(count)
- . "," . sprint(total) . "," . sprint(total/count));
+ printf("writes=%d, sum=%d, avg=%d\n", count, total, total/count);
}
- log("");
+ println("");
}
}
global names, opens, reads, writes
-probe begin { log("starting probe") }
+probe begin { println("starting probe") }
probe timer.ms(10000) {
- log("stopping probe after 10 seconds")
+ println("stopping probe after 10 seconds")
exit()
}
#! stap
+
global odds, evens
+
probe begin {
# "no" and "ne" are local integers
for (i=1; i<10; i++) {
probe end {
foreach (x+ in odds) {
- log("odds[" . sprint(x) . "] = " . sprint(odds[x]))
+ printf("odds[%d] = %d\n", x, odds[x])
}
foreach (x in evens-) {
- log("evens[" . sprint(x) . "] = " . sprint(evens[x]))
+ printf("evens[%d] = %d\n", x, evens[x])
}
}
THIS->__retvalue = strlen(current->parent->comm);
%}
-probe begin { log("systemtap starting probe") }
+probe begin { println("systemtap starting probe") }
probe
timer.profile,
%}
probe end {
- log("systemtap ending probe")
+ println("systemtap ending probe")
printf("count = %d\n", @count(length))
printf("sum = %d\n", @sum(length))
printf("min = %d\n", @min(length))
* valid, even though it dereferenced without crashing.
*/
if (@min(length) > 0) {
- log("systemtap test success")
+ println("systemtap test success")
} else {
- log("unexpected minimum length")
- log("systemtap test failure")
+ println("unexpected minimum length")
+ println("systemtap test failure")
}
if (@max(length) < get_TASK_COMM_LEN()) {
- log("systemtap test success")
+ println("systemtap test success")
} else {
- log("unexpected maximum length")
- log("systemtap test failure")
+ println("unexpected maximum length")
+ println("systemtap test failure")
}
}