aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/intel-pt-decoder/intel-pt-log.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2015-09-25 09:15:35 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-09-28 15:45:26 -0400
commit116f349c5bf8c7aec4047dd6e06c310354b46e4f (patch)
tree6a6596049af5450e5a521915a7a56bddb39d4393 /tools/perf/util/intel-pt-decoder/intel-pt-log.c
parent9992c2d50a73f442653968a98a9e5f3bf4e769e9 (diff)
perf intel-pt: Make logging slightly more efficient
Logging is only used for debugging. Use macros to save calling into the functions only to return immediately when logging is not enabled. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1443186956-18718-5-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/intel-pt-decoder/intel-pt-log.c')
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-log.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-log.c b/tools/perf/util/intel-pt-decoder/intel-pt-log.c
index d09c7d9f9050..319bef33a64b 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-log.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-log.c
@@ -29,18 +29,18 @@
29 29
30static FILE *f; 30static FILE *f;
31static char log_name[MAX_LOG_NAME]; 31static char log_name[MAX_LOG_NAME];
32static bool enable_logging; 32bool intel_pt_enable_logging;
33 33
34void intel_pt_log_enable(void) 34void intel_pt_log_enable(void)
35{ 35{
36 enable_logging = true; 36 intel_pt_enable_logging = true;
37} 37}
38 38
39void intel_pt_log_disable(void) 39void intel_pt_log_disable(void)
40{ 40{
41 if (f) 41 if (f)
42 fflush(f); 42 fflush(f);
43 enable_logging = false; 43 intel_pt_enable_logging = false;
44} 44}
45 45
46void intel_pt_log_set_name(const char *name) 46void intel_pt_log_set_name(const char *name)
@@ -80,7 +80,7 @@ static void intel_pt_print_no_data(uint64_t pos, int indent)
80 80
81static int intel_pt_log_open(void) 81static int intel_pt_log_open(void)
82{ 82{
83 if (!enable_logging) 83 if (!intel_pt_enable_logging)
84 return -1; 84 return -1;
85 85
86 if (f) 86 if (f)
@@ -91,15 +91,15 @@ static int intel_pt_log_open(void)
91 91
92 f = fopen(log_name, "w+"); 92 f = fopen(log_name, "w+");
93 if (!f) { 93 if (!f) {
94 enable_logging = false; 94 intel_pt_enable_logging = false;
95 return -1; 95 return -1;
96 } 96 }
97 97
98 return 0; 98 return 0;
99} 99}
100 100
101void intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len, 101void __intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len,
102 uint64_t pos, const unsigned char *buf) 102 uint64_t pos, const unsigned char *buf)
103{ 103{
104 char desc[INTEL_PT_PKT_DESC_MAX]; 104 char desc[INTEL_PT_PKT_DESC_MAX];
105 105
@@ -111,7 +111,7 @@ void intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len,
111 fprintf(f, "%s\n", desc); 111 fprintf(f, "%s\n", desc);
112} 112}
113 113
114void intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip) 114void __intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip)
115{ 115{
116 char desc[INTEL_PT_INSN_DESC_MAX]; 116 char desc[INTEL_PT_INSN_DESC_MAX];
117 size_t len = intel_pt_insn->length; 117 size_t len = intel_pt_insn->length;
@@ -128,7 +128,8 @@ void intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip)
128 fprintf(f, "Bad instruction!\n"); 128 fprintf(f, "Bad instruction!\n");
129} 129}
130 130
131void intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn, uint64_t ip) 131void __intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn,
132 uint64_t ip)
132{ 133{
133 char desc[INTEL_PT_INSN_DESC_MAX]; 134 char desc[INTEL_PT_INSN_DESC_MAX];
134 135
@@ -142,7 +143,7 @@ void intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn, uint64_t ip)
142 fprintf(f, "Bad instruction!\n"); 143 fprintf(f, "Bad instruction!\n");
143} 144}
144 145
145void intel_pt_log(const char *fmt, ...) 146void __intel_pt_log(const char *fmt, ...)
146{ 147{
147 va_list args; 148 va_list args;
148 149