int rc = 0;
- // override PATH and LC_ALL
- const char *path = "/bin:/sbin:/usr/bin:/usr/sbin";
- rc = setenv("PATH", path, 1) || setenv("LC_ALL", "C", 1);
- if (rc)
- {
- const char* e = strerror (errno);
- cerr << "setenv (\"PATH=" << path << "\" + \"LC_ALL=C\"): "
- << e << endl;
- }
-
- // Get rid of a few standard environment variables (which might
- // cause us to do unintended things).
- rc = unsetenv("IFS") || unsetenv("CDPATH") || unsetenv("ENV")
- || unsetenv("BASH_ENV");
- if (rc)
- {
- const char* e = strerror (errno);
- cerr << "unsetenv failed: " << e << endl;
- }
+ // For PR1477, we used to override $PATH and $LC_ALL and other stuff
+ // here. We seem to use complete pathnames in
+ // buildrun.cxx/tapsets.cxx now, so this is not necessary. Further,
+ // it interferes with util.cxx:find_executable(), used for $PATH
+ // resolution.
s.kernel_base_release.assign(s.kernel_release, 0, s.kernel_release.find('-'));
if (rc || s.last_pass == 3 || pending_interrupts) goto cleanup;
// PASS 4: COMPILATION
+
times (& tms_before);
gettimeofday (&tv_before, NULL);
rc = compile_pass (s);
if (has_module)
has_process = false;
else
- has_process = get_string_param(params, TOK_PROCESS, module_val);
+ {
+ has_process = get_string_param(params, TOK_PROCESS, module_val);
+ if (has_process)
+ module_val = find_executable (module_val);
+ }
assert (has_kernel || has_process || has_module);
}
}
else if (get_param (parameters, TOK_PROCESS, module_name))
{
+ module_name = find_executable (module_name); // canonicalize it
+
// user-space target; we use one dwflpp instance per module name
// (= program or shared library)
if (user_dw.find(module_name) == user_dw.end())
// If we have a path, we need to validate it.
if (has_path)
- {
- string::size_type start_pos, end_pos;
- string component;
-
- // Make sure it starts with '/'.
- if (path[0] != '/')
- throw semantic_error ("process path must start with a '/'",
- location->tok);
-
- start_pos = 1; // get past the initial '/'
- while ((end_pos = path.find('/', start_pos)) != string::npos)
- {
- component = path.substr(start_pos, end_pos - start_pos);
- // Make sure it isn't empty.
- if (component.size() == 0)
- throw semantic_error ("process path component cannot be empty",
- location->tok);
- // Make sure it isn't relative.
- else if (component == "." || component == "..")
- throw semantic_error ("process path cannot be relative (and contain '.' or '..')", location->tok);
-
- start_pos = end_pos + 1;
- }
- component = path.substr(start_pos);
- // Make sure it doesn't end with '/'.
- if (component.size() == 0)
- throw semantic_error ("process path cannot end with a '/'", location->tok);
- // Make sure it isn't relative.
- else if (component == "." || component == "..")
- throw semantic_error ("process path cannot be relative (and contain '.' or '..')", location->tok);
- }
+ path = find_executable (path);
finished_results.push_back(new itrace_derived_probe(sess, base, location,
has_path, path, pid,
- single_step
+ single_step
));
}
};
probe* p, probe_point* l,
bool hp, string &pn, int64_t pd,
enum utrace_derived_probe_flags f):
- derived_probe(p, l), has_path(hp), path(pn), pid(pd), flags(f),
+ derived_probe (p, new probe_point (*l) /* .components soon rewritten */ ),
+ has_path(hp), path(pn), pid(pd), flags(f),
target_symbol_seen(false)
{
// Make a local-variable-expanded copy of the probe body
utrace_var_expanding_copy_visitor v (s, name, flags);
require <statement*> (&v, &(this->body), base->body);
target_symbol_seen = v.target_symbol_seen;
+
+ // Reset the sole element of the "locations" vector as a
+ // "reverse-engineered" form of the incoming (q.base_loc) probe
+ // point. This allows a user to see what program etc.
+ // number any particular match of the wildcards.
+
+ vector<probe_point::component*> comps;
+ if (hp)
+ comps.push_back (new probe_point::component(TOK_PROCESS, new literal_string(path)));
+ else
+ comps.push_back (new probe_point::component(TOK_PROCESS, new literal_number(pid)));
+ switch (flags)
+ {
+ case UDPF_THREAD_BEGIN:
+ comps.push_back (new probe_point::component(TOK_THREAD));
+ comps.push_back (new probe_point::component(TOK_BEGIN));
+ break;
+ case UDPF_THREAD_END:
+ comps.push_back (new probe_point::component(TOK_THREAD));
+ comps.push_back (new probe_point::component(TOK_END));
+ break;
+ case UDPF_SYSCALL:
+ comps.push_back (new probe_point::component(TOK_SYSCALL));
+ break;
+ case UDPF_SYSCALL_RETURN:
+ comps.push_back (new probe_point::component(TOK_SYSCALL));
+ comps.push_back (new probe_point::component(TOK_RETURN));
+ break;
+ case UDPF_BEGIN:
+ comps.push_back (new probe_point::component(TOK_BEGIN));
+ break;
+ case UDPF_END:
+ comps.push_back (new probe_point::component(TOK_END));
+ break;
+ default:
+ assert (0);
+ }
+
+ // Overwrite it.
+ this->sole_location()->components = comps;
}
bool has_path = get_param (parameters, TOK_PROCESS, path);
bool has_pid = get_param (parameters, TOK_PROCESS, pid);
enum utrace_derived_probe_flags flags = UDPF_NONE;
+
assert (has_path || has_pid);
if (has_null_param (parameters, TOK_THREAD))
// If we have a path, we need to validate it.
if (has_path)
{
- string::size_type start_pos, end_pos;
- string component;
-
- // XXX: these checks should be done in terms of filesystem
- // operations.
-
- // Make sure it starts with '/'.
- if (path[0] != '/')
- throw semantic_error ("process path must start with a '/'",
- location->tok);
-
- start_pos = 1; // get past the initial '/'
- while ((end_pos = path.find('/', start_pos)) != string::npos)
- {
- component = path.substr(start_pos, end_pos - start_pos);
- // Make sure it isn't empty.
- if (component.size() == 0)
- throw semantic_error ("process path component cannot be empty",
- location->tok);
- // Make sure it isn't relative.
- else if (component == "." || component == "..")
- throw semantic_error ("process path cannot be relative (and contain '.' or '..')", location->tok);
-
- start_pos = end_pos + 1;
- }
- component = path.substr(start_pos);
- // Make sure it doesn't end with '/'.
- if (component.size() == 0)
- throw semantic_error ("process path cannot end with a '/'", location->tok);
- // Make sure it isn't relative.
- else if (component == "." || component == "..")
- throw semantic_error ("process path cannot be relative (and contain '.' or '..')", location->tok);
-
+ path = find_executable (path);
sess.unwindsym_modules.insert (path);
}