From 828c3ed51a7270278c96f8db910f615bfd17dae5 Mon Sep 17 00:00:00 2001 From: dsmith Date: Mon, 22 May 2006 19:40:09 +0000 Subject: 2006-05-22 David Smith * elaborate.cxx (find_and_build): Fixed issue #2643. Wildcard code was being too optimistic. --- ChangeLog | 5 +++++ elaborate.cxx | 52 +++++++++++++++++++++++++++------------------------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index c0943900..ce4c399d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-05-22 David Smith + + * elaborate.cxx (find_and_build): Fixed issue #2643. Wildcard + code was being too optimistic. + 2006-05-22 Li Guanglei * lket.in.5: draft version of manpage for LKET * Makefile.in, configure, stap.1.in: add lket.in.5 diff --git a/elaborate.cxx b/elaborate.cxx index 195f805a..bdeb14f5 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -244,35 +244,37 @@ match_node::find_and_build (systemtap_session& s, } else if (loc->components[pos]->functor == "*") // wildcard? { - // Recursively call derive_probes for all matches of the current - // key position. To do this, we have to perform almost an - // alias-level duplication of the probe body and synthesis of - // new probe_points. - - probe * n = new probe(); - n->tok = p->tok; - n->body = deep_copy_visitor::deep_copy(p->body); - - // Construct N probe_point instances: one per wildcard match + // Call find_and_build for each possible match. Ignore errors - + // unless we don't find any match. + unsigned int num_results = results.size(); for (sub_map_iterator_t i = sub.begin(); i != sub.end(); i++) { - const match_key& match = i->first; - probe_point *loc2 = new probe_point; - loc2->tok = loc->tok; - - // deep-copy probe point components, except for this wildcard position - for (unsigned k=0; kcomponents.size(); k++) - if (pos != k) - loc2->components.push_back(new probe_point::component(loc->components[k]->functor, - loc->components[k]->arg)); - else - // NB: we retain wildcard arg - foo.*(5).bar => foo.a(5).bar, foo.b(5).bar - loc2->components.push_back(new probe_point::component(match.name, - loc->components[k]->arg)); - n->locations.push_back (loc2); + match_node* subnode = i->second; + // recurse + try + { + subnode->find_and_build (s, p, loc, pos+1, results); + } + catch (const semantic_error& e) + { + // Ignore semantic_errors while expanding wildcards. If + // we get done and nothing was expanded, the code + // following the loop will complain. + } } - derive_probes (s, n, results, false); + if (num_results == results.size()) + { + // We didn't find any wildcard matches (since the size of + // the result vector didn't change). Throw an error. + string alternatives; + for (sub_map_iterator_t i = sub.begin(); i != sub.end(); i++) + alternatives += string(" ") + i->first.str(); + + throw semantic_error(string("probe point mismatch at position ") + + lex_cast (pos) + + " (alternatives:" + alternatives + ")"); + } } else { -- cgit