* parse.cxx: parse_probe_points - Remove alias seen flag.
* staptree.h: struct probe_point - New auto_path flag.
* tapsets.cxx: dwarf_builder::build - Expand process component
for /PATH/ directory.
void do_parse_functiondecl (vector<functiondecl*>&, const token*,
string const&, bool);
embeddedcode* parse_embeddedcode ();
- vector<probe_point*> parse_probe_points (bool alias_seen);
- vector<probe_point*> parse_components (bool alias_seen);
- vector<probe_point*> parse_component (bool alias_seen);
+ vector<probe_point*> parse_probe_points ();
+ vector<probe_point*> parse_components ();
+ vector<probe_point*> parse_component ();
literal_string* consume_string_literals (const token*);
literal_string* parse_literal_string ();
literal* parse_literal ();
vector<probe_point *> locations;
int epilogue_alias = 0;
- bool alias_seen = false;
while (1)
{
- vector<probe_point*> pps = parse_probe_points(alias_seen);
+ vector<probe_point*> pps = parse_probe_points();
const token* t = peek ();
if (pps.size() == 1 && t
if (pps[0]->optional || pps[0]->sufficient)
throw PARSE_ERROR (_("probe point alias name cannot be optional nor sufficient"), pps[0]->components.front()->tok);
aliases.push_back(pps[0]);
- alias_seen = true;
swallow ();
continue;
}
throw PARSE_ERROR (_("probe point alias name cannot be optional nor sufficient"), pps[0]->components.front()->tok);
aliases.push_back(pps[0]);
epilogue_alias = 1;
- alias_seen = true;
swallow ();
continue;
}
}
vector<probe_point*>
-parser::parse_probe_points(bool alias_seen)
+parser::parse_probe_points()
{
vector<probe_point*> pps;
while (1)
{
- vector<probe_point*> tail = parse_components(alias_seen);
+ vector<probe_point*> tail = parse_components();
pps.insert(pps.end(), tail.begin(), tail.end());
const token* t = peek();
}
vector<probe_point*>
-parser::parse_components(bool alias_seen)
+parser::parse_components()
{
vector<probe_point*> pps;
while (1)
{
- vector<probe_point*> suffix = parse_component(alias_seen);
+ vector<probe_point*> suffix = parse_component();
// Cartesian product of components
if (pps.empty())
{
probe_point* pp = new probe_point;
pp->components.insert(pp->components.end(),
- pps[i]->components.begin(), pps[i]->components.end());
+ pps[i]->components.begin(),
+ pps[i]->components.end());
pp->components.insert(pp->components.end(),
- suffix[j]->components.begin(), suffix[j]->components.end());
+ suffix[j]->components.begin(),
+ suffix[j]->components.end());
pp->optional = suffix[j]->optional;
pp->sufficient = suffix[j]->sufficient;
+ pp->auto_path = suffix[j]->auto_path;
pp->condition = suffix[j]->condition;
product.push_back(pp);
}
}
vector<probe_point*>
-parser::parse_component(bool alias_seen)
+parser::parse_component()
{
const token* t = next ();
if (! (t->type == tok_identifier
if (t && t->type == tok_operator && t->content == "{")
{
swallow();
- vector<probe_point*> pps = parse_probe_points(alias_seen);
+ vector<probe_point*> pps = parse_probe_points();
t = peek();
if (!(t && t->type == tok_operator && t->content == "}"))
throw PARSE_ERROR (_("expected '}'"));
c->tok = t;
vector<probe_point*> pps;
probe_point* pp = new probe_point;
+ pp->auto_path = auto_path;
pp->components.push_back(c);
pps.push_back(pp);
// NB we may add c->arg soon
swallow (); // consume "("
c->arg = parse_literal ();
- // prefix argument with file location from PATH directory
- if (auto_path && c->functor == "process")
- {
- literal_string* ls = dynamic_cast<literal_string*>(c->arg);
- if (ls && !ls->value.empty() && ls->value[0] != '/')
- {
- string::size_type start = input_name.find("PATH/") + 4;
- string::size_type end = input_name.rfind("/");
- string path = input_name.substr(start, end-start+1) + ls->value.to_string();
- ls->value = path;
- }
- }
-
t = next ();
if (! (t->type == tok_operator && t->content == ")"))
throw PARSE_ERROR (_("expected ')'"));
swallow ();
}
- else if (alias_seen && auto_path && c->functor == "process")
- {
- // PATH expansion of process component without argument.
- // The filename without the .stp extension is used.
- string::size_type start = input_name.find("PATH/") + 4;
- string::size_type end = input_name.rfind(".stp");
- string path = input_name.substr(start, end - start);
- c->arg = new literal_string(path);
- }
return pps;
}
probe_point::probe_point (std::vector<component*> const & comps):
components(comps), optional (false), sufficient (false),
- well_formed (false), condition (0)
+ well_formed (false), auto_path (false), condition (0)
{
}
// NB: shallow-copy of compoonents & condition!
probe_point::probe_point (const probe_point& pp):
components(pp.components), optional (pp.optional), sufficient (pp.sufficient),
- well_formed (pp.well_formed), condition (pp.condition)
+ well_formed (pp.well_formed), auto_path (pp.auto_path), condition (pp.condition)
{
}
probe_point::probe_point ():
- optional (false), sufficient (false), well_formed (false), condition (0)
+ optional (false), sufficient (false), well_formed (false), auto_path (false),
+ condition (0)
{
}
bool optional;
bool sufficient;
bool well_formed; // used in derived_probe::script_location()
+ bool auto_path;
expression* condition;
void print (std::ostream& o, bool print_extras=true) const;
probe_point ();
if(has_null_param(filled_parameters, TOK_PROCESS))
{
- string file;
- try
+ if (location->auto_path)
{
- file = sess.cmd_file();
- }
- catch (const semantic_error& e)
- {
- if(sess.target_pid)
- throw SEMANTIC_ERROR(_("invalid -x pid for unspecified process"
- " probe [man stapprobes]"), NULL, NULL, &e);
- else
- throw SEMANTIC_ERROR(_("invalid -c command for unspecified process"
- " probe [man stapprobes]"), NULL, NULL, &e);
+ if (location->components[0]->functor == TOK_PROCESS &&
+ location->components[0]->arg == 0)
+ {
+ // PATH expansion of process component without argument.
+ // The filename without the .stp extension is used.
+ string full_path = location->components[0]->tok->location.file->name;
+ string::size_type start = full_path.find("PATH/") + 4;
+ string::size_type end = full_path.rfind(".stp");
+ module_name = full_path.substr(start, end - start);
+ location->components[0]->arg = new literal_string(module_name);
+ filled_parameters[TOK_PROCESS] = new literal_string(module_name);
+ }
}
- if(file.empty())
- throw SEMANTIC_ERROR(_("unspecified process probe is invalid without"
- " a -c COMMAND or -x PID [man stapprobes]"));
- module_name = sess.sysroot + file;
- filled_parameters[TOK_PROCESS] = new literal_string(module_name);// this needs to be used in place of the blank map
- // in the case of TOK_MARK we need to modify locations as well // XXX why?
- if(location->components[0]->functor==TOK_PROCESS &&
- location->components[0]->arg == 0)
+ else
{
- if (sess.target_pid)
- location->components[0]->arg = new literal_number(sess.target_pid);
- else
- location->components[0]->arg = new literal_string(module_name);
+ string file;
+ try
+ {
+ file = sess.cmd_file();
+ }
+ catch (const semantic_error& e)
+ {
+ if(sess.target_pid)
+ throw SEMANTIC_ERROR(_("invalid -x pid for unspecified process"
+ " probe [man stapprobes]"), NULL, NULL, &e);
+ else
+ throw SEMANTIC_ERROR(_("invalid -c command for unspecified process"
+ " probe [man stapprobes]"), NULL, NULL, &e);
+ }
+ if(file.empty())
+ throw SEMANTIC_ERROR(_("unspecified process probe is invalid without"
+ " a -c COMMAND or -x PID [man stapprobes]"));
+ module_name = sess.sysroot + file;
+ filled_parameters[TOK_PROCESS] = new literal_string(module_name);// this needs to be used in place of the blank map
+ // in the case of TOK_MARK we need to modify locations as well // XXX why?
+ if(location->components[0]->functor==TOK_PROCESS &&
+ location->components[0]->arg == 0)
+ {
+ if (sess.target_pid)
+ location->components[0]->arg = new literal_number(sess.target_pid);
+ else
+ location->components[0]->arg = new literal_string(module_name);
+ }
}
}
// we get the module_name out.
else if (get_param (parameters, TOK_PROCESS, module_name))
{
- module_name = (string)sess.sysroot + (string)module_name;
- filled_parameters[TOK_PROCESS] = new literal_string(module_name);
+ if (location->auto_path)
+ {
+ if (!module_name.empty() && module_name[0] != '/')
+ {
+ // prefix argument with file location from PATH directory
+ string full_path = location->components[0]->tok->location.file->name;
+ string::size_type start = full_path.find("PATH/") + 4;
+ string::size_type end = full_path.rfind("/");
+ string arg = module_name;
+ module_name = full_path.substr(start, end-start+1) + arg;
+ location->components[0]->arg = new literal_string(module_name);
+ filled_parameters[TOK_PROCESS] = new literal_string(module_name);
+ }
+ }
+ else
+ {
+ module_name = (string)sess.sysroot + (string)module_name;
+ filled_parameters[TOK_PROCESS] = new literal_string(module_name);
+ }
}
else if (get_param (parameters, TOK_PROCESS, proc_pid))