Format problem in printa() for negative values
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 10 Dec 2022 20:24:40 UTC
On my laptop running FreeBSD 12.3-STABLE #3 r371380 a saw a problem with the printa() function of DTrace. To explain I use the C program printa: #include <stdio.h> #include <unistd.h> void fkt1() { printf( "fkt1() called\n" ); } void fkt2() { printf( "fkt2() called\n" ); } int main () { sleep( 10 ); fkt1(); fkt2(); fkt1(); fkt2(); fkt1(); } After start of printa I run the following DTrace script with "dtrace -p $(pgrep printa) -s printa.d" : dtrace:::BEGIN { printf("demo for printa\n"); } pid$target::fkt1:entry /execname == "printa"/ { @fkt1 = count(); @saldo1 = sum(1); @saldo2 = sum(-1); } pid$target::fkt2:entry /execname == "printa"/ { @fkt2 = count(); @saldo1 = sum(-1); @saldo2 = sum(1); } dtrace:::END { printf("demo for printa\n"); printa("fkt1=%@d, fkt2=%@d, saldo1=%@d\n", @fkt1, @fkt2, @saldo1); printa("fkt1=%@d, fkt2=%@d, saldo2=%@d\n", @fkt1, @fkt2, @saldo2); printa("saldo2=%@d, fkt1=%@d, fkt2=%@d\n", @saldo2, @fkt1, @fkt2); } The result is dtrace: script './printa.d' matched 4 probes CPU ID FUNCTION:NAME 3 1 :BEGIN demo for printa fkt1() called fkt2() called fkt1() called fkt2() called fkt1() called dtrace: pid 11387 has exited 2 2 :END demo for printa fkt1=3, fkt2=2, saldo1=1 fkt1=3, fkt2=2, saldo2=18446744073709551615 saldo2=-1, fkt1=3, fkt2=2 The negative value of @saldo2 is wrong, when it is not the first parameter in the printa() function.