Linux Perf
intel-pt-log.h
Go to the documentation of this file.
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 
16 #ifndef INCLUDE__INTEL_PT_LOG_H__
17 #define INCLUDE__INTEL_PT_LOG_H__
18 
19 #include <linux/compiler.h>
20 #include <stdint.h>
21 #include <inttypes.h>
22 
23 struct intel_pt_pkt;
24 
25 void intel_pt_log_enable(void);
26 void intel_pt_log_disable(void);
27 void intel_pt_log_set_name(const char *name);
28 
29 void __intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len,
30  uint64_t pos, const unsigned char *buf);
31 
32 struct intel_pt_insn;
33 
34 void __intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip);
36  uint64_t ip);
37 
38 void __intel_pt_log(const char *fmt, ...) __printf(1, 2);
39 
40 #define intel_pt_log(fmt, ...) \
41  do { \
42  if (intel_pt_enable_logging) \
43  __intel_pt_log(fmt, ##__VA_ARGS__); \
44  } while (0)
45 
46 #define intel_pt_log_packet(arg, ...) \
47  do { \
48  if (intel_pt_enable_logging) \
49  __intel_pt_log_packet(arg, ##__VA_ARGS__); \
50  } while (0)
51 
52 #define intel_pt_log_insn(arg, ...) \
53  do { \
54  if (intel_pt_enable_logging) \
55  __intel_pt_log_insn(arg, ##__VA_ARGS__); \
56  } while (0)
57 
58 #define intel_pt_log_insn_no_data(arg, ...) \
59  do { \
60  if (intel_pt_enable_logging) \
61  __intel_pt_log_insn_no_data(arg, ##__VA_ARGS__); \
62  } while (0)
63 
64 #define x64_fmt "0x%" PRIx64
65 
66 extern bool intel_pt_enable_logging;
67 
68 static inline void intel_pt_log_at(const char *msg, uint64_t u)
69 {
70  intel_pt_log("%s at " x64_fmt "\n", msg, u);
71 }
72 
73 static inline void intel_pt_log_to(const char *msg, uint64_t u)
74 {
75  intel_pt_log("%s to " x64_fmt "\n", msg, u);
76 }
77 
78 #endif
void __intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip)
Definition: intel-pt-log.c:114
#define intel_pt_log(fmt,...)
Definition: intel-pt-log.h:40
void intel_pt_log_enable(void)
Definition: intel-pt-log.c:34
void intel_pt_log_disable(void)
Definition: intel-pt-log.c:39
const char * name
void __intel_pt_log(const char *fmt,...) __printf(1
const char * fmt
Definition: dso.c:193
bool intel_pt_enable_logging
Definition: intel-pt-log.c:32
void intel_pt_log_set_name(const char *name)
Definition: intel-pt-log.c:46
static void intel_pt_log_at(const char *msg, uint64_t u)
Definition: intel-pt-log.h:68
static int __printf(2, 3)
Definition: cs-etm.c:622
void __intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len, uint64_t pos, const unsigned char *buf)
Definition: intel-pt-log.c:101
static void intel_pt_log_to(const char *msg, uint64_t u)
Definition: intel-pt-log.h:73
#define x64_fmt
Definition: intel-pt-log.h:64
void __intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn, uint64_t ip)
Definition: intel-pt-log.c:131