intel-pt-log.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * intel_pt_log.h: Intel Processor Trace support
  3. * Copyright (c) 2013-2014, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. */
  15. #ifndef INCLUDE__INTEL_PT_LOG_H__
  16. #define INCLUDE__INTEL_PT_LOG_H__
  17. #include <linux/compiler.h>
  18. #include <stdint.h>
  19. #include <inttypes.h>
  20. struct intel_pt_pkt;
  21. void *intel_pt_log_fp(void);
  22. void intel_pt_log_enable(void);
  23. void intel_pt_log_disable(void);
  24. void intel_pt_log_set_name(const char *name);
  25. void __intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len,
  26. uint64_t pos, const unsigned char *buf);
  27. struct intel_pt_insn;
  28. void __intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip);
  29. void __intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn,
  30. uint64_t ip);
  31. void __intel_pt_log(const char *fmt, ...) __printf(1, 2);
  32. #define intel_pt_log(fmt, ...) \
  33. do { \
  34. if (intel_pt_enable_logging) \
  35. __intel_pt_log(fmt, ##__VA_ARGS__); \
  36. } while (0)
  37. #define intel_pt_log_packet(arg, ...) \
  38. do { \
  39. if (intel_pt_enable_logging) \
  40. __intel_pt_log_packet(arg, ##__VA_ARGS__); \
  41. } while (0)
  42. #define intel_pt_log_insn(arg, ...) \
  43. do { \
  44. if (intel_pt_enable_logging) \
  45. __intel_pt_log_insn(arg, ##__VA_ARGS__); \
  46. } while (0)
  47. #define intel_pt_log_insn_no_data(arg, ...) \
  48. do { \
  49. if (intel_pt_enable_logging) \
  50. __intel_pt_log_insn_no_data(arg, ##__VA_ARGS__); \
  51. } while (0)
  52. #define x64_fmt "0x%" PRIx64
  53. extern bool intel_pt_enable_logging;
  54. static inline void intel_pt_log_at(const char *msg, uint64_t u)
  55. {
  56. intel_pt_log("%s at " x64_fmt "\n", msg, u);
  57. }
  58. static inline void intel_pt_log_to(const char *msg, uint64_t u)
  59. {
  60. intel_pt_log("%s to " x64_fmt "\n", msg, u);
  61. }
  62. #endif