Skip to content

gh-120144: Refactor bdb monitoring backend to match settrace behavior #132484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2025

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented Apr 13, 2025

The existing behavior of bdb's monitoring backend does not fully match what sys.settrace does. The update for opcode events is separated from the other local events, which does not quite make sense.

This PR unifies the event handling - update_local_events() will simply check f_trace and f_trace_opcode to decide what events should be enabled for that code object.

This actually cleans up the logic for the monitoring backend.

The check_trace_opcodes() is removed from stop_trace() because clear_id does the work.

There was a small bug in the original code - check_trace_opcodes will actually erase the work check_trace_func does. It did not matter because we always do start_trace() when we start trace and we are only interested in opcode events. However, theoretically it's still wrong. Now it has the correct behavior.

This is not really "user observable", so it should be considered as a refactoring. (However it blocks something I'm working on for async stuff).

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@gaogaotiantian
Copy link
Member Author

Hi @iritkatriel , this PR basically just make it clearer how the monitoring backend behavior matches the settrace bahavior, while fixing a small bug. Hope it won't be too much work to review :)

@gaogaotiantian
Copy link
Member Author

Wow that was fast! Thanks!

@gaogaotiantian gaogaotiantian merged commit 084d6dc into python:main Apr 13, 2025
46 checks passed
@gaogaotiantian gaogaotiantian deleted the fix-bdb-opcode-trace branch April 13, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants