9
9
#include <sys/types.h>
10
10
#include <stddef.h>
11
11
12
- #include "_vmprof .h"
12
+ #include "vmprof .h"
13
13
#include "compat.h"
14
14
15
15
#ifdef VMP_SUPPORTS_NATIVE_PROFILING
32
32
33
33
#ifdef PY_TEST
34
34
// for testing only!
35
- PyObject * vmprof_eval (PyFrameObject * f , int throwflag ) { return NULL ; }
35
+ PY_EVAL_RETURN_T * vmprof_eval (PY_STACK_FRAME_T * f , int throwflag ) { return NULL ; }
36
36
#endif
37
37
38
38
static int vmp_native_traces_enabled = 0 ;
39
- static ptr_t * vmp_ranges = NULL ;
39
+ static intptr_t * vmp_ranges = NULL ;
40
40
static ssize_t vmp_range_count = 0 ;
41
41
static int _vmp_profiles_lines = 0 ;
42
42
@@ -93,7 +93,7 @@ static PyFrameObject * _write_python_stack_entry(PyFrameObject * frame, void **
93
93
return frame -> f_back ;
94
94
}
95
95
96
- int vmp_walk_and_record_python_stack_only (PyFrameObject * frame , void * * result ,
96
+ int vmp_walk_and_record_python_stack_only (PY_STACK_FRAME_T * frame , void * * result ,
97
97
int max_depth , int depth )
98
98
{
99
99
while (depth < max_depth && frame ) {
@@ -114,7 +114,7 @@ int _write_native_stack(void* addr, void ** result, int depth) {
114
114
}
115
115
#endif
116
116
117
- int vmp_walk_and_record_stack (PyFrameObject * frame , void * * result ,
117
+ int vmp_walk_and_record_stack (PY_STACK_FRAME_T * frame , void * * result ,
118
118
int max_depth , int native_skip ) {
119
119
// called in signal handler
120
120
#ifdef VMP_SUPPORTS_NATIVE_PROFILING
@@ -179,7 +179,7 @@ int vmp_walk_and_record_stack(PyFrameObject *frame, void ** result,
179
179
}
180
180
top_most_frame = _write_python_stack_entry (top_most_frame , result , & depth );
181
181
}
182
- } else if (vmp_ignore_ip ((ptr_t )func_addr )) {
182
+ } else if (vmp_ignore_ip ((intptr_t )func_addr )) {
183
183
// this is an instruction pointer that should be ignored,
184
184
// (that is any function name in the mapping range of
185
185
// cpython, but of course not extenstions in site-packages))
@@ -239,22 +239,22 @@ int _reset_vmp_ranges(void) {
239
239
int max_count = 10 ;
240
240
vmp_range_count = 0 ;
241
241
if (vmp_ranges != NULL ) { free (vmp_ranges ); }
242
- vmp_ranges = malloc (max_count * sizeof (ptr_t ));
242
+ vmp_ranges = malloc (max_count * sizeof (intptr_t ));
243
243
return max_count ;
244
244
}
245
245
246
246
247
- int _resize_ranges (ptr_t * * cursor , int max_count ) {
247
+ int _resize_ranges (intptr_t * * cursor , int max_count ) {
248
248
ptrdiff_t diff = (* cursor - vmp_ranges );
249
249
if (diff + 2 > max_count ) {
250
250
max_count *= 2 ;
251
- vmp_ranges = realloc (vmp_ranges , max_count * sizeof (ptr_t ));
251
+ vmp_ranges = realloc (vmp_ranges , max_count * sizeof (intptr_t ));
252
252
* cursor = vmp_ranges + diff ;
253
253
}
254
254
return max_count ;
255
255
}
256
256
257
- ptr_t * _add_to_range (ptr_t * cursor , ptr_t start , ptr_t end ) {
257
+ intptr_t * _add_to_range (intptr_t * cursor , intptr_t start , intptr_t end ) {
258
258
if (cursor [0 ] == start ) {
259
259
// the last range is extended, this reduces the entry count
260
260
// which makes the querying faster
@@ -286,7 +286,7 @@ int vmp_read_vmaps(const char * fname) {
286
286
char * start_hex = NULL , * end_hex = NULL ;
287
287
size_t n = 0 ;
288
288
ssize_t size ;
289
- ptr_t start , end ;
289
+ intptr_t start , end ;
290
290
291
291
// assumptions to be verified:
292
292
// 1) /proc/self/maps is ordered ascending by start address
@@ -296,7 +296,7 @@ int vmp_read_vmaps(const char * fname) {
296
296
// candidates
297
297
298
298
int max_count = _reset_vmp_ranges ();
299
- ptr_t * cursor = vmp_ranges ;
299
+ intptr_t * cursor = vmp_ranges ;
300
300
cursor [0 ] = -1 ;
301
301
while ((size = getline (& line , & n , fd )) >= 0 ) {
302
302
assert (line != NULL );
@@ -347,7 +347,7 @@ int vmp_read_vmaps(const char * fname) {
347
347
348
348
addr = 0 ;
349
349
int max_count = _reset_vmp_ranges ();
350
- ptr_t * cursor = vmp_ranges ;
350
+ intptr_t * cursor = vmp_ranges ;
351
351
cursor [0 ] = -1 ;
352
352
353
353
do {
@@ -405,23 +405,23 @@ void vmp_native_disable(void) {
405
405
vmp_range_count = 0 ;
406
406
}
407
407
408
- int vmp_ignore_ip (ptr_t ip ) {
408
+ int vmp_ignore_ip (intptr_t ip ) {
409
409
int i = vmp_binary_search_ranges (ip , vmp_ranges , vmp_range_count );
410
410
if (i == -1 ) {
411
411
return 0 ;
412
412
}
413
413
414
414
assert ((i & 1 ) == 0 && "returned index MUST be even" );
415
415
416
- ptr_t v = vmp_ranges [i ];
417
- ptr_t v2 = vmp_ranges [i + 1 ];
416
+ intptr_t v = vmp_ranges [i ];
417
+ intptr_t v2 = vmp_ranges [i + 1 ];
418
418
return v <= ip && ip <= v2 ;
419
419
}
420
420
421
- int vmp_binary_search_ranges (ptr_t ip , ptr_t * l , int count ) {
422
- ptr_t * r = l + count ;
423
- ptr_t * ol = l ;
424
- ptr_t * or = r - 1 ;
421
+ int vmp_binary_search_ranges (intptr_t ip , intptr_t * l , int count ) {
422
+ intptr_t * r = l + count ;
423
+ intptr_t * ol = l ;
424
+ intptr_t * or = r - 1 ;
425
425
while (1 ) {
426
426
ptrdiff_t i = (r - l )/2 ;
427
427
if (i == 0 ) {
@@ -440,7 +440,7 @@ int vmp_binary_search_ranges(ptr_t ip, ptr_t * l, int count) {
440
440
return i ;
441
441
}
442
442
}
443
- ptr_t * m = l + i ;
443
+ intptr_t * m = l + i ;
444
444
if (ip < * m ) {
445
445
r = m ;
446
446
} else {
@@ -454,11 +454,11 @@ int vmp_ignore_symbol_count(void) {
454
454
return vmp_range_count ;
455
455
}
456
456
457
- ptr_t * vmp_ignore_symbols (void ) {
457
+ intptr_t * vmp_ignore_symbols (void ) {
458
458
return vmp_ranges ;
459
459
}
460
460
461
- void vmp_set_ignore_symbols (ptr_t * symbols , int count ) {
461
+ void vmp_set_ignore_symbols (intptr_t * symbols , int count ) {
462
462
vmp_ranges = symbols ;
463
463
vmp_range_count = count ;
464
464
}
0 commit comments