How to do it...

To use SystemTap on a Yocto system, we need to run the crosstap utility in the host, passing it the systemtap script to run. For example, to run the sys_open.stp sample script, we can use the following code:

probe begin 
{ 
        print("Monitoring starts
") 
        printf("%6s %6s %16s
", "UID", "PID", "NAME"); 
} 
 
probe kernel.function("sys_open") 
{ 
          printf("%6d %6d %16s
", uid(), pid(), execname()); 
} 
 
probe timer.s(60) 
{ 
        print("Monitoring ends
") 
        exit() 
} 

We would run the following commands:

    $ source setup-environment wandboard
    $ cd </path/to/systemtap_script/folder>
    $ crosstap root@<target_ip> sys_open.stp
  
If you get the following error:
Error: Native (host) systemtap not found. 
It means the host does not have SystemTap installed, which is needed by CrossTap. You can just ask BitBake to build it by doing:
$ bitbake systemtap-native

Yocto does not support running scripts on the target, as that would require building modules on the target, and that is untested.

Once the module loads on the target, the host will report all the open syscalls in a 60-second period.

Monitoring starts
UID    PID             NAME
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
  0    622               ls
 Monitoring ends
  
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset