通过简单的例子,学习systemtap
看例子先! 怎样遍历数组: 1. # 2. # Print the system call count by process name in descending order. 3. # 4. 5. global syscalls 6. 7. probe begin { 8. print ("Collecting data... Type Ctrl-C to exit and display results\n") 9. } 10. 11. probe syscall.* { 12. syscalls[execname()]++ 13. } 14. 15. probe end { 16. printf ("%-10s %-s\n", "#SysCalls", "Process Name") 17. foreach (proc in syscalls-) 18. printf("%-10d %-s\n", syscalls[proc], proc) 19. } 这中间,比较难理解的是第17行,那么它的解释如下: The variable proc is an index variable that iterates over the range of values possible for the array index of syscalls. Also note the en dash (-) after syscalls that denotes that the iteration runs in reverse order. This character ensures that the number of system calls made print in descending order. To print in ascending order, change the...