public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6317] libsanitizer: cherry-pick commit 8f5962b1ccb5fcd4d4544121d43efb860ac3cc6d from upstream Date: Fri, 24 Feb 2023 08:20:41 +0000 (GMT) [thread overview] Message-ID: <20230224082041.EC183385B51F@sourceware.org> (raw) https://gcc.gnu.org/g:cab2636174feaec4f12fb8a2d09b1f8dd3bcdf3c commit r13-6317-gcab2636174feaec4f12fb8a2d09b1f8dd3bcdf3c Author: Martin Liska <mliska@suse.cz> Date: Fri Feb 24 09:14:40 2023 +0100 libsanitizer: cherry-pick commit 8f5962b1ccb5fcd4d4544121d43efb860ac3cc6d from upstream ASAN: keep support for Global::location We as GCC still emit __asan_global_source_location for global variables and we would like to use it in the future. On other hand, we don't support llvm-symbolizer and the default libbacktraace symbolizer does not support location info. Diff: --- libsanitizer/asan/asan_globals.cpp | 9 +++++++++ libsanitizer/asan/asan_interface_internal.h | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libsanitizer/asan/asan_globals.cpp b/libsanitizer/asan/asan_globals.cpp index 8f3491f0199..01a243927ca 100644 --- a/libsanitizer/asan/asan_globals.cpp +++ b/libsanitizer/asan/asan_globals.cpp @@ -92,6 +92,10 @@ static void ReportGlobal(const Global &g, const char *prefix) { if (info.line != 0) { Report(" location: name=%s, %d\n", info.file, static_cast<int>(info.line)); } + else if (g.gcc_location != 0) { + // Fallback to Global::gcc_location + Report(" location: name=%s, %d\n", g.gcc_location->filename, g.gcc_location->line_no); + } } static u32 FindRegistrationSite(const Global *g) { @@ -283,6 +287,11 @@ void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g) { if (info.line != 0) { str->append("%s:%d", info.file, static_cast<int>(info.line)); + } else if (g.gcc_location != 0) { + // Fallback to Global::gcc_location + str->append("%s", g.gcc_location->filename ? g.gcc_location->filename : g.module_name); + if (g.gcc_location->line_no) str->append(":%d", g.gcc_location->line_no); + if (g.gcc_location->column_no) str->append(":%d", g.gcc_location->column_no); } else { str->append("%s", g.module_name); } diff --git a/libsanitizer/asan/asan_interface_internal.h b/libsanitizer/asan/asan_interface_internal.h index 987f855c0f9..a9982637802 100644 --- a/libsanitizer/asan/asan_interface_internal.h +++ b/libsanitizer/asan/asan_interface_internal.h @@ -53,9 +53,10 @@ extern "C" { const char *module_name; // Module name as a C string. This pointer is a // unique identifier of a module. uptr has_dynamic_init; // Non-zero if the global has dynamic initializer. - uptr windows_padding; // TODO: Figure out how to remove this padding - // that's simply here to make the MSVC incremental - // linker happy... + __asan_global_source_location *gcc_location; // Source location of a global, + // used by GCC compiler. LLVM uses + // llvm-symbolizer that relies + // on DWARF debugging info. uptr odr_indicator; // The address of the ODR indicator symbol. };
reply other threads:[~2023-02-24 8:20 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230224082041.EC183385B51F@sourceware.org \ --to=marxin@gcc.gnu.org \ --cc=gcc-cvs@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).