On Fri, Sep 22, 2017 at 04:03:20AM -0500, Tor Jeremiassen wrote:
The actual decode of the binary trace is performed by a separate open source library that is linked in when enabled in the build process. The code that interacts with the decoder library is factored out into the cs-etm-decoder subdirectory, and has it's own api that is called from the auxtrace handling performed in cs-etm.c
This patch defines the initial basic data structures for the library interface.
This patch contains code contributed by Mike Leach as a separate commit which had to be adjusted and distributed across several patches.
Cc: Mike Leach mike.leach@linaro.org Signed-off-by: Tor Jeremiassen tor@ti.com
tools/perf/Makefile.config | 21 +++++ tools/perf/util/Build | 1 + tools/perf/util/cs-etm-decoder/Build | 2 + tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 47 +++++++++++ tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 107 ++++++++++++++++++++++++ tools/perf/util/cs-etm.c | 1 + 6 files changed, 179 insertions(+) create mode 100644 tools/perf/util/cs-etm-decoder/Build create mode 100644 tools/perf/util/cs-etm-decoder/cs-etm-decoder.c create mode 100644 tools/perf/util/cs-etm-decoder/cs-etm-decoder.h
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index d1a83aa..4e70526 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -342,6 +342,27 @@ endif ifdef CSTRACE_PATH CFLAGS += -DHAVE_CSTRACE_SUPPORT CFLAGS-$(CONFIG_AUXTRACE) += -DHAVE_CSTRACE_SUPPORT
- ifeq (${IS_64_BIT}, 1)
- CSTRACE_LNX = linux64
- ifeq (${ARCH}, arm64)
CSTRACE_LNX = linux-arm64
- endif
- else
- CSTRACE_LNX = linux
- ifeq (${ARCH}, arm)
CSTRACE_LNX = linux-arm
- endif
- endif
- ifeq (${DEBUG}, 1)
- LIBCSTRACE = -lcstraced_c_api -lcstraced
- CSTRACE_LIB_PATH = $(CSTRACE_PATH)/lib/$(CSTRACE_LNX)/dbg
- else
- LIBCSTRACE = -lcstraced_c_api -lcstraced
- CSTRACE_LIB_PATH = $(CSTRACE_PATH)/lib/$(CSTRACE_LNX)/rel
- endif
- $(call detected,CSTRACE)
- $(call detected_var,CSTRACE_PATH)
- EXTLIBS += -L$(CSTRACE_LIB_PATH) $(LIBCSTRACE) -lstdc++
What does linking with the standard C++ library gives us? I removed it and everything compiled (and ran) fine.
endif ifndef NO_LIBELF diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 23439f4..d73f4db 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -86,6 +86,7 @@ libperf-$(CONFIG_AUXTRACE) += intel-bts.o ifdef CSTRACE_PATH libperf-$(CONFIG_AUXTRACE) += cs-etm.o +libperf-$(CONFIG_AUXTRACE) += cs-etm-decoder/ endif libperf-y += parse-branch-options.o diff --git a/tools/perf/util/cs-etm-decoder/Build b/tools/perf/util/cs-etm-decoder/Build new file mode 100644 index 0000000..d926514 --- /dev/null +++ b/tools/perf/util/cs-etm-decoder/Build @@ -0,0 +1,2 @@ +CFLAGS_cs-etm-decoder.o += -I$(CSTRACE_PATH)/include +libperf-$(CONFIG_AUXTRACE) += cs-etm-decoder.o diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c new file mode 100644 index 0000000..e698387 --- /dev/null +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -0,0 +1,47 @@ +/*
- Copyright(C) 2015-2017 Linaro Limited. All rights reserved.
- Author: Tor Jeremiassen tor@ti.com
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License version 2 as published
- by the Free Software Foundation.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- Public License for more details.
- You should have received a copy of the GNU GEneral Public License along
- with this program. If not, see http://www.gnu.org/licenses/.
- */
+#include <linux/err.h> +#include <linux/list.h> +#include <stdlib.h>
+#include "cs-etm.h" +#include "cs-etm-decoder.h" +#include "c_api/opencsd_c_api.h" +#include "etmv4/trc_pkt_types_etmv4.h" +#include "ocsd_if_types.h" +#include "util.h"
I removed the extra line.
+#define MAX_BUFFER 1024
+struct cs_etm_decoder {
- struct cs_etm_state state;
- dcd_tree_handle_t dcd_tree;
- void (*packet_printer)(const char *);
- cs_etm_mem_cb_type mem_access;
- ocsd_datapath_resp_t prev_return;
- size_t prev_processed;
- bool trace_on;
- bool discontinuity;
- struct cs_etm_packet packet_buffer[MAX_BUFFER];
- uint32_t packet_count;
- uint32_t head;
- uint32_t tail;
- uint32_t end_tail;
- struct list_head channel_list;
+}; diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h new file mode 100644 index 0000000..ff4a2c6 --- /dev/null +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -0,0 +1,107 @@ +/*
- Copyright(C) 2015-2017 Linaro Limited. All rights reserved.
- Author: Tor Jeremiassen tor@ti.com
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License version 2 as published
- by the Free Software Foundation.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- Public License for more details.
- You should have received a copy of the GNU GEneral Public License along
- with this program. If not, see http://www.gnu.org/licenses/.
- */
+#ifndef INCLUDE__CS_ETM_DECODER_H__ +#define INCLUDE__CS_ETM_DECODER_H__
+#include <linux/types.h> +#include <stdio.h>
+struct cs_etm_decoder;
+struct cs_etm_buffer {
- const unsigned char *buf;
- size_t len;
- uint64_t offset;
- uint64_t ref_timestamp;
+};
+enum cs_etm_sample_type {
- CS_ETM_RANGE = 1 << 0,
+};
+struct cs_etm_state {
- int err;
- void *data;
- unsigned int isa;
- uint64_t start;
- uint64_t end;
- uint64_t timestamp;
+};
+struct cs_etm_packet {
- enum cs_etm_sample_type sample_type;
- uint64_t start_addr;
- uint64_t end_addr;
- bool exc;
- bool exc_ret;
- int cpu;
+};
+struct cs_etm_queue;
+typedef uint32_t (*cs_etm_mem_cb_type)(struct cs_etm_queue *, uint64_t,
size_t, uint8_t *);
+struct cs_etm_trace_params {
- void *etmv4i_packet_handler;
- uint32_t reg_idr0;
- uint32_t reg_idr1;
- uint32_t reg_idr2;
- uint32_t reg_idr8;
- uint32_t reg_configr;
- uint32_t reg_traceidr;
- int protocol;
+};
+struct cs_etm_decoder_params {
- int operation;
- void (*packet_printer)(const char *);
- cs_etm_mem_cb_type mem_acc_cb;
- bool formatted;
- bool fsyncs;
- bool hsyncs;
- bool frame_aligned;
- void *data;
+};
Same here.
+/* Error return codes */ +enum {
- CS_ETM_ERR_NOMEM = 1,
- CS_ETM_ERR_NODATA,
- CS_ETM_ERR_PARAM,
- CS_ETM_ERR_OVERFLOW,
- CS_ETM_ERR_DECODER,
+};
+/*
- The following enums are indexed starting with 1 to align with the
- open source coresight trace decoder library.
- */
+enum {
- CS_ETM_PROTO_ETMV3 = 1,
- CS_ETM_PROTO_ETMV4i,
- CS_ETM_PROTO_ETMV4d,
+};
+enum {
- CS_ETM_OPERATION_PRINT = 1,
- CS_ETM_OPERATION_DECODE,
+}; +#endif /* INCLUDE__CS_ETM_DECODER_H__ */ diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 85de61e..d228395 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -26,6 +26,7 @@ #include "auxtrace.h" #include "color.h" #include "cs-etm.h" +#include "cs-etm-decoder/cs-etm-decoder.h" #include "debug.h" #include "evlist.h"
#include "intlist.h"
2.7.4
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight