Skip to content

Commit 8dc3819

Browse files
committed
chore(heap-profiling): if a user doesnt opt into live heap, ensure the USDT does not land in the process
1 parent e026a3c commit 8dc3819

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

libdd-profiling-heap-sampler/include/datadog/heap/probes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@
3131
*/
3232
void dd_probe_alloc(void *user, uint64_t size, uint64_t weight);
3333

34+
#if DD_HEAP_LIVE_TRACKING
3435
/*
3536
* Emits the `ddheap:free` USDT.
3637
* ptr - user-visible pointer being freed
38+
*
39+
* Only available when compiled with live-heap tracking. The absence of
40+
* the `ddheap:free` note in .note.stapsdt signals to external profilers
41+
* that this binary does not support live-heap correlation.
3742
*/
3843
void dd_probe_free(void *ptr);
44+
#endif
3945

4046
#endif

libdd-profiling-heap-sampler/src/allocation_freed.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ dd_alloc_freed_t dd_allocation_freed_slow(void *ptr, void *raw, size_t size,
2222
size_t alignment) {
2323
/* Fire with the user-visible pointer, matching what was reported at alloc
2424
* time, so the profiler can correlate the two events by address. */
25+
#if DD_HEAP_LIVE_TRACKING
2526
dd_probe_free(ptr);
27+
#endif
2628

2729
dd_alloc_freed_t out = {
2830
/* Return the raw pointer so the caller passes the real allocation base

libdd-profiling-heap-sampler/src/probes.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ void dd_probe_alloc(void *user, uint64_t size, uint64_t weight) {
2323
USDT(ddheap, alloc, user, size, weight);
2424
}
2525

26+
#if DD_HEAP_LIVE_TRACKING
2627
void dd_probe_free(void *ptr) {
2728
USDT(ddheap, free, ptr);
28-
}
29+
}
30+
#endif

0 commit comments

Comments
 (0)