summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--elaborate.cxx3
-rw-r--r--parse.cxx52
-rw-r--r--session.h3
-rw-r--r--stap.1.in11
-rw-r--r--staptree.cxx6
-rw-r--r--translate.cxx10
7 files changed, 53 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index 53133549..c61370f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-09-12 Martin Hunt <hunt@redhat.com>
+ PR 5019
+ * elaborate.cxx (visit_hist_op): Remove log histogram param.
+ * translate.cxx (assert_hist_compatible): Ditto.
+ * staptree.cxx (hist_op::print): Ditto.
+ * session.h (statistic_decl): Ditto.
+
+ * parse.cxx (expect_number): Allow negative numbers.
+ Also validate that input is really numeric. This is used
+ by histograms to get the parameters.
+ (parse_hist_op_or_bare_name): Remove code to get parameter
+ for log histograms.
+
2007-09-12 David Smith <dsmith@redhat.com>
* translate.cxx (c_unparser::emit_common_header): Added 'data'
diff --git a/elaborate.cxx b/elaborate.cxx
index 12926846..094fbbac 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -831,8 +831,7 @@ struct stat_decl_collector
{
assert (e->htype == hist_log);
new_stat.type = statistic_decl::logarithmic;
- assert (e->params.size() == 1);
- new_stat.logarithmic_buckets = e->params[0];
+ assert (e->params.size() == 0);
}
map<string, statistic_decl>::iterator i = session.stat_decls.find(sym->name);
diff --git a/parse.cxx b/parse.cxx
index e22c58ea..7b8713f9 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -451,13 +451,37 @@ parser::expect_kw (std::string const & expected)
}
const token*
-parser::expect_number (int64_t & expected)
+parser::expect_number (int64_t & value)
{
- std::string tmp;
- token const * tt = expect_unknown (tok_number, tmp);
- istringstream iss(tmp);
- iss >> expected;
- return tt;
+ bool neg = false;
+ const token *t = next();
+ if (t->type == tok_operator && t->content == "-")
+ {
+ neg = true;
+ t = next ();
+ }
+ if (!(t && t->type == tok_number))
+ throw parse_error ("expected number");
+
+ const char* startp = t->content.c_str ();
+ char* endp = (char*) startp;
+
+ // NB: we allow controlled overflow from LLONG_MIN .. ULLONG_MAX
+ // Actually, this allows all the way from -ULLONG_MAX to ULLONG_MAX,
+ // since the lexer only gives us positive digit strings, but we'll
+ // limit it to LLONG_MIN when a '-' operator is fed into the literal.
+ errno = 0;
+ value = (int64_t) strtoull (startp, & endp, 0);
+ if (errno == ERANGE || errno == EINVAL || *endp != '\0'
+ || (neg && (unsigned long long) value > 9223372036854775808ULL)
+ || (unsigned long long) value > 18446744073709551615ULL
+ || value < -9223372036854775807LL-1)
+ throw parse_error ("number invalid or out of range");
+
+ if (neg)
+ value = -value;
+
+ return t;
}
@@ -2171,22 +2195,6 @@ parser::parse_hist_op_or_bare_name (hist_op *&hop, string &name)
hop->params.push_back (tnum);
}
}
- else
- {
- assert(hop->htype == hist_log);
- if (peek_op (","))
- {
- expect_op (",");
- expect_number (tnum);
- hop->params.push_back (tnum);
- }
- else
- {
- // FIXME (magic value): Logarithmic histograms get 64
- // buckets by default.
- hop->params.push_back (64);
- }
- }
expect_op(")");
}
return t;
diff --git a/session.h b/session.h
index b7c9bac0..1c0e1890 100644
--- a/session.h
+++ b/session.h
@@ -48,18 +48,15 @@ struct statistic_decl
{
statistic_decl()
: type(none),
- logarithmic_buckets(0),
linear_low(0), linear_high(0), linear_step(0)
{}
enum { none, linear, logarithmic } type;
- int64_t logarithmic_buckets;
int64_t linear_low;
int64_t linear_high;
int64_t linear_step;
bool operator==(statistic_decl const & other)
{
return type == other.type
- && logarithmic_buckets == other.logarithmic_buckets
&& linear_low == other.linear_low
&& linear_high == other.linear_high
&& linear_step == other.linear_step;
diff --git a/stap.1.in b/stap.1.in
index 41f39bc0..ffca672f 100644
--- a/stap.1.in
+++ b/stap.1.in
@@ -599,12 +599,11 @@ integers.
.PP
Histograms are also available, but are more complicated because they
have a vector rather than scalar value.
-.I @hist_linear(v,L,H,W)
-represents a linear histogram whose low/high/width parameters are
-given by the following three literal numbers. Similarly,
-.I @hist_log(v,N)
-represents a base-2 logarithmic histogram with the given number of
-buckets. N may be omitted, and defaults to 64. Printing a histogram
+.I @hist_linear(v,start,stop,interval)
+represents a linear histogram from "start" to "stop" by increments
+of "interval". The interval must be positive. Similarly,
+.I @hist_log(v)
+represents a base-2 logarithmic histogram. Printing a histogram
with the
.I print
family of functions renders a histogram object as a tabular
diff --git a/staptree.cxx b/staptree.cxx
index 10572803..a1a8211b 100644
--- a/staptree.cxx
+++ b/staptree.cxx
@@ -718,13 +718,9 @@ hist_op::print (ostream& o) const
break;
case hist_log:
- assert(params.size() == 1);
+ assert(params.size() == 0);
o << "hist_log(";
stat->print(o);
- for (size_t i = 0; i < params.size(); ++i)
- {
- o << ", " << params[i];
- }
o << ")";
break;
}
diff --git a/translate.cxx b/translate.cxx
index a8c18874..96d4d62b 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -313,8 +313,7 @@ public:
break;
case statistic_decl::logarithmic:
assert(hop.htype == hist_log);
- assert(hop.params.size() == 1);
- assert(hop.params[0] == sd.logarithmic_buckets);
+ assert(hop.params.size() == 0);
break;
case statistic_decl::none:
assert(false);
@@ -384,8 +383,7 @@ public:
break;
case statistic_decl::logarithmic:
- prefix += string("HIST_LOG")
- + ", " + stringify(sd.logarithmic_buckets);
+ prefix += string("HIST_LOG");
break;
default:
@@ -676,9 +674,7 @@ struct mapvar
break;
case statistic_decl::logarithmic:
- if (sdecl().logarithmic_buckets > 64)
- throw semantic_error("cannot support > 64 logarithmic buckets");
- prefix = prefix + ", HIST_LOG" + ", " + stringify(sdecl().logarithmic_buckets);
+ prefix = prefix + ", HIST_LOG";
break;
}
}