1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdlib.h>
3 #include <dwarf.h>
4 #include <elfutils/libdw.h>
5 #include <elfutils/libdwfl.h>
6 #include <elfutils/version.h>
7
test_libdw(void)8 int test_libdw(void)
9 {
10 Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
11
12 return (long)dbg;
13 }
14
test_libdw_unwind(void)15 int test_libdw_unwind(void)
16 {
17 /*
18 * This function is guarded via: __nonnull_attribute__ (1, 2).
19 * Passing '1' as arguments value. This code is never executed,
20 * only compiled.
21 */
22 dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
23 return 0;
24 }
25
test_libdw_getlocations(void)26 int test_libdw_getlocations(void)
27 {
28 Dwarf_Addr base, start, end;
29 Dwarf_Attribute attr;
30 Dwarf_Op *op;
31 size_t nops;
32 ptrdiff_t offset = 0;
33
34 return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops);
35 }
36
test_libdw_getcfi(void)37 int test_libdw_getcfi(void)
38 {
39 Dwarf *dwarf = NULL;
40
41 return dwarf_getcfi(dwarf) == NULL;
42 }
43
test_elfutils(void)44 int test_elfutils(void)
45 {
46 Dwarf_CFI *cfi = NULL;
47
48 dwarf_cfi_end(cfi);
49 return 0;
50 }
51
main(void)52 int main(void)
53 {
54 return test_libdw() + test_libdw_unwind() + test_libdw_getlocations() +
55 test_libdw_getcfi() + test_elfutils();
56 }
57