btf.h 1008 B

1234567891011121314151617181920212223242526272829303132
  1. /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
  2. /* Copyright (c) 2018 Facebook */
  3. #ifndef __LIBBPF_BTF_H
  4. #define __LIBBPF_BTF_H
  5. #include <linux/types.h>
  6. #ifndef LIBBPF_API
  7. #define LIBBPF_API __attribute__((visibility("default")))
  8. #endif
  9. #define BTF_ELF_SEC ".BTF"
  10. struct btf;
  11. struct btf_type;
  12. typedef int (*btf_print_fn_t)(const char *, ...)
  13. __attribute__((format(printf, 1, 2)));
  14. LIBBPF_API void btf__free(struct btf *btf);
  15. LIBBPF_API struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
  16. LIBBPF_API __s32 btf__find_by_name(const struct btf *btf,
  17. const char *type_name);
  18. LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf,
  19. __u32 id);
  20. LIBBPF_API __s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
  21. LIBBPF_API int btf__resolve_type(const struct btf *btf, __u32 type_id);
  22. LIBBPF_API int btf__fd(const struct btf *btf);
  23. LIBBPF_API const char *btf__name_by_offset(const struct btf *btf, __u32 offset);
  24. #endif /* __LIBBPF_BTF_H */