[PATCH] D78178: [NFC] Introduce a `LateInitialize()` method to `SymbolizerTool` that is called during the LateInitialize stage of the sanitizer runtimes.
Dan Liew via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 16 13:23:37 PDT 2020
delcypher updated this revision to Diff 258150.
delcypher added a comment.
- `Symbolizer::LateInitializeTools()` should be private.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78178/new/
https://reviews.llvm.org/D78178
Files:
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
Index: compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
@@ -310,7 +310,7 @@
}
void Symbolizer::LateInitialize() {
- Symbolizer::GetOrInit();
+ Symbolizer::GetOrInit()->LateInitializeTools();
}
} // namespace __sanitizer
Index: compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
@@ -488,7 +488,7 @@
}
void Symbolizer::LateInitialize() {
- Symbolizer::GetOrInit();
+ Symbolizer::GetOrInit()->LateInitializeTools();
InitializeSwiftDemangler();
}
Index: compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
@@ -94,7 +94,9 @@
return new (symbolizer_allocator_) Symbolizer({});
}
-void Symbolizer::LateInitialize() { Symbolizer::GetOrInit(); }
+void Symbolizer::LateInitialize() {
+ Symbolizer::GetOrInit()->LateInitializeTools();
+}
void StartReportDeadlySignal() {}
void ReportDeadlySignal(const SignalContext &sig, u32 tid,
Index: compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
+++ compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
@@ -69,6 +69,11 @@
virtual const char *Demangle(const char *name) {
return nullptr;
}
+
+ // Called during the LateInitialize phase of Sanitizer initialization.
+ // Usually this is a safe to call code that might need to use user memory
+ // allocators.
+ virtual void LateInitialize() {}
};
// SymbolizerProcess encapsulates communication between the tool and
Index: compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
+++ compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
@@ -209,6 +209,9 @@
private:
const Symbolizer *sym_;
};
+
+ // Calls `LateInitialize()` on all `SymbolizerTool` in `tools_`.
+ void LateInitializeTools();
};
#ifdef SANITIZER_WINDOWS
Index: compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.cpp
@@ -126,4 +126,10 @@
sym_->end_hook_();
}
+void Symbolizer::LateInitializeTools() {
+ for (auto &tool : tools_) {
+ tool.LateInitialize();
+ }
+}
+
} // namespace __sanitizer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78178.258150.patch
Type: text/x-patch
Size: 3084 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200416/bf9f6628/attachment-0001.bin>
More information about the llvm-commits
mailing list