Repository navigation
Add line-hooking - #4275
Add line-hooking#4275bwoebi wants to merge 5 commits into
Conversation
DDTrace\install_line_hook(file, line, begin, endLine, end) runs callbacks before a source line, or around a line range, and hands them a LineHookData exposing the instrumented frame's variables. Ranges close on every exit from the range, including exceptional ones. It returns negative ids (accepted by remove_hook()) distinguishing it from function hooks. interceptor/line_hook.c arms a site by replacing the opline's VM handler with a trampoline jumping to the original afterward. Records for op_arrays in OPcache's shared segments are refcounted in a shared mapping so concurrent workers can arm and restore the same opline, and zai_line_hook_handle_fork() reacquires the child's references. hook/line_hooks.c has a lot of machinery to find the entry point of hooks. Sadly this requires a full scan for the filenames and a full forward scan through the opcodes to find the begin and end lines, including identifying exit points. Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 113 Pipeline jobs failed
|
Benchmarks [ tracer ]Benchmark execution time: 2026-10-06 18:50:37 Comparing candidate commit 46307f4 in PR branch Found 1 performance improvements and 24 performance regressions! Performance is the same for 167 metrics, 2 unstable metrics.
|
And add some accidentally not staged tests. Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
DDTrace\install_line_hook(file, line, begin, endLine, end) runs callbacks before a source line, or around a line range, and hands them a LineHookData exposing the instrumented frame's variables. Ranges close on every exit from the range, including exceptional ones. It returns negative ids (accepted by remove_hook()) distinguishing it from function hooks.
interceptor/line_hook.c arms a site by replacing the opline's VM handler with a trampoline jumping to the original afterward. Records for op_arrays in OPcache's shared segments are refcounted in a shared mapping so concurrent workers can arm and restore the same opline, and zai_line_hook_handle_fork() reacquires the child's references.
hook/line_hooks.c has a lot of machinery to find the entry point of hooks. Sadly this requires a full scan for the filenames and a full forward scan through the opcodes to find the begin and end lines, including identifying exit points.