Skip to content

Commit 610d10a

Browse files
authored
Merge pull request #3 from dillonfranke/ignore-duplicate-modules
Made skipping re-instrumentation of duplicate modules default behavior
2 parents 88b42ad + 39bad59 commit 610d10a

3 files changed

Lines changed: 3 additions & 21 deletions

File tree

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ In addition to the general-purpose API documented above, TinyInst also implement
188188

189189
`-indirect_instrumentation [none|local|global|auto]` which instrumentation to use for indirect jump/calls
190190

191-
`-ignore_duplicates_module [module name]` Ensures only the first loaded instance of `[module name]` is instrumented, ignoring subsequent duplicates. Useful when instrumenting system libraries (e.g., `CoreAudio`) on macOS Sequoia and later, where multiple distinct libraries with the same name may be loaded.
192-
193191
`-patch_return_addresses` - replaces return address with the original value, causes returns to be instrumented using whatever `-indirect_instrumentation` method is specified
194192

195193
`-generate_unwind` - Generates stack unwinding data for instrumented code (for faster C++ exception handling). Note that it might not work correctly on some older Windows versions.

tinyinst.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ ModuleInfo::ModuleInfo() {
4343
max_address = 0;
4444
loaded = false;
4545
instrumented = false;
46-
ignore_duplicates = false;
4746
instrumented_code_local = NULL;
4847
instrumented_code_remote = NULL;
4948
instrumented_code_remote_previous = NULL;
@@ -852,7 +851,7 @@ void TinyInst::OnModuleInstrumented(ModuleInfo* module) {
852851
if(address) {
853852
resolved_hooks[address] = hook;
854853
} else {
855-
FATAL("Could not resolve function %s in module %s", hook->GetFunctionName().c_str(), hook->GetModuleName().c_str());
854+
WARN("Could not resolve function %s in module %s", hook->GetFunctionName().c_str(), hook->GetModuleName().c_str());
856855
}
857856
}
858857
}
@@ -1078,14 +1077,8 @@ void TinyInst::OnInstrumentModuleLoaded(void *module, ModuleInfo *target_module)
10781077
target_module->module_header &&
10791078
(target_module->module_header != (void *)module))
10801079
{
1081-
if (target_module->ignore_duplicates) {
1082-
WARN("Skipping duplicate module %s.", target_module->module_name.c_str());
1083-
return;
1084-
} else {
1085-
WARN("Instrumented module loaded on a different address than seen previously\n"
1086-
"Module will need to be re-instrumented. Expect a drop in performance.");
1087-
ClearInstrumentation(target_module);
1088-
}
1080+
WARN("Skipping re-instrumentation of duplicate module %s.", target_module->module_name.c_str());
1081+
return;
10891082
}
10901083

10911084
target_module->module_header = (void *)module;
@@ -1285,9 +1278,6 @@ void TinyInst::Init(int argc, char **argv) {
12851278
std::list <char *> module_names;
12861279
GetOptionAll("-instrument_module", argc, argv, &module_names);
12871280

1288-
std::list <char *> ignored_duplicate_modules;
1289-
GetOptionAll("-ignore_duplicates_module", argc, argv, &ignored_duplicate_modules);
1290-
12911281
#if defined(__APPLE__) && defined(ARM64)
12921282
std::set <std::string> orig_uniq_mod_names;
12931283
std::set <std::string> new_uniq_mod_names;
@@ -1327,11 +1317,6 @@ void TinyInst::Init(int argc, char **argv) {
13271317
for (const auto module_name: module_names) {
13281318
ModuleInfo *new_module = new ModuleInfo();
13291319
new_module->module_name = module_name;
1330-
for (const auto& ignored_module : ignored_duplicate_modules) {
1331-
if (strcmp(ignored_module, module_name) == 0) {
1332-
new_module->ignore_duplicates = true;
1333-
}
1334-
}
13351320
AddInstrumentedModule(module_name, true);
13361321
// SAY("--- %s\n", module_name);
13371322
}

tinyinst.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ class ModuleInfo {
293293
size_t code_size;
294294
bool loaded;
295295
bool instrumented;
296-
bool ignore_duplicates;
297296
std::list<AddressRange> executable_ranges;
298297

299298
size_t instrumented_code_size;

0 commit comments

Comments
 (0)