myaut/dtrace-stap-book

The issue about script in lang/intro.md.

NanXiao opened this issue · 1 comments

Hi myaut,

In intro chapter:

There is a hackish way of building loops in DTrace using timer probes:

int count;
BEGIN {
	count = 10;
}
timer-1ms
/--count > 0/ {
	printf("Hello, world!\n");
}

This script prints "Hello, world" phrase each millisecond 10 times.

On my FreeBSD system, running this script complains:

(1) ... built-in identifier redeclared: count
(2) ... probe description :::timer-1ms does not match any probes

I modify the script as this:

int i;
BEGIN {
    i = 10;
}
tick-1ms
/--i > 0/ {
    printf("Hello, world!\n");
}

BTW, "This script prints "Hello, world" phrase each millisecond 10 times.", shouldn't it be "... each millisecond 1 time."?

Please check these, thanks very much!

Best Regards
Nan Xiao

myaut commented

One more mistake I should be ashamed of has been fixed. Comments on delay are also expanded.
Thanks for catching it!