public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Why is the same log printed twice when using probe alias?
@ 2015-12-01  9:06 Nan Xiao
  2015-12-01 15:57 ` Frank Ch. Eigler
  0 siblings, 1 reply; 2+ messages in thread
From: Nan Xiao @ 2015-12-01  9:06 UTC (permalink / raw)
  To: systemtap

Hi all,

I am writing a simple script to test probe alias:

# cat test.stp
#!/usr/bin/stap

probe timer_alias = timer.s(3) {printf("Entering timer\n")}
probe timer_alias += timer.s(3) {printf("Leaving timer\n")}
probe timer_alias {printf("In timer\n")}

But executing it will outputs "In timer" twice:

# ./test.stp
Entering timer
In timer
In timer
Leaving timer
Entering timer
In timer
In timer
Leaving timer
.......

Is it the expected behavior? How to understand it?

Thanks very much in advance!

Best Regards
Nan Xiao

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

* Re: Why is the same log printed twice when using probe alias?
  2015-12-01  9:06 Why is the same log printed twice when using probe alias? Nan Xiao
@ 2015-12-01 15:57 ` Frank Ch. Eigler
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Ch. Eigler @ 2015-12-01 15:57 UTC (permalink / raw)
  To: Nan Xiao; +Cc: systemtap

Nan Xiao <xiaonan830818@gmail.com> writes:

> [...]
> probe timer_alias = timer.s(3) {printf("Entering timer\n")}
> probe timer_alias += timer.s(3) {printf("Leaving timer\n")}
> probe timer_alias {printf("In timer\n")}

> # ./test.stp
> Entering timer
> In timer
> In timer
> Leaving timer
> [...]


This is correct.  Each probe alias definition is independent of the
others, so in this case, timer_alias expands to two separate
timer.s(3) probes.  The += just means that the {} block associated
with the latter is supposed to be executed -after- the user's handler
rather than before.  (It is not an addition to the other alias's
probe handler or something like that.)


- FChE

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

end of thread, other threads:[~2015-12-01 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-01  9:06 Why is the same log printed twice when using probe alias? Nan Xiao
2015-12-01 15:57 ` Frank Ch. Eigler

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).