Skip to content

Commit 4f916a1

Browse files
authored
AGENTS.md: add quick code location technique (#26569)
1 parent aac7792 commit 4f916a1

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

‎AGENTS.md‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,22 @@ skipped coverage in the summary.
581581
* JS/native/wasm: prefer small, focused test files with
582582
`-b js|native|wasm` and `-show-c-output` where applicable; avoid
583583
broad `-b <backend> test vlib/`.
584+
* Quick code location technique:
585+
When debugging code generation issues, add unique comment tags to
586+
relevant code generation points (e.g., `/*tom51*/`) in the compiler
587+
source. Rebuild and generate C code, then search the generated file for these
588+
tags to quickly map generated C code back to the exact compiler source
589+
location. This is especially useful when multiple code paths generate
590+
similar-looking output and you need to identify which path is actually used.
591+
Example:
592+
```v
593+
// In vlib/v/gen/c/assign.v:
594+
g.write('builtin___option_ok/*tom51*/(&(${styp}[]) { ')
595+
596+
// After rebuild, search generated C code for "tom51":
597+
// builtin___option_ok/*tom51*/(&(int[]) { ... });
598+
```
599+
Remember to remove these debug tags after fixing the issue.
584600

585601
## Compiler Architecture
586602
The V compiler has the following stages, orchestrated by the
@@ -708,4 +724,4 @@ v.callgraph, etc.
708724
* New tests or test infra changes.
709725
* Output tests or `.out` updates.
710726
* Broad refactors or compiler-wide changes.
711-
* Unsure which slow test runner applies to your change.
727+
* Unsure which slow test runner applies to your change.

0 commit comments

Comments
 (0)