1 Star2 Stars3 Stars4 Stars5 Stars (还没有评分)
Loading...

DTrace tricks and tips (17) -trace(),print()和printf()的区别

用一个例子来展示trace()print()printf()的区别:

# dtrace -qn 'BEGIN{ trace(walltimestamp); exit(0) }'
1670295094532869758
# dtrace -qn 'BEGIN{ print(walltimestamp); exit(0) }'
int64_t 0x172e148c77c367d3

# dtrace -qn 'BEGIN{ printf(walltimestamp); exit(0)}'
dtrace: invalid probe specifier BEGIN{ printf(walltimestamp); exit(0)}: printf( ) argument #1 is incompatible with prototype:
        prototype: string constant
         argument: int64_t
# dtrace -qn 'BEGIN{ printf("%d\n", walltimestamp); exit(0)}'
1670295157720493229

参考:Output Formatting

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.