disasm.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
  2. * Copyright (c) 2016 Facebook
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of version 2 of the GNU General Public
  6. * License as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. */
  13. #ifndef __BPF_DISASM_H__
  14. #define __BPF_DISASM_H__
  15. #include <linux/bpf.h>
  16. #include <linux/kernel.h>
  17. #include <linux/stringify.h>
  18. #ifndef __KERNEL__
  19. #include <stdio.h>
  20. #include <string.h>
  21. #endif
  22. extern const char *const bpf_alu_string[16];
  23. extern const char *const bpf_class_string[8];
  24. const char *func_id_name(int id);
  25. typedef __printf(2, 3) void (*bpf_insn_print_t)(void *private_data,
  26. const char *, ...);
  27. typedef const char *(*bpf_insn_revmap_call_t)(void *private_data,
  28. const struct bpf_insn *insn);
  29. typedef const char *(*bpf_insn_print_imm_t)(void *private_data,
  30. const struct bpf_insn *insn,
  31. __u64 full_imm);
  32. struct bpf_insn_cbs {
  33. bpf_insn_print_t cb_print;
  34. bpf_insn_revmap_call_t cb_call;
  35. bpf_insn_print_imm_t cb_imm;
  36. void *private_data;
  37. };
  38. void print_bpf_insn(const struct bpf_insn_cbs *cbs,
  39. const struct bpf_insn *insn,
  40. bool allow_ptr_leaks);
  41. #endif