Skip to content

Commit bf7f43f

Browse files
committed
checker,cgen: support -d trace_check and -d trace_cgen to help diagnose checker and cgen ordering issues
1 parent e08cc4e commit bf7f43f

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,14 @@ a copy of the compiler rather than replacing it with `v self`.
325325
| `trace_scanner` | Prints details about the recognized tokens. *Very* verbose. Use with `./vnew -no-builtin -check-syntax file.v` . |
326326
| `trace_parse` | Prints details about the parsed files (number of tokens, lines, bytes). Use it for parsing order issues. |
327327
| `trace_parser` | Prints details about parsed statements and expressions. Very verbose. Use it for panics in the parser. |
328+
| `trace_check` | Prints the .v file which is checked. Use it to diagnose checker order issues. |
328329
| `trace_checker` | Prints details about the statements being checked. Very verbose. Use it for panics in the checker. |
329330
| `trace_transformer` | Prints details about the statements being transformed. Very verbose. Use it for panics in the transformer stage. |
330331
| | |
331332
| `trace_gen` | Prints all the strings written to the generated C file. Very verbose. |
332333
| `trace_gen_wanted_value` | Prints a backtrace, when a specific *wanted* value, is part of what is printed in the generated C file. |
333334
| | Use: `v -g -o vgen -d trace_gen_wanted -d trace_gen_wanted_value="message = _SLIT0" cmd/v && ./vgen bug.v` |
335+
| `trace_cgen` | Prints the .v file for which C code generation runs. Use it to diagnose cgen order issues. |
334336
| `trace_cgen_stmt` | Prints details about the statements that are being processed by cgen. |
335337
| | Use it for panics in cgen, to see the closest input V source line, that caused the panic. |
336338
| | Note: you need `v -no-parallel -d trace_cgen_stmt -o w cmd/v` to make sense of the output of that, |

vlib/v/checker/checker.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ fn (mut c Checker) reset_checker_state_at_start_of_new_file() {
218218
}
219219

220220
pub fn (mut c Checker) check(mut ast_file ast.File) {
221+
$if trace_check ? {
222+
eprintln('> ${@FILE}:${@LINE} | ast_file.path: ${ast_file.path}')
223+
}
221224
$if trace_checker ? {
222225
eprintln('start checking file: ${ast_file.path}')
223226
}

vlib/v/gen/c/cgen.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,9 @@ pub fn (mut g Gen) free_builders() {
924924
}
925925

926926
pub fn (mut g Gen) gen_file() {
927+
$if trace_cgen ? {
928+
eprintln('> ${@FILE}:${@LINE} | g.file.path: ${g.file.path}')
929+
}
927930
g.timers.start('cgen_file ${g.file.path}')
928931
g.unique_file_path_hash = fnv1a.sum64_string(g.file.path)
929932
if g.pref.is_vlines {

0 commit comments

Comments
 (0)