From 758f6da687b825112f493e7f6086c9d6f1853daf Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Thu, 25 Jul 2019 00:19:02 +0000 Subject: [PATCH] [sanitizer_common] Allow customization of StartSymbolizerSubprocess Summary: Make SymbolizerProcess::StartSymbolizerSubprocess virtual and protected to allow subclasses to customize it via "override and call". Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D65252 llvm-svn: 366967 --- .../lib/sanitizer_common/sanitizer_symbolizer_internal.h | 15 ++++++++------- .../lib/sanitizer_common/sanitizer_symbolizer_mac.cc | 5 +++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h index 4611b7d..3031f28 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h @@ -80,26 +80,27 @@ class SymbolizerProcess { const char *SendCommand(const char *command); protected: + /// The maximum number of arguments required to invoke a tool process. + static const unsigned kArgVMax = 6; + + // Customizable by subclasses. + virtual bool StartSymbolizerSubprocess(); + virtual bool ReadFromSymbolizer(char *buffer, uptr max_length); + + private: virtual bool ReachedEndOfOutput(const char *buffer, uptr length) const { UNIMPLEMENTED(); } - /// The maximum number of arguments required to invoke a tool process. - enum { kArgVMax = 6 }; - /// Fill in an argv array to invoke the child process. virtual void GetArgV(const char *path_to_binary, const char *(&argv)[kArgVMax]) const { UNIMPLEMENTED(); } - virtual bool ReadFromSymbolizer(char *buffer, uptr max_length); - - private: bool Restart(); const char *SendCommandImpl(const char *command); bool WriteToSymbolizer(const char *buffer, uptr length); - bool StartSymbolizerSubprocess(); const char *path_; fd_t input_fd_; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cc index d356657..0ece4cf 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cc @@ -57,6 +57,11 @@ class AtosSymbolizerProcess : public SymbolizerProcess { } private: + virtual bool StartSymbolizerSubprocess() override { + // Configure sandbox before starting atos process. + return SymbolizerProcess::StartSymbolizerSubprocess(); + } + bool ReachedEndOfOutput(const char *buffer, uptr length) const override { return (length >= 1 && buffer[length - 1] == '\n'); } -- 2.7.4