Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / build / feature / test-libdw.c
blob2fb59479ab77168765fadb50b5468039a924cc4d
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>
8 int test_libdw(void)
10 Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
12 return (long)dbg;
15 int test_libdw_unwind(void)
18 * This function is guarded via: __nonnull_attribute__ (1, 2).
19 * Passing '1' as arguments value. This code is never executed,
20 * only compiled.
22 dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
23 return 0;
26 int test_libdw_getlocations(void)
28 Dwarf_Addr base, start, end;
29 Dwarf_Attribute attr;
30 Dwarf_Op *op;
31 size_t nops;
32 ptrdiff_t offset = 0;
34 return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops);
37 int test_libdw_getcfi(void)
39 Dwarf *dwarf = NULL;
41 return dwarf_getcfi(dwarf) == NULL;
44 int test_elfutils(void)
46 Dwarf_CFI *cfi = NULL;
48 dwarf_cfi_end(cfi);
49 return 0;
52 int main(void)
54 return test_libdw() + test_libdw_unwind() + test_libdw_getlocations() +
55 test_libdw_getcfi() + test_elfutils();