You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1 KiB

  1. #ifndef Py_TRACEBACK_H
  2. #define Py_TRACEBACK_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include "pystate.h"
  7. struct _frame;
  8. /* Traceback interface */
  9. #ifndef Py_LIMITED_API
  10. typedef struct _traceback {
  11. PyObject_HEAD
  12. struct _traceback *tb_next;
  13. struct _frame *tb_frame;
  14. int tb_lasti;
  15. int tb_lineno;
  16. } PyTracebackObject;
  17. #endif
  18. PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *);
  19. PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
  20. #ifndef Py_LIMITED_API
  21. PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
  22. #endif
  23. /* Reveal traceback type so we can typecheck traceback objects */
  24. PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
  25. #define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type)
  26. /* Write the Python traceback into the file 'fd'. For example:
  27. Traceback (most recent call first):
  28. File "xxx", line xxx in <xxx>
  29. File "xxx", line xxx in <xxx>
  30. ...
  31. File "xxx", line xxx in <xxx>
  32. This function is written for debug purpose only, to dump the traceback in
  33. the worst case: after a segmentation fault, at fatal error, etc. That's why,
  34. it is very limited. Strings are truncated to 100 characters and encoded to
  35. ASCII with backslashreplace. It doesn't write the source code, only the
  36. function name, filename and line number of each frame. Write only the first
  37. 100 frames: if the traceback is truncated, write the line " ...".
  38. This function is signal safe. */
  39. PyAPI_DATA(void) _Py_DumpTraceback(
  40. int fd,
  41. PyThreadState *tstate);
  42. /* Write the traceback of all threads into the file 'fd'. current_thread can be
  43. NULL. Return NULL on success, or an error message on error.
  44. This function is written for debug purpose only. It calls
  45. _Py_DumpTraceback() for each thread, and so has the same limitations. It
  46. only write the traceback of the first 100 threads: write "..." if there are
  47. more threads.
  48. This function is signal safe. */
  49. PyAPI_DATA(const char*) _Py_DumpTracebackThreads(
  50. int fd, PyInterpreterState *interp,
  51. PyThreadState *current_thread);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif /* !Py_TRACEBACK_H */