xref: /linux/tools/perf/util/intel-pt-decoder/intel-pt-log.h (revision a2cce7a9f1b8cc3d4edce106fb971529f1d4d9ce)
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 <stdint.h>
20 #include <inttypes.h>
21 
22 struct intel_pt_pkt;
23 
24 void intel_pt_log_enable(void);
25 void intel_pt_log_disable(void);
26 void intel_pt_log_set_name(const char *name);
27 
28 void intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len,
29 			 uint64_t pos, const unsigned char *buf);
30 
31 struct intel_pt_insn;
32 
33 void intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip);
34 void intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn,
35 			       uint64_t ip);
36 
37 __attribute__((format(printf, 1, 2)))
38 void intel_pt_log(const char *fmt, ...);
39 
40 #define x64_fmt "0x%" PRIx64
41 
42 static inline void intel_pt_log_at(const char *msg, uint64_t u)
43 {
44 	intel_pt_log("%s at " x64_fmt "\n", msg, u);
45 }
46 
47 static inline void intel_pt_log_to(const char *msg, uint64_t u)
48 {
49 	intel_pt_log("%s to " x64_fmt "\n", msg, u);
50 }
51 
52 #endif
53