]> sourceware.org Git - systemtap.git/commitdiff
2006-01-05 Josh Stone <joshua.i.stone@intel.com>
authorjistone <jistone>
Thu, 5 Jan 2006 21:59:21 +0000 (21:59 +0000)
committerjistone <jistone>
Thu, 5 Jan 2006 21:59:21 +0000 (21:59 +0000)
PR 2056
* translate.cxx (var::~var, var::hist, var::buckets): make these
methods virtual, so we can use polymorphism.
(mapvar::hist, mapvar::buckets):  Override the corresponding var
methods to handle pmaps correctly.
(c_unparser::visit_arrayindex, c_unparser::visit_print_format): Make
use of the new polymorphic behavior of var & mapvar when dealing with
histogram data.
* testsuite/buildok/pmap_foreach.stp: Add tests to check histogram
accesses with for/foreach.

ChangeLog
testsuite/buildok/pmap_foreach.stp
translate.cxx

index 892e8460fe2ec8c0c6d21e4541d331b715745764..d86a54ba0c4f6ebc58dd4328320ca563df49a0e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-01-05  Josh Stone  <joshua.i.stone@intel.com>
+
+       PR 2056
+       * translate.cxx (var::~var, var::hist, var::buckets): make these
+       methods virtual, so we can use polymorphism.
+       (mapvar::hist, mapvar::buckets):  Override the corresponding var
+       methods to handle pmaps correctly.
+       (c_unparser::visit_arrayindex, c_unparser::visit_print_format): Make
+       use of the new polymorphic behavior of var & mapvar when dealing with
+       histogram data.
+       * testsuite/buildok/pmap_foreach.stp: Add tests to check histogram
+       accesses with for/foreach.
+
 2006-01-04  Frank Ch. Eigler  <fche@elastic.org>
 
        PR 2057.
index 8cc8decd0998833624baf52c165a16e84d2bd159..14912e1625fbae7c522cddd8536a48dd46277b70 100755 (executable)
@@ -14,9 +14,17 @@ probe begin {
 }
 
 probe end {
-       for (i=1;i<4;i++)
+       for (i=1;i<4;i++) {
                printf("count of foo[%d] = %d\n", i, @count(foo[i]))
+               printf("first bucket of hist_log of foo[%d] = %d\n",
+                               i, @hist_log(foo[i])[0])
+               print(@hist_log(foo[i]))
+       }
 
-       foreach (i in foo)
+       foreach (i in foo) {
                printf("count of foo[%d] = %d\n", i, @count(foo[i]))
+               printf("first bucket of hist_log of foo[%d] = %d\n",
+                               i, @hist_log(foo[i])[0])
+               print(@hist_log(foo[i]))
+    }
 }
index 5bad6bdf3ffd6d06f926343c680258a9cf3e35c6..791e54342bdf7f692ea2a5fe7083427fbbcf7a0f 100644 (file)
@@ -1,6 +1,6 @@
 // translation pass
 // Copyright (C) 2005, 2006 Red Hat Inc.
-// Copyright (C) 2005 Intel Corporation
+// Copyright (C) 2005, 2006 Intel Corporation
 //
 // This file is part of systemtap, and is free software.  You can
 // redistribute it and/or modify it under the terms of the GNU General
@@ -294,6 +294,8 @@ public:
     : local(local), ty(ty), name(name)
   {}
 
+  virtual ~var() {}
+
   bool is_local() const
   {
     return local;
@@ -340,14 +342,14 @@ public:
       return "global_" + name;
   }
 
-  string hist() const
+  virtual string hist() const
   {
     assert (ty == pe_stats);
     assert (sd.type != statistic_decl::none);
     return "(&(" + qname() + "->hist))";
   }
 
-  string buckets() const
+  virtual string buckets() const
   {
     assert (ty == pe_stats);
     assert (sd.type != statistic_decl::none);
@@ -633,6 +635,20 @@ struct mapvar
     else
       throw semantic_error("setting a value of an unsupported map type");
   }
+
+  string hist() const
+  {
+    assert (ty == pe_stats);
+    assert (sd.type != statistic_decl::none);
+    return "(&(" + fetch_existing_aggregate() + "->hist))";
+  }
+
+  string buckets() const
+  {
+    assert (ty == pe_stats);
+    assert (sd.type != statistic_decl::none);
+    return "(" + fetch_existing_aggregate() + "->hist.buckets)";
+  }
                
   string init () const
   {
@@ -2854,13 +2870,19 @@ c_unparser::visit_arrayindex (arrayindex* e)
       assert(idx[0].type() == pe_long);        
 
       symbol *sym = get_symbol_within_expression (hist->stat);
-      var v = getvar(sym->referent, sym->tok);
-      v.assert_hist_compatible(*hist);
+
+      var *v;
+      if (sym->referent->arity < 1)
+       v = new var(getvar(sym->referent, e->tok));
+      else
+       v = new mapvar(getmap(sym->referent, e->tok));
+
+      v->assert_hist_compatible(*hist);
 
       {
-       varlock_w guard(*this, v);
+       varlock_w guard(*this, *v);
        o->newline() << "c->last_stmt = " << lex_cast_qstring(*e->tok) << ";";
-       o->newline() << "if (" << histogram_index_check(v, idx[0]) << ")";
+       o->newline() << "if (" << histogram_index_check(*v, idx[0]) << ")";
        o->newline() << "{";
        o->newline(1)  << res << " = " << agg << "->histogram[" << idx[0] << "];";
        o->newline(-1) << "}";
@@ -2871,6 +2893,8 @@ c_unparser::visit_arrayindex (arrayindex* e)
        o->newline(-1) << "}";
       }
 
+      delete v;
+
       o->newline() << res << ";";
     }
 }
@@ -3161,13 +3185,23 @@ c_unparser::visit_print_format (print_format* e)
       stmt_expr block(*this);  
       symbol *sym = get_symbol_within_expression (e->hist->stat);
       aggvar agg = gensym_aggregate ();
-      var v = getvar(sym->referent, e->tok);
-      v.assert_hist_compatible(*e->hist);
 
-      varlock_w guard(*this, v);
-      load_aggregate(e->hist->stat, agg);
-      o->newline() << "c->last_stmt = " << lex_cast_qstring(*e->tok) << ";";
-      o->newline() << "_stp_stat_print_histogram (" << v.hist() << ", " << agg.qname() << ");";
+      var *v;
+      if (sym->referent->arity < 1)
+        v = new var(getvar(sym->referent, e->tok));
+      else
+        v = new mapvar(getmap(sym->referent, e->tok));
+
+      v->assert_hist_compatible(*e->hist);
+
+      {
+       varlock_w guard(*this, *v);
+       load_aggregate(e->hist->stat, agg);
+       o->newline() << "c->last_stmt = " << lex_cast_qstring(*e->tok) << ";";
+       o->newline() << "_stp_stat_print_histogram (" << v->hist() << ", " << agg.qname() << ");";
+      }
+
+      delete v;
     }
   else
     {
This page took 0.052194 seconds and 5 git commands to generate.