]> sourceware.org Git - systemtap.git/commitdiff
plt: Throw an appropriate error for missing $var
authorJosh Stone <jistone@redhat.com>
Fri, 28 Oct 2011 21:42:23 +0000 (14:42 -0700)
committerJosh Stone <jistone@redhat.com>
Fri, 28 Oct 2011 21:42:23 +0000 (14:42 -0700)
* tapsets.cxx (plt_expanding_visitor::visit_target_symbol): Throw a
  semantic_error for missing $var, so it may be caught and chained for
  later.  This ensures that the visitor always has a provide() too.
* testsuite/semko/plt1.stp: New, check that missing $var is an error.
* testsuite/semok/plt1.stp: New, check that $$name works, as does
  @defined on a missing $var.

tapsets.cxx
testsuite/semko/plt1.stp [new file with mode: 0755]
testsuite/semok/plt1.stp [new file with mode: 0755]

index 29fb6f1b6513b2931da5da3767146a7329e5ad3c..7eceafafefa14c1d72ea257b5f525eb777502d06 100644 (file)
@@ -5688,6 +5688,12 @@ plt_expanding_visitor::visit_target_symbol (target_symbol *e)
          provide(myname);
          return;
        }
+
+      // variable not found -> throw a semantic error
+      // (only to be caught right away, but this may be more complex later...)
+      string alternatives = "$$name";
+      throw semantic_error(_F("unable to find plt variable '%s' (alternatives: %s)",
+                              e->name.c_str(), alternatives.c_str()), e->tok);
     }
   catch (const semantic_error &er)
     {
diff --git a/testsuite/semko/plt1.stp b/testsuite/semko/plt1.stp
new file mode 100755 (executable)
index 0000000..cea5bf7
--- /dev/null
@@ -0,0 +1,6 @@
+#! stap -p2
+
+probe process("stap").plt {
+    println($no_such_var)
+}
+
diff --git a/testsuite/semok/plt1.stp b/testsuite/semok/plt1.stp
new file mode 100755 (executable)
index 0000000..ecff19a
--- /dev/null
@@ -0,0 +1,6 @@
+#! stap -p2
+
+probe process("stap").plt {
+    println($$name)
+    println(@defined($no_such_var) ? $no_such_var : 0)
+}
This page took 0.040488 seconds and 5 git commands to generate.