1# Copyright (c) 2021-2023 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 16processdump_sources = [ 17 "dfx_fault_stack.cpp", 18 "dfx_logger.cpp", 19 "dfx_process.cpp", 20 "dfx_ring_buffer_wrapper.cpp", 21 "dfx_stack_info_formatter.cpp", 22 "dfx_thread.cpp", 23 "process_dumper.cpp", 24] 25 26if (target_cpu == "x86_64") { 27 processdump_sources += [ 28 "$faultloggerd_frameworks_path/unwinder/dfx_config.cpp", 29 "$faultloggerd_frameworks_path/unwinder/dfx_elf.cpp", 30 "$faultloggerd_frameworks_path/unwinder/dfx_frame_format.cpp", 31 "$faultloggerd_frameworks_path/unwinder/dfx_maps.cpp", 32 "$faultloggerd_frameworks_path/unwinder/dfx_memory.cpp", 33 "$faultloggerd_frameworks_path/unwinder/dfx_memory_file.cpp", 34 "$faultloggerd_frameworks_path/unwinder/dfx_ptrace.cpp", 35 "$faultloggerd_frameworks_path/unwinder/dfx_regs.cpp", 36 "$faultloggerd_frameworks_path/unwinder/dfx_regs_arm.cpp", 37 "$faultloggerd_frameworks_path/unwinder/dfx_regs_arm64.cpp", 38 "$faultloggerd_frameworks_path/unwinder/dfx_regs_x86_64.cpp", 39 "$faultloggerd_frameworks_path/unwinder/dfx_signal.cpp", 40 "$faultloggerd_frameworks_path/unwinder/dfx_symbols.cpp", 41 "dfx_unwind_remote_emulator.cpp", 42 "printer_emulator.cpp", 43 ] 44} else { 45 processdump_sources += [ 46 "dfx_unwind_remote.cpp", 47 "printer.cpp", 48 ] 49} 50 51if (defined(ohos_lite)) { 52 config("processdump_config") { 53 visibility = [ "*:*" ] 54 cflags = [] 55 56 defines = [ 57 "HAVE_CONFIG_H", 58 "HAVE_ELF_H", 59 "HAVE_LINK_H", 60 "is_ohos_lite", 61 ] 62 63 include_dirs = [ 64 ".", 65 "$c_utils_include_path", 66 "$faultloggerd_common_path/dfxlog", 67 "$faultloggerd_common_path/dfxutil", 68 "$faultloggerd_interfaces_path/common", 69 "$faultloggerd_interfaces_path/innerkits/faultloggerd_client/include", 70 "$faultloggerd_interfaces_path/innerkits/procinfo/include", 71 "$faultloggerd_interfaces_path/innerkits/unwinder/include", 72 "$hilog_lite_include_path", 73 ] 74 } 75 76 source_set("process_info_src") { 77 sources = processdump_sources 78 public_configs = [ ":processdump_config" ] 79 80 deps = [ 81 "$faultloggerd_common_path/dfxlog:dfx_hilog", 82 "$faultloggerd_common_path/dfxutil:dfx_util", 83 "$faultloggerd_interfaces_path/innerkits/faultloggerd_client:libfaultloggerd", 84 "$faultloggerd_interfaces_path/innerkits/procinfo:libdfx_procinfo", 85 "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder", 86 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 87 ] 88 } 89 90 executable("processdump") { 91 sources = processdump_sources 92 sources += [ 93 "cppcrash_reporter.cpp", 94 "main.cpp", 95 ] 96 public_configs = [ ":processdump_config" ] 97 98 deps = [ 99 "$faultloggerd_common_path/dfxlog:dfx_hilog", 100 "$faultloggerd_common_path/dfxutil:dfx_util", 101 "$faultloggerd_interfaces_path/innerkits/faultloggerd_client:libfaultloggerd", 102 "$faultloggerd_interfaces_path/innerkits/procinfo:libdfx_procinfo", 103 "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder", 104 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 105 "//third_party/libunwind:libunwind", 106 ] 107 } 108} else { 109 config("processdump_config") { 110 visibility = [ ":*" ] 111 112 include_dirs = [ 113 ".", 114 "$faultloggerd_interfaces_path/common", 115 "$faultloggerd_interfaces_path/innerkits/procinfo/include", 116 "$faultloggerd_interfaces_path/innerkits/signal_handler", 117 "$faultloggerd_path/common", 118 ] 119 120 if (target_cpu == "x86_64") { 121 include_dirs += [ "$faultloggerd_frameworks_path/unwinder/include" ] 122 } else { 123 include_dirs += 124 [ "$faultloggerd_interfaces_path/innerkits/unwinder/include" ] 125 } 126 127 cflags_cc = [ "-DRUSTC_DEMANGLE" ] 128 129 if (processdump_minidebuginfo_enable) { 130 defines = [ "PROCESSDUMP_MINIDEBUGINFO" ] 131 } 132 133 if (enable_mixstack && target_cpu == "arm64") { 134 defines += [ "ENABLE_MIXSTACK" ] 135 } 136 } 137 138 ohos_source_set("process_info_src") { 139 sources = processdump_sources 140 configs = [ 141 ":processdump_config", 142 "$faultloggerd_common_path/build:coverage_flags", 143 "//third_party/jsoncpp:jsoncpp_public_config", 144 ] 145 146 deps = [ 147 "$faultloggerd_common_path/dfxlog:dfx_hilog", 148 "$faultloggerd_common_path/dfxutil:dfx_util", 149 "$faultloggerd_interfaces_path/innerkits/faultloggerd_client:libfaultloggerd", 150 "$faultloggerd_interfaces_path/innerkits/procinfo:libdfx_procinfo", 151 "//third_party/jsoncpp:jsoncpp", 152 ] 153 154 if (target_cpu == "x86_64") { 155 deps += [ "//third_party/libunwind:libunwind" ] 156 } else { 157 deps += [ "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder" ] 158 } 159 160 external_deps = [ 161 "c_utils:utils", 162 "hilog:libhilog", 163 ] 164 165 part_name = "faultloggerd" 166 subsystem_name = "hiviewdfx" 167 } 168 169 ohos_executable("processdump") { 170 install_enable = true 171 configs = [ 172 ":processdump_config", 173 "$faultloggerd_path/common/build:coverage_flags", 174 "//third_party/jsoncpp:jsoncpp_public_config", 175 ] 176 sources = processdump_sources 177 sources += [ 178 "cppcrash_reporter.cpp", 179 "main.cpp", 180 ] 181 182 cflags_cc = [ "-DDEBUG_CRASH_LOCAL_HANDLER" ] 183 184 deps = [ 185 "$faultloggerd_common_path/dfxlog:dfx_hilog_base", 186 "$faultloggerd_common_path/dfxutil:dfx_util", 187 "$faultloggerd_interfaces_path/innerkits/faultloggerd_client:libfaultloggerd", 188 "$faultloggerd_interfaces_path/innerkits/procinfo:libdfx_procinfo", 189 "$faultloggerd_interfaces_path/innerkits/signal_handler:dfx_local_handler", 190 "//third_party/jsoncpp:jsoncpp", 191 ] 192 193 if (target_cpu == "x86_64") { 194 deps += [ "//third_party/libunwind:libunwind" ] 195 } else { 196 deps += [ "$faultloggerd_interfaces_path/innerkits/unwinder:libunwinder" ] 197 } 198 199 external_deps = [ 200 "c_utils:utils", 201 "hilog:libhilog_base", 202 ] 203 204 install_images = [ 205 "system", 206 "updater", 207 ] 208 209 part_name = "faultloggerd" 210 subsystem_name = "hiviewdfx" 211 } 212} 213