Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:18:10

0001 #ifndef Py_INTERNAL_TRACEBACK_H
0002 #define Py_INTERNAL_TRACEBACK_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006 
0007 #ifndef Py_BUILD_CORE
0008 #  error "this header requires Py_BUILD_CORE define"
0009 #endif
0010 
0011 /* Write the Python traceback into the file 'fd'. For example:
0012 
0013        Traceback (most recent call first):
0014          File "xxx", line xxx in <xxx>
0015          File "xxx", line xxx in <xxx>
0016          ...
0017          File "xxx", line xxx in <xxx>
0018 
0019    This function is written for debug purpose only, to dump the traceback in
0020    the worst case: after a segmentation fault, at fatal error, etc. That's why,
0021    it is very limited. Strings are truncated to 100 characters and encoded to
0022    ASCII with backslashreplace. It doesn't write the source code, only the
0023    function name, filename and line number of each frame. Write only the first
0024    100 frames: if the traceback is truncated, write the line " ...".
0025 
0026    This function is signal safe. */
0027 
0028 PyAPI_FUNC(void) _Py_DumpTraceback(
0029     int fd,
0030     PyThreadState *tstate);
0031 
0032 /* Write the traceback of all threads into the file 'fd'. current_thread can be
0033    NULL.
0034 
0035    Return NULL on success, or an error message on error.
0036 
0037    This function is written for debug purpose only. It calls
0038    _Py_DumpTraceback() for each thread, and so has the same limitations. It
0039    only write the traceback of the first 100 threads: write "..." if there are
0040    more threads.
0041 
0042    If current_tstate is NULL, the function tries to get the Python thread state
0043    of the current thread. It is not an error if the function is unable to get
0044    the current Python thread state.
0045 
0046    If interp is NULL, the function tries to get the interpreter state from
0047    the current Python thread state, or from
0048    _PyGILState_GetInterpreterStateUnsafe() in last resort.
0049 
0050    It is better to pass NULL to interp and current_tstate, the function tries
0051    different options to retrieve this information.
0052 
0053    This function is signal safe. */
0054 
0055 PyAPI_FUNC(const char*) _Py_DumpTracebackThreads(
0056     int fd,
0057     PyInterpreterState *interp,
0058     PyThreadState *current_tstate);
0059 
0060 /* Write a Unicode object into the file descriptor fd. Encode the string to
0061    ASCII using the backslashreplace error handler.
0062 
0063    Do nothing if text is not a Unicode object. The function accepts Unicode
0064    string which is not ready (PyUnicode_WCHAR_KIND).
0065 
0066    This function is signal safe. */
0067 PyAPI_FUNC(void) _Py_DumpASCII(int fd, PyObject *text);
0068 
0069 /* Format an integer as decimal into the file descriptor fd.
0070 
0071    This function is signal safe. */
0072 PyAPI_FUNC(void) _Py_DumpDecimal(
0073     int fd,
0074     size_t value);
0075 
0076 /* Format an integer as hexadecimal with width digits into fd file descriptor.
0077    The function is signal safe. */
0078 PyAPI_FUNC(void) _Py_DumpHexadecimal(
0079     int fd,
0080     uintptr_t value,
0081     Py_ssize_t width);
0082 
0083 PyAPI_FUNC(PyObject*) _PyTraceBack_FromFrame(
0084     PyObject *tb_next,
0085     PyFrameObject *frame);
0086 
0087 #define EXCEPTION_TB_HEADER "Traceback (most recent call last):\n"
0088 #define EXCEPTION_GROUP_TB_HEADER "Exception Group Traceback (most recent call last):\n"
0089 
0090 /* Write the traceback tb to file f. Prefix each line with
0091    indent spaces followed by the margin (if it is not NULL). */
0092 PyAPI_FUNC(int) _PyTraceBack_Print_Indented(
0093     PyObject *tb, int indent, const char* margin,
0094     const char *header_margin, const char *header, PyObject *f);
0095 PyAPI_FUNC(int) _Py_WriteIndentedMargin(int, const char*, PyObject *);
0096 PyAPI_FUNC(int) _Py_WriteIndent(int, PyObject *);
0097 
0098 #ifdef __cplusplus
0099 }
0100 #endif
0101 #endif /* !Py_INTERNAL_TRACEBACK_H */