Repository navigation
Write interpreter inputs to files for debuggers (experimental) - #1156
conrade-ctc wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1156 +/- ##
==========================================
+ Coverage 88.70% 88.77% +0.06%
==========================================
Files 24 24
Lines 6978 7020 +42
==========================================
+ Hits 6190 6232 +42
Misses 788 788
🚀 New features to boost your workflow:
|
Vipul-Cariappa
left a comment
There was a problem hiding this comment.
Not sure if we should condition this on a macro CPPINTEROP_ENABLE_JIT_SOURCE_DIR. We are already conditioning this feature on an environmental variable CPPINTEROP_JIT_SOURCE_DIR.
Think about shipping CppInterOp. We will need to ship two different versions, one that supports debugging and another that does not support it.
I did not go through the PR in detail, but from what I can see, if we enable debugging support by default, it will not cost us much, as we still enable it only when the env var is defined.
856b44d to
a367f97
Compare
Agreed, I had thought to make it completely opt-in... not actually ship this, but treat it as experimental. But the cost should be small, so maybe not work treating that way. I'll remove for now, and if anyone else has an objection and prefers to keep it experimental, we can reintroduce it. |
|
clang-tidy review says "All clean, LGTM! 👍" |
a367f97 to
1c9675a
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
1c9675a to
475ca79
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
475ca79 to
e40772a
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
clang-repl registers jitted code with GDB, but the debug info names in-memory buffers such as input_line_5. Thus a debugger cannot show the source or set a breakpoint by file and line. The support is experimental. If CPPINTEROP_JIT_SOURCE_DIR is set, write each input to a file in that directory. Parse the input after a #line directive that names the file. The file name is a hash of the input, so the path stays the same between runs. A new test runs gdb in batch mode if gdb is on the PATH. Co-developed-with-the-help-of: Claude Code (Opus 5.5, human in the loop)
e40772a to
0c1c68a
Compare
Description
clang-repl registers JIT code with gdb, but the debug info names in-memory buffers such as
input_line_5. Thus a debugger cannot show the source or set a breakpoint by file and line.This adds experimental support. If
CPPINTEROP_JIT_SOURCE_DIRis set, the interpreter writes each input to a file in that directory. It then parses the input after a#linedirective that names the file. The file name is a hash of the input, so the path stays the same between runs and breakpoints stay valid. Without the variable, the cost is onegetenvwhen the interpreter starts and one check for each input.cppjit uses this for its experimental debugger support (compiler-research/cppjit#167).
Type of change
Testing
Interpreter_JitSourceDirchecks that the input goes to a file and that__FILE__names that file.Interpreter_JitSourceDirGdbruns gdb in batch mode, if gdb is on the PATH, and stops at a line of the file. Both tests run with clang-repl on Linux and macOS. Locally (Linux, gdb 16.3) both pass.Checklist
🤖 Done with the help of Claude Code (Opus 5.5, human in the loop)