Skip to content

Commit 1265cc3

Browse files
tor-jeremiassenmathieupoirier
authored andcommitted
perf tools: decoding capailitity for CoreSight traces
Added user space perf functionality for CoreSight trace decoding.
1 parent 56139d0 commit 1265cc3

15 files changed

Lines changed: 2237 additions & 9 deletions

File tree

tools/perf/Makefile.perf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ include config/utilities.mak
7777
# Define NO_AUXTRACE if you do not want AUX area tracing support
7878
#
7979
# Define NO_LIBBPF if you do not want BPF support
80+
#
81+
# Define NO_CSTRACE if you do not want CoreSight trace decoding support
82+
#
8083

8184
# As per kernel Makefile, avoid funny character set dependencies
8285
unexport LC_ALL

tools/perf/builtin-script.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ static struct {
9292

9393
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
9494
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
95-
PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
95+
PERF_OUTPUT_EVNAME | PERF_OUTPUT_ADDR |
96+
PERF_OUTPUT_IP |
9697
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO |
9798
PERF_OUTPUT_PERIOD,
9899

tools/perf/config/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,24 @@ endif
433433
grep-libs = $(filter -l%,$(1))
434434
strip-libs = $(filter-out -l%,$(1))
435435

436+
ifdef CSTRACE_PATH
437+
ifeq (${IS_64_BIT}, 1)
438+
CSTRACE_LNX = linux64
439+
else
440+
CSTRACE_LNX = linux
441+
endif
442+
ifdef DEBUG
443+
LIBCSTRACE = -lcstraced_c_api -lcstraced
444+
CSTRACE_LIB_PATH = $(CSTRACE_PATH)/lib/$(CSTRACE_LNX)/dbg
445+
else
446+
LIBCSTRACE = -lcstrace_c_api -lcstrace
447+
CSTRACE_LIB_PATH = $(CSTRACE_PATH)/lib/$(CSTRACE_LNX)/rel
448+
endif
449+
$(call detected,CSTRACE)
450+
$(call detected_var,CSTRACE_PATH)
451+
EXTLIBS += -L$(CSTRACE_LIB_PATH) $(LIBCSTRACE) -lstdc++
452+
endif
453+
436454
ifdef NO_LIBPERL
437455
CFLAGS += -DNO_LIBPERL
438456
else

tools/perf/util/Build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ libperf-$(CONFIG_AUXTRACE) += auxtrace.o
8484
libperf-$(CONFIG_AUXTRACE) += intel-pt-decoder/
8585
libperf-$(CONFIG_AUXTRACE) += intel-pt.o
8686
libperf-$(CONFIG_AUXTRACE) += intel-bts.o
87+
libperf-$(CONFIG_AUXTRACE) += cs-etm.o
88+
libperf-$(CONFIG_AUXTRACE) += cs-etm-decoder/
8789
libperf-y += parse-branch-options.o
8890
libperf-y += parse-regs-options.o
8991

tools/perf/util/auxtrace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
#include "intel-pt.h"
5151
#include "intel-bts.h"
52+
#include "cs-etm.h"
5253

5354
int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
5455
struct auxtrace_mmap_params *mp,
@@ -893,6 +894,7 @@ int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused,
893894
case PERF_AUXTRACE_INTEL_BTS:
894895
return intel_bts_process_auxtrace_info(event, session);
895896
case PERF_AUXTRACE_CS_ETM:
897+
return cs_etm__process_auxtrace_info(event, session);
896898
case PERF_AUXTRACE_UNKNOWN:
897899
default:
898900
return -EINVAL;

tools/perf/util/build-id.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static int asnprintf(char **strp, size_t size, const char *fmt, ...)
145145
return ret;
146146
}
147147

148-
static char *build_id__filename(const char *sbuild_id, char *bf, size_t size)
148+
char *build_id__filename(const char *sbuild_id, char *bf, size_t size)
149149
{
150150
char *tmp = bf;
151151
int ret = asnprintf(&bf, size, "%s/.build-id/%.2s/%s", buildid_dir,

tools/perf/util/build-id.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
extern struct perf_tool build_id__mark_dso_hit_ops;
1212
struct dso;
1313

14+
char *build_id__filename(const char *sbuild_id, char *bf, size_t size);
1415
int build_id__sprintf(const u8 *build_id, int len, char *bf);
1516
int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id);
1617
int filename__sprintf_build_id(const char *pathname, char *sbuild_id);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ifeq ($(CSTRACE_PATH),)
2+
libperf-$(CONFIG_AUXTRACE) += cs-etm-decoder-stub.o
3+
else
4+
CFLAGS_cs-etm-decoder.o += -I$(CSTRACE_PATH)/include
5+
libperf-$(CONFIG_AUXTRACE) += cs-etm-decoder.o
6+
endif
7+
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
*
3+
* Copyright(C) 2015 Linaro Limited. All rights reserved.
4+
* Author: Tor Jeremiassen <tor.jeremiassen@linaro.org>
5+
*
6+
* This program is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License version 2 as published
8+
* by the Free Software Foundation.
9+
*
10+
* This program is distributed in the hope that it will be useful, but
11+
* WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13+
* Public License for more details.
14+
*
15+
* You should have received a copy of the GNU GEneral Public License along
16+
* with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#include <stdlib.h>
20+
21+
#include "cs-etm-decoder.h"
22+
#include "../util.h"
23+
24+
25+
struct cs_etm_decoder
26+
{
27+
void *state;
28+
int dummy;
29+
};
30+
31+
int cs_etm_decoder__flush(struct cs_etm_decoder *decoder)
32+
{
33+
(void) decoder;
34+
return -1;
35+
}
36+
37+
int cs_etm_decoder__add_bin_file(struct cs_etm_decoder *decoder, uint64_t offset, uint64_t address, uint64_t len, const char *fname)
38+
{
39+
(void) decoder;
40+
(void) offset;
41+
(void) address;
42+
(void) len;
43+
(void) fname;
44+
return -1;
45+
}
46+
47+
const struct cs_etm_state *cs_etm_decoder__process_data_block(struct cs_etm_decoder *decoder,
48+
uint64_t indx,
49+
const uint8_t *buf,
50+
size_t len,
51+
size_t *consumed)
52+
{
53+
(void) decoder;
54+
(void) indx;
55+
(void) buf;
56+
(void) len;
57+
(void) consumed;
58+
return NULL;
59+
}
60+
61+
int cs_etm_decoder__add_mem_access_cb(struct cs_etm_decoder *decoder, uint64_t address, uint64_t len, cs_etm_mem_cb_type cb_func)
62+
{
63+
(void) decoder;
64+
(void) address;
65+
(void) len;
66+
(void) cb_func;
67+
return -1;
68+
}
69+
70+
int cs_etm_decoder__get_packet(struct cs_etm_decoder *decoder,
71+
struct cs_etm_packet *packet)
72+
{
73+
(void) decoder;
74+
(void) packet;
75+
return -1;
76+
}
77+
78+
struct cs_etm_decoder *cs_etm_decoder__new(uint32_t num_cpu, struct cs_etm_decoder_params *d_params, struct cs_etm_trace_params t_params[])
79+
{
80+
(void) num_cpu;
81+
(void) d_params;
82+
(void) t_params;
83+
return NULL;
84+
}
85+
86+
87+
void cs_etm_decoder__free(struct cs_etm_decoder *decoder)
88+
{
89+
(void) decoder;
90+
return;
91+
}

0 commit comments

Comments
 (0)