disasm.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
  3. * Copyright (c) 2016 Facebook
  4. */
  5. #ifndef __BPF_DISASM_H__
  6. #define __BPF_DISASM_H__
  7. #include <linux/bpf.h>
  8. #include <linux/kernel.h>
  9. #include <linux/stringify.h>
  10. #ifndef __KERNEL__
  11. #include <stdio.h>
  12. #include <string.h>
  13. #endif
  14. extern const char *const bpf_alu_string[16];
  15. extern const char *const bpf_class_string[8];
  16. const char *func_id_name(int id);
  17. typedef __printf(2, 3) void (*bpf_insn_print_t)(void *private_data,
  18. const char *, ...);
  19. typedef const char *(*bpf_insn_revmap_call_t)(void *private_data,
  20. const struct bpf_insn *insn);
  21. typedef const char *(*bpf_insn_print_imm_t)(void *private_data,
  22. const struct bpf_insn *insn,
  23. __u64 full_imm);
  24. struct bpf_insn_cbs {
  25. bpf_insn_print_t cb_print;
  26. bpf_insn_revmap_call_t cb_call;
  27. bpf_insn_print_imm_t cb_imm;
  28. void *private_data;
  29. };
  30. void print_bpf_insn(const struct bpf_insn_cbs *cbs,
  31. const struct bpf_insn *insn,
  32. bool allow_ptr_leaks);
  33. #endif