From 3d69c03f37c05136a01481994e239f1287138f6a Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 28 Oct 2011 14:42:23 -0700 Subject: [PATCH] plt: Throw an appropriate error for missing $var * 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 | 6 ++++++ testsuite/semko/plt1.stp | 6 ++++++ testsuite/semok/plt1.stp | 6 ++++++ 3 files changed, 18 insertions(+) create mode 100755 testsuite/semko/plt1.stp create mode 100755 testsuite/semok/plt1.stp diff --git a/tapsets.cxx b/tapsets.cxx index 29fb6f1b6..7eceafafe 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -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 index 000000000..cea5bf7ee --- /dev/null +++ b/testsuite/semko/plt1.stp @@ -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 index 000000000..ecff19a3a --- /dev/null +++ b/testsuite/semok/plt1.stp @@ -0,0 +1,6 @@ +#! stap -p2 + +probe process("stap").plt { + println($$name) + println(@defined($no_such_var) ? $no_such_var : 0) +} -- 2.43.5