@@ -17,31 +17,32 @@ extern "C" {
17
17
18
18
// Macros to burn global values in custom sections so out-of-process
19
19
// profilers can locate them easily.
20
-
21
- #define GENERATE_DEBUG_SECTION (name , declaration ) \
22
- _GENERATE_DEBUG_SECTION_WINDOWS(name) \
23
- _GENERATE_DEBUG_SECTION_APPLE(name) \
24
- declaration \
25
- _GENERATE_DEBUG_SECTION_LINUX(name)
20
+ #define GENERATE_DEBUG_SECTION (name , declaration ) \
21
+ _GENERATE_DEBUG_SECTION_WINDOWS(name) \
22
+ _GENERATE_DEBUG_SECTION_APPLE(name) \
23
+ declaration \
24
+ _GENERATE_DEBUG_SECTION_LINUX(name)
26
25
27
26
#if defined(MS_WINDOWS )
28
27
#define _GENERATE_DEBUG_SECTION_WINDOWS (name ) \
29
- _Pragma(Py_STRINGIFY(section(Py_STRINGIFY(name), read, write))) \
30
- __declspec(allocate(Py_STRINGIFY(name)))
28
+ _Pragma(Py_STRINGIFY(section(Py_STRINGIFY(name), read, write))) \
29
+ __declspec(allocate(Py_STRINGIFY(name)))
31
30
#else
32
31
#define _GENERATE_DEBUG_SECTION_WINDOWS (name )
33
32
#endif
34
33
35
34
#if defined(__APPLE__ )
36
35
#define _GENERATE_DEBUG_SECTION_APPLE (name ) \
37
- __attribute__((section(SEG_DATA "," Py_STRINGIFY(name))))
36
+ __attribute__((section(SEG_DATA "," Py_STRINGIFY(name)))) \
37
+ __attribute__((used))
38
38
#else
39
39
#define _GENERATE_DEBUG_SECTION_APPLE (name )
40
40
#endif
41
41
42
42
#if defined(__linux__ ) && (defined(__GNUC__ ) || defined(__clang__ ))
43
43
#define _GENERATE_DEBUG_SECTION_LINUX (name ) \
44
- __attribute__((section("." Py_STRINGIFY(name))))
44
+ __attribute__((section("." Py_STRINGIFY(name)))) \
45
+ __attribute__((used))
45
46
#else
46
47
#define _GENERATE_DEBUG_SECTION_LINUX (name )
47
48
#endif
@@ -327,6 +328,29 @@ typedef struct _Py_DebugOffsets {
327
328
}, \
328
329
}
329
330
331
+ // Collection of extern declarations for debug offset symbols in extension
332
+ // modules. These declarations are here to ensure the compiler marks them
333
+ // as external symbols. Unfortunately there isn't a cross platform way to
334
+ // do this elegantly withing the compilation unit itself as different compilers
335
+ // complain in different ways.
336
+
337
+ typedef struct _Py_AsyncioModuleDebugOffsets {
338
+ struct _asyncio_task_object {
339
+ uint64_t size ;
340
+ uint64_t task_name ;
341
+ uint64_t task_awaited_by ;
342
+ uint64_t task_is_task ;
343
+ uint64_t task_awaited_by_is_set ;
344
+ uint64_t task_coro ;
345
+ } asyncio_task_object ;
346
+ struct _asyncio_thread_state {
347
+ uint64_t size ;
348
+ uint64_t asyncio_running_loop ;
349
+ uint64_t asyncio_running_task ;
350
+ } asyncio_thread_state ;
351
+ } Py_AsyncioModuleDebugOffsets ;
352
+ PyAPI_DATA (Py_AsyncioModuleDebugOffsets ) AsyncioDebug ;
353
+
330
354
331
355
#ifdef __cplusplus
332
356
}
0 commit comments