1 /* 2 * Copyright (C) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef FD_OUTPUT_H 16 #define FD_OUTPUT_H 17 18 #include <string> 19 #include <vector> 20 #include <mutex> 21 22 #include "common.h" 23 #include "common/dumper_parameter.h" 24 #include "hidumper_executor.h" 25 #include "raw_param.h" 26 27 #define HIDUMPER_DEBUG 28 #ifdef HIDUMPER_DEBUG 29 #define LOG_DEBUG_DUMP(format, ...) \ 30 do { \ 31 fprintf(stdout, "Debug:" format "\n", ##__VA_ARGS__); \ 32 } while (0) 33 #else 34 #define LOG_DEBUG(format, ...) 35 #endif 36 37 namespace OHOS { 38 namespace HiviewDFX { 39 class FDOutput : public HidumperExecutor { 40 public: 41 FDOutput(); 42 ~FDOutput(); 43 DumpStatus PreExecute(const std::shared_ptr<DumperParameter>& parameter, 44 StringMatrix dumpDatas) override; 45 DumpStatus Execute() override; 46 DumpStatus AfterExecute() override; 47 void OutMethod(); 48 void NewLineMethod(std::string &str); 49 50 private: 51 int fd_; 52 std::string path_; 53 StringMatrix dumpDatas_; 54 std::string dataStr_; 55 std::vector<std::string> lineData_; 56 std::shared_ptr<RawParam> ptrReqCtl_; 57 static const mode_t OPEN_ARGV; 58 std::mutex mutex_; 59 }; 60 } // namespace HiviewDFX 61 } // namespace OHOS 62 #endif // FD_OUTPUT_H 63