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 21 #include "common.h" 22 #include "common/dumper_parameter.h" 23 #include "hidumper_executor.h" 24 #include "raw_param.h" 25 26 #define HIDUMPER_DEBUG 27 #ifdef HIDUMPER_DEBUG 28 #define LOG_DEBUG_DUMP(format, ...) \ 29 do { \ 30 fprintf(stdout, "Debug:" format "\n", ##__VA_ARGS__); \ 31 } while (0) 32 #else 33 #define LOG_DEBUG(format, ...) 34 #endif 35 36 namespace OHOS { 37 namespace HiviewDFX { 38 class FDOutput : public HidumperExecutor { 39 public: 40 FDOutput(); 41 ~FDOutput(); 42 DumpStatus PreExecute(const std::shared_ptr<DumperParameter>& parameter, 43 StringMatrix dumpDatas) override; 44 DumpStatus Execute() override; 45 DumpStatus AfterExecute() override; 46 void OutMethod(); 47 void NewLineMethod(std::string &str); 48 49 private: 50 int fd_; 51 std::string path_; 52 StringMatrix dumpDatas_; 53 std::string dataStr_; 54 std::vector<std::string> lineData_; 55 std::shared_ptr<RawParam> ptrReqCtl_; 56 static const mode_t OPEN_ARGV; 57 }; 58 } // namespace HiviewDFX 59 } // namespace OHOS 60 #endif // FD_OUTPUT_H 61