1# Copyright (c) 2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//base/hiviewdfx/faultloggerd/faultloggerd.gni") 15 16if (!defined(ohos_lite)) { 17 import("//build/config/features.gni") 18 import("//build/test.gni") 19 20 config("dfx_sighook_config") { 21 visibility = [ "*:*" ] 22 23 include_dirs = [ 24 ".", 25 "$faultloggerd_path/common", 26 ] 27 } 28 29 ohos_shared_library("dfxsighook") { 30 public_configs = [ 31 ":dfx_sighook_config", 32 "$faultloggerd_path/common/build:coverage_flags", 33 ] 34 install_enable = true 35 36 cflags = [ 37 "-DDFX_LOG_USE_HILOG_BASE", 38 "-DDFX_LOG_USE_DMESG", 39 ] 40 41 sources = [ 42 "dfx_hook_utils.c", 43 "dfx_signal_hook.c", 44 ] 45 46 deps = [ 47 "$faultloggerd_path/common/dfxlog:static_hilog_base_dmesg", 48 "//third_party/libunwind:libunwind", 49 ] 50 51 external_deps = [ 52 "c_utils:utils", 53 "hilog:libhilog_base", 54 ] 55 56 part_name = "faultloggerd" 57 subsystem_name = "hiviewdfx" 58 } 59 60 ohos_shared_library("dfxexithook") { 61 public_configs = [ 62 ":dfx_sighook_config", 63 "$faultloggerd_path/common/build:coverage_flags", 64 ] 65 install_enable = true 66 67 cflags = [ "-DDFX_LOG_USE_DMESG" ] 68 69 sources = [ 70 "dfx_exit_hook.c", 71 "dfx_hook_utils.c", 72 ] 73 74 deps = [ 75 "$faultloggerd_path/common/dfxlog:static_common_log", 76 "//third_party/libunwind:libunwind", 77 ] 78 79 external_deps = [ 80 "c_utils:utils", 81 "hilog:libhilog", 82 ] 83 84 part_name = "faultloggerd" 85 subsystem_name = "hiviewdfx" 86 } 87 88 ohos_unittest("DfxFuncHookUnitTest") { 89 testonly = true 90 module_out_path = "faultloggerd/dfxfunchook" 91 sources = [ "dfx_func_hook_unittest.cpp" ] 92 93 configs = [ 94 ":dfx_sighook_config", 95 "$faultloggerd_path/common/build:coverage_flags", 96 ] 97 98 deps = [ 99 ":dfxexithook", 100 ":dfxsighook", 101 "//third_party/googletest:gtest_main", 102 ] 103 104 external_deps = [ "c_utils:utils" ] 105 if (use_musl) { 106 resource_config_file = 107 "//base/hiviewdfx/faultloggerd/test/funchook/ohos_test.xml" 108 } else { 109 resource_config_file = 110 "//base/hiviewdfx/faultloggerd/test/funchook/ohos_bionic_test.xml" 111 } 112 113 part_name = "faultloggerd" 114 subsystem_name = "hiviewdfx" 115 } 116} 117 118group("dfxfunchook_unittest") { 119 if (!defined(ohos_lite)) { 120 testonly = true 121 deps = [ ":DfxFuncHookUnitTest" ] 122 } 123} 124