1 /* 2 * Copyright (c) 2023 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 SANITIZERD_REPORTER_H 17 #define SANITIZERD_REPORTER_H 18 #include <map> 19 #include <string> 20 21 constexpr static unsigned MAX_SANITIZERD_TYPE = 20; 22 23 namespace OHOS { 24 namespace HiviewDFX { 25 enum SanitizerdType { 26 ASAN_LOG_RPT, 27 KASAN_LOG_RPT, 28 UBSAN_LOG_RPT, 29 LSAN_LOG_RPT, 30 MAX_LOG_RPT 31 }; 32 enum FieldTypeOfSanitizerd { 33 ORISANITIZERTYPE, 34 HISYSEVENTTYPE, 35 PREFIXFILENAME, 36 MAX_FIELD_TYPE 37 }; 38 39 /** 40 * {"match origin sanitizer", "match hisysevent", "match prefix of filename"}, 41 */ 42 const char SANITIZERD_TYPE_STR[][MAX_FIELD_TYPE][MAX_SANITIZERD_TYPE] = { 43 {"AddressSanitizer", "ADDR_SANITIZER", "asan"}, 44 {"KASAN", "KERN_ADDR_SANITIZER", "kasan"}, 45 {"UBSAN", "UND_SANITIZER", "ubsan"}, 46 {"LeakSanitizer", "LEAK_SANITIZER", "leak"}, 47 }; 48 49 using T_SANITIZERD_PARAMS = struct { 50 SanitizerdType type; 51 std::string hash; 52 int32_t pid; 53 int32_t uid; 54 std::string procName; 55 std::string appVersion; 56 std::string errType; 57 std::string errTypeInShort; 58 std::string logName; 59 std::string description; 60 uint64_t happenTime; 61 std::string func; 62 }; 63 64 void Upload(T_SANITIZERD_PARAMS *params); 65 int Init(SanitizerdType type); 66 } // namespace HiviewDFX 67 } // namespace OHOS 68 69 #endif // SANITIZERD_REPORTER_H 70 71