public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Command line arg for kernel Tracepoints
@ 2010-12-30  8:25 h patel
  2010-12-30  9:23 ` Adrien Kunysz
  0 siblings, 1 reply; 7+ messages in thread
From: h patel @ 2010-12-30  8:25 UTC (permalink / raw)
  To: systemtap

Hi,

I am using kernel tracepoints with systemtap scripts.
My requirement is to enable disable certain traces out of these
defined tracepoints in kernel modules.

I tried to pass argument to script but it didn't work, looks like
kernel.trace don't accept command line argument.
Is it true ?

If yes, then i have to write multiple scripts for diff events. Any
other suggestion ?

Thanks,
hp

parse error: command line argument index 1 out of range [1-0]
        at: junk '@1' at test.stp:16:20
     source: probe kernel.trace(@1) { printf("%s
called\n",kernel_string($log)) }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Command line arg for kernel Tracepoints
  2010-12-30  8:25 Command line arg for kernel Tracepoints h patel
@ 2010-12-30  9:23 ` Adrien Kunysz
       [not found]   ` <AANLkTinjLCVwnUXxFLV=xfCk698M=ZfO=RC7JM10mgMF@mail.gmail.com>
  0 siblings, 1 reply; 7+ messages in thread
From: Adrien Kunysz @ 2010-12-30  9:23 UTC (permalink / raw)
  To: h patel; +Cc: systemtap

[-- Attachment #1: Type: text/plain, Size: 279 bytes --]

On Thu, Dec 30, 2010 at 01:55:26PM +0530, h patel wrote:
> parse error: command line argument index 1 out of range [1-0]

This means @1 and $1 don't exist as no argument was passed to the script
and I doubt this has anything to do with .trace itself. How did you run
the script?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Command line arg for kernel Tracepoints
       [not found]     ` <20101230093858.GC4390@baltika>
@ 2011-01-03 12:09       ` h patel
  2011-01-03 12:44         ` Mark Wielaard
  0 siblings, 1 reply; 7+ messages in thread
From: h patel @ 2011-01-03 12:09 UTC (permalink / raw)
  To: Adrien Kunysz, systemtap

Sorry, forgot to reply all.

Hi,

It didn't work. Script can take the argument but kernel.trace can not.
Looks like kernel.trace only handles pattern, not argument.
In that case, I will limit down the types of events.

Thanks,
hp

