@@ -11,71 +11,3 @@ struct _traceback {
1111 int tb_lasti ;
1212 int tb_lineno ;
1313};
14-
15- /* Buffer size for the filename and name fields in PyUnstable_FrameInfo:
16- up to 500 content bytes plus '\0' (1). */
17- #define Py_UNSTABLE_FRAMEINFO_STRSIZE 501
18-
19- /* Structured, plain-data representation of a single Python frame.
20- PyUnstable_CollectCallStack and PyUnstable_PrintCallStack() do not
21- acquire or release the GIL or allocate heap memory, so they can be called
22- from signal handlers and are suitable for low-overhead observability tools
23- such as sampling profilers and tracers.
24-
25- Populated by PyUnstable_CollectCallStack. filename and name are
26- ASCII-encoded (non-ASCII characters are backslash-escaped) and
27- null-terminated; they are empty strings if the corresponding code
28- attribute is missing or not a unicode object. lineno is -1 when it
29- cannot be determined. filename_truncated and name_truncated are 1 if
30- the respective string was longer than Py_UNSTABLE_FRAMEINFO_STRSIZE-1
31- bytes and was truncated. */
32- typedef struct {
33- int lineno ;
34- int filename_truncated ;
35- int name_truncated ;
36- char filename [Py_UNSTABLE_FRAMEINFO_STRSIZE ];
37- char name [Py_UNSTABLE_FRAMEINFO_STRSIZE ];
38- } PyUnstable_FrameInfo ;
39-
40- /* Collect up to max_frames frames from tstate into the caller-supplied
41- frames array and return the number of frames written (0..max_frames).
42- Returns -1 if frames is NULL, tstate is freed, or tstate has no current
43- Python frame.
44-
45- The filename and function names are encoded to ASCII with backslashreplace
46- and truncated to 500 characters; when truncated, the corresponding
47- filename_truncated or name_truncated field is set to 1.
48-
49- In crash scenarios such as signal handlers for SIGSEGV, where the
50- interpreter may be in an inconsistent state, the function might produce
51- incomplete output or it may even crash itself.
52-
53- The caller does not need to hold an attached thread state, nor does tstate
54- need to be attached.
55-
56- This function does not acquire or release the GIL, modify reference counts,
57- or allocate heap memory. */
58- PyAPI_FUNC (int ) PyUnstable_CollectCallStack (
59- PyThreadState * tstate ,
60- PyUnstable_FrameInfo * frames ,
61- int max_frames );
62-
63- /* Write a traceback collected by PyUnstable_CollectCallStack to fd.
64- The format looks like:
65-
66- Stack (most recent call first):
67- File "foo/bar.py", line 42 in myfunc
68- File "foo/bar.py", line 99 in caller
69-
70- Pass write_header=1 to emit the "Stack (most recent call first):" header
71- line, or write_header=0 to omit it.
72-
73- This function only reads the caller-supplied frames array and does not
74- access interpreter state. It is async-signal-safe: it does not acquire or
75- release the GIL, modify reference counts, or allocate heap memory, and its
76- only I/O is via write(2). */
77- PyAPI_FUNC (void ) PyUnstable_PrintCallStack (
78- int fd ,
79- const PyUnstable_FrameInfo * frames ,
80- int n_frames ,
81- int write_header );
0 commit comments