@@ -90,14 +90,14 @@ isDeallocator(const Allocator& allocator)
90
90
__builtin_unreachable ();
91
91
}
92
92
93
- #define FOR_EACH_HOOKED_FUNCTION (f ) SymbolHook<decltype(&::f)> f (#f, &::f);
93
+ #define FOR_EACH_HOOKED_FUNCTION (f ) SymbolHook<decltype(&::f)> MEMRAY_ORIG_NO_NS (f) (#f, &::f);
94
94
MEMRAY_HOOKED_FUNCTIONS
95
95
#undef FOR_EACH_HOOKED_FUNCTION
96
96
97
97
void
98
98
ensureAllHooksAreValid ()
99
99
{
100
- #define FOR_EACH_HOOKED_FUNCTION (f ) f .ensureValidOriginalSymbol();
100
+ #define FOR_EACH_HOOKED_FUNCTION (f ) MEMRAY_ORIG(f) .ensureValidOriginalSymbol();
101
101
MEMRAY_HOOKED_FUNCTIONS
102
102
#undef FOR_EACH_HOOKED_FUNCTION
103
103
}
@@ -166,12 +166,12 @@ pymalloc_free(void* ctx, void* ptr) noexcept
166
166
void *
167
167
malloc (size_t size) noexcept
168
168
{
169
- assert (hooks:: malloc);
169
+ assert (MEMRAY_ORIG ( malloc) );
170
170
171
171
void * ptr;
172
172
{
173
173
tracking_api::RecursionGuard guard;
174
- ptr = hooks:: malloc (size);
174
+ ptr = MEMRAY_ORIG ( malloc) (size);
175
175
}
176
176
if (ptr) {
177
177
tracking_api::Tracker::trackAllocation (ptr, size, hooks::Allocator::MALLOC);
@@ -182,7 +182,7 @@ malloc(size_t size) noexcept
182
182
void
183
183
free (void * ptr) noexcept
184
184
{
185
- assert (hooks:: free);
185
+ assert (MEMRAY_ORIG ( free) );
186
186
187
187
// We need to call our API before we call the real free implementation
188
188
// to make sure that the pointer is not reused in-between.
@@ -192,19 +192,19 @@ free(void* ptr) noexcept
192
192
193
193
{
194
194
tracking_api::RecursionGuard guard;
195
- hooks:: free (ptr);
195
+ MEMRAY_ORIG ( free) (ptr);
196
196
}
197
197
}
198
198
199
199
void *
200
200
realloc (void * ptr, size_t size) noexcept
201
201
{
202
- assert (hooks:: realloc);
202
+ assert (MEMRAY_ORIG ( realloc) );
203
203
204
204
void * ret;
205
205
{
206
206
tracking_api::RecursionGuard guard;
207
- ret = hooks:: realloc (ptr, size);
207
+ ret = MEMRAY_ORIG ( realloc) (ptr, size);
208
208
}
209
209
if (ret) {
210
210
if (ptr != nullptr ) {
@@ -218,12 +218,12 @@ realloc(void* ptr, size_t size) noexcept
218
218
void *
219
219
calloc (size_t num, size_t size) noexcept
220
220
{
221
- assert (hooks:: calloc);
221
+ assert (MEMRAY_ORIG ( calloc) );
222
222
223
223
void * ret;
224
224
{
225
225
tracking_api::RecursionGuard guard;
226
- ret = hooks:: calloc (num, size);
226
+ ret = MEMRAY_ORIG ( calloc) (num, size);
227
227
}
228
228
if (ret) {
229
229
tracking_api::Tracker::trackAllocation (ret, num * size, hooks::Allocator::CALLOC);
@@ -234,11 +234,11 @@ calloc(size_t num, size_t size) noexcept
234
234
void *
235
235
mmap (void * addr, size_t length, int prot, int flags, int fd, off_t offset) noexcept
236
236
{
237
- assert (hooks:: mmap);
237
+ assert (MEMRAY_ORIG ( mmap) );
238
238
void * ptr;
239
239
{
240
240
tracking_api::RecursionGuard guard;
241
- ptr = hooks:: mmap (addr, length, prot, flags, fd, offset);
241
+ ptr = MEMRAY_ORIG ( mmap) (addr, length, prot, flags, fd, offset);
242
242
}
243
243
if (ptr != MAP_FAILED) {
244
244
tracking_api::Tracker::trackAllocation (ptr, length, hooks::Allocator::MMAP);
@@ -250,11 +250,11 @@ mmap(void* addr, size_t length, int prot, int flags, int fd, off_t offset) noexc
250
250
void *
251
251
mmap64 (void * addr, size_t length, int prot, int flags, int fd, off64_t offset) noexcept
252
252
{
253
- assert (hooks:: mmap64);
253
+ assert (MEMRAY_ORIG ( mmap64) );
254
254
void * ptr;
255
255
{
256
256
tracking_api::RecursionGuard guard;
257
- ptr = hooks:: mmap64 (addr, length, prot, flags, fd, offset);
257
+ ptr = MEMRAY_ORIG ( mmap64) (addr, length, prot, flags, fd, offset);
258
258
}
259
259
if (ptr != MAP_FAILED) {
260
260
tracking_api::Tracker::trackAllocation (ptr, length, hooks::Allocator::MMAP);
@@ -266,23 +266,23 @@ mmap64(void* addr, size_t length, int prot, int flags, int fd, off64_t offset) n
266
266
int
267
267
munmap (void * addr, size_t length) noexcept
268
268
{
269
- assert (hooks:: munmap);
269
+ assert (MEMRAY_ORIG ( munmap) );
270
270
tracking_api::Tracker::trackDeallocation (addr, length, hooks::Allocator::MUNMAP);
271
271
{
272
272
tracking_api::RecursionGuard guard;
273
- return hooks:: munmap (addr, length);
273
+ return MEMRAY_ORIG ( munmap) (addr, length);
274
274
}
275
275
}
276
276
277
277
void *
278
278
valloc (size_t size) noexcept
279
279
{
280
- assert (hooks:: valloc );
280
+ assert (MEMRAY_ORIG ( valloc ) );
281
281
282
282
void * ret;
283
283
{
284
284
tracking_api::RecursionGuard guard;
285
- ret = hooks:: valloc (size);
285
+ ret = MEMRAY_ORIG ( valloc ) (size);
286
286
}
287
287
if (ret) {
288
288
tracking_api::Tracker::trackAllocation (ret, size, hooks::Allocator::VALLOC);
@@ -293,12 +293,12 @@ valloc(size_t size) noexcept
293
293
int
294
294
posix_memalign (void ** memptr, size_t alignment, size_t size) noexcept
295
295
{
296
- assert (hooks:: posix_memalign);
296
+ assert (MEMRAY_ORIG ( posix_memalign) );
297
297
298
298
int ret;
299
299
{
300
300
tracking_api::RecursionGuard guard;
301
- ret = hooks:: posix_memalign (memptr, alignment, size);
301
+ ret = MEMRAY_ORIG ( posix_memalign) (memptr, alignment, size);
302
302
}
303
303
if (!ret) {
304
304
tracking_api::Tracker::trackAllocation (*memptr, size, hooks::Allocator::POSIX_MEMALIGN);
@@ -360,11 +360,11 @@ static DlsymCache dlsym_cache;
360
360
void *
361
361
dlsym (void * handle, const char * symbol) noexcept
362
362
{
363
- assert (hooks:: dlsym);
363
+ assert (MEMRAY_ORIG ( dlsym) );
364
364
void * ret;
365
365
{
366
366
tracking_api::RecursionGuard guard;
367
- ret = hooks:: dlsym (handle, symbol);
367
+ ret = MEMRAY_ORIG ( dlsym) (handle, symbol);
368
368
}
369
369
if (ret) {
370
370
auto [_, inserted] = dlsym_cache.insert (handle);
@@ -383,12 +383,12 @@ dlsym(void* handle, const char* symbol) noexcept
383
383
int
384
384
dlclose (void * handle) noexcept
385
385
{
386
- assert (hooks:: dlclose);
386
+ assert (MEMRAY_ORIG ( dlclose) );
387
387
388
388
int ret;
389
389
{
390
390
tracking_api::RecursionGuard guard;
391
- ret = hooks:: dlclose (handle);
391
+ ret = MEMRAY_ORIG ( dlclose) (handle);
392
392
}
393
393
dlsym_cache.erase (handle);
394
394
tracking_api::NativeTrace::flushCache ();
@@ -399,12 +399,12 @@ dlclose(void* handle) noexcept
399
399
void *
400
400
aligned_alloc (size_t alignment, size_t size) noexcept
401
401
{
402
- assert (hooks:: aligned_alloc );
402
+ assert (MEMRAY_ORIG ( aligned_alloc ) );
403
403
404
404
void * ret;
405
405
{
406
406
tracking_api::RecursionGuard guard;
407
- ret = hooks:: aligned_alloc (alignment, size);
407
+ ret = MEMRAY_ORIG ( aligned_alloc ) (alignment, size);
408
408
}
409
409
if (ret) {
410
410
tracking_api::Tracker::trackAllocation (ret, size, hooks::Allocator::ALIGNED_ALLOC);
@@ -417,12 +417,12 @@ aligned_alloc(size_t alignment, size_t size) noexcept
417
417
void *
418
418
memalign (size_t alignment, size_t size) noexcept
419
419
{
420
- assert (hooks:: memalign);
420
+ assert (MEMRAY_ORIG ( memalign) );
421
421
422
422
void * ret;
423
423
{
424
424
tracking_api::RecursionGuard guard;
425
- ret = hooks:: memalign (alignment, size);
425
+ ret = MEMRAY_ORIG ( memalign) (alignment, size);
426
426
}
427
427
if (ret) {
428
428
tracking_api::Tracker::trackAllocation (ret, size, hooks::Allocator::MEMALIGN);
@@ -434,12 +434,12 @@ memalign(size_t alignment, size_t size) noexcept
434
434
void *
435
435
pvalloc (size_t size) noexcept
436
436
{
437
- assert (hooks:: pvalloc);
437
+ assert (MEMRAY_ORIG ( pvalloc) );
438
438
439
439
void * ret;
440
440
{
441
441
tracking_api::RecursionGuard guard;
442
- ret = hooks:: pvalloc (size);
442
+ ret = MEMRAY_ORIG ( pvalloc) (size);
443
443
}
444
444
if (ret) {
445
445
tracking_api::Tracker::trackAllocation (ret, size, hooks::Allocator::PVALLOC);
@@ -464,7 +464,7 @@ prctl(int option, ...) noexcept
464
464
tracking_api::Tracker::registerThreadName (name);
465
465
}
466
466
467
- unsigned long ret = hooks:: prctl (option, args[0 ], args[1 ], args[2 ], args[3 ]);
467
+ unsigned long ret = MEMRAY_ORIG ( prctl) (option, args[0 ], args[1 ], args[2 ], args[3 ]);
468
468
469
469
return ret;
470
470
}
@@ -473,7 +473,7 @@ prctl(int option, ...) noexcept
473
473
PyGILState_STATE
474
474
PyGILState_Ensure () noexcept
475
475
{
476
- PyGILState_STATE ret = hooks:: PyGILState_Ensure ();
476
+ PyGILState_STATE ret = MEMRAY_ORIG ( PyGILState_Ensure) ();
477
477
tracking_api::install_trace_function ();
478
478
return ret;
479
479
}
0 commit comments