[compiler-rt] [symbolizer] Don't threat symbolizer API as optional (PR #76103)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 20 13:43:01 PST 2023
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/76103
There is an assumption that we dont need to to mix sanitizer with
symbolizer from different LLVM revison. If so we can detect it by
`__sanitizer_symbolize_code` and assume that the rest is present.
>From 85edda91a2c476fc44b90f6f96decae92102c66a Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Wed, 20 Dec 2023 13:42:52 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
---
.../sanitizer_symbolizer_posix_libcdep.cpp | 23 ++++++++-----------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
index 28f11352a6b5bb..3b61eb42993ec9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
@@ -341,15 +341,14 @@ __sanitizer_symbolize_set_inline_frames(bool InlineFrames);
class InternalSymbolizer final : public SymbolizerTool {
public:
static InternalSymbolizer *get(LowLevelAllocator *alloc) {
- if (&__sanitizer_symbolize_set_demangle)
- CHECK(__sanitizer_symbolize_set_demangle(common_flags()->demangle));
- if (&__sanitizer_symbolize_set_inline_frames)
- CHECK(__sanitizer_symbolize_set_inline_frames(
+ // These one is the most used one, so we will use it to detect a presense of
+ // internal symbolizer.
+ if (&__sanitizer_symbolize_code == nullptr)
+ return nullptr;
+ CHECK(__sanitizer_symbolize_set_demangle(common_flags()->demangle));
+ CHECK(__sanitizer_symbolize_set_inline_frames(
common_flags()->symbolize_inline_frames));
- // These are essential, we don't have InternalSymbolizer without them.
- if (&__sanitizer_symbolize_code && &__sanitizer_symbolize_data)
- return new (*alloc) InternalSymbolizer();
- return 0;
+ return new (*alloc) InternalSymbolizer();
}
bool SymbolizePC(uptr addr, SymbolizedStack *stack) override {
@@ -371,8 +370,6 @@ class InternalSymbolizer final : public SymbolizerTool {
}
bool SymbolizeFrame(uptr addr, FrameInfo *info) override {
- if (&__sanitizer_symbolize_frame == nullptr)
- return false;
bool result = __sanitizer_symbolize_frame(info->module, info->module_offset,
buffer_, sizeof(buffer_));
if (result)
@@ -381,13 +378,11 @@ class InternalSymbolizer final : public SymbolizerTool {
}
void Flush() override {
- if (&__sanitizer_symbolize_flush)
- __sanitizer_symbolize_flush();
+ __sanitizer_symbolize_flush();
}
const char *Demangle(const char *name) override {
- if (&__sanitizer_symbolize_demangle &&
- __sanitizer_symbolize_demangle(name, buffer_, sizeof(buffer_))) {
+ if (__sanitizer_symbolize_demangle(name, buffer_, sizeof(buffer_))) {
char *res_buff = nullptr;
ExtractToken(buffer_, "", &res_buff);
return res_buff;
More information about the llvm-commits
mailing list