@@ -70,6 +70,7 @@ def _debug(msg: str) -> None:
7070 _debug ("in core.py" )
7171
7272 # Check the conditions that preclude us from using sys.monitoring.
73+ # This applies to both sysmon and csysmon.
7374 reason_no_sysmon = ""
7475 if not env .PYBEHAVIOR .pep669 :
7576 reason_no_sysmon = "sys.monitoring isn't available in this version"
@@ -89,9 +90,12 @@ def _debug(msg: str) -> None:
8990 core_name = config .core
9091 _debug (f"core.py: core from config is { core_name !r} " )
9192
92- if core_name == "sysmon" and reason_no_sysmon :
93- _debug (f"core.py: defaulting because sysmon not usable: { reason_no_sysmon } " )
94- warn (f"Can't use core=sysmon: { reason_no_sysmon } , using default core" , slug = "no-sysmon" )
93+ if core_name in ("sysmon" , "csysmon" ) and reason_no_sysmon :
94+ _debug (f"core.py: defaulting because { core_name } not usable: { reason_no_sysmon } " )
95+ warn (
96+ f"Can't use core={ core_name } : { reason_no_sysmon } , using default core" ,
97+ slug = "no-sysmon" ,
98+ )
9599 core_name = None
96100
97101 if core_name is None :
@@ -108,6 +112,12 @@ def _debug(msg: str) -> None:
108112 warn (f"Couldn't import C tracer: { IMPORT_ERROR } " , slug = "no-ctracer" , once = True )
109113 core_name = "pytrace"
110114 _debug ("core.py: Falling back to pytrace because C tracer not available" )
115+ elif core_name == "csysmon" :
116+ if not CTRACER_FILE :
117+ if IMPORT_ERROR and env .SHIPPING_WHEELS :
118+ warn (f"Couldn't import C tracer: { IMPORT_ERROR } " , slug = "no-csysmon" , once = True )
119+ core_name = "sysmon"
120+ _debug ("core.py: Falling back to sysmon because C tracer not available" )
111121
112122 _debug (f"core.py: Using core={ core_name } " )
113123
@@ -120,6 +130,13 @@ def _debug(msg: str) -> None:
120130 self .supports_plugins = False
121131 self .packed_arcs = False
122132 self .systrace = False
133+ elif core_name == "csysmon" :
134+ self .tracer_class = coverage .tracer .CSysMonitor
135+ self .tracer_kwargs ["tool_id" ] = 3 if metacov else 1
136+ self .file_disposition_class = FileDisposition
137+ self .supports_plugins = False
138+ self .packed_arcs = False
139+ self .systrace = False
123140 elif core_name == "ctrace" :
124141 self .tracer_class = coverage .tracer .CTracer
125142 self .file_disposition_class = coverage .tracer .CFileDisposition
0 commit comments