public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] docs: Suggest options to improve ASAN stack traces
@ 2022-12-07 20:34 Marek Polacek
  2022-12-08  7:25 ` Florian Weimer
  0 siblings, 1 reply; 8+ messages in thread
From: Marek Polacek @ 2022-12-07 20:34 UTC (permalink / raw)
  To: GCC Patches

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 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 726392409b6..2de14466dd3 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -16510,6 +16510,14 @@ 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{-O} (which, for instance, prevents most function inlining),
+@option{-fno-optimize-sibling-calls} (which prevents optimizing sibling
+and tail recursive calls), or @option{-fno-ipa-icf} (which disables Identical
+Code Folding for functions and read-only variables).  Since multiple runs
+of the program may yield backtraces with different addresses due to ASLR,
+it may be desirable to turn off ASLR: @samp{setarch `uname -m` -R ./prog}.
+
 @item -fsanitize=kernel-address
 @opindex fsanitize=kernel-address
 Enable AddressSanitizer for Linux kernel.

base-commit: 3ad0f470c16d5528a5283060b007f8b419c33c92
-- 
2.38.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-12-08 23:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07 20:34 [PATCH] docs: Suggest options to improve ASAN stack traces Marek Polacek
2022-12-08  7:25 ` Florian Weimer
2022-12-08 14:11   ` Marek Polacek
2022-12-08 14:28     ` Jakub Jelinek
2022-12-08 14:34       ` [PATCH v2] " Marek Polacek
2022-12-08 15:00         ` Jakub Jelinek
2022-12-08 22:56           ` [PATCH v3] " Marek Polacek
2022-12-08 23:11             ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).