public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* adding statements in alias definition as epilogue
@ 2006-04-03  9:25 Li Guanglei
  2006-04-03  9:59 ` bibo,mao
  2006-04-03 16:00 ` Frank Ch. Eigler
  0 siblings, 2 replies; 9+ messages in thread
From: Li Guanglei @ 2006-04-03  9:25 UTC (permalink / raw)
  To: systemtap

Currently the statement block that follows an alias definition is 
implicitly added as a prologue to any probe that refers to the alias. 
But it seems to me that only allowing adding those statements 
contained in an alias definition as a prologue makes me to lose some 
controls over them.

For example, I have a tapsets:

probe addevent.tskdispatch.cpuidle
         = kernel.inline("idle_balance")
{
         log_cpuidle_tracedata(HOOKID_TASK_CPUIDLE, backtrace)
}

What I want is to let user specify whether to log backtrace in his 
scripts, like the following:

stap -e "probe addevent.tskdispatch.cpuidle { backtrace=1 } -I 
LKET_TAPSETS

But unfortunately, it won't work because "backtrace=1" is added after 
"log_cpuidle_tracedata(HOOKID_TASK_CPUIDLE, backtrace)". So how about 
providing a way to specify whether the statements in a alias 
definition could be added as prologue or epilogue to any probe that 
refers to that alias?

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: adding statements in alias definition as epilogue
@ 2006-04-05  0:41 Guang Lei Li
  2006-04-05  1:24 ` Frank Ch. Eigler
  0 siblings, 1 reply; 9+ messages in thread
From: Guang Lei Li @ 2006-04-05  0:41 UTC (permalink / raw)
  To: fche, systemtap

>> [...] What I want is to let user specify whether to log backtrace in 
his
>> scripts, like the following:
>> stap -e "probe addevent.tskdispatch.cpuidle { backtrace=1 } [...]
>> But unfortunately, it won't work because "backtrace=1" is added after
>> "log_cpuidle_tracedata(HOOKID_TASK_CPUIDLE, backtrace)". [...]

> You can have two alias definitions:

> probe addevent.tskdispatch.cpuidle.backtrace = 
addevent.tskdispatch.cpuidle {
>   backtrace = 1
> }

> probe addevent.tskdispatch.cpuidle = .... {
>   if (backtrace) log_more ();
> }
But this won't work either. Because addevent.tskdispatch.cpuidle.backtrace 
will
be expanded into:

probe ... {
    if (backtrace) log_more ();
    backtrace = 1
}

I tried the following patch:
root:/home/lgl/systemtap/src> diff -uprN elaborate.cxx.ori elaborate.cxx
--- elaborate.cxx.ori   2006-04-04 15:34:27.000000000 +0800
+++ elaborate.cxx       2006-04-04 15:34:53.000000000 +0800
@@ -334,15 +334,15 @@ alias_expansion_builder
     // there's concatenated code here and we only want one vardecl per
     // resulting variable.

-    for (unsigned i = 0; i < alias->body->statements.size(); ++i)
+    for (unsigned i = 0; i < use->body->statements.size(); ++i)
       {
-       statement *s = 
deep_copy_visitor::deep_copy(alias->body->statements[i]);
+       statement *s = 
deep_copy_visitor::deep_copy(use->body->statements[i]);
        n->body->statements.push_back(s);
       }

-    for (unsigned i = 0; i < use->body->statements.size(); ++i)
+    for (unsigned i = 0; i < alias->body->statements.size(); ++i)
       {
-       statement *s = 
deep_copy_visitor::deep_copy(use->body->statements[i]);
+       statement *s = 
deep_copy_visitor::deep_copy(alias->body->statements[i]);
        n->body->statements.push_back(s);
       }

And it can cause the statements in alias definitions to be put as 
epilogue.

So do we need the option to specify whether to put the statements in an 
alias definition as prologue or epilogue?
that is to say:

probe derived_probes := probe_alias {
   statements_in_derived_probes
}

probe probe_alias_definitions {
   statements_in_alias_definitions
}

and systemtap will generate:

probe derived_probes {
   statements_in_derived_probes
   statements_in_alias_definitions
}

And if you change "probe derived_probes := probe_alias" to "probe 
derived_probes = probe_alias", systemtap will generate:
probe derived_probes { 
   statements_in_alias_definitions
   statements_in_derived_probes
}

I am not sure if other people than me have this requirement too. But it 
seems to me that being able to put statements in an alias definitions as 
epilogue enables you to change the default behaviors define in original 
probe alias, which should be useful.


Li Guanglei

- Linux Performance, China Systems & Technology Lab
China Development Lab, Beijing Tel: 86-10-82782244 Ext.3516
Email: liguangl@cn.ibm.com, IMAP: guanglei@cn.ibm.com

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

end of thread, other threads:[~2006-04-05 20:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-03  9:25 adding statements in alias definition as epilogue Li Guanglei
2006-04-03  9:59 ` bibo,mao
2006-04-03 16:00 ` Frank Ch. Eigler
2006-04-05  0:41 Guang Lei Li
2006-04-05  1:24 ` Frank Ch. Eigler
2006-04-05  2:46   ` Guang Lei Li
2006-04-05 12:03     ` Frank Ch. Eigler
2006-04-05 16:06       ` Guang Lei Li
2006-04-05 20:16         ` 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).