1 2 /* 3 * Copyright (C) 2020 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #ifndef SRC_PROFILING_SYMBOLIZER_SUBPROCESS_H_ 19 #define SRC_PROFILING_SYMBOLIZER_SUBPROCESS_H_ 20 21 #include <string> 22 #include <vector> 23 24 #include "perfetto/base/build_config.h" 25 26 #if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) 27 #include <sys/types.h> 28 #include <unistd.h> 29 #include "perfetto/ext/base/pipe.h" 30 #endif 31 32 namespace perfetto { 33 namespace profiling { 34 35 class Subprocess { 36 public: 37 Subprocess(const std::string& file, std::vector<std::string> args); 38 ~Subprocess(); 39 40 int64_t Write(const char* buffer, size_t size); 41 int64_t Read(char* buffer, size_t size); 42 43 private: 44 #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) 45 void* child_pipe_in_read_ = nullptr; 46 void* child_pipe_in_write_ = nullptr; 47 void* child_pipe_out_read_ = nullptr; 48 void* child_pipe_out_write_ = nullptr; 49 #else 50 base::Pipe input_pipe_; 51 base::Pipe output_pipe_; 52 53 pid_t pid_ = -1; 54 #endif 55 }; 56 57 } // namespace profiling 58 } // namespace perfetto 59 60 #endif // SRC_PROFILING_SYMBOLIZER_SUBPROCESS_H_ 61