Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i#4318 xarch memtrace: Make alt lib dir take precedence #4360

Merged
merged 3 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/drcachesim/common/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ droption_t<std::string> op_alt_module_dir(
DROPTION_SCOPE_FRONTEND, "alt_module_dir", "", "Alternate module search directory",
"Specifies a directory containing libraries referenced in -module_file for "
"analysis tools, or in the raw modules file for post-prcoessing of offline "
"raw trace files.");
"raw trace files. This directory takes precedence over the recorded path.");

droption_t<std::string> op_funclist_file(
DROPTION_SCOPE_ALL, "funclist_file", "",
Expand Down
3 changes: 2 additions & 1 deletion clients/drcachesim/tools/opcode_mix_launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ static droption_t<std::string> op_module_file(

static droption_t<std::string> op_alt_module_dir(
DROPTION_SCOPE_FRONTEND, "alt_module_dir", "", "Alternate module search directory",
"Specifies a directory containing libraries referenced in -module_file.");
"Specifies a directory containing libraries referenced in -module_file. "
"This directory takes precedence over the recorded path.");

droption_t<unsigned int> op_verbose(DROPTION_SCOPE_ALL, "verbose", 0, 0, 64,
"Verbosity level",
Expand Down
18 changes: 14 additions & 4 deletions clients/drcachesim/tracer/raw2trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,18 +346,28 @@ module_mapper_t::read_and_map_modules()
modvec_[info.containing_index].map_base, 0));
} else {
size_t map_size;
byte *base_pc =
dr_map_executable_file(info.path, DR_MAPEXE_SKIP_WRITABLE, &map_size);
if (base_pc == NULL && !alt_module_dir_.empty()) {
byte *base_pc = NULL;
if (!alt_module_dir_.empty()) {
// First try the specified module dir. It takes precedence to allow
// overriding the recorded path even when an identical-seeming path
// exists on the processing machine (e.g., system libraries).
// XXX: We should add a checksum on UNIX to match Windows and have
// a sanity check on the library version.
std::string basename(info.path);
size_t sep_index = basename.find_last_of(DIRSEP ALT_DIRSEP);
if (sep_index != std::string::npos)
basename = std::string(basename, sep_index + 1, std::string::npos);
std::string new_path = alt_module_dir_ + DIRSEP + basename;
VPRINT(1, "Failed to find %s; trying %s\n", info.path, new_path.c_str());
VPRINT(2, "Trying to map %s\n", new_path.c_str());
base_pc = dr_map_executable_file(new_path.c_str(),
DR_MAPEXE_SKIP_WRITABLE, &map_size);
}
if (base_pc == NULL) {
// Try the recorded path.
VPRINT(2, "Trying to map %s\n", info.path);
base_pc =
dr_map_executable_file(info.path, DR_MAPEXE_SKIP_WRITABLE, &map_size);
}
if (base_pc == NULL) {
// We expect to fail to map dynamorio.dll for x64 Windows as it
// is built /fixed. (We could try to have the map succeed w/o relocs,
Expand Down
2 changes: 1 addition & 1 deletion clients/drcachesim/tracer/raw2trace_launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static droption_t<std::string>
static droption_t<std::string> op_alt_module_dir(
DROPTION_SCOPE_FRONTEND, "alt_module_dir", "", "Alternate module search directory",
"Specifies a directory to look for binaries needed to post-process "
"the trace that are not found in the path recorded during tracing.");
"the trace. This directory takes precedence over the recorded path.");

static droption_t<unsigned int> op_verbose(DROPTION_SCOPE_FRONTEND, "verbose", 0,
"Verbosity level for diagnostic output",
Expand Down