| 95 | } |
| 96 | |
| 97 | void 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 | |
| 121 | void NativeLockTracer::recordNativeLock(void* address, u64 start_time, u64 end_time) { |
| 122 | const u64 duration_ticks = end_time - start_time; |
nothing calls this directly
no test coverage detected