This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
duplicate body remover
- From: Li Guanglei <guanglei at cn dot ibm dot com>
- To: "systemtap at sourceware dot org" <systemtap at sourceware dot org>
- Date: Thu, 19 Oct 2006 23:32:12 +0800
- Subject: duplicate body remover
- Organization: IBM CSTL
Hi,
today when I tried to shrink the size of the generate .c file from
stap, I met some problems. One of them is the lack of removing
duplicated probe bodies across different probes. Here is an example:
probe kernel.function("netif_receive_skb"),
kernel.function("dev_queue_xmit")
{
log("here")
}
stap -p2 -v shows the output is:
# functions
log:unknown (msg:string)
%{
_stp_printf ("%s\n", THIS->msg);
%}
# probes
kernel.function("netif_receive_skb@net/core/dev.c:1673")
{
log("here")
}
kernel.function("dev_queue_xmit@net/core/dev.c:1318")
{
log("here")
}
But I think stap should further optimize it as:
# functions
log:unknown (msg:string)
%{
_stp_printf ("%s\n", THIS->msg);
%}
# probes
kernel.function("netif_receive_skb@net/core/dev.c:1673"),
kernel.function("dev_queue_xmit@net/core/dev.c:1318")
{
log("here")
}
How about having a new class duplicate_body_remover, and a new
function get_bodysig() to determine the duplication of probe body?
Much of the logic could resemble the current duplicated function
removing codes called inside semantic_pass_opt5().
BTW, currently when stap optimizes unused statements, it will leave a
";" instead of delete that statement, which will make the optimized
results look like:
kernel.function("sys_write@fs/read_write.c:361")
{
;
;
;
;
;
log("here")
}
After applying the patch in the attachment, the optimized results will
look like:
kernel.function("sys_write@fs/read_write.c:361")
{
log("here")
}
- Guanglei
Index: staptree.cxx
===================================================================
RCS file: /cvs/systemtap/src/staptree.cxx,v
retrieving revision 1.50
diff -u -r1.50 staptree.cxx
--- staptree.cxx 9 Jun 2006 09:20:03 -0000 1.50
+++ staptree.cxx 19 Oct 2006 14:51:23 -0000
@@ -720,7 +720,13 @@
{
o << "{" << endl;
for (unsigned i=0; i<statements.size(); i++)
- o << *statements [i] << endl;
+ {
+ if(typeid(*statements[i])==typeid(null_statement))
+ o << *statements[i];
+ else
+ o << *statements [i] << endl;
+ }
+
o << "}";
}
@@ -759,7 +765,6 @@
void null_statement::print (ostream& o) const
{
- o << ";";
}