test-libdw.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. int test_libdw(void)
  8. {
  9. Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
  10. return dbg == NULL;
  11. }
  12. int test_libdw_unwind(void)
  13. {
  14. /*
  15. * This function is guarded via: __nonnull_attribute__ (1, 2).
  16. * Passing '1' as arguments value. This code is never executed,
  17. * only compiled.
  18. */
  19. dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
  20. return 0;
  21. }
  22. int test_libdw_getlocations(void)
  23. {
  24. Dwarf_Addr base, start, end;
  25. Dwarf_Attribute attr;
  26. Dwarf_Op *op;
  27. size_t nops;
  28. ptrdiff_t offset = 0;
  29. return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops);
  30. }
  31. int test_libdw_getcfi(void)
  32. {
  33. Dwarf *dwarf = NULL;
  34. return dwarf_getcfi(dwarf) == NULL;
  35. }
  36. int test_elfutils(void)
  37. {
  38. Dwarf_CFI *cfi = NULL;
  39. dwarf_cfi_end(cfi);
  40. return 0;
  41. }
  42. int main(void)
  43. {
  44. return test_libdw() + test_libdw_unwind() + test_libdw_getlocations() +
  45. test_libdw_getcfi() + test_elfutils();
  46. }