obstack_printf (pool, "/* pragma:vma */");
obstack_printf (pool, "({ unsigned long addr = 0; ");
obstack_printf (pool, "addr = _stp_umodule_relocate (\"%s\",%#" PRIx64 ", current); ",
- canonicalize_file_name(module_name.c_str()), address);
+ resolve_path(module_name.c_str()).c_str(), address);
obstack_printf (pool, "addr; })");
}
}
return 1;
}
// At runtime user module names are resolved through their
- // canonical (absolute) path.
- const char *mpath = canonicalize_file_name (optarg);
- if (mpath == NULL) // Must be a kernel module name
- mpath = optarg;
- unwindsym_modules.insert (string (mpath));
+ // canonical (absolute) path, or else it's a kernel module name.
+ unwindsym_modules.insert (resolve_path (optarg));
// NB: we used to enable_vma_tracker() here for PR10228, but now
// we'll leave that to pragma:vma functions which actually use it.
break;
cerr << "ERROR: multiple --sysroot options not supported" << endl;
return 1;
} else {
- const char *spath = canonicalize_file_name (optarg);
+ char *spath = canonicalize_file_name (optarg);
if (spath == NULL) {
cerr << _F("ERROR: %s is an invalid directory for --sysroot", optarg) << endl;
return 1;
}
sysroot = string(spath);
+ free (spath);
if (sysroot[sysroot.size() - 1] != '/')
sysroot.append("/");
// patterns like process("stap*"). Otherwise it may go through
// to the next round of expansion as ("stap"), leading to a $PATH
// search that's not consistent with the glob search already done.
-
- char *cf = canonicalize_file_name (globbed);
- if (cf) globbed = cf;
+ string canononicalized = resolve_path (globbed);
+ globbed = canononicalized.c_str();
// synthesize a new probe_point, with the glob-expanded string
probe_point *pp = new probe_point (*location);
// For user space modules store canonical path and base name.
// For kernel modules just the name itself.
- const char *mainpath = canonicalize_file_name(mainfile);
- const char *mainname = strrchr(mainpath, '/');
+ string mainpath = resolve_path(mainfile);
+ const char *mainname = mainpath.c_str() + mainpath.rfind('/');
if (modname[0] == '/')
mainname++;
else
retpath = sysroot + name;
// Canonicalize the path name.
- char *cf = canonicalize_file_name (retpath.c_str());
- if (cf)
- {
- string scf = string(cf);
- if (sysroot.empty())
- retpath = scf;
- else {
- int pos = scf.find(sysroot);
- if (pos == 0)
- retpath = scf;
- else
- throw runtime_error(_F("find_executable(): file %s not in sysroot %s", cf, sysroot.c_str()));
- }
- free (cf);
- }
-
- return retpath;
+ string scf = resolve_path(retpath);
+ if (!startswith(scf, sysroot))
+ throw runtime_error(_F("find_executable(): file %s not in sysroot %s",
+ scf.c_str(), sysroot.c_str()));
+ return scf;
}
return (s.compare(0, std::strlen(prefix), prefix) == 0);
}
+inline bool
+startswith(const std::string & s, const std::string & prefix)
+{
+ return (s.compare(0, prefix.length(), prefix) == 0);
+}
+
// Returns whether a string ends with the given suffix
inline bool