summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--elaborate.cxx52
-rw-r--r--staptree.cxx15
-rwxr-xr-xtestsuite/semko/nine.stp2
-rwxr-xr-xtestsuite/semko/six.stp1
-rwxr-xr-xtestsuite/transko/one.stp6
6 files changed, 51 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index a5063923..5b495119 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-06-03 Frank Ch. Eigler <fche@elastic.org>
+
+ * elaborate.cxx (find_*): Remove arity checks from here ...
+ * staptree.cxx (set_arity): Put arity match assertion here.
+ * testsuite/semko/{six,nine}.stp: Confirm logic.
+ * testsuite/transko/one.stp: First translation-time ko test.
+
2005-06-03 Frank Ch. Eigler <fche@redhat.com>
* TODO: Removed entries already represented in bugzilla.
diff --git a/elaborate.cxx b/elaborate.cxx
index e733132f..c6596da6 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -292,43 +292,48 @@ symresolution_info::find_scalar (const string& name)
current_probe->locals);
for (unsigned i=0; i<locals.size(); i++)
if (locals[i]->name == name)
- // NB: no need to check arity here: locals always scalar
- return locals[i];
+ {
+ // NB: no need to check arity here: formal args always scalar
+ locals[i]->set_arity (0);
+ return locals[i];
+ }
// search function formal parameters (if any)
if (current_function)
for (unsigned i=0; i<current_function->formal_args.size(); i++)
if (current_function->formal_args[i]->name == name)
- // NB: no need to check arity here: formal args always scalar
- return current_function->formal_args[i];
+ {
+ // NB: no need to check arity here: formal args always scalar
+ current_function->formal_args[i]->set_arity (0);
+ return current_function->formal_args[i];
+ }
// search globals
for (unsigned i=0; i<session.globals.size(); i++)
if (session.globals[i]->name == name)
- if (session.globals[i]->arity <= 0)
- {
- session.globals[i]->set_arity (0);
- return session.globals[i];
- }
+ {
+ session.globals[i]->set_arity (0);
+ return session.globals[i];
+ }
// search library globals
for (unsigned i=0; i<session.library_files.size(); i++)
{
stapfile* f = session.library_files[i];
for (unsigned j=0; j<f->globals.size(); j++)
- if (f->globals[j]->name == name &&
- f->globals[j]->index_types.size() == 0)
+ if (f->globals[j]->name == name)
{
// put library into the queue if not already there
if (0) // (session.verbose_resolution)
cerr << " scalar " << name << " "
<< "is defined from " << f->name << endl;
-
+
if (find (session.files.begin(), session.files.end(), f)
== session.files.end())
session.files.push_back (f);
// else .. print different message?
+ f->globals[j]->set_arity (0);
return f->globals[j];
}
}
@@ -353,7 +358,6 @@ symresolution_info::find_scalar (const string& name)
}
return 0;
- // XXX: add checking for conflicting array or function
}
@@ -363,13 +367,10 @@ symresolution_info::find_array (const string& name, unsigned arity)
// search processed globals
for (unsigned i=0; i<session.globals.size(); i++)
if (session.globals[i]->name == name)
- if ((arity > 0 && (session.globals[i]->arity == (int) arity)) ||
- session.globals[i]->arity < 0)
- {
- if (arity > 0)
- session.globals[i]->set_arity (arity);
- return session.globals[i];
- }
+ {
+ session.globals[i]->set_arity (arity);
+ return session.globals[i];
+ }
// search library globals
for (unsigned i=0; i<session.library_files.size(); i++)
@@ -377,28 +378,24 @@ symresolution_info::find_array (const string& name, unsigned arity)
stapfile* f = session.library_files[i];
for (unsigned j=0; j<f->globals.size(); j++)
if (f->globals[j]->name == name)
- if ((arity > 0 && (f->globals[j]->arity == (int) arity)) ||
- f->globals[j]->arity < 0)
{
- if (arity > 0)
- f->globals[j]->set_arity (arity);
+ f->globals[j]->set_arity (arity);
// put library into the queue if not already there
if (0) // (session.verbose_resolution)
cerr << " array " << name << " "
<< "is defined from " << f->name << endl;
-
+
if (find (session.files.begin(), session.files.end(), f)
== session.files.end())
session.files.push_back (f);
// else .. print different message?
-
+
return f->globals[j];
}
}
return 0;
- // XXX: add checking for conflicting scalar or function
}
@@ -436,7 +433,6 @@ symresolution_info::find_function (const string& name, unsigned arity)
}
return 0;
- // XXX: add checking for conflicting variables
}
diff --git a/staptree.cxx b/staptree.cxx
index a8651d1d..756fbc1e 100644
--- a/staptree.cxx
+++ b/staptree.cxx
@@ -96,10 +96,17 @@ void
vardecl::set_arity (int a)
{
assert (a >= 0);
- arity = a;
- index_types.resize (arity);
- for (int i=0; i<arity; i++)
- index_types[i] = pe_unknown;
+
+ if (arity != a && arity >= 0)
+ throw semantic_error ("inconsistent arity", tok);
+
+ if (arity != a)
+ {
+ arity = a;
+ index_types.resize (arity);
+ for (int i=0; i<arity; i++)
+ index_types[i] = pe_unknown;
+ }
}
diff --git a/testsuite/semko/nine.stp b/testsuite/semko/nine.stp
index f9a704f1..05d53d09 100755
--- a/testsuite/semko/nine.stp
+++ b/testsuite/semko/nine.stp
@@ -1,5 +1,7 @@
#! stap -p2
+global a
+
probe foo {
a[4] = 1;
a = 2;
diff --git a/testsuite/semko/six.stp b/testsuite/semko/six.stp
index 89457fac..c9071431 100755
--- a/testsuite/semko/six.stp
+++ b/testsuite/semko/six.stp
@@ -1,5 +1,6 @@
#! stap -p2
+global bar
probe foo {
bar[1] = 2;
bar[1, 2] = 3; # inconsistent array dimensions
diff --git a/testsuite/transko/one.stp b/testsuite/transko/one.stp
new file mode 100755
index 00000000..b6bb3e89
--- /dev/null
+++ b/testsuite/transko/one.stp
@@ -0,0 +1,6 @@
+#! stap -p3
+
+probe foo {
+ 1 = a
+ a+1 = 4
+}