| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "vmprof.h" |
| 4 |
#include "machine.h" |
| 5 |
#include "compat.h" |
| 6 |
|
| 7 |
#include <stddef.h> |
| 8 |
#include <time.h> |
| 9 |
#include <stdlib.h> |
| 10 |
|
| 11 |
#ifdef VMPROF_UNIX |
| 12 |
#include <sys/time.h> |
| 13 |
#include "vmprof_mt.h" |
| 14 |
#include <signal.h> |
| 15 |
#include <pthread.h> |
| 16 |
#endif |
| 17 |
|
| 18 |
#ifdef VMPROF_UNIX |
| 19 |
#include "vmprof_getpc.h" |
| 20 |
#endif |
| 21 |
|
| 22 |
#ifdef VMPROF_LINUX |
| 23 |
#include <syscall.h> |
| 24 |
#endif |
| 25 |
|
| 26 |
#ifdef VMPROF_BSD |
| 27 |
#include <sys/syscall.h> |
| 28 |
#endif |
| 29 |
|
| 30 |
#define MAX_FUNC_NAME 1024 |
| 31 |
|
| 32 |
#ifdef VMPROF_UNIX |
| 33 |
|
| 34 |
ssize_t search_thread(pthread_t tid, ssize_t i); |
| 35 |
ssize_t insert_thread(pthread_t tid, ssize_t i); |
| 36 |
ssize_t remove_thread(pthread_t tid, ssize_t i); |
| 37 |
ssize_t remove_threads(void); |
| 38 |
|
| 39 |
#endif |
| 40 |
|
| 41 |
#define MAX_STACK_DEPTH \ |
| 42 |
((SINGLE_BUF_SIZE - sizeof(struct prof_stacktrace_s)) / sizeof(void *)) |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
typedef struct prof_stacktrace_s { |
| 66 |
#ifdef VMPROF_WINDOWS |
| 67 |
|
| 68 |
|
| 69 |
char padding[sizeof(void*) - 1]; |
| 70 |
#else |
| 71 |
char padding[sizeof(long) - 1]; |
| 72 |
#endif |
| 73 |
char marker; |
| 74 |
long count, depth; |
| 75 |
void *stack[]; |
| 76 |
} prof_stacktrace_s; |
| 77 |
|
| 78 |
#define SIZEOF_PROF_STACKTRACE sizeof(long)+sizeof(long)+sizeof(char) |
| 79 |
|
| 80 |
RPY_EXTERN |
| 81 |
char *vmprof_init(int fd, double interval, int memory, |
| 82 |
int proflines, const char *interp_name, int native, int real_time); |
| 83 |
|
| 84 |
int opened_profile(const char *interp_name, int memory, int proflines, int native, int real_time); |
| 85 |
|
| 86 |
#ifdef RPYTHON_VMPROF |
| 87 |
PY_STACK_FRAME_T *get_vmprof_stack(void); |
| 88 |
RPY_EXTERN |
| 89 |
intptr_t vmprof_get_traceback(void *stack, void *ucontext, |
| 90 |
void **result_p, intptr_t result_length); |
| 91 |
#endif |
| 92 |
|
| 93 |
int vmprof_get_signal_type(void); |
| 94 |
long vmprof_get_prepare_interval_usec(void); |
| 95 |
long vmprof_get_profile_interval_usec(void); |
| 96 |
void vmprof_set_prepare_interval_usec(long value); |
| 97 |
void vmprof_set_profile_interval_usec(long value); |
| 98 |
int vmprof_is_enabled(void); |
| 99 |
void vmprof_set_enabled(int value); |
| 100 |
int vmprof_get_itimer_type(void); |
| 101 |
#ifdef VMPROF_UNIX |
| 102 |
int broadcast_signal_for_threads(void); |
| 103 |
int is_main_thread(void); |
| 104 |
#endif |