summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
diff options
context:
space:
mode:
authorKuba Brecka <kuba.brecka@gmail.com>2015-02-25 19:50:38 +0000
committerKuba Brecka <kuba.brecka@gmail.com>2015-02-25 19:50:38 +0000
commit8f12ce082508a700c463f186da67a36cfea7d568 (patch)
tree49477dbaa372a8ff2ed71f76f9d4bb80f32f8632 /compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
parentd831a73b3260bfa3e563e240381ad0fdcd806ac6 (diff)
downloadbcm5719-llvm-8f12ce082508a700c463f186da67a36cfea7d568.tar.gz
bcm5719-llvm-8f12ce082508a700c463f186da67a36cfea7d568.zip
[compiler-rt] Symbolizer refactoring: Move SymbolizerProcess interface to header
Reviewed at http://reviews.llvm.org/D7868 llvm-svn: 230530
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h55
1 files changed, 55 insertions, 0 deletions
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
OpenPOWER on IntegriCloud