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 #ifndef FAULTLOG_CPPCRASH_H 16 #define FAULTLOG_CPPCRASH_H 17 18 #include <string> 19 20 #include "faultlog_info.h" 21 #include "faultlog_manager.h" 22 #include "faultlog_processor_base.h" 23 #include "json/json.h" 24 25 namespace OHOS { 26 namespace HiviewDFX { 27 class FaultLogCppCrash : public FaultLogProcessorBase { 28 private: 29 bool ReportEventToAppEvent(const FaultLogInfo& info) override; 30 void AddSpecificInfo(FaultLogInfo& info) override; 31 void DoFaultLogLimit(const std::string& logPath, int32_t faultType) const override; 32 void ReportCppCrashToAppEvent(const FaultLogInfo& info) const; 33 std::string GetStackInfo(const FaultLogInfo& info) const; 34 void AddCppCrashInfo(FaultLogInfo& info); 35 void CheckFaultLogAsync(const FaultLogInfo& info); 36 static bool CheckFaultLog(const FaultLogInfo& info); 37 std::string ReadStackFromPipe(const FaultLogInfo& info) const; 38 Json::Value FillStackInfo(const FaultLogInfo& info, std::string& stackInfoOriginal) const; 39 bool TruncateLogIfExceedsLimit(std::string& readContent) const; 40 bool RemoveHiLogSection(std::string& readContent) const; 41 int64_t GetLastLineHilogTime(const std::string& lastLineHilog) const; 42 void CheckHilogTime(FaultLogInfo& info); 43 }; 44 } // namespace HiviewDFX 45 } // namespace OHOS 46 #endif 47