Debian Codegraph @

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

raw symbols SCIP
1 #pragma once
2
3 #define _GNU_SOURCE 1
4
5 #ifndef RPYTHON_VMPROF
6 #include <Python.h>
7 #endif
8
9 #ifdef VMPROF_UNIX
10 #include <unistd.h>
11 #endif
12
13 // common defines
14 #define MARKER_STACKTRACE '\x01'
15 #define MARKER_VIRTUAL_IP '\x02'
16 #define MARKER_TRAILER '\x03'
17 #define MARKER_INTERP_NAME '\x04' /* deprecated */
18 #define MARKER_HEADER '\x05'
19 #define MARKER_TIME_N_ZONE '\x06'
20 #define MARKER_META '\x07'
21 #define MARKER_NATIVE_SYMBOLS '\x08'
22
23 #define VERSION_BASE '\x00'
24 #define VERSION_THREAD_ID '\x01'
25 #define VERSION_TAG '\x02'
26 #define VERSION_MEMORY '\x03'
27 #define VERSION_MODE_AWARE '\x04'
28 #define VERSION_DURATION '\x05'
29 #define VERSION_TIMESTAMP '\x06'
30
31 #define PROFILE_MEMORY '\x01'
32 #define PROFILE_LINES '\x02'
33 #define PROFILE_NATIVE '\x04'
34 #define PROFILE_RPYTHON '\x08'
35 #define PROFILE_REAL_TIME '\x10'
36
37 #define DYN_JIT_FLAG 0xbeefbeef
38
39 #ifdef _WIN32
40 #ifndef VMPROF_WINDOWS
41 #define VMPROF_WINDOWS
42 #endif
43 #endif
44
45 #ifdef __x86_64__
46 #define X86_64
47 #elif defined(__i386__)
48 #define X86_32
49 #endif
50
51 #ifdef VMPROF_UNIX
52 #if defined(X86_64) || defined(X86_32) || defined(__powerpc64__)
53 #define VMP_SUPPORTS_NATIVE_PROFILING
54 #endif
55 #endif
56
57 #ifdef RPYTHON_VMPROF
58 // only for pypy
59 #include "rvmprof.h"
60 #include "vmprof_stack.h"
61 #define PY_STACK_FRAME_T vmprof_stack_t
62 #define PY_EVAL_RETURN_T void
63 #define PY_THREAD_STATE_T void
64 #define FRAME_STEP(f) f->next
65 #define FRAME_CODE(f) f->
66 int IS_VMPROF_EVAL(void * ptr);
67 #else
68 #define RPY_EXTERN
69 // for cpython
70 #include "_vmprof.h"
71 #include <Python.h>
72 #include <pythread.h>
73 #include <frameobject.h>
74 #define PY_STACK_FRAME_T PyFrameObject
75 #define PY_EVAL_RETURN_T PyObject
76 #define PY_THREAD_STATE_T PyThreadState
77 #define FRAME_STEP(f) f->f_back
78
79 #if PY_VERSION_HEX < 0x030900B1
80 static inline PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
81 {
82 Py_INCREF(frame->f_code);
83 return frame->f_code;
84 }
85 #endif
86
87 #define FRAME_CODE(f) PyFrame_GetCode(f)
88
89 #if CPYTHON_HAS_FRAME_EVALUATION
90 #define IS_VMPROF_EVAL(PTR) PTR == (void*)_PyEval_EvalFrameDefault
91 #else
92 #define IS_VMPROF_EVAL(PTR) (PTR == (void*)PyEval_EvalFrameEx || PTR == (void*)PyEval_EvalFrame)
93 #endif
94
95 #endif
96
97 void set_current_codes(void * to);
98 int opened_profile(const char *interp_name, int memory, int proflines, int native, int real_time);
99 void flush_codes(void);
100