summaryrefslogtreecommitdiffstats
path: root/parse.cxx
diff options
context:
space:
mode:
authorjistone <jistone>2006-12-22 02:34:05 +0000
committerjistone <jistone>2006-12-22 02:34:05 +0000
commitef474d24145b85f933d06a1648b0d9cbf6695fe5 (patch)
tree4025671f55ad05735ad61d94cca720aa33c4d65e /parse.cxx
parent9c66f4e068e743727dfec5acec6547cd18a4030c (diff)
downloadsystemtap-steved-ef474d24145b85f933d06a1648b0d9cbf6695fe5.tar.gz
systemtap-steved-ef474d24145b85f933d06a1648b0d9cbf6695fe5.tar.xz
systemtap-steved-ef474d24145b85f933d06a1648b0d9cbf6695fe5.zip
2006-12-21 Josh Stone <joshua.i.stone@intel.com>
PR 3671 * parse.cxx (parser::parse_global): Allow a maxsize on global arrays. * staptree.h (struct vardecl): Add the maxsize field. * staptree.cxx (vardecl::vardecl): Init. maxsize. (vardecl::set_arity): Don't allow arity 0 when there's a maxsize. (vardecl::compatible_arity): Ditto. (vardecl::print): Include maxsize in output. (target_symbol::print): Ditto. * translate.cxx (struct mapvar, mapvar::mapvar): Add maxsize. (mapvar::init): Init maps with the given maxsize if specified, else keep using MAXMAPENTRIES. (mapvar::set): Make the error message give the maxsize. (mapvar::add): Ditto, and check for overflow on pmap add. (c_unparser::getmap): Pass the maxsize from the vardecl to mapvar.
Diffstat (limited to 'parse.cxx')
-rw-r--r--parse.cxx29
1 files changed, 22 insertions, 7 deletions
diff --git a/parse.cxx b/parse.cxx
index 26792010..881c75bc 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -1043,14 +1043,29 @@ parser::parse_global (vector <vardecl*>& globals, vector<probe*>& probes)
globals.push_back (d);
t = peek ();
+
+ if (t && t->type == tok_operator && t->content == "[") // array size
+ {
+ int64_t size;
+ next ();
+ expect_number(size);
+ if (size <= 0 || size > 1000000) // arbitrary max
+ throw parse_error("array size out of range");
+ d->maxsize = (int)size;
+ expect_known(tok_operator, "]");
+ t = peek ();
+ }
+
if (t && t->type == tok_operator && t->content == "=") // initialization
- {
- next ();
- d->init = parse_literal ();
- d->set_arity(0);
- d->type = d->init->type;
- t = peek ();
- }
+ {
+ if (!d->compatible_arity(0))
+ throw parse_error("only scalar globals can be initialized");
+ d->set_arity(0);
+ next ();
+ d->init = parse_literal ();
+ d->type = d->init->type;
+ t = peek ();
+ }
if (t && t->type == tok_operator && t->content == ",") // next global
{