From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1734) id 1986B382EF37; Thu, 8 Dec 2022 23:15:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1986B382EF37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670541338; bh=xGxtXJjMUJKeco4oXymNYHYmF5Rpr1aaPGMKq5DiM14=; h=From:To:Subject:Date:From; b=G5nQYSGgWL3xXlxmeOykrMY5qH5ndy2IEHdvW/ynZPxmlTGuPkr4Y3dgH5c3Xqi6b APMwheE2WSIWMDScPVcygx2+YmnDeaNCTmdUpoP+WC5F8z9Vy8Pc0MTe1w2FjMQMqo 6A1Q7O+1dbGU7w6ht0VK2Bfbroh48v+In/dKTsA4= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marek Polacek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4569] docs: Suggest options to improve ASAN stack traces X-Act-Checkin: gcc X-Git-Author: Marek Polacek X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 3a9f6d5a8ee490adf9a18f93feaf86542642be7d X-Git-Newrev: 6a07798c6bc602c355a546057187169f79872696 Message-Id: <20221208231538.1986B382EF37@sourceware.org> Date: Thu, 8 Dec 2022 23:15:38 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6a07798c6bc602c355a546057187169f79872696 commit r13-4569-g6a07798c6bc602c355a546057187169f79872696 Author: Marek Polacek Date: Wed Dec 7 15:27:27 2022 -0500 docs: Suggest options to improve ASAN stack traces I got a complaint that while Clang docs suggest options that improve the quality of the backtraces ASAN prints (cf. ), 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. Diff: --- gcc/doc/invoke.texi | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 726392409b6..3f2512ce16a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -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.