Sanitizer: Mention -g option in documentation [PR56682]

gcc/ChangeLog
	PR sanitizer/56682
	* doc/invoke.texi (Instrumentation Options): Document that -g
	is useful with -fsanitize=thread and -fsanitize=address.
	Also mention -fno-omit-frame-pointer per the asan wiki.
This commit is contained in:
Sandra Loosemore 2025-03-07 22:50:19 +00:00
parent d71139982a
commit 313edeeeb6

View file

@ -17861,12 +17861,16 @@ The option cannot be combined with @option{-fsanitize=thread} or
(only with @code{-mlam=u48} or @code{-mlam=u57} options) and AArch64,
in both cases only in ABIs with 64-bit pointers.
When compiling with @option{-fsanitize=address}, you should also also
use @option{-g} to produce more meaningful output.
To get more accurate stack traces, it is possible to use options such as
@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
optimizing sibling and tail recursive calls; this option is implicit for
@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
disables Identical Code Folding for functions). Since multiple runs of the
disables Identical Code Folding for functions).
Using @option{-fno-omit-frame-pointer} also improves stack traces.
Since multiple runs of the
program may yield backtraces with different addresses due to ASLR (Address
Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
this can be achieved with @samp{setarch `uname -m` -R ./prog}.
@ -17972,6 +17976,9 @@ supported options.
The option cannot be combined with @option{-fsanitize=address},
@option{-fsanitize=leak}.
When compiling with @option{-fsanitize=thread}, you should also use
@option{-g} to produce more meaningful output.
Note that sanitized atomic builtins cannot throw exceptions when
operating on invalid memory addresses with non-call exceptions
(@option{-fnon-call-exceptions}).