Error :
parse error: expected literal string or number
       saw: identifier 'tpoint' at test.stp:9:20
    source: probe kernel.trace(tpoint) { printf("%s
called\n",kernel_string($log)) }

On Thu, Dec 30, 2010 at 3:08 PM, Adrien Kunysz <adrien@kunysz.be> wrote:
> I don't think that will ever work like that as @1 and $1 are expanded at
> compile time (I think). You probably need to use a named global variable
> as described in the "ARGUMENTS" section of staprun(8).
>
>        global tpoint = "whateverDefaultProbeYouLike"
>        probe kernel.trace(tpoint) { printf("oh hai\n") }
>
> # stap -m test test.stp
> # staprun test.ko tpoint="anotherTracepoint"
>
> I haven't verified this will work.
>
> On Thu, Dec 30, 2010 at 02:59:58PM +0530, h patel wrote:
>> It's cross compile :
>> host> stap -gv -r /linux-2.6.32.10 -I /target/share/systemtap/tapset
>> -R /target/share/systemtap/runtime -m test test.stp -v
>>
>> host> cat test.stp
>>
>> #! /usr/bin/env stap
>>
>> # Note when we turn the monitor on and off
>> probe begin { printf("Monitoring for wncreg\n") }
>> probe end { printf("Stopping monitor\n") }
>>
>> probe kernel.trace(@1) { printf("%s called\n",kernel_string($log)) }
>>
>>
>>
>>
>> On Thu, Dec 30, 2010 at 2:52 PM, Adrien Kunysz <adrien@kunysz.be> wrote:
>> > On Thu, Dec 30, 2010 at 01:55:26PM +0530, h patel wrote:
>> >> parse error: command line argument index 1 out of range [1-0]
>> >
>> > This means @1 and $1 don't exist as no argument was passed to the script
>> > and I doubt this has anything to do with .trace itself. How did you run
>> > the script?
>> >
>> > -----BEGIN PGP SIGNATURE-----
>> > Version: GnuPG v1.4.9 (GNU/Linux)
>> >
>> > iEYEARECAAYFAk0cT2sACgkQKLX03ZSPZGxRBgCeL/KX+tOJDvgXDy/qz9jR4a+U
>> > uNYAoJszrKWPVm2B3a9n56oavpo7gcR3
>> > =NCSz
>> > -----END PGP SIGNATURE-----
>> >
>> >
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAk0cUzIACgkQKLX03ZSPZGwuMQCgisjEWsv6UfkD48ws/TdFt/qL
> 0moAniM28a+br6l+vU245Rjb2czhtTwv
> =PkyI
> -----END PGP SIGNATURE-----
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Command line arg for kernel Tracepoints
  2011-01-03 12:09       ` h patel
@ 2011-01-03 12:44         ` Mark Wielaard
  2011-01-03 14:32           ` h patel
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Wielaard @ 2011-01-03 12:44 UTC (permalink / raw)
  To: h patel; +Cc: Adrien Kunysz, systemtap

On Mon, 2011-01-03 at 17:39 +0530, h patel wrote:
> It didn't work. Script can take the argument but kernel.trace can not.
> Looks like kernel.trace only handles pattern, not argument.
> In that case, I will limit down the types of events.
>
> Error :
> parse error: expected literal string or number
>        saw: identifier 'tpoint' at test.stp:9:20
>     source: probe kernel.trace(tpoint) { printf("%s
> called\n",kernel_string($log)) }

Note that kernel.trace() takes a string.
So it would be kernel.trace("tpoint") in your case.
To use wildcards, embed * inside the string.
For example to get a list of all kernel trace points:
stap -l 'kernel.trace("*")'

Cheers,

Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Command line arg for kernel Tracepoints
  2011-01-03 12:44         ` Mark Wielaard
@ 2011-01-03 14:32           ` h patel
  2011-01-03 14:39             ` Mark Wielaard
  0 siblings, 1 reply; 7+ messages in thread
From: h patel @ 2011-01-03 14:32 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: Adrien Kunysz, systemtap

Hi Mark,

tpoint is the global variable.  I want to enable disable tracepoints
at runtime.
Adrien suggested following way :

 global tpoint = "whateverDefaultProbeYouLike"
probe kernel.trace(tpoint) { printf("oh hai\n") }

# stap -m test test.stp
# staprun test.ko tpoint="anotherTracepoint"

I tried kernel.trace(tpoint), kernel.trace($tpoint),
kernel.trace("tpoint"), none of them worked.

Regards,
hp


On Mon, Jan 3, 2011 at 6:14 PM, Mark Wielaard <mjw@redhat.com> wrote:
> On Mon, 2011-01-03 at 17:39 +0530, h patel wrote:
>> It didn't work. Script can take the argument but kernel.trace can not.
>> Looks like kernel.trace only handles pattern, not argument.
>> In that case, I will limit down the types of events.
>>
>> Error :
>> parse error: expected literal string or number
>>        saw: identifier 'tpoint' at test.stp:9:20
>>     source: probe kernel.trace(tpoint) { printf("%s
>> called\n",kernel_string($log)) }
>
> Note that kernel.trace() takes a string.
> So it would be kernel.trace("tpoint") in your case.
> To use wildcards, embed * inside the string.
> For example to get a list of all kernel trace points:
> stap -l 'kernel.trace("*")'
>
> Cheers,
>
> Mark
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Command line arg for kernel Tracepoints
  2011-01-03 14:32           ` h patel
@ 2011-01-03 14:39             ` Mark Wielaard
  2011-01-03 15:00               ` Mark Wielaard
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Wielaard @ 2011-01-03 14:39 UTC (permalink / raw)
  To: h patel; +Cc: Adrien Kunysz, systemtap

On Mon, 2011-01-03 at 20:02 +0530, h patel wrote:
> Hi Mark,
> 
> tpoint is the global variable.  I want to enable disable tracepoints
> at runtime.
> Adrien suggested following way :
> 
>  global tpoint = "whateverDefaultProbeYouLike"
> probe kernel.trace(tpoint) { printf("oh hai\n") }
> 
> # stap -m test test.stp
> # staprun test.ko tpoint="anotherTracepoint"
> 
> I tried kernel.trace(tpoint), kernel.trace($tpoint),
> kernel.trace("tpoint"), none of them worked.

Aha. Sorry, I had misunderstood what you were trying to do. Apologies.

Something like the following should work for that use case:
$ stap -e 'probe kernel.trace(@1) { log(pp()); exit();}' "sys_enter"
kernel.trace("sys_enter")
$ stap -e 'probe kernel.trace(@1) { log(pp()); exit();}' "timer_start"
kernel.trace("timer_start")

Cheers,

Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Command line arg for kernel Tracepoints
  2011-01-03 14:39             ` Mark Wielaard
@ 2011-01-03 15:00               ` Mark Wielaard
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Wielaard @ 2011-01-03 15:00 UTC (permalink / raw)
  To: h patel; +Cc: Adrien Kunysz, systemtap

On Mon, 2011-01-03 at 15:39 +0100, Mark Wielaard wrote:
> On Mon, 2011-01-03 at 20:02 +0530, h patel wrote:
> > tpoint is the global variable.  I want to enable disable tracepoints
> > at runtime.
> > Adrien suggested following way :
> > 
> >  global tpoint = "whateverDefaultProbeYouLike"
> > probe kernel.trace(tpoint) { printf("oh hai\n") }
> > 
> > # stap -m test test.stp
> > # staprun test.ko tpoint="anotherTracepoint"
> > 
> > I tried kernel.trace(tpoint), kernel.trace($tpoint),
> > kernel.trace("tpoint"), none of them worked.
> 
> Aha. Sorry, I had misunderstood what you were trying to do. Apologies.
> 
> Something like the following should work for that use case:
> $ stap -e 'probe kernel.trace(@1) { log(pp()); exit();}' "sys_enter"
> kernel.trace("sys_enter")
> $ stap -e 'probe kernel.trace(@1) { log(pp()); exit();}' "timer_start"
> kernel.trace("timer_start")

Actually, I see I am missing the point again.
That would compile in the trace point string.
So you cannot change it at staprun time.

I believe there is indeed no way to change the actual probe at staprun
time at the moment.

Sorry,

Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-01-03 15:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-30  8:25 Command line arg for kernel Tracepoints h patel
2010-12-30  9:23 ` Adrien Kunysz
     [not found]   ` <AANLkTinjLCVwnUXxFLV=xfCk698M=ZfO=RC7JM10mgMF@mail.gmail.com>
     [not found]     ` <20101230093858.GC4390@baltika>
2011-01-03 12:09       ` h patel
2011-01-03 12:44         ` Mark Wielaard
2011-01-03 14:32           ` h patel
2011-01-03 14:39             ` Mark Wielaard
2011-01-03 15:00               ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).