Debian Codegraph @

rpython/rlib/rvmprof/src/shared/vmprof_unix.h

raw symbols SCIP
1 #pragma once
2
3 /* VMPROF
4 *
5 * statistical sampling profiler specifically designed to profile programs
6 * which run on a Virtual Machine and/or bytecode interpreter, such as Python,
7 * etc.
8 *
9 * The logic to dump the C stack traces is partly stolen from the code in
10 * gperftools.
11 * The file "getpc.h" has been entirely copied from gperftools.
12 *
13 * Tested only on gcc, linux, x86_64.
14 *
15 * Copyright (C) 2014-2017
16 * Antonio Cuni - [email protected]
17 * Maciej Fijalkowski - [email protected]
18 * Armin Rigo - [email protected]
19 * Richard Plangger - [email protected]
20 *
21 */
22
23 #include "vmprof.h"
24
25 #include "vmprof_mt.h"
26
27 #ifdef __FreeBSD__
28 #include <ucontext.h>
29 #endif
30 #include <signal.h>
31
32 RPY_EXTERN void vmprof_ignore_signals(int ignored);
33 RPY_EXTERN long vmprof_enter_signal(void);
34 RPY_EXTERN long vmprof_exit_signal(void);
35
36 /* *************************************************************
37 * functions to dump the stack trace
38 * *************************************************************
39 */
40
41 #ifndef RPYTHON_VMPROF
42 PY_THREAD_STATE_T * _get_pystate_for_this_thread(void);
43 #endif
44 int get_stack_trace(PY_THREAD_STATE_T * current, void** result, int max_depth, intptr_t pc);
45
46 /* *************************************************************
47 * the signal handler
48 * *************************************************************
49 */
50
51 #include <setjmp.h>
52
53 void segfault_handler(int arg);
54 int _vmprof_sample_stack(struct profbuf_s *p, PY_THREAD_STATE_T * tstate, ucontext_t * uc);
55 void sigprof_handler(int sig_nr, siginfo_t* info, void *ucontext);
56
57
58 /* *************************************************************
59 * the setup and teardown functions
60 * *************************************************************
61 */
62
63 int install_sigprof_handler(void);
64 int remove_sigprof_handler(void);
65 int install_sigprof_timer(void);
66 int remove_sigprof_timer(void);
67 void atfork_disable_timer(void);
68 void atfork_enable_timer(void);
69 void atfork_close_profile_file(void);
70 int install_pthread_atfork_hooks(void);
71
72 #ifdef VMP_SUPPORTS_NATIVE_PROFILING
73 void init_cpyprof(int native);
74 static void disable_cpyprof(void);
75 #endif
76
77 int close_profile(void);
78
79 RPY_EXTERN
80 int vmprof_enable(int memory, int native, int real_time);
81 RPY_EXTERN
82 int vmprof_disable(void);
83 RPY_EXTERN
84 int vmprof_register_virtual_function(char *code_name, intptr_t code_uid,
85 int auto_retry);
86
87
88 void vmprof_aquire_lock(void);
89 void vmprof_release_lock(void);