intel-pt-log.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <stdint.h>
  18. #include <inttypes.h>
  19. struct intel_pt_pkt;
  20. void intel_pt_log_enable(void);
  21. void intel_pt_log_disable(void);
  22. void intel_pt_log_set_name(const char *name);
  23. void __intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len,
  24. uint64_t pos, const unsigned char *buf);
  25. struct intel_pt_insn;
  26. void __intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip);
  27. void __intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn,
  28. uint64_t ip);
  29. __attribute__((format(printf, 1, 2)))
  30. void __intel_pt_log(const char *fmt, ...);
  31. #define intel_pt_log(fmt, ...) \
  32. do { \
  33. if (intel_pt_enable_logging) \
  34. __intel_pt_log(fmt, ##__VA_ARGS__); \
  35. } while (0)
  36. #define intel_pt_log_packet(arg, ...) \
  37. do { \
  38. if (intel_pt_enable_logging) \
  39. __intel_pt_log_packet(arg, ##__VA_ARGS__); \
  40. } while (0)
  41. #define intel_pt_log_insn(arg, ...) \
  42. do { \
  43. if (intel_pt_enable_logging) \
  44. __intel_pt_log_insn(arg, ##__VA_ARGS__); \
  45. } while (0)
  46. #define intel_pt_log_insn_no_data(arg, ...) \
  47. do { \
  48. if (intel_pt_enable_logging) \
  49. __intel_pt_log_insn_no_data(arg, ##__VA_ARGS__); \
  50. } while (0)
  51. #define x64_fmt "0x%" PRIx64
  52. extern bool intel_pt_enable_logging;
  53. static inline void intel_pt_log_at(const char *msg, uint64_t u)
  54. {
  55. intel_pt_log("%s at " x64_fmt "\n", msg, u);
  56. }
  57. static inline void intel_pt_log_to(const char *msg, uint64_t u)
  58. {
  59. intel_pt_log("%s to " x64_fmt "\n", msg, u);
  60. }
  61. #endif