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

Method initialize

src/mallocTracer.cpp:152–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152void MallocTracer::initialize() {
153 CodeCache* lib = Profiler::instance()->findLibraryByAddress((void*)MallocTracer::initialize);
154 assert(lib);
155
156 resolveMallocSymbols();
157
158 SAVE_IMPORT(malloc);
159 SAVE_IMPORT(free);
160 SAVE_IMPORT(calloc);
161 SAVE_IMPORT(realloc);
162 SAVE_IMPORT(posix_memalign);
163 SAVE_IMPORT(aligned_alloc);
164
165 detectNestedMalloc();
166
167 lib->mark(
168 [](const char* s) -> bool {
169 return strcmp(s, "malloc_hook") == 0
170 || strcmp(s, "calloc_hook") == 0
171 || strcmp(s, "realloc_hook") == 0
172 || strcmp(s, "free_hook") == 0
173 || strcmp(s, "posix_memalign_hook") == 0
174 || strcmp(s, "aligned_alloc_hook") == 0;
175 },
176 MARK_ASYNC_PROFILER);
177}
178
179// To avoid complexity in hooking and tracking reentrancy, a TLS-based approach is not used.
180// Reentrant allocation calls would result in double-accounting. However, this does not impact

Callers

nothing calls this directly

Calls 4

resolveMallocSymbolsFunction · 0.85
detectNestedMallocFunction · 0.85
findLibraryByAddressMethod · 0.80
markMethod · 0.45

Tested by

no test coverage detected