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: adding statements in alias definition as epilogue


>> [...] 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


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