]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
docs: Suggest options to improve ASAN stack traces
authorMarek Polacek <polacek@redhat.com>
Wed, 7 Dec 2022 20:27:27 +0000 (15:27 -0500)
committerMarek Polacek <polacek@redhat.com>
Thu, 8 Dec 2022 22:49:28 +0000 (17:49 -0500)
I got a complaint that while Clang docs suggest options that improve
the quality of the backtraces ASAN prints (cf.
<https://clang.llvm.org/docs/AddressSanitizer.html#usage>), our docs
don't say anything to that effect.  This patch amends that with a new
paragraph.  (It deliberately doesn't mention -fno-omit-frame-pointer.)

gcc/ChangeLog:

* doc/invoke.texi (-fsanitize=address): Suggest options to improve
stack traces.

gcc/doc/invoke.texi

index 726392409b67277f454e6ae30bdbbdbf024a6123..3f2512ce16a3568f7946cb02a78eee1cfbc398e8 100644 (file)
@@ -16510,6 +16510,16 @@ The option cannot be combined with @option{-fsanitize=thread} or
 @option{-fsanitize=hwaddress}.  Note that the only target
 @option{-fsanitize=hwaddress} is currently supported on is AArch64.
 
+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
+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}.
+
 @item -fsanitize=kernel-address
 @opindex fsanitize=kernel-address
 Enable AddressSanitizer for Linux kernel.