/home/mdboom/Work/builds/cpython/Include/internal/pycore_traceback.h
Line | Count | Source |
1 | #ifndef Py_INTERNAL_TRACEBACK_H |
2 | #define Py_INTERNAL_TRACEBACK_H |
3 | #ifdef __cplusplus |
4 | extern "C" { |
5 | #endif |
6 | |
7 | #ifndef Py_BUILD_CORE |
8 | # error "this header requires Py_BUILD_CORE define" |
9 | #endif |
10 | |
11 | /* Write the Python traceback into the file 'fd'. For example: |
12 | |
13 | Traceback (most recent call first): |
14 | File "xxx", line xxx in <xxx> |
15 | File "xxx", line xxx in <xxx> |
16 | ... |
17 | File "xxx", line xxx in <xxx> |
18 | |
19 | This function is written for debug purpose only, to dump the traceback in |
20 | the worst case: after a segmentation fault, at fatal error, etc. That's why, |
21 | it is very limited. Strings are truncated to 100 characters and encoded to |
22 | ASCII with backslashreplace. It doesn't write the source code, only the |
23 | function name, filename and line number of each frame. Write only the first |
24 | 100 frames: if the traceback is truncated, write the line " ...". |
25 | |
26 | This function is signal safe. */ |
27 | |
28 | PyAPI_FUNC(void) _Py_DumpTraceback( |
29 | int fd, |
30 | PyThreadState *tstate); |
31 | |
32 | /* Write the traceback of all threads into the file 'fd'. current_thread can be |
33 | NULL. |
34 | |
35 | Return NULL on success, or an error message on error. |
36 | |
37 | This function is written for debug purpose only. It calls |
38 | _Py_DumpTraceback() for each thread, and so has the same limitations. It |
39 | only write the traceback of the first 100 threads: write "..." if there are |
40 | more threads. |
41 | |
42 | If current_tstate is NULL, the function tries to get the Python thread state |
43 | of the current thread. It is not an error if the function is unable to get |
44 | the current Python thread state. |
45 | |
46 | If interp is NULL, the function tries to get the interpreter state from |
47 | the current Python thread state, or from |
48 | _PyGILState_GetInterpreterStateUnsafe() in last resort. |
49 | |
50 | It is better to pass NULL to interp and current_tstate, the function tries |
51 | different options to retrieve this information. |
52 | |
53 | This function is signal safe. */ |
54 | |
55 | PyAPI_FUNC(const char*) _Py_DumpTracebackThreads( |
56 | int fd, |
57 | PyInterpreterState *interp, |
58 | PyThreadState *current_tstate); |
59 | |
60 | /* Write a Unicode object into the file descriptor fd. Encode the string to |
61 | ASCII using the backslashreplace error handler. |
62 | |
63 | Do nothing if text is not a Unicode object. The function accepts Unicode |
64 | string which is not ready (PyUnicode_WCHAR_KIND). |
65 | |
66 | This function is signal safe. */ |
67 | PyAPI_FUNC(void) _Py_DumpASCII(int fd, PyObject *text); |
68 | |
69 | /* Format an integer as decimal into the file descriptor fd. |
70 | |
71 | This function is signal safe. */ |
72 | PyAPI_FUNC(void) _Py_DumpDecimal( |
73 | int fd, |
74 | size_t value); |
75 | |
76 | /* Format an integer as hexadecimal with width digits into fd file descriptor. |
77 | The function is signal safe. */ |
78 | PyAPI_FUNC(void) _Py_DumpHexadecimal( |
79 | int fd, |
80 | uintptr_t value, |
81 | Py_ssize_t width); |
82 | |
83 | PyAPI_FUNC(PyObject*) _PyTraceBack_FromFrame( |
84 | PyObject *tb_next, |
85 | PyFrameObject *frame); |
86 | |
87 | #define EXCEPTION_TB_HEADER "Traceback (most recent call last):\n" |
88 | #define EXCEPTION_GROUP_TB_HEADER "Exception Group Traceback (most recent call last):\n" |
89 | |
90 | /* Write the traceback tb to file f. Prefix each line with |
91 | indent spaces followed by the margin (if it is not NULL). */ |
92 | PyAPI_FUNC(int) _PyTraceBack_Print_Indented( |
93 | PyObject *tb, int indent, const char* margin, |
94 | const char *header_margin, const char *header, PyObject *f); |
95 | PyAPI_FUNC(int) _Py_WriteIndentedMargin(int, const char*, PyObject *); |
96 | PyAPI_FUNC(int) _Py_WriteIndent(int, PyObject *); |
97 | |
98 | #ifdef __cplusplus |
99 | } |
100 | #endif |
101 | #endif /* !Py_INTERNAL_TRACEBACK_H */ |