[compiler-rt] r234690 - [Sanitizer] Merge POSIXSymbolizer and WinSymbolizer
Kuba Brecka
kuba.brecka at gmail.com
Sat Apr 11 10:16:25 PDT 2015
Author: kuba.brecka
Date: Sat Apr 11 12:16:25 2015
New Revision: 234690
URL: http://llvm.org/viewvc/llvm-project?rev=234690&view=rev
Log:
[Sanitizer] Merge POSIXSymbolizer and WinSymbolizer
The two subclasses of Symbolizer now only define two virtual functions, PlatformDemangle and PlatformPrepareForSandboxing. Let's make these non-virtual and directly defined by individual platforms.
Reviewed at http://reviews.llvm.org/D8912
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_win.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h?rev=234690&r1=234689&r2=234690&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h Sat Apr 11 12:16:25 2015
@@ -75,7 +75,7 @@ struct DataInfo {
class SymbolizerTool;
-class Symbolizer {
+class Symbolizer final {
public:
/// Initialize and return platform-specific implementation of symbolizer
/// (if it wasn't already initialized).
@@ -146,8 +146,8 @@ class Symbolizer {
bool modules_fresh_;
// Platform-specific default demangler, must not return nullptr.
- virtual const char *PlatformDemangle(const char *name) { UNIMPLEMENTED(); }
- virtual void PlatformPrepareForSandboxing() { UNIMPLEMENTED(); }
+ const char *PlatformDemangle(const char *name);
+ void PlatformPrepareForSandboxing();
static Symbolizer *symbolizer_;
static StaticSpinMutex init_mu_;
@@ -160,7 +160,6 @@ class Symbolizer {
typedef IntrusiveList<SymbolizerTool>::Iterator Iterator;
IntrusiveList<SymbolizerTool> tools_;
- protected:
explicit Symbolizer(IntrusiveList<SymbolizerTool> tools);
static LowLevelAllocator symbolizer_allocator_;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc?rev=234690&r1=234689&r2=234690&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc Sat Apr 11 12:16:25 2015
@@ -349,23 +349,16 @@ class InternalSymbolizer : public Symbol
#endif // SANITIZER_SUPPORTS_WEAK_HOOKS
-class POSIXSymbolizer : public Symbolizer {
- public:
- explicit POSIXSymbolizer(IntrusiveList<SymbolizerTool> tools)
- : Symbolizer(tools) {}
-
- private:
- const char *PlatformDemangle(const char *name) override {
- return DemangleCXXABI(name);
- }
+const char *Symbolizer::PlatformDemangle(const char *name) {
+ return DemangleCXXABI(name);
+}
- void PlatformPrepareForSandboxing() override {
+void Symbolizer::PlatformPrepareForSandboxing() {
#if SANITIZER_LINUX && !SANITIZER_ANDROID
- // Cache /proc/self/exe on Linux.
- CacheBinaryName();
+ // Cache /proc/self/exe on Linux.
+ CacheBinaryName();
#endif
- }
-};
+}
static SymbolizerTool *ChooseExternalSymbolizer(LowLevelAllocator *allocator) {
const char *path = common_flags()->external_symbolizer_path;
@@ -448,7 +441,7 @@ Symbolizer *Symbolizer::PlatformInit() {
IntrusiveList<SymbolizerTool> list;
list.clear();
ChooseSymbolizerTools(&list, &symbolizer_allocator_);
- return new(symbolizer_allocator_) POSIXSymbolizer(list);
+ return new(symbolizer_allocator_) Symbolizer(list);
}
} // namespace __sanitizer
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_win.cc?rev=234690&r1=234689&r2=234690&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_win.cc Sat Apr 11 12:16:25 2015
@@ -129,22 +129,19 @@ const char *WinSymbolizerTool::Demangle(
return name;
}
-// TODO(kuba.brecka): To be merged with POSIXSymbolizer.
-class WinSymbolizer : public Symbolizer {
- public:
- explicit WinSymbolizer(IntrusiveList<SymbolizerTool> tools)
- : Symbolizer(tools) {}
+const char *Symbolizer::PlatformDemangle(const char *name) {
+ return name;
+}
- private:
- const char *PlatformDemangle(const char *name) override { return name; }
- void PlatformPrepareForSandboxing() override { }
-};
+void Symbolizer::PlatformPrepareForSandboxing() {
+ // Do nothing.
+}
Symbolizer *Symbolizer::PlatformInit() {
IntrusiveList<SymbolizerTool> list;
list.clear();
list.push_back(new(symbolizer_allocator_) WinSymbolizerTool());
- return new(symbolizer_allocator_) WinSymbolizer(list);
+ return new(symbolizer_allocator_) Symbolizer(list);
}
} // namespace __sanitizer
More information about the llvm-commits
mailing list