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