File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 3ff01361d578d611d3b09c3abca059f7cecd204c
2
+ refs/heads/master: b17145b4ae36f78ed9b53b8875b6822ae59da1ae
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5
5
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
Original file line number Diff line number Diff line change 1
1
#include " rust_internal.h"
2
2
#include " memory_region.h"
3
3
4
+ #if RUSTRT_TRACK_ALLOCATIONS >= 3
5
+ #include < execinfo.h>
6
+ #endif
7
+
4
8
#if RUSTRT_TRACK_ALLOCATIONS >= 1
5
9
// For some platforms, 16 byte alignment is required.
6
10
# define PTR_SIZE 16
@@ -148,6 +152,13 @@ memory_region::~memory_region() {
148
152
header->tag ,
149
153
(uintptr_t ) get_data (header));
150
154
++leak_count;
155
+
156
+ # if RUSTRT_TRACK_ALLOCATIONS >= 3
157
+ if (_detailed_leaks) {
158
+ backtrace_symbols_fd (header->bt + 1 ,
159
+ header->btframes - 1 , 2 );
160
+ }
161
+ # endif
151
162
}
152
163
}
153
164
assert (leak_count == _live_allocations);
@@ -199,6 +210,12 @@ memory_region::claim_alloc(void *mem) {
199
210
if (_synchronized) { _lock.unlock (); }
200
211
# endif
201
212
213
+ # if RUSTRT_TRACK_ALLOCATIONS >= 3
214
+ if (_detailed_leaks) {
215
+ alloc->btframes = ::backtrace (alloc->bt , 32 );
216
+ }
217
+ # endif
218
+
202
219
add_alloc ();
203
220
}
204
221
Original file line number Diff line number Diff line change 16
16
// 0 --- no headers, no debugging support
17
17
// 1 --- support poison, but do not track allocations
18
18
// 2 --- track allocations in detail
19
+ // 3 --- record backtraces of every allocation
19
20
//
20
21
// NB: please do not commit code with level 2. It's
21
22
// hugely expensive and should only be used as a last resort.
@@ -31,6 +32,10 @@ class memory_region {
31
32
int index;
32
33
const char *tag;
33
34
uint32_t size;
35
+ # if RUSTRT_TRACK_ALLOCATIONS >= 3
36
+ void *bt[32 ];
37
+ int btframes;
38
+ # endif
34
39
# endif
35
40
};
36
41
You can’t perform that action at this time.
0 commit comments