diff options
Diffstat (limited to 'elaborate.cxx')
-rw-r--r-- | elaborate.cxx | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/elaborate.cxx b/elaborate.cxx index 9271e847..93500239 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -261,8 +261,9 @@ match_key::globmatch(match_key const & other) const // ------------------------------------------------------------------------ match_node::match_node() - : end(NULL) -{} + : end(NULL), unprivileged_ok (false) +{ +} match_node * match_node::bind(match_key const & k) @@ -304,6 +305,18 @@ match_node::bind_num(string const & k) return bind(match_key(k).with_number()); } +match_node* +match_node::allow_unprivileged (bool b) +{ + unprivileged_ok = b; + return this; +} + +bool +match_node::unprivileged_allowed () const +{ + return unprivileged_ok; +} void match_node::find_and_build (systemtap_session& s, @@ -331,6 +344,14 @@ match_node::find_and_build (systemtap_session& s, param_map[loc->components[i]->functor] = loc->components[i]->arg; // maybe 0 + // Are we compiling for unprivileged users? */ + if (s.unprivileged) + { + // Is this probe point ok for unprivileged users? + if (! unprivileged_allowed ()) + throw semantic_error (string("probe point is not allowed for unprivileged users")); + } + b->build (s, p, loc, param_map, results); } else if (isglob(loc->components[pos]->functor)) // wildcard? @@ -1023,7 +1044,7 @@ semantic_pass_conditions (systemtap_session & sess) expression* e = p->sole_location()->condition; if (e) { - varuse_collecting_visitor vut; + varuse_collecting_visitor vut(sess); e->visit (& vut); if (! vut.written.empty()) @@ -1178,7 +1199,7 @@ void add_global_var_display (systemtap_session& s) // it would clutter up the list of probe points with "end ...". if (s.listing_mode) return; - varuse_collecting_visitor vut; + varuse_collecting_visitor vut(s); for (unsigned i=0; i<s.probes.size(); i++) { s.probes[i]->body->visit (& vut); @@ -1965,7 +1986,7 @@ void semantic_pass_opt1 (systemtap_session& s, bool& relaxed_p) // written nor read. void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p, unsigned iterations) { - varuse_collecting_visitor vut; + varuse_collecting_visitor vut(s); for (unsigned i=0; i<s.probes.size(); i++) { @@ -2162,7 +2183,7 @@ dead_assignment_remover::visit_assignment (assignment* e) break; } - varuse_collecting_visitor lvut; + varuse_collecting_visitor lvut(session); e->left->visit (& lvut); if (lvut.side_effect_free () && !is_global) // XXX: use _wrt() once we track focal_vars { @@ -2195,7 +2216,7 @@ void semantic_pass_opt3 (systemtap_session& s, bool& relaxed_p) // Recompute the varuse data, which will probably match the opt2 // copy of the computation, except for those totally unused // variables that opt2 removed. - varuse_collecting_visitor vut; + varuse_collecting_visitor vut(s); for (unsigned i=0; i<s.probes.size(); i++) s.probes[i]->body->visit (& vut); // includes reachable functions too @@ -2299,7 +2320,7 @@ dead_stmtexpr_remover::visit_if_statement (if_statement *s) { // We may be able to elide this statement, if the condition // expression is side-effect-free. - varuse_collecting_visitor vct; + varuse_collecting_visitor vct(session); s->condition->visit(& vct); if (vct.side_effect_free ()) { @@ -2363,7 +2384,7 @@ dead_stmtexpr_remover::visit_for_loop (for_loop *s) { // We may be able to elide this statement, if the condition // expression is side-effect-free. - varuse_collecting_visitor vct; + varuse_collecting_visitor vct(session); if (s->init) s->init->visit(& vct); s->cond->visit(& vct); if (s->incr) s->incr->visit(& vct); @@ -2400,7 +2421,7 @@ dead_stmtexpr_remover::visit_expr_statement (expr_statement *s) // NB. While we don't share nodes in the parse tree, let's not // deallocate *s anyway, just in case... - varuse_collecting_visitor vut; + varuse_collecting_visitor vut(session); s->value->visit (& vut); if (vut.side_effect_free_wrt (focal_vars)) @@ -2741,7 +2762,7 @@ void_statement_reducer::visit_functioncall (functioncall* e) return; } - varuse_collecting_visitor vut; + varuse_collecting_visitor vut(session); vut.traversed.insert (e->referent); vut.current_function = e->referent; e->referent->body->visit (& vut); |