1

I am new to systemtap and would like to understand how to attach instrumentation dynamically to a production application using debug information in the application.

For a target application (example apache webserver). I would like to find the amount of time spent in the execution of a given function. i.e. i'd like to find time spent from beginning to end of a function, using the function's symbolic information. How can I do this using systemtap- Can you please give the instructions on:

  1. A tapset script for user-space probing using debug information
  2. How to execute this tapset script with a target application.

In particular I would like to find out how I can use the - Debuginfo-based instrumentation for user space tracing.

Here is the reference for "Debuginfo-based information" - https://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps

4

1 回答 1

2

列出函数:

stap -L 'process("/usr/sbin/httpd").function("*").call'

函数调用率的基本计数:

stap /usr/share/doc/systemtap*/examples/*/eventcount.stp \
    'process("/usr/sbin/httpd").function("*").call'

计时函数:

stap -e 'probe process("/usr/sbin/httpd").function("ap_getword_conf").return {
    printf("%s %d\n", ppfunc(), gettimeofday_us()-@entry(gettimeofday_us()))
}'
于 2016-05-12T15:35:06.427 回答