From db135493669e5e2e1d0dc5c30c8d4a38bfd6653f Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Thu, 8 Apr 2010 17:15:49 -0400 Subject: PR11343: backward compatibility option/conditional * main.cxx: Add "--compatible=VERSION" option. * session.h (compatible): Store it. * parse.cxx (eval_pp_conditional): Look at it as %( systemtap_v CMP VALUE ... %) * stap.1.in: Document it. * testsuite/parseko/preprocess17.stp, parseok/twenty.stp: Test it. --- parse.cxx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'parse.cxx') diff --git a/parse.cxx b/parse.cxx index 6cdf76d9..72bfdd96 100644 --- a/parse.cxx +++ b/parse.cxx @@ -183,6 +183,7 @@ bool eval_comparison (const OPERAND& lhs, const token* op, const OPERAND& rhs) // The basic form is %( CONDITION %? THEN-TOKENS %: ELSE-TOKENS %) // where CONDITION is: kernel_v[r] COMPARISON-OP "version-string" // or: arch COMPARISON-OP "arch-string" +// or: systemtap_v COMPARISON-OP "version-string" // or: CONFIG_foo COMPARISON-OP "config-string" // or: CONFIG_foo COMPARISON-OP number // or: CONFIG_foo COMPARISON-OP CONFIG_bar @@ -202,17 +203,21 @@ bool eval_pp_conditional (systemtap_session& s, const token* l, const token* op, const token* r) { if (l->type == tok_identifier && (l->content == "kernel_v" || - l->content == "kernel_vr")) + l->content == "kernel_vr" || + l->content == "systemtap_v")) { + if (! (r->type == tok_string)) + throw parse_error ("expected string literal", r); + string target_kernel_vr = s.kernel_release; string target_kernel_v = s.kernel_base_release; + string target; - if (! (r->type == tok_string)) - throw parse_error ("expected string literal", r); + if (l->content == "kernel_v") target = target_kernel_v; + else if (l->content == "kernel_vr") target = target_kernel_vr; + else if (l->content == "systemtap_v") target = s.compatible; + else assert (0); - string target = (l->content == "kernel_vr" ? - target_kernel_vr.c_str() : - target_kernel_v.c_str()); string query = r->content; bool rhs_wildcard = (strpbrk (query.c_str(), "*?[") != 0); @@ -2471,6 +2476,8 @@ expression* parser::parse_symbol () if (name == "@cast" || (name.size()>0 && name[0] == '$')) return parse_target_symbol (t); + // NB: PR11343: @defined() is not incompatible with earlier versions + // of stap, so no need to check session.compatible for 1.2 if (name == "@defined") return parse_defined_op (t); -- cgit