1 /* 2 * Copyright (c) 2025 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 16 #ifndef REPORTER_H 17 #define REPORTER_H 18 19 #include <memory> 20 #include <string> 21 #include "dfx_dump_request.h" 22 #include "dfx_process.h" 23 #include "smart_fd.h" 24 25 namespace OHOS { 26 namespace HiviewDFX { 27 class Reporter { 28 public: 29 virtual ~Reporter() = default; 30 virtual void Report(DfxProcess& process, const ProcessDumpRequest &request) = 0; 31 }; 32 33 class SysEventReporter { 34 public: 35 explicit SysEventReporter(const ProcessDumpType& processDumpType); 36 void Report(DfxProcess& process, const ProcessDumpRequest &request); 37 private: 38 std::shared_ptr<Reporter> reporter_ = nullptr; 39 }; 40 41 class CppCrashReporter : public Reporter { 42 public: 43 void Report(DfxProcess& process, const ProcessDumpRequest &request); 44 private: 45 void ReportToHiview(DfxProcess& process, const ProcessDumpRequest &request); 46 void ReportToAbilityManagerService(const DfxProcess& process); 47 std::string GetRegsString(std::shared_ptr<DfxRegs> regs); 48 SmartFd TranferCrashInfoToHiview(const std::string& cppCrashInfo); 49 std::string GetSummary(DfxProcess& process); 50 }; 51 52 class AddrSanitizerReporter : public Reporter { 53 public: 54 void Report(DfxProcess& process, const ProcessDumpRequest &request); 55 }; 56 } // namespace HiviewDFX 57 } // namespace OHOS 58 #endif 59