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 36 sources = [ 37 "dfx_hook_utils.c", 38 "dfx_signal_hook.c", 39 ] 40 41 deps = [ 42 "$faultloggerd_path/common/dfxlog:dfx_hilog_base", 43 "//third_party/libunwind:libunwind", 44 ] 45 46 external_deps = [ 47 "c_utils:utils", 48 "hilog:libhilog_base", 49 ] 50 51 part_name = "faultloggerd" 52 subsystem_name = "hiviewdfx" 53 } 54 55 ohos_shared_library("dfxexithook") { 56 public_configs = [ 57 ":dfx_sighook_config", 58 "$faultloggerd_path/common/build:coverage_flags", 59 ] 60 install_enable = true 61 62 sources = [ 63 "dfx_exit_hook.c", 64 "dfx_hook_utils.c", 65 ] 66 67 deps = [ 68 "$faultloggerd_path/common/dfxlog:dfx_hilog", 69 "//third_party/libunwind:libunwind", 70 ] 71 72 external_deps = [ 73 "c_utils:utils", 74 "hilog:libhilog", 75 ] 76 77 part_name = "faultloggerd" 78 subsystem_name = "hiviewdfx" 79 } 80 81 ohos_unittest("DfxFuncHookUnitTest") { 82 testonly = true 83 module_out_path = "faultloggerd/dfxfunchook" 84 sources = [ "dfx_func_hook_unittest.cpp" ] 85 86 configs = [ 87 ":dfx_sighook_config", 88 "$faultloggerd_path/common/build:coverage_flags", 89 ] 90 91 deps = [ 92 ":dfxexithook", 93 ":dfxsighook", 94 "//third_party/googletest:gtest_main", 95 ] 96 97 external_deps = [ "c_utils:utils" ] 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