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

Method setupThreadHook

src/cpuEngine.cpp:58–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58bool CpuEngine::setupThreadHook() {
59 if (_pthread_entry != NULL) {
60 return true;
61 }
62
63 if (!VM::loaded()) {
64 static void* dummy_pthread_entry;
65 _pthread_entry = &dummy_pthread_entry;
66 return true;
67 }
68
69 // Depending on Zing version, pthread_setspecific is called either from libazsys.so or from libjvm.so
70 if (VM::isZing()) {
71 CodeCache* libazsys = Profiler::instance()->findLibraryByName("libazsys");
72 if (libazsys != NULL && (_pthread_entry = libazsys->findImport(im_pthread_setspecific)) != NULL) {
73 return true;
74 }
75 }
76
77 CodeCache* lib = Profiler::instance()->findJvmLibrary("libj9thr");
78 return lib != NULL && (_pthread_entry = lib->findImport(im_pthread_setspecific)) != NULL;
79}
80
81void CpuEngine::enableThreadHook() {
82 *_pthread_entry = (void*)pthread_setspecific_hook;

Callers

nothing calls this directly

Calls 3

findLibraryByNameMethod · 0.80
findImportMethod · 0.80
findJvmLibraryMethod · 0.80

Tested by

no test coverage detected