Changes

Jump to navigation Jump to search
2,151 bytes added ,  15:55, 10 March 2014
no edit summary
Line 21: Line 21:     
If you install from git and from the repositories, in the same system, can have conflicts trying to run the probes.
 
If you install from git and from the repositories, in the same system, can have conflicts trying to run the probes.
 +
 +
=== Adding your user to the needed groups ===
 +
 +
To run stap as a user, you need add it to the following groups
 +
 +
# usermod -a -G stapusr gonzalo
 +
# usermod -a -G stapsys gonzalo
 +
# usermod -a -G stapdev gonzalo
 +
 +
after that, you need restart your session.
 +
 +
You always can run stap as root too.
    
=== Using systemtap ===
 
=== Using systemtap ===
   −
Systemtap have  
+
Systemtap have "probes" already included in the kernel, and several libraries in user space too.
 +
Both GLib and python have probes, making it very useful for us.
 +
You can use it to monitor when files are read, or when objects are created or destroyed.
 +
To do it, have a language to create scripts. Several scripts are already created,
 +
and you can create new or modify them.
 +
 
 +
Systemtap monitor events in all the process in the system, but you can define a filter
 +
to monitor only a specific process.
 +
 
 +
This example show how to analyze memory use with SystemTap [http://blog.verbum.org/2011/03/19/analyzing-memory-use-with-systemtap/]
 +
 
 +
=== Using with sugar-buid ===
 +
 
 +
In sugar-build, we build glib, then we need move the global glib and gobject probes, to not have comflicts.
 +
 
 +
I renamed the global probes:
 +
 
 +
# cd /usr/share/systemtap/tapset/
 +
# mv 64-glib.stp 64-glib.stp.old
 +
# mv 64-gobject.stp 64-gobject.stp.old
 +
 
 +
Now we can download a sample test, like [http://people.gnome.org/~walters/glib-memtrace2.stp] and run it in our sugar-build session.
 +
 
 +
To attach it to a running process, can use the -x parameter.
 +
 
 +
To get the sugar process PID, can do:
 +
 
 +
$ ps ax | grep jarabe
 +
24673 ?        Sl    0:28 python2 -m jarabe.main
 +
 
 +
The first number is the PID
 +
 
 +
Running stap with the PID we found:
 +
 
 +
$ stap -v -x 24673 glib-memtrace2.stp
 +
 
 +
This will show every 5 seconds, the memory use and if GObjects were created.
 +
 
 +
Another probe you can use is [[File:Pyfuntime.stp]]
 +
 
 +
$ stap -v -x 24673 pyfuntime.stp
 +
 
 +
Will show every time a python method start and finish, and the time spent.
 +
 
 +
Finally, to have a "top" like of python functions, download [[File:Pyfuntop.stp]]
 +
 
 +
== Troubleshoting ==
 +
 
 +
* If your user can't run stap, execute the command "groups" and check if stapusr, stapsys and stapdev groups are present.
 +
 
 +
* If you need check what directories is using systemtap to look for the probes, can do:
 +
 
 +
stap -p1 -vv 'probe begin  { }' > /dev/null
    
== External links ==
 
== External links ==
   −
Analyzing memory use with SystemTap [http://blog.verbum.org/2011/03/19/analyzing-memory-use-with-systemtap/]
+
Systemtap wiki https://sourceware.org/systemtap/wiki
628

edits

Navigation menu