@@ -137,6 +137,61 @@ class Symbolizer {
137
137
};
138
138
};
139
139
140
+ class ExternalSymbolizerInterface {
141
+ public:
142
+ // Can't declare pure virtual functions in sanitizer runtimes:
143
+ // __cxa_pure_virtual might be unavailable.
144
+ virtual char *SendCommand (bool is_data, const char *module_name,
145
+ uptr module_offset) {
146
+ UNIMPLEMENTED ();
147
+ }
148
+ };
149
+
150
+ // SymbolizerProcess encapsulates communication between the tool and
151
+ // external symbolizer program, running in a different subprocess.
152
+ // SymbolizerProcess may not be used from two threads simultaneously.
153
+ class SymbolizerProcess : public ExternalSymbolizerInterface {
154
+ public:
155
+ explicit SymbolizerProcess (const char *path);
156
+ char *SendCommand (bool is_data, const char *module_name,
157
+ uptr module_offset) override ;
158
+
159
+ private:
160
+ bool Restart ();
161
+ char *SendCommandImpl (bool is_data, const char *module_name,
162
+ uptr module_offset);
163
+ bool ReadFromSymbolizer (char *buffer, uptr max_length);
164
+ bool WriteToSymbolizer (const char *buffer, uptr length);
165
+ bool StartSymbolizerSubprocess ();
166
+
167
+ virtual bool RenderInputCommand (char *buffer, uptr max_length, bool is_data,
168
+ const char *module_name,
169
+ uptr module_offset) const {
170
+ UNIMPLEMENTED ();
171
+ }
172
+
173
+ virtual bool ReachedEndOfOutput (const char *buffer, uptr length) const {
174
+ UNIMPLEMENTED ();
175
+ }
176
+
177
+ virtual void ExecuteWithDefaultArgs (const char *path_to_binary) const {
178
+ UNIMPLEMENTED ();
179
+ }
180
+
181
+ const char *path_;
182
+ int input_fd_;
183
+ int output_fd_;
184
+
185
+ static const uptr kBufferSize = 16 * 1024 ;
186
+ char buffer_[kBufferSize ];
187
+
188
+ static const uptr kMaxTimesRestarted = 5 ;
189
+ static const int kSymbolizerStartupTimeMillis = 10 ;
190
+ uptr times_restarted_;
191
+ bool failed_to_start_;
192
+ bool reported_invalid_path_;
193
+ };
194
+
140
195
} // namespace __sanitizer
141
196
142
197
#endif // SANITIZER_SYMBOLIZER_H
0 commit comments