[PATCH] don't generate empty struct global

Wenji Huang wenji.huang@oracle.com
Mon Feb 23 09:56:00 GMT 2009


Impact: clean up

struct global will keep the defined global variables. It will be 
generated but no reference even no global variables. like,

static struct {
} global = {

};

This patch will skip the struct if no global variable.

diff --git a/translate.cxx b/translate.cxx
index 530b077..5c11855 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -4950,6 +4950,7 @@ translate_pass (systemtap_session& s)
            s.op->newline() << s.embeds[i]->code << "\n";
          }

+      if (s.globals.size()>0) {
        s.op->newline() << "static struct {";
        s.op->indent(1);
        for (unsigned i=0; i<s.globals.size(); i++)
@@ -4965,6 +4966,7 @@ translate_pass (systemtap_session& s)
          }
        s.op->newline(-1) << "};";
        s.op->assert_0_indent();
+      }

        for (map<string,functiondecl*>::iterator it = 
s.functions.begin(); it != s.functions.end(); it++)
         {



More information about the Systemtap mailing list