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_interfaces_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 defines = [ "DFX_LOG_HILOG_BASE" ] 36 37 sources = [ 38 "dfx_hook_utils.c", 39 "dfx_signal_hook.c", 40 ] 41 42 deps = [ "$faultloggerd_path/common/dfxlog:dfx_hilog_base" ] 43 44 external_deps = [ 45 "c_utils:utils", 46 "hilog:libhilog_base", 47 "libunwind:libunwind", 48 ] 49 50 part_name = "faultloggerd" 51 subsystem_name = "hiviewdfx" 52 } 53 54 ohos_shared_library("dfxexithook") { 55 public_configs = [ 56 ":dfx_sighook_config", 57 "$faultloggerd_path/common/build:coverage_flags", 58 ] 59 install_enable = true 60 defines = [ "DFX_LOG_HILOG_BASE" ] 61 62 sources = [ 63 "dfx_exit_hook.c", 64 "dfx_hook_utils.c", 65 ] 66 67 deps = [ "$faultloggerd_path/common/dfxlog:dfx_hilog_base" ] 68 69 external_deps = [ 70 "c_utils:utils", 71 "hilog:libhilog_base", 72 "libunwind:libunwind", 73 ] 74 75 part_name = "faultloggerd" 76 subsystem_name = "hiviewdfx" 77 } 78 79 ohos_unittest("DfxFuncHookUnitTest") { 80 testonly = true 81 module_out_path = "faultloggerd/dfxfunchook" 82 sources = [ "dfx_func_hook_unittest.cpp" ] 83 84 configs = [ 85 ":dfx_sighook_config", 86 "$faultloggerd_path/common/build:coverage_flags", 87 ] 88 89 deps = [ 90 ":dfxexithook", 91 ":dfxsighook", 92 ] 93 94 external_deps = [ 95 "c_utils:utils", 96 "googletest:gtest_main", 97 ] 98 99 if (use_musl) { 100 resource_config_file = 101 "//base/hiviewdfx/faultloggerd/test/funchook/ohos_test.xml" 102 } else { 103 resource_config_file = 104 "//base/hiviewdfx/faultloggerd/test/funchook/ohos_bionic_test.xml" 105 } 106 107 part_name = "faultloggerd" 108 subsystem_name = "hiviewdfx" 109 } 110} 111 112group("dfxfunchook") { 113 if (!defined(ohos_lite)) { 114 testonly = true 115 deps = [ ":DfxFuncHookUnitTest" ] 116 } 117} 118