]> sourceware.org Git - systemtap.git/commitdiff
2007-02-17 Frank Ch. Eigler <fche@elastic.org>
authorfche <fche>
Sat, 17 Feb 2007 12:26:14 +0000 (12:26 +0000)
committerfche <fche>
Sat, 17 Feb 2007 12:26:14 +0000 (12:26 +0000)
PR 4066.
* translate.cxx (var::init): Check stat scalar initialization,
just like is done for arrays.
(emit_module_exit): Check unlikely but possible null timing stat.

ChangeLog
translate.cxx

index 45453c64de17e791b5f5904f88a1f1962acb3478..1926988d6faf7b17fec39a7a31cb68b6d9a9c011 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-02-17  Frank Ch. Eigler  <fche@elastic.org>
+
+       PR 4066.
+       * translate.cxx (var::init): Check stat scalar initialization,
+       just like is done for arrays.
+       (emit_module_exit): Check unlikely but possible null timing stat.
+
 2007-02-15  David Smith  <dsmith@redhat.com>
 
        PR 3625.
index 30fb21b818a8cc602d2d0837aca80ebfb2bf2a34..83ee88150d5b478f96ea6503ff041ec9d15326aa 100644 (file)
@@ -348,29 +348,39 @@ public:
         else
           return qname() + " = 0;";
       case pe_stats:
-       switch (sd.type)
-         {
-         case statistic_decl::none:
-           return (qname() 
-                   + " = _stp_stat_init (HIST_NONE);");
-           break;
-           
-         case statistic_decl::linear:
-           return (qname() 
-                   + " = _stp_stat_init (HIST_LINEAR"
-                   + ", " + stringify(sd.linear_low) 
-                   + ", " + stringify(sd.linear_high) 
-                   + ", " + stringify(sd.linear_step)
-                   + ");");
-           break;
-
-         case statistic_decl::logarithmic:
-           return (qname() 
-                   + " = _stp_stat_init (HIST_LOG"
-                   + ", " + stringify(sd.logarithmic_buckets) 
-                   + ");");
-           break;
-         }
+        {
+          // See also mapvar::init().
+          
+          string prefix = qname() + " = _stp_stat_init (";
+          // Check for errors during allocation.
+          string suffix = "if (" + qname () + " == NULL) rc = -ENOMEM;";
+          
+          switch (sd.type)
+            {
+            case statistic_decl::none:
+              prefix += "HIST_NONE";
+              break;
+              
+            case statistic_decl::linear:
+              prefix += string("HIST_LINEAR")
+                + ", " + stringify(sd.linear_low) 
+                + ", " + stringify(sd.linear_high) 
+                + ", " + stringify(sd.linear_step);
+              break;
+              
+            case statistic_decl::logarithmic:
+              prefix += string("HIST_LOG")
+                + ", " + stringify(sd.logarithmic_buckets);
+              break;
+              
+            default:
+              throw semantic_error("unsupported stats type for " + qname());
+            }
+          
+          prefix = prefix + "); ";
+          return string (prefix + suffix);
+        }
+        
       default:
        throw semantic_error("unsupported initializer for " + qname());
       }
@@ -601,6 +611,8 @@ struct mapvar
     string prefix = qname() + " = _stp_" + mtype + "_new_" + keysym() + " (" + 
       (maxsize > 0 ? stringify(maxsize) : "MAXMAPENTRIES") ;
 
+    // See also var::init().
+
     // Check for errors during allocation.
     string suffix = "if (" + qname () + " == NULL) rc = -ENOMEM;";
 
@@ -1078,6 +1090,8 @@ c_unparser::emit_module_init ()
       if (basest_names.find(nm) == basest_names.end())
         {
           o->newline() << "time_" << nm << " = _stp_stat_init (HIST_NONE);";
+          // NB: we don't check for null return here, but instead at
+          // passage to probe handlers and at final printing.
           basest_names.insert (nm);
         }
     }
@@ -1209,7 +1223,8 @@ c_unparser::emit_module_exit ()
         if (basest_names.find(nm) == basest_names.end())
           {
             basest_names.insert (nm);
-            o->newline() << "{";
+            // NB: check for null stat object
+            o->newline() << "if (likely (time_" << p->name << ")) {";
             o->newline(1) << "const char *probe_point = " 
                          << lex_cast_qstring (* p->locations[0])
                          << (p->locations.size() > 1 ? "\"+\"" : "")
This page took 0.049154 seconds and 5 git commands to generate.