summaryrefslogtreecommitdiffstats
path: root/parse.cxx
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2010-04-08 17:15:49 -0400
committerFrank Ch. Eigler <fche@elastic.org>2010-04-08 17:17:47 -0400
commitdb135493669e5e2e1d0dc5c30c8d4a38bfd6653f (patch)
tree17e5dcfbecd418cca47b0417117d905e4e79669d /parse.cxx
parent0161aa7bab9847980aad1a368efcaa0594e91b24 (diff)
downloadsystemtap-steved-db135493669e5e2e1d0dc5c30c8d4a38bfd6653f.tar.gz
systemtap-steved-db135493669e5e2e1d0dc5c30c8d4a38bfd6653f.tar.xz
systemtap-steved-db135493669e5e2e1d0dc5c30c8d4a38bfd6653f.zip
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.
Diffstat (limited to 'parse.cxx')
-rw-r--r--parse.cxx19
1 files changed, 13 insertions, 6 deletions
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);