Skip to content

Commit d31c416

Browse files
committed
wip: switch from BRANCH_TAKEN to BRANCH_RIGHT
1 parent 07fae3b commit d31c416

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

coverage/core.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ def __init__(self, warn: TWarnFn, config: CoverageConfig, metacov: bool) -> None
6464
warn("sys.monitoring isn't available, using default core", slug="no-sysmon")
6565
core_name = None
6666

67-
if core_name == "sysmon" and config.branch and not env.PYBEHAVIOR.branch_taken:
68-
warn(
69-
"sys.monitoring can't yet measure branches well, using default core",
70-
slug="no-sysmon",
71-
)
72-
core_name = None
67+
# if core_name == "sysmon" and config.branch and not env.PYBEHAVIOR.branch_right_left:
68+
# warn(
69+
# "sys.monitoring can't yet measure branches well, using default core",
70+
# slug="no-sysmon",
71+
# )
72+
# core_name = None
7373

7474
if not core_name:
7575
# Once we're comfortable with sysmon as a default:

coverage/env.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ class PYBEHAVIOR:
159159
# PEP649 and PEP749: Deferred annotations
160160
deferred_annotations = (PYVERSION >= (3, 14))
161161

162-
# Does sys.monitoring support BRANCH_TAKEN?
163-
branch_taken = (
162+
# Does sys.monitoring support BRANCH_RIGHT and BRANCH_LEFT?
163+
branch_right_left = (
164164
pep669 and
165-
hasattr(sys.monitoring.events, "BRANCH_TAKEN") # type:ignore[attr-defined,unused-ignore]
165+
hasattr(sys.monitoring.events, "BRANCH_RIGHT") # type:ignore[attr-defined,unused-ignore]
166166
)
167167

168168

coverage/sysmon.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ def start(self) -> None:
246246
if self.trace_arcs:
247247
register(events.PY_RETURN, self.sysmon_py_return)
248248
register(events.LINE, self.sysmon_line_arcs)
249-
register(events.BRANCH_TAKEN, self.sysmon_branch_taken)
250-
register(events.BRANCH_NOT_TAKEN, self.sysmon_branch_not_taken)
249+
register(events.BRANCH_RIGHT, self.sysmon_branch_right) # type:ignore[attr-defined]
250+
register(events.BRANCH_LEFT, self.sysmon_branch_left) # type:ignore[attr-defined]
251251
else:
252252
register(events.LINE, self.sysmon_line_lines)
253253
sys_monitoring.restart_events()
@@ -343,9 +343,9 @@ def sysmon_py_start( # pylint: disable=useless-return
343343
assert sys_monitoring is not None
344344
local_events = events.PY_RETURN | events.PY_RESUME | events.LINE
345345
if self.trace_arcs:
346-
assert env.PYBEHAVIOR.branch_taken
346+
assert env.PYBEHAVIOR.branch_right_left
347347
local_events |= (
348-
events.BRANCH_TAKEN | events.BRANCH_NOT_TAKEN
348+
events.BRANCH_RIGHT | events.BRANCH_LEFT # type:ignore[attr-defined]
349349
)
350350
sys_monitoring.set_local_events(self.myid, code, local_events)
351351
self.local_event_codes[id(code)] = code
@@ -390,10 +390,10 @@ def sysmon_line_arcs(self, code: CodeType, line_number: int) -> MonitorReturn:
390390
return DISABLE
391391

392392
@panopticon("code", "@", "@")
393-
def sysmon_branch_taken(
393+
def sysmon_branch_right(
394394
self, code: CodeType, instruction_offset: int, destination_offset: int
395395
) -> MonitorReturn:
396-
"""Handed BRANCH_TAKEN and BRANCH_NOT_TAKEN events."""
396+
"""Handed BRANCH_RIGHT and BRANCH_LEFT events."""
397397
code_info = self.code_infos[id(code)]
398398
if code_info.file_data is not None:
399399
b2l = code_info.byte_to_line
@@ -404,10 +404,10 @@ def sysmon_branch_taken(
404404
return DISABLE
405405

406406
@panopticon("code", "@", "@")
407-
def sysmon_branch_not_taken(
407+
def sysmon_branch_left(
408408
self, code: CodeType, instruction_offset: int, destination_offset: int
409409
) -> MonitorReturn:
410-
"""Handed BRANCH_TAKEN and BRANCH_NOT_TAKEN events."""
410+
"""Handed BRANCH_RIGHT and BRANCH_LEFT events."""
411411
code_info = self.code_infos[id(code)]
412412
if code_info.file_data is not None:
413413
b2l = code_info.byte_to_line

lab/run_sysmon.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def bytes_to_lines(code):
3131
events.PY_RETURN
3232
| events.PY_RESUME
3333
| events.LINE
34-
| events.BRANCH_TAKEN
35-
| events.BRANCH_NOT_TAKEN
34+
| events.BRANCH_RIGHT
35+
| events.BRANCH_LEFT
3636
| events.JUMP
3737
)
3838

@@ -82,13 +82,13 @@ def sysmon_branch(code, instruction_offset, destination_offset):
8282
return sys.monitoring.DISABLE
8383

8484

85-
def sysmon_branch_taken(code, instruction_offset, destination_offset):
86-
show_off_off("BRANCH_TAKEN", code, instruction_offset, destination_offset)
85+
def sysmon_branch_right(code, instruction_offset, destination_offset):
86+
show_off_off("BRANCH_RIGHT", code, instruction_offset, destination_offset)
8787
return sys.monitoring.DISABLE
8888

8989

90-
def sysmon_branch_not_taken(code, instruction_offset, destination_offset):
91-
show_off_off("BRANCH_NOT_TAKEN", code, instruction_offset, destination_offset)
90+
def sysmon_branch_left(code, instruction_offset, destination_offset):
91+
show_off_off("BRANCH_LEFT", code, instruction_offset, destination_offset)
9292
return sys.monitoring.DISABLE
9393

9494

@@ -108,8 +108,8 @@ def sysmon_jump(code, instruction_offset, destination_offset):
108108
# register(events.PY_UNWIND, sysmon_py_unwind_arcs)
109109
register(events.LINE, sysmon_line)
110110
register(events.BRANCH, sysmon_branch)
111-
register(events.BRANCH_TAKEN, sysmon_branch_taken)
112-
register(events.BRANCH_NOT_TAKEN, sysmon_branch_not_taken)
111+
register(events.BRANCH_RIGHT, sysmon_branch_right)
112+
register(events.BRANCH_LEFT, sysmon_branch_left)
113113
register(events.JUMP, sysmon_jump)
114114

115115
exec(code)

tests/test_concurrency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ def test_multiprocessing_with_branching(self, start_method: str) -> None:
556556
expected_out = f"{nprocs} pids, total = {total}"
557557
expect_warn = (
558558
env.PYBEHAVIOR.pep669
559-
and (not env.PYBEHAVIOR.branch_taken)
559+
and (not env.PYBEHAVIOR.branch_right_left)
560560
and testenv.SYS_MON
561561
)
562562
self.make_file("multi.py", code)

0 commit comments

Comments
 (0)