• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2023-2024 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
16dfx_unwinder_sources = [
17  "arch_util.cpp",
18  "dfx_accessors.cpp",
19  "dfx_ark.cpp",
20  "dfx_config.cpp",
21  "dfx_elf.cpp",
22  "dfx_elf_parser.cpp",
23  "dfx_frame_formatter.cpp",
24  "dfx_hap.cpp",
25  "dfx_instr_statistic.cpp",
26  "dfx_instructions.cpp",
27  "dfx_map.cpp",
28  "dfx_maps.cpp",
29  "dfx_memory.cpp",
30  "dfx_mmap.cpp",
31  "dfx_ptrace.cpp",
32  "dfx_regs.cpp",
33  "dfx_regs_arm.cpp",
34  "dfx_regs_arm64.cpp",
35  "dfx_regs_loongarch64.cpp",
36  "dfx_regs_riscv64.cpp",
37  "dfx_regs_x86_64.cpp",
38  "dfx_signal.cpp",
39  "dfx_symbols.cpp",
40  "getcontext_x86_64.S",
41  "thread_context.cpp",
42  "unwinder.cpp",
43  "unwinder_config.cpp",
44]
45
46dfx_exidx_sources = [ "arm_exidx.cpp" ]
47
48dfx_dwarf_sources = [
49  "dwarf_cfa_instructions.cpp",
50  "dwarf_op.cpp",
51  "dwarf_section.cpp",
52]
53
54if (defined(ohos_lite)) {
55  config("ohos_lite_config") {
56    defines = [
57      "is_ohos=${is_ohos}",
58      "is_ohos_lite",
59    ]
60  }
61
62  shared_library("libunwinder") {
63    visibility = [ "*:*" ]
64
65    public_configs = [ ":ohos_lite_config" ]
66
67    include_dirs = [
68      "include",
69      "$c_utils_include_path",
70      "$faultloggerd_common_path/dfxlog",
71      "$faultloggerd_common_path/dfxutil",
72      "$faultloggerd_interfaces_path/common",
73      "$hilog_lite_include_path",
74    ]
75
76    dfx_unwinder_sources -= [ "getcontext_x86_64.S" ]
77    sources = dfx_unwinder_sources
78    sources += dfx_exidx_sources
79    sources += dfx_dwarf_sources
80    sources += [ "$c_utils_src_path/directory_ex.cpp" ]
81
82    deps = [
83      "$faultloggerd_common_path/dfxlog:dfx_hilog",
84      "$faultloggerd_common_path/dfxutil:dfx_util",
85      "$faultloggerd_common_path/trace:dfx_trace_dlsym",
86      "$hilog_lite_deps_path",
87    ]
88
89    external_deps = [ "bounds_checking_function:libsec_shared" ]
90  }
91
92  static_library("libunwinder_static") {
93    visibility = [ "*:*" ]
94
95    public_configs = [ ":ohos_lite_config" ]
96
97    include_dirs = [
98      "include",
99      "$c_utils_include_path",
100      "$faultloggerd_common_path/dfxlog",
101      "$faultloggerd_common_path/dfxutil",
102      "$faultloggerd_interfaces_path/common",
103      "$hilog_lite_include_path",
104    ]
105
106    dfx_unwinder_sources -= [ "getcontext_x86_64.S" ]
107    sources = dfx_unwinder_sources
108    sources += dfx_exidx_sources
109    sources += dfx_dwarf_sources
110    sources += [ "$c_utils_src_path/directory_ex.cpp" ]
111
112    deps = [
113      "$faultloggerd_common_path/dfxlog:dfx_hilog",
114      "$faultloggerd_common_path/dfxutil:dfx_util",
115      "$faultloggerd_common_path/trace:dfx_trace_dlsym",
116      "$hilog_lite_deps_path",
117    ]
118    external_deps = [ "bounds_checking_function:libsec_shared" ]
119  }
120
121  static_library("unwinder_host") {
122    # empty
123  }
124} else {
125  config("dfx_unwinder_config") {
126    visibility = [ "*:*" ]
127
128    include_dirs = [
129      "include",
130      "$faultloggerd_common_path/dfxlog",
131      "$faultloggerd_common_path/dfxutil",
132      "$faultloggerd_interfaces_path/common",
133    ]
134
135    defines = [
136      "is_ohos=${is_ohos}",
137      "is_linux=${is_linux}",
138      "is_mingw=${is_mingw}",
139      "RUSTC_DEMANGLE",
140    ]
141
142    if (libunwinder_debug) {
143      defines += [ "DFX_LOG_UNWIND" ]
144    }
145  }
146
147  config("mixstack_config") {
148    if (target_cpu == "arm64") {
149      defines = [ "ENABLE_MIXSTACK" ]
150    }
151  }
152
153  config("lzma_config") {
154    if (is_ohos && !is_mingw && !is_emulator) {
155      defines = [ "ENABLE_MINIDEBUGINFO" ]
156    }
157  }
158
159  ohos_shared_library("libunwinder") {
160    branch_protector_ret = "pac_ret"
161    public_configs = [
162      ":dfx_unwinder_config",
163      ":lzma_config",
164      ":mixstack_config",
165      "$faultloggerd_common_path/build:coverage_flags",
166    ]
167    defines = [
168      "DFX_UNWIND_ERROR",
169      "DFX_ENABLE_TRACE",
170    ]
171    if (target_cpu == "arm64") {
172      defines += [ "ENABLE_PARAMETER" ]
173    }
174
175    if (target_cpu != "x86_64") {
176      dfx_unwinder_sources -= [ "getcontext_x86_64.S" ]
177    }
178    sources = dfx_unwinder_sources
179    sources += dfx_exidx_sources
180    sources += dfx_dwarf_sources
181
182    deps = [
183      "$faultloggerd_common_path/dfxlog:dfx_hilog",
184      "$faultloggerd_common_path/dfxutil:dfx_util",
185      "$faultloggerd_common_path/trace:dfx_trace_dlsym",
186    ]
187
188    if (is_ohos && !is_mingw && !is_emulator) {
189      sources += [ "dfx_xz_utils.cpp" ]
190    }
191    version_script = "libunwinder.map"
192    public_external_deps = [ "lzma:lzma_shared" ]
193    external_deps = [
194      "bounds_checking_function:libsec_shared",
195      "c_utils:utils",
196      "hilog:libhilog",
197      "init:libbegetutil",
198    ]
199    install_images = [
200      "system",
201      "updater",
202    ]
203    innerapi_tags = [
204      "chipsetsdk_indirect",
205      "platformsdk_indirect",
206    ]
207    part_name = "faultloggerd"
208    subsystem_name = "hiviewdfx"
209  }
210
211  ohos_static_library("libunwinder_static") {
212    public_configs = [
213      ":dfx_unwinder_config",
214      ":lzma_config",
215      ":mixstack_config",
216    ]
217
218    if (target_cpu != "x86_64") {
219      dfx_unwinder_sources -= [ "getcontext_x86_64.S" ]
220    }
221    sources = dfx_unwinder_sources
222    sources += dfx_exidx_sources
223    sources += dfx_dwarf_sources
224
225    deps = [
226      "$faultloggerd_common_path/dfxlog:dfx_hilog",
227      "$faultloggerd_common_path/dfxutil:dfx_util",
228      "$faultloggerd_common_path/trace:dfx_trace_dlsym",
229    ]
230
231    if (is_ohos && !is_mingw && !is_emulator) {
232      sources += [ "dfx_xz_utils.cpp" ]
233    }
234    public_external_deps = [ "lzma:lzma_shared" ]
235    external_deps = [
236      "bounds_checking_function:libsec_shared",
237      "c_utils:utils",
238      "hilog:libhilog",
239    ]
240    part_name = "faultloggerd"
241    subsystem_name = "hiviewdfx"
242  }
243
244  ohos_static_library("libunwinder_base") {
245    public_configs = [
246      ":dfx_unwinder_config",
247      ":lzma_config",
248      ":mixstack_config",
249    ]
250    defines = [ "DFX_LOG_HILOG_BASE" ]
251
252    if (target_cpu != "x86_64") {
253      dfx_unwinder_sources -= [ "getcontext_x86_64.S" ]
254    }
255    sources = dfx_unwinder_sources
256    sources += dfx_exidx_sources
257    sources += dfx_dwarf_sources
258
259    deps = [
260      "$faultloggerd_common_path/dfxlog:dfx_hilog_base_static",
261      "$faultloggerd_common_path/dfxutil:dfx_util_static",
262      "$faultloggerd_common_path/trace:dfx_trace_dlsym_static",
263    ]
264
265    if (is_ohos && !is_mingw && !is_emulator) {
266      sources += [ "dfx_xz_utils.cpp" ]
267    }
268    public_external_deps = [ "lzma:lzma_static" ]
269    external_deps = [
270      "bounds_checking_function:libsec_static",
271      "c_utils:utilsbase",
272      "hilog:libhilog_base",
273    ]
274    part_name = "faultloggerd"
275    subsystem_name = "hiviewdfx"
276  }
277
278  ohos_source_set("libunwinder_src") {
279    public_configs = [
280      ":dfx_unwinder_config",
281      ":lzma_config",
282      ":mixstack_config",
283    ]
284    defines = [
285      "DFX_LOG_UNWIND",
286      "DFX_UNWIND_ERROR",
287      "INSTR_STATISTIC_ENABLE",
288    ]
289
290    if (target_cpu != "x86_64") {
291      dfx_unwinder_sources -= [ "getcontext_x86_64.S" ]
292    }
293    sources = dfx_unwinder_sources
294    sources += dfx_exidx_sources
295    sources += dfx_dwarf_sources
296
297    deps = [
298      "$faultloggerd_common_path/dfxlog:dfx_hilog",
299      "$faultloggerd_common_path/dfxutil:dfx_util",
300      "$faultloggerd_common_path/trace:dfx_trace_dlsym",
301    ]
302
303    if (is_ohos && !is_mingw && !is_emulator) {
304      sources += [ "dfx_xz_utils.cpp" ]
305    }
306    public_external_deps = [ "lzma:lzma_shared" ]
307    external_deps = [
308      "bounds_checking_function:libsec_shared",
309      "c_utils:utils",
310      "hilog:libhilog",
311    ]
312    part_name = "faultloggerd"
313    subsystem_name = "hiviewdfx"
314  }
315
316  config("unwinder_host_config") {
317    visibility = [ "*:*" ]
318
319    include_dirs = [
320      "include",
321      "$faultloggerd_common_path/dfxlog",
322      "$faultloggerd_common_path/dfxutil",
323      "$faultloggerd_interfaces_path/common",
324      "$faultloggerd_interfaces_path/nonlinux",
325    ]
326
327    defines = [
328      "is_ohos=${is_ohos}",
329      "is_linux=${is_linux}",
330      "is_mingw=${is_mingw}",
331      "is_emulator=${is_emulator}",
332      "DFX_NO_PRINT_LOG",
333    ]
334  }
335
336  ohos_static_library("unwinder_host") {
337    public_configs = [ ":unwinder_host_config" ]
338    sources = [
339      "dfx_elf.cpp",
340      "dfx_elf_parser.cpp",
341      "dfx_hap.cpp",
342      "dfx_map.cpp",
343      "dfx_maps.cpp",
344      "dfx_memory.cpp",
345      "dfx_mmap.cpp",
346      "dfx_symbols.cpp",
347      "unwinder_config.cpp",
348    ]
349    if (is_ohos && !is_mingw && !is_emulator) {
350      sources += [ "dfx_xz_utils.cpp" ]
351      public_external_deps = [ "lzma:lzma_static" ]
352    }
353    deps = [
354      "$faultloggerd_common_path/dfxutil:dfx_util_host",
355      "$faultloggerd_common_path/trace:dfx_trace_dlsym",
356    ]
357    external_deps = [ "bounds_checking_function:libsec_static" ]
358    if (is_ohos) {
359      external_deps += [ "c_utils:utils" ]
360    }
361    part_name = "faultloggerd"
362    subsystem_name = "hiviewdfx"
363  }
364}
365