Skip to content

Commit

Permalink
v.pref: support -debug and -cdebug, as more explicit alternative …
Browse files Browse the repository at this point in the history
…names for `-g` and `-cg` (#23208)
  • Loading branch information
spytheman authored Dec 19, 2024
1 parent 939d243 commit 30ececc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions vlib/v/help/build/build-c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ see also `v help build`.
your custom one loaded from specified <path>.

# Debugging:
-g
-g, -debug
Generate more debug information in the compiled executable.
This makes program backtraces more useful.
Using debuggers like gdb/lldb with such executables is easier too.
Unlike `-cg` (described below), `-g` will enforce V source line numbers
so that your debugger and the stacktraces will show you directly
what .v file is responsible for each call/panic.

-cg
-cg, -cdebug
Like -g, but do not use V source line numbers.
When debugging code that wraps C libraries, this option may be
more useful than -g, since it will reduce the amount of context
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/help/default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Examples:
`hello` or `hello.exe`.
v run hello.v Same as above but also run the produced
executable immediately after compilation.
v -cg run hello.v Same as above, but make debugging easier
v -g run hello.v Same as above, but make debugging easier
(in case your program crashes).
v crun hello.v Same as above, but do not recompile, if the
executable already exists, and is newer than the
Expand Down
6 changes: 3 additions & 3 deletions vlib/v/pref/pref.v
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub mut:
is_eval_argument bool // true for `v -e 'println(2+2)'`. `println(2+2)` will be in pref.eval_argument .
is_run bool // compile and run a v program, passing arguments to it, and deleting the executable afterwards
is_crun bool // similar to run, but does not recompile the executable, if there were no changes to the sources
is_debug bool // turned on by -g or -cg, it tells v to pass -g to the C backend compiler.
is_debug bool // turned on by -g/-debug or -cg/-cdebug, it tells v to pass -g to the C backend compiler.
is_vlines bool // turned on by -g (it slows down .tmp.c generation slightly).
is_stats bool // `v -stats file.v` will produce more detailed statistics for the file that is compiled
show_asserts bool // `VTEST_SHOW_ASSERTS=1 v file_test.v` will show details about the asserts done by a test file. Also activated for `-stats` and `-show-asserts`.
Expand Down Expand Up @@ -516,12 +516,12 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
}
i++
}
'-g' {
'-g', '-debug' {
res.is_debug = true
res.is_vlines = true
res.build_options << arg
}
'-cg' {
'-cg', '-cdebug' {
res.is_debug = true
res.is_vlines = false
res.build_options << arg
Expand Down

0 comments on commit 30ececc

Please sign in to comment.