Skip to content

Commit a7161f9

Browse files
gh-90110: Get the C Analyzer Tool Working Again (gh-95545)
1 parent c7e5bba commit a7161f9

File tree

4 files changed

+118
-5
lines changed

4 files changed

+118
-5
lines changed

Tools/c-analyzer/check-c-globals.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import sys
2+
13
from cpython.__main__ import main, configure_logger
24

35

4-
def parse_args():
6+
def parse_args(argv=sys.argv[1:]):
57
import argparse
68
from c_common.scriptutil import (
79
add_verbosity_cli,
@@ -13,7 +15,8 @@ def parse_args():
1315
processors = [
1416
add_verbosity_cli(parser),
1517
add_traceback_cli(parser),
16-
_cli_check(parser, checks='<globals>'),
18+
#_cli_check(parser, checks='<globals>'),
19+
_cli_check(parser),
1720
]
1821

1922
args = parser.parse_args()

Tools/c-analyzer/cpython/_parser.py

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def clean_lines(text):
7171
Python/dynload_hpux.c # dl.h
7272
Python/thread_pthread.h
7373
Python/emscripten_signal.c
74+
Python/thread_pthread_stubs.h
7475
7576
# only huge constants (safe but parsing is slow)
7677
Modules/_blake2/impl/blake2-kat.h
@@ -136,6 +137,7 @@ def clean_lines(text):
136137
Include/internal/*.h Py_BUILD_CORE 1
137138
Python/**/*.c Py_BUILD_CORE 1
138139
Parser/**/*.c Py_BUILD_CORE 1
140+
Parser/**/*.h Py_BUILD_CORE 1
139141
Objects/**/*.c Py_BUILD_CORE 1
140142
141143
Modules/_asynciomodule.c Py_BUILD_CORE 1
@@ -205,6 +207,7 @@ def clean_lines(text):
205207
Include/cpython/tupleobject.h Py_CPYTHON_TUPLEOBJECT_H 1
206208
Include/cpython/unicodeobject.h Py_CPYTHON_UNICODEOBJECT_H 1
207209
Include/internal/pycore_code.h SIZEOF_VOID_P 8
210+
Include/internal/pycore_frame.h SIZEOF_VOID_P 8
208211
209212
# implied include of pyport.h
210213
Include/**/*.h PyAPI_DATA(RTYPE) extern RTYPE

Tools/c-analyzer/cpython/globals-to-fix.tsv

+26-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Objects/genericaliasobject.c - _Py_GenericAliasIterType -
114114
Objects/iterobject.c - _PyAnextAwaitable_Type -
115115
# Not in a .h file:
116116
Objects/memoryobject.c - _PyMemoryIter_Type -
117-
#Objects/unicodeobject.c - _PyUnicodeASCIIIter_Type -
117+
Objects/unicodeobject.c - _PyUnicodeASCIIIter_Type -
118118
Objects/unionobject.c - _PyUnion_Type -
119119
Python/context.c - _PyContextTokenMissing_Type -
120120
Python/hamt.c - _PyHamtItems_Type -
@@ -349,7 +349,10 @@ Objects/clinic/unicodeobject.c.h unicode_split _parser -
349349
Objects/clinic/unicodeobject.c.h unicode_splitlines _parser -
350350
Python/clinic/Python-tokenize.c.h tokenizeriter_new _parser -
351351
Python/clinic/_warnings.c.h warnings_warn _parser -
352+
Python/clinic/_warnings.c.h warnings_warn_explicit _parser -
353+
Python/clinic/bltinmodule.c.h builtin___import__ _parser -
352354
Python/clinic/bltinmodule.c.h builtin_compile _parser -
355+
Python/clinic/bltinmodule.c.h builtin_exec _parser -
353356
Python/clinic/bltinmodule.c.h builtin_pow _parser -
354357
Python/clinic/bltinmodule.c.h builtin_print _parser -
355358
Python/clinic/bltinmodule.c.h builtin_round _parser -
@@ -511,6 +514,8 @@ Python/bootstrap_hash.c - urandom_cache -
511514
Python/ceval.c - lltrace -
512515
# XXX This should have been found by the analyzer but wasn't:
513516
Python/ceval.c make_pending_calls busy -
517+
Python/ceval.c _PyEval_SetProfile reentrant -
518+
Python/ceval.c _PyEval_SetTrace reentrant -
514519
Python/dynload_shlib.c - handles -
515520
Python/dynload_shlib.c - nhandles -
516521
# XXX This should have been found by the analyzer but wasn't:
@@ -587,6 +592,10 @@ Modules/_io/textio.c - PyIncrementalNewlineDecoder_Type -
587592
Modules/_io/textio.c - PyTextIOBase_Type -
588593
Modules/_io/textio.c - PyTextIOWrapper_Type -
589594
Modules/_io/winconsoleio.c - PyWindowsConsoleIO_Type -
595+
Modules/_testcapi/vectorcall.c - MethodDescriptorBase_Type -
596+
Modules/_testcapi/vectorcall.c - MethodDescriptorDerived_Type -
597+
Modules/_testcapi/vectorcall.c - MethodDescriptorNopGet_Type -
598+
Modules/_testcapi/vectorcall.c - MethodDescriptor2_Type -
590599
Modules/_threadmodule.c - Locktype -
591600
Modules/_threadmodule.c - RLocktype -
592601
Modules/_threadmodule.c - localdummytype -
@@ -629,6 +638,10 @@ Modules/signalmodule.c - ItimerError -
629638
# cached - initialized once
630639

631640
# _PyArg_Parser
641+
Modules/clinic/_asynciomodule.c.h _asyncio_Task__check_future _parser -
642+
Modules/clinic/_csv.c.h _csv_unregister_dialect _parser -
643+
Modules/clinic/_csv.c.h _csv_get_dialect _parser -
644+
Modules/clinic/_csv.c.h _csv_field_size_limit _parser -
632645
Modules/clinic/_codecsmodule.c.h _codecs_decode _parser -
633646
Modules/clinic/_codecsmodule.c.h _codecs_encode _parser -
634647
Modules/clinic/_sre.c.h _sre_SRE_Match_expand _parser -
@@ -646,6 +659,10 @@ Modules/clinic/_sre.c.h _sre_SRE_Pattern_subn _parser -
646659
Modules/clinic/_sre.c.h _sre_SRE_Scanner_match _parser -
647660
Modules/clinic/_sre.c.h _sre_SRE_Scanner_search _parser -
648661
Modules/clinic/_sre.c.h _sre_compile _parser -
662+
Modules/clinic/_winapi.c.h _winapi_LCMapStringEx _parser -
663+
Modules/clinic/arraymodule.c.h array_array_fromfile _parser -
664+
Modules/clinic/arraymodule.c.h array_array_tofile _parser -
665+
Modules/clinic/arraymodule.c.h array_array___reduce_ex__ _parser -
649666
Modules/clinic/gcmodule.c.h gc_collect _parser -
650667
Modules/clinic/gcmodule.c.h gc_get_objects _parser -
651668
Modules/clinic/itertoolsmodule.c.h itertools_accumulate _parser -
@@ -681,6 +698,7 @@ Modules/clinic/posixmodule.c.h os_scandir _parser -
681698
Modules/clinic/posixmodule.c.h os_stat _parser -
682699
Modules/clinic/posixmodule.c.h os_unlink _parser -
683700
Modules/clinic/posixmodule.c.h os_utime _parser -
701+
Modules/clinic/socketmodule.c.h sock_initobj _parser -
684702

685703
#-----------------------
686704
# other
@@ -942,6 +960,7 @@ Modules/xxmodule.c - ErrorObject -
942960
# _Py_IDENTIFIER (global)
943961
Modules/_asynciomodule.c - PyId___asyncio_running_event_loop__ -
944962
Modules/_asynciomodule.c - PyId__asyncio_future_blocking -
963+
Modules/_asynciomodule.c - PyId__check_future static -
945964
Modules/_asynciomodule.c - PyId_add_done_callback -
946965
Modules/_asynciomodule.c - PyId_call_soon -
947966
Modules/_asynciomodule.c - PyId_cancel -
@@ -1256,11 +1275,13 @@ Modules/clinic/zlibmodule.c.h zlib_decompressobj _parser -
12561275
# other - during module init
12571276
Modules/_asynciomodule.c - asyncio_mod -
12581277
Modules/_asynciomodule.c - traceback_extract_stack -
1259-
Modules/_asynciomodule.c - asyncio_get_event_loop_policy -
1278+
Modules/_asynciomodule.c - asyncio_future_repr_func -
12601279
Modules/_asynciomodule.c - asyncio_future_repr_info_func -
1280+
Modules/_asynciomodule.c - asyncio_get_event_loop_policy -
12611281
Modules/_asynciomodule.c - asyncio_iscoroutine_func -
12621282
Modules/_asynciomodule.c - asyncio_task_get_stack_func -
12631283
Modules/_asynciomodule.c - asyncio_task_print_stack_func -
1284+
Modules/_asynciomodule.c - asyncio_task_repr_func -
12641285
Modules/_asynciomodule.c - asyncio_task_repr_info_func -
12651286
Modules/_asynciomodule.c - asyncio_InvalidStateError -
12661287
Modules/_asynciomodule.c - asyncio_CancelledError -
@@ -1303,6 +1324,7 @@ Modules/_ssl.c - lib_codes_to_names -
13031324
Modules/_ssl.c - _ssl_locks -
13041325
Modules/_struct.c - cache -
13051326
Modules/arraymodule.c array_array___reduce_ex__ array_reconstructor -
1327+
Modules/arraymodule.c array_array___reduce_ex___impl array_reconstructor -
13061328
Modules/cjkcodecs/cjkcodecs.h getmultibytecodec cofunc -
13071329

13081330
# state
@@ -1313,6 +1335,7 @@ Modules/_asynciomodule.c - all_tasks -
13131335
Modules/_asynciomodule.c - current_tasks -
13141336
Modules/_asynciomodule.c - iscoroutine_typecache -
13151337
Modules/_ctypes/_ctypes.c - _ctypes_ptrtype_cache -
1338+
Modules/_testinternalcapi.c - record_list -
13161339
Modules/_tkinter.c - tcl_lock -
13171340
Modules/_tkinter.c - excInCmd -
13181341
Modules/_tkinter.c - valInCmd -
@@ -1401,3 +1424,4 @@ Modules/rotatingtree.c - random_stream -
14011424
Modules/rotatingtree.c - random_value -
14021425
Modules/socketmodule.c - defaulttimeout -
14031426
Modules/syslogmodule.c - S_log_open -
1427+
Modules/clinic/_asynciomodule.c.h _asyncio_Task__check_future _parser -

0 commit comments

Comments
 (0)