MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / patchLibraries

Method patchLibraries

src/nativeLockTracer.cpp:97–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97void NativeLockTracer::patchLibraries() {
98 MutexLocker ml(_patch_lock);
99
100 CodeCacheArray* native_libs = Profiler::instance()->nativeLibs();
101 int native_lib_count = native_libs->count();
102
103 while (_patched_libs < native_lib_count) {
104 CodeCache* cc = (*native_libs)[_patched_libs++];
105
106 if (cc->contains((const void*)NativeLockTracer::initialize)) {
107 continue;
108 }
109
110 UnloadProtection handle(cc);
111 if (!handle.isValid()) {
112 continue;
113 }
114
115 cc->patchImport(im_pthread_mutex_lock, (void*)pthread_mutex_lock_hook);
116 cc->patchImport(im_pthread_rwlock_rdlock, (void*)pthread_rwlock_rdlock_hook);
117 cc->patchImport(im_pthread_rwlock_wrlock, (void*)pthread_rwlock_wrlock_hook);
118 }
119}
120
121void NativeLockTracer::recordNativeLock(void* address, u64 start_time, u64 end_time) {
122 const u64 duration_ticks = end_time - start_time;

Callers

nothing calls this directly

Calls 5

nativeLibsMethod · 0.80
isValidMethod · 0.80
patchImportMethod · 0.80
countMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected