User:Tbscope/examplesystemtapscripts/usingsysopen: Difference between revisions

From KDE TechBase
(New page: == Script == The following text is the contents of the debug.stp file. global starttime probe begin { starttime = gettimeofday_s() } probe kernel.function("sys_open").call { if...)
 
(Show the results correctly 2/2)
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
The following text is the contents of the debug.stp file.
The following text is the contents of the debug.stp file.


<code>
global starttime
global starttime


Line 17: Line 18:
     }
     }
}
}
</code>


== Results for plasma ==
== Results for plasma ==


When the script is run like this:
When the script is run like this:
<code>
sudo stap -v ./debug.stp plasma
sudo stap -v ./debug.stp plasma
</code>


It gives the following results:
It gives the following results:
<code>
Pass 1: parsed user script and 47 library script(s) in 330usr/0sys/342real ms.
Pass 1: parsed user script and 47 library script(s) in 330usr/0sys/342real ms.
Pass 2: analyzed script: 2 probe(s), 7 function(s), 1 embed(s), 1 global(s) in 220usr/30sys/244real ms.
Pass 2: analyzed script: 2 probe(s), 7 function(s), 1 embed(s), 1 global(s) in 220usr/30sys/244real ms.
Line 47: Line 52:
[    59] plasma(5239) open /proc/mounts
[    59] plasma(5239) open /proc/mounts
^CPass 5: run completed in 0usr/0sys/65800real ms.
^CPass 5: run completed in 0usr/0sys/65800real ms.
</code>


As you can see, plasma opens three specific files every 10 seconds.
As you can see, plasma opens three specific files every 10 seconds.
Line 52: Line 58:
== Results for Konsole ==
== Results for Konsole ==
When the script is run like this:
When the script is run like this:
<code>
sudo stap -v ./debug.stp konsole
sudo stap -v ./debug.stp konsole
</code>


It gives the following results:
It gives the following results:
<code>
Pass 1: parsed user script and 47 library script(s) in 320usr/20sys/338real ms.
Pass 1: parsed user script and 47 library script(s) in 320usr/20sys/338real ms.
Pass 2: analyzed script: 2 probe(s), 7 function(s), 1 embed(s), 1 global(s) in 210usr/30sys/247real ms.
Pass 2: analyzed script: 2 probe(s), 7 function(s), 1 embed(s), 1 global(s) in 210usr/30sys/247real ms.
Line 68: Line 77:
[    44] konsole(5257) open /var/tmp/kdecache-kde4/kpc/kde-icon-cache.updated
[    44] konsole(5257) open /var/tmp/kdecache-kde4/kpc/kde-icon-cache.updated
^CPass 5: run completed in 0usr/10sys/47755real ms.
^CPass 5: run completed in 0usr/10sys/47755real ms.
</code>

Latest revision as of 16:52, 29 November 2008

Script

The following text is the contents of the debug.stp file.

global starttime

probe begin {

   starttime = gettimeofday_s()

}

probe kernel.function("sys_open").call {

   if(execname()==@1) {
       filename = user_string($filename)
       printf("[%6d] %s(%d) open %s\n", (gettimeofday_s() - starttime), execname(), pid(), filename)
   }

}

Results for plasma

When the script is run like this: sudo stap -v ./debug.stp plasma

It gives the following results: Pass 1: parsed user script and 47 library script(s) in 330usr/0sys/342real ms. Pass 2: analyzed script: 2 probe(s), 7 function(s), 1 embed(s), 1 global(s) in 220usr/30sys/244real ms. Pass 3: translated to C into "/tmp/stap34SfoX/stap_8db786e95cd1a11f8070bb0ef7f3ca06_1906.c" in 500usr/190sys/693real ms. Pass 4: compiled C into "stap_8db786e95cd1a11f8070bb0ef7f3ca06_1906.ko" in 3940usr/480sys/4443real ms. Pass 5: starting run. [ 9] plasma(5239) open /etc/fstab [ 9] plasma(5239) open /etc/mtab [ 9] plasma(5239) open /proc/mounts [ 19] plasma(5239) open /etc/mtab [ 19] plasma(5239) open /proc/mounts [ 19] plasma(5239) open /etc/fstab [ 25] plasma(5239) open /var/tmp/kdecache-kde4/kpc/kde-icon-cache.updated [ 29] plasma(5239) open /etc/mtab [ 29] plasma(5239) open /proc/mounts [ 39] plasma(5239) open /etc/fstab [ 39] plasma(5239) open /etc/mtab [ 39] plasma(5239) open /proc/mounts [ 49] plasma(5239) open /etc/mtab [ 49] plasma(5239) open /proc/mounts [ 59] plasma(5239) open /etc/fstab [ 59] plasma(5239) open /etc/mtab [ 59] plasma(5239) open /proc/mounts ^CPass 5: run completed in 0usr/0sys/65800real ms.

As you can see, plasma opens three specific files every 10 seconds.

Results for Konsole

When the script is run like this: sudo stap -v ./debug.stp konsole

It gives the following results: Pass 1: parsed user script and 47 library script(s) in 320usr/20sys/338real ms. Pass 2: analyzed script: 2 probe(s), 7 function(s), 1 embed(s), 1 global(s) in 210usr/30sys/247real ms. Pass 3: translated to C into "/tmp/stapKL9fWp/stap_f06923bc6d17872e0d5cfb29c594b1a7_1907.c" in 420usr/250sys/679real ms. Pass 4: compiled C into "stap_f06923bc6d17872e0d5cfb29c594b1a7_1907.ko" in 3920usr/510sys/4450real ms. Pass 5: starting run. [ 10] konsole(5257) open /var/tmp/kdecache-kde4/kpc/kde-icon-cache.updated [ 10] konsole(5257) open /var/tmp/kdecache-kde4/kpc/kde-icon-cache.lock.CE5257 [ 10] konsole(5257) open /var/tmp/kdecache-kde4/kpc/kde-icon-cache.lock.gW5257 [ 15] konsole(5257) open /var/tmp/kdecache-kde4/kpc/kde-icon-cache.updated [ 39] konsole(5257) open /var/tmp/kdecache-kde4/kpc/kde-icon-cache.updated [ 41] konsole(5257) open /var/tmp/kdecache-kde4/kpc/kde-icon-cache.lock.nu5257 [ 44] konsole(5257) open /var/tmp/kdecache-kde4/kpc/kde-icon-cache.updated ^CPass 5: run completed in 0usr/10sys/47755real ms.