summaryrefslogtreecommitdiffstats
path: root/tapsets.cxx
diff options
context:
space:
mode:
authorRajan Arora <rarora@redhat.com>2009-03-11 18:44:21 -0400
committerRajan Arora <rarora@redhat.com>2009-03-11 18:58:30 -0400
commit3bd0d4df7ccfd9afe7771441b26d8baaaf180e29 (patch)
treeb8195f2cb1b61dee52acd701a47723abb7ecb59c /tapsets.cxx
parente248aea9a04dd0d3c4e066afdca52176aaf9a536 (diff)
downloadsystemtap-steved-3bd0d4df7ccfd9afe7771441b26d8baaaf180e29.tar.gz
systemtap-steved-3bd0d4df7ccfd9afe7771441b26d8baaaf180e29.tar.xz
systemtap-steved-3bd0d4df7ccfd9afe7771441b26d8baaaf180e29.zip
PR 7071: Optional $context variables fix
* tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol): Substitute erroneous target symbol with literal 0 if session level flag, skip_badvars is set. * session.h (struct systemtap_session): New flag: skip_badvars. * main.cxx: Command line argument --skip-badvars added. * stap.1.in: Entry for new option --skip-badvars. * NEWS: Added blurb for new option now available. * testsuite/semok/badvar.stp: Test case to check added functionality.
Diffstat (limited to 'tapsets.cxx')
-rw-r--r--tapsets.cxx37
1 files changed, 25 insertions, 12 deletions
diff --git a/tapsets.cxx b/tapsets.cxx
index b1d0b04e..dce73534 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -4842,18 +4842,31 @@ dwarf_var_expanding_visitor::visit_target_symbol (target_symbol *e)
}
catch (const semantic_error& er)
{
- // We suppress this error message, and pass the unresolved
- // target_symbol to the next pass. We hope that this value ends
- // up not being referenced after all, so it can be optimized out
- // quietly.
- provide (e);
- semantic_error* saveme = new semantic_error (er); // copy it
- saveme->tok1 = e->tok; // XXX: token not passed to q.dw code generation routines
- // NB: we can have multiple errors, since a $target variable
- // may be expanded in several different contexts:
- // function ("*") { $var }
- saveme->chain = e->saved_conversion_error;
- e->saved_conversion_error = saveme;
+ if (!q.sess.skip_badvars)
+ {
+ // We suppress this error message, and pass the unresolved
+ // target_symbol to the next pass. We hope that this value ends
+ // up not being referenced after all, so it can be optimized out
+ // quietly.
+ provide (e);
+ semantic_error* saveme = new semantic_error (er); // copy it
+ saveme->tok1 = e->tok; // XXX: token not passed to q.dw code generation routines
+ // NB: we can have multiple errors, since a $target variable
+ // may be expanded in several different contexts:
+ // function ("*") { $var }
+ saveme->chain = e->saved_conversion_error;
+ e->saved_conversion_error = saveme;
+ }
+ else
+ {
+ // Upon user request for ignoring context, the symbol is replaced
+ // with a literal 0 and a warning message displayed
+ literal_number* ln_zero = new literal_number (0);
+ ln_zero->tok = e->tok;
+ provide (ln_zero);
+ q.sess.print_warning ("Bad variable being substituted with literal 0",
+ e->tok);
+ }
delete fdecl;
delete ec;
return;