public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/112708] "gcc -fsanitize=address" produces wrong debug info for variables in function prologue Date: Mon, 27 Nov 2023 10:29:10 +0000 [thread overview] Message-ID: <bug-112708-4-oflj2vFdRV@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-112708-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112708 --- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Bruno Haible from comment #8) > (In reply to Richard Biener from comment #7) > > It's -fvar-tracking, not -fvar-tracking-assignments. At -O0 debug info > > during the prologue is unreliable without that. > > Then how about enabling -fvar-tracking automatically when "-g" or "-ggdb" is > requested and the debug format supports it? There are major problems with that. var-tracking is very compile time intensive, so it would significantly slow down -O0 compilation. And, most of the time at -O0 variables live in their memory slots, so that var-tracking time would be also wasted. The only things which need var-tracking at -O0 are: 1) register variables (or whatever else doesn't get an allocated stack slot) 2) variables at the start and end of their lifetime, where they are not yet in their stack slot or no longer in them (so, often function prologues and epilogues, or say for VLAs before everything is set up etc.) So, as written in other PRs, for -O0 we'd likely want to invent some cheaper var-tracking variant which would only track the above 2 and not waste time on the rest. > The documentation > https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Debugging-Options.html says: > "It is enabled by default when compiling with optimization (-Os, -O, -O2, > …), debugging information (-g) and the debug info format supports it." > > Why not also enable it when compiling _without_ optimization? > > I'm not using "-Og" because the documentation > https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Optimize-Options.html says > "-Og enables all -O1 optimization flags except for those that may interfere > with debugging", but what I want is optimal debugging and don't want to > spend CPU cycles on optimization. As for -Og, -Og doesn't perform too many optimizations and in function prologues code is usually better debuggable than with -O0. But there is one major obstackle also recorded in various PRs, we don't artificially make all vars used at the end of their scope, which means that if some var is unused after certain point in a function, it might no longer be available and e.g. DWARF5 DW_OP_entry_value used as the last resort; but that doesn't work always. For the -fsanitize=address case, the thing is that the marking of end of prologue is something we do during function prologue generation in pro_and_epilogue (or debugger does that from scanning the function IL). While the asan "prologue" is something emitted during RTL expansion and so for pro_and_epilogue seen as part of function body.
next prev parent reply other threads:[~2023-11-27 10:29 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-11-25 4:35 [Bug sanitizer/112708] New: " bruno at clisp dot org 2023-11-25 4:54 ` [Bug sanitizer/112708] " pinskia at gcc dot gnu.org 2023-11-25 4:54 ` pinskia at gcc dot gnu.org 2023-11-25 4:56 ` pinskia at gcc dot gnu.org 2023-11-25 5:50 ` bruno at clisp dot org 2023-11-25 6:22 ` bruno at clisp dot org 2023-11-26 2:08 ` bruno at clisp dot org 2023-11-27 8:04 ` rguenth at gcc dot gnu.org 2023-11-27 10:07 ` bruno at clisp dot org 2023-11-27 10:29 ` jakub at gcc dot gnu.org [this message] 2023-11-28 1:03 ` bruno at clisp dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-112708-4-oflj2vFdRV@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).