From 8f12ce082508a700c463f186da67a36cfea7d568 Mon Sep 17 00:00:00 2001 From: Kuba Brecka Date: Wed, 25 Feb 2015 19:50:38 +0000 Subject: [compiler-rt] Symbolizer refactoring: Move SymbolizerProcess interface to header Reviewed at http://reviews.llvm.org/D7868 llvm-svn: 230530 --- .../lib/sanitizer_common/sanitizer_symbolizer.h | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h') diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h index 3ccfce9995b..3a807744d98 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h @@ -137,6 +137,61 @@ class Symbolizer { }; }; +class ExternalSymbolizerInterface { + public: + // Can't declare pure virtual functions in sanitizer runtimes: + // __cxa_pure_virtual might be unavailable. + virtual char *SendCommand(bool is_data, const char *module_name, + uptr module_offset) { + UNIMPLEMENTED(); + } +}; + +// SymbolizerProcess encapsulates communication between the tool and +// external symbolizer program, running in a different subprocess. +// SymbolizerProcess may not be used from two threads simultaneously. +class SymbolizerProcess : public ExternalSymbolizerInterface { + public: + explicit SymbolizerProcess(const char *path); + char *SendCommand(bool is_data, const char *module_name, + uptr module_offset) override; + + private: + bool Restart(); + char *SendCommandImpl(bool is_data, const char *module_name, + uptr module_offset); + bool ReadFromSymbolizer(char *buffer, uptr max_length); + bool WriteToSymbolizer(const char *buffer, uptr length); + bool StartSymbolizerSubprocess(); + + virtual bool RenderInputCommand(char *buffer, uptr max_length, bool is_data, + const char *module_name, + uptr module_offset) const { + UNIMPLEMENTED(); + } + + virtual bool ReachedEndOfOutput(const char *buffer, uptr length) const { + UNIMPLEMENTED(); + } + + virtual void ExecuteWithDefaultArgs(const char *path_to_binary) const { + UNIMPLEMENTED(); + } + + const char *path_; + int input_fd_; + int output_fd_; + + static const uptr kBufferSize = 16 * 1024; + char buffer_[kBufferSize]; + + static const uptr kMaxTimesRestarted = 5; + static const int kSymbolizerStartupTimeMillis = 10; + uptr times_restarted_; + bool failed_to_start_; + bool reported_invalid_path_; +}; + } // namespace __sanitizer #endif // SANITIZER_SYMBOLIZER_H -- cgit v1.2.3