This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Met Problem on Enable SystemTap on Android


Hi,

I would also suggest for any topic to have a look at http://sourceware.org/systemtap -> documentation (top right) -> all examples (by keyword).
For example, in SYSCALL keyword, you will find lots of examples showing how to dump immediately syscalls or accumulate in arrays and dump at the end. This page + tapset are a big source inspiration (thanks to all contributors)
Depending on the needs, it can be interesting to accumulate internally rather than tracing everything (but you may then lose some info)

Example from http://sources.redhat.com/ml/systemtap/2011-q3/msg00085.html:

global starttime, timebycall
probe begin { printf("Collecting data - type Ctrl-C to print output and exit... %d\n", get_32k()) }

probe syscall.* { starttime[name, tid()] = <function to get time> }

probe syscall.*.return {
    # Skip if we have not seen this before
    if (!([name, tid()] in starttime)) next
    delta = <function to get time> - starttime[name, tid()]
    timebycall[name, tid(), execname()] <<< delta
    delete starttime[name, tid()]
}

function print_header() {
        printf("%22s %16s:%-6s %10s %12s %12s %12s %12s\n",
               "System Call", "execname", "pid", "Count", "Total 32K",
               "Avg 32K", "Min 32K", "Max 32K")
}

probe end {
  printf("END TIME %d\n", <function to get time>)

  printf("\nTimes for XXX:\n\n")
  print_header()
  foreach ([call, pidt+, exe] in timebycall)
    printf("%22s %16s:%-6d %10d %12d %12d %12d %12d\n", call, exe, pidt,
      @count(timebycall[call, pidt, exe]),
      @sum(timebycall[call, pidt, exe]),
      @avg(timebycall[call, pidt, exe]),
      @min(timebycall[call, pidt, exe]),
      @max(timebycall[call, pidt, exe]))


  delete timebycall
}

Regards
Fred

Frederic Turgis
OMAP Platform Business Unit - OMAP System Engineering - Platform Enablement



>
Texas Instruments France SA, 821 Avenue Jack Kilby, 06270 Villeneuve Loubet. 036 420 040 R.C.S Antibes. Capital de EUR 753.920

-----Original Message-----

>From: Yao,Yanjun [mailto:jiaoyang28@gmail.com]
>Sent: Wednesday, September 14, 2011 10:41 PM
>To: David Smith
>Cc: Turgis, Frederic; Mark Wielaard; Josh Stone;
>systemtap@sourceware.org
>Subject: Re: Met Problem on Enable SystemTap on Android
>
>Thanks a lot.
>
>This just fits what I want.
>
>Yours
>Sincerely
>
>2011/9/14 David Smith <dsmith@redhat.com>:
>> On 09/14/2011 03:20 PM, Yao,Yanjun wrote:
>>
>>> Thanks Turgis,
>>>
>>> I got the problem fixed as what you said.
>>>
>>> One last question, in my implementation, we want to know
>what system
>>> calls each program made. However, in SystemTap tutorial or
>examples,
>>> people already know what to probe, then they go to probe that file.
>>>
>>> What's in my mind is like:
>>> probe syscall.* {
>>>    //print out the * part of the target "syscall.*"
>>> }
>>>
>>> May I ask how can I do that?
>>
>>
>> Like this:
>>
>> probe syscall.* { printf("%s: %s (%s) = ", execname(), name,
>argstr) }
>>
>> If you want to get fancier and see the return values also, do this
>> (this is from testsuite/buildok/syscall.stp):
>>
>> probe syscall.*, syscall.*.return {
>>
>>    if (retstr != "")
>>        printf("%s\n", retstr)
>>    else
>>        printf("%s: %s (%s) = ", execname(), name, argstr) }
>>
>>
>> --
>> David Smith
>> dsmith@redhat.com
>> Red Hat
>> http://www.redhat.com
>> 256.217.0141 (direct)
>> 256.837.0057 (fax)
>>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]