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 DFX_SIGNAL_H 16 #define DFX_SIGNAL_H 17 18 #include <csignal> 19 #include <cstdint> 20 #include "iosfwd" 21 22 namespace OHOS { 23 namespace HiviewDFX { 24 class DfxSignal { 25 public: 26 explicit DfxSignal(const int32_t signal); ~DfxSignal()27 ~DfxSignal() {} 28 29 bool IsAvailable() const; 30 bool IsAddrAvailable() const; 31 bool IsPidAvailable() const; 32 int32_t GetSignal() const; 33 private: 34 int32_t signal_ = 0; 35 DfxSignal() = delete; 36 }; 37 38 std::string PrintSignal(const siginfo_t &info); 39 std::string FormatSignalName(const int32_t signal); 40 std::string FormatCodeName(const int32_t signal, const int32_t signalCode); 41 42 std::string FormatSIGBUSCodeName(const int32_t signalCode); 43 std::string FormatSIGILLCodeName(const int32_t signalCode); 44 std::string FormatSIGFPECodeName(const int32_t signalCode); 45 std::string FormatSIGSEGVCodeName(const int32_t signalCode); 46 std::string FormatSIGTRAPCodeName(const int32_t signalCode); 47 std::string FormatCommonSignalCodeName(const int32_t signalCode); 48 } // namespace Dfx 49 } // namespace OHOS 50 #endif 51