aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuslan Bukin <br@FreeBSD.org>2019-10-10 13:19:21 +0000
committerRuslan Bukin <br@FreeBSD.org>2019-10-10 13:19:21 +0000
commitcf98ba14dc260458f757fa46419575cf69f45a44 (patch)
tree1cafc844f372337d2a95c8a416b915d46bf4daf8
parenta6157d81121ac9559d806dafa346039199598442 (diff)
downloadsrc-cf98ba14dc260458f757fa46419575cf69f45a44.tar.gz
src-cf98ba14dc260458f757fa46419575cf69f45a44.zip
Import OpenCSD -- an ARM CoreSight Trace Decode library.vendor/opencsd/a1961c91b02a92f3c6ed8b145c636ac4c5565aca
Git ID a1961c91b02a92f3c6ed8b145c636ac4c5565aca Sponsored by: DARPA, AFRL
Notes
Notes: svn path=/vendor/opencsd/a1961c91b02a92f3c6ed8b145c636ac4c5565aca/; revision=353391 svn path=/vendor/opencsd/dist/; revision=353392; tag=vendor/opencsd/a1961c91b02a92f3c6ed8b145c636ac4c5565aca
-rw-r--r--HOWTO.md41
-rw-r--r--README.md58
-rw-r--r--decoder/build/linux/makefile146
-rw-r--r--decoder/build/linux/makefile.dev62
-rw-r--r--decoder/build/linux/rctdl_c_api_lib/makefile44
-rw-r--r--decoder/build/linux/ref_trace_decode_lib/makefile44
-rw-r--r--decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.sln21
-rw-r--r--decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj4
-rw-r--r--decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj.filters12
-rw-r--r--decoder/docs/build_libs.md89
-rw-r--r--decoder/docs/doxygen_config.dox341
-rw-r--r--decoder/docs/prog_guide/cs_trace_hw.jpgbin0 -> 78065 bytes
-rw-r--r--decoder/docs/prog_guide/decode_data_path_resp.jpgbin0 -> 29840 bytes
-rw-r--r--decoder/docs/prog_guide/dt_components.jpgbin0 -> 59125 bytes
-rw-r--r--decoder/docs/prog_guide/lib_usage.jpgbin0 -> 36058 bytes
-rw-r--r--decoder/docs/prog_guide/memacc_objs.jpgbin0 -> 42596 bytes
-rw-r--r--decoder/docs/prog_guide/prog_guide_generic_pkts.md400
-rw-r--r--decoder/docs/prog_guide/prog_guide_main.md597
-rw-r--r--decoder/docs/test_progs.md61
-rw-r--r--decoder/include/common/ocsd_code_follower.h6
-rw-r--r--decoder/include/common/ocsd_dcd_tree.h22
-rw-r--r--decoder/include/common/ocsd_error_logger.h4
-rw-r--r--decoder/include/common/ocsd_msg_logger.h25
-rw-r--r--decoder/include/common/trc_gen_elem.h11
-rw-r--r--decoder/include/i_dec/trc_i_decode.h1
-rw-r--r--decoder/include/i_dec/trc_idec_arminst.h11
-rw-r--r--decoder/include/interfaces/trc_error_log_i.h6
-rw-r--r--decoder/include/mem_acc/trc_mem_acc_base.h3
-rw-r--r--decoder/include/mem_acc/trc_mem_acc_bufptr.h2
-rw-r--r--decoder/include/mem_acc/trc_mem_acc_cache.h149
-rw-r--r--decoder/include/mem_acc/trc_mem_acc_cb.h25
-rw-r--r--decoder/include/mem_acc/trc_mem_acc_file.h4
-rw-r--r--decoder/include/mem_acc/trc_mem_acc_mapper.h5
-rw-r--r--decoder/include/opencsd/c_api/ocsd_c_api_types.h1
-rw-r--r--decoder/include/opencsd/c_api/opencsd_c_api.h19
-rw-r--r--decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h20
-rw-r--r--decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h12
-rw-r--r--decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h13
-rw-r--r--decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h29
-rw-r--r--decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h137
-rw-r--r--decoder/include/opencsd/ocsd_if_types.h42
-rw-r--r--decoder/include/opencsd/ocsd_if_version.h (renamed from decoder/include/ocsd_if_version.h)8
-rw-r--r--decoder/include/opencsd/trc_gen_elem_types.h8
-rw-r--r--decoder/include/pkt_printers/pkt_printer_t.h2
-rw-r--r--decoder/source/c_api/ocsd_c_api.cpp13
-rw-r--r--decoder/source/etmv3/trc_pkt_decode_etmv3.cpp3
-rw-r--r--decoder/source/etmv4/trc_cmp_cfg_etmv4.cpp2
-rw-r--r--decoder/source/etmv4/trc_etmv4_stack_elem.cpp14
-rw-r--r--decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp188
-rw-r--r--decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp295
-rw-r--r--decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.cpp374
-rw-r--r--decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.h75
-rw-r--r--decoder/source/i_dec/trc_i_decode.cpp63
-rw-r--r--decoder/source/i_dec/trc_idec_arminst.cpp167
-rw-r--r--decoder/source/mem_acc/trc_mem_acc_bufptr.cpp2
-rw-r--r--decoder/source/mem_acc/trc_mem_acc_cache.cpp176
-rw-r--r--decoder/source/mem_acc/trc_mem_acc_cb.cpp4
-rw-r--r--decoder/source/mem_acc/trc_mem_acc_file.cpp2
-rw-r--r--decoder/source/mem_acc/trc_mem_acc_mapper.cpp75
-rw-r--r--decoder/source/ocsd_code_follower.cpp1
-rw-r--r--decoder/source/ocsd_dcd_tree.cpp48
-rw-r--r--decoder/source/ocsd_error.cpp4
-rw-r--r--decoder/source/ocsd_error_logger.cpp2
-rw-r--r--decoder/source/ocsd_version.cpp2
-rw-r--r--decoder/source/ptm/trc_pkt_decode_ptm.cpp9
-rw-r--r--decoder/source/trc_core_arch_map.cpp12
-rw-r--r--decoder/source/trc_frame_deformatter.cpp39
-rw-r--r--decoder/source/trc_gen_elem.cpp25
-rw-r--r--decoder/source/trc_printable_elem.cpp15
-rw-r--r--decoder/tests/auto-fdo/autofdo.md523
-rwxr-xr-xdecoder/tests/auto-fdo/record.sh68
-rw-r--r--decoder/tests/build/linux/c_api_pkt_print_test/makefile21
-rw-r--r--decoder/tests/build/linux/echo_test_dcd_lib/makefile26
-rw-r--r--decoder/tests/build/linux/mem_buffer_eg/makefile90
-rw-r--r--decoder/tests/build/linux/snapshot_parser_lib/makefile22
-rw-r--r--decoder/tests/build/linux/trc_pkt_lister/makefile27
-rw-r--r--decoder/tests/build/win-vs2015/mem-buffer-eg/mem-buffer-eg.vcxproj154
-rw-r--r--decoder/tests/build/win-vs2015/mem-buffer-eg/mem-buffer-eg.vcxproj.filters22
-rw-r--r--decoder/tests/ext_dcd_test_eg/c_api_echo_test/ext_dcd_echo_test.c2
-rwxr-xr-xdecoder/tests/run_pkt_decode_tests.bash78
-rw-r--r--decoder/tests/snapshot_parser_lib/source/ss_to_dcdtree.cpp33
-rw-r--r--decoder/tests/source/c_api_pkt_print_test.c97
-rw-r--r--decoder/tests/source/mem_buff_demo.cpp416
-rw-r--r--decoder/tests/source/trc_pkt_lister.cpp58
84 files changed, 4766 insertions, 966 deletions
diff --git a/HOWTO.md b/HOWTO.md
index dfaf9de6452e..b16294a317ef 100644
--- a/HOWTO.md
+++ b/HOWTO.md
@@ -21,10 +21,10 @@ supplemented with modifications to the CoreSight framework and drivers to be
usable by the Perf core. The remaining out of tree patches are being
upstreamed incrementally.
-From there compiling the perf tools with `make -C tools/perf` will yield a
-`perf` executable that will support CoreSight trace collection. Note that if
-traces are to be decompressed *off* target, there is no need to download and
-compile the openCSD library (on the target).
+From there compiling the perf tools with `make -C tools/perf CORESIGHT=1` will
+yield a `perf` executable that will support CoreSight trace collection. Note
+that if traces are to be decompressed *off* target, there is no need to download
+and compile the openCSD library (on the target).
Before launching a trace run a sink that will collect trace data needs to be
identified. All CoreSight blocks identified by the framework are registed in
@@ -306,7 +306,7 @@ and needs to be installed on a system prior to compilation. Information about
the status of the openCSD library on a system is given at compile time by the
perf tools build script:
- linaro@t430:~/linaro/linux-kernel$ make VF=1 -C tools/perf
+ linaro@t430:~/linaro/linux-kernel$ make CORESIGHT=1 VF=1 -C tools/perf
Auto-detecting system features:
... dwarf: [ on ]
... dwarf_getlocations: [ on ]
@@ -376,8 +376,8 @@ build script where to get the header file and libraries, namely CSINCLUDES and
CSLIBS:
linaro@t430:~/linaro/linux-kernel$ export CSINCLUDES=~/linaro/coresight/my-opencsd/decoder/include/
- linaro@t430:~/linaro/linux-kernel$ export CSLIBS=~/linaro/coresight/my-opencsd/decoder/lib/linux64-rel/
- linaro@t430:~/linaro/linux-kernel$ make VF=1 -C tools/perf
+ linaro@t430:~/linaro/linux-kernel$ export CSLIBS=~/linaro/coresight/my-opencsd/decoder/lib/builddir/
+ linaro@t430:~/linaro/linux-kernel$ make CORESIGHT=1 VF=1 -C tools/perf
This will have the effect of compiling and linking against the provided library.
Since the system's openCSD library is in the loader's search patch the
@@ -611,37 +611,12 @@ will add the --dump option to the end of the command line and run
Generating coverage files for Feedback Directed Optimization: AutoFDO
---------------------------------------------------------------------
-Below is an example of using ARM ETM for autoFDO. The updates to the perf
-support for this is experimental and available on the 'autoFDO' branch of
-the [perf-opencsd github repository][1].
-
-It also requires autofdo (https://github.com/google/autofdo) and gcc version 5. The bubble
-sort example is from the AutoFDO tutorial (https://gcc.gnu.org/wiki/AutoFDO/Tutorial).
-
- $ gcc-5 -O3 sort.c -o sort_optimized
- $ taskset -c 2 ./sort_optimized
- Bubble sorting array of 30000 elements
- 5910 ms
-
- $ perf record -e cs_etm/@20070000.etr/u --per-thread taskset -c 2 ./sort
- Bubble sorting array of 30000 elements
- 12543 ms
- [ perf record: Woken up 35 times to write data ]
- [ perf record: Captured and wrote 69.640 MB perf.data ]
-
- $ perf inject -i perf.data -o inj.data --itrace=il64 --strip
- $ create_gcov --binary=./sort --profile=inj.data --gcov=sort.gcov -gcov_version=1
- $ gcc-5 -O3 -fauto-profile=sort.gcov sort.c -o sort_autofdo
- $ taskset -c 2 ./sort_autofdo
- Bubble sorting array of 30000 elements
- 5806 ms
+See autofdo.md (@ref AutoFDO) for details and scripts.
The Linaro CoreSight Team
-------------------------
- Mike Leach
-- Tor Jeremiassen
-- Chunyan Zang
- Mathieu Poirier
diff --git a/README.md b/README.md
index 44b7c6807c35..c3f238ff1946 100644
--- a/README.md
+++ b/README.md
@@ -27,11 +27,11 @@ Releases will appear on the master branch in the git repository with an appropri
CoreSight Trace Component Support.
----------------------------------
-_Current Version 0.8.2_
+_Current Version 0.12.0_
### Current support:
-- ETMv4 (v4.1) instruction trace - packet processing and packet decode.
+- ETMv4 (v4.4) instruction trace - packet processing and packet decode.
- PTM (v1.1) instruction trace - packet processing and packet decode.
- ETMv3 (v3.5) instruction trace - packet processing and packet decode.
- ETMv3 (v3.5) data trace - packet processing.
@@ -73,12 +73,20 @@ Run `doxygen` on the `./doxygen_config.dox` file located in the `./docs` directo
This will produce the documentation in the `./docs/html` directory. The doxygen configuration also includes
the `*.md` files as part of the documentation.
+Application Programming using the Library
+-----------------------------------------
-Building the Library
---------------------
+See the [programmers guide](@ref prog_guide) for details on usage of the library in custom applications.
+(`./docs/prog_guide/prog_guide_main.md`).
+
+
+Building and Installing the Library
+-----------------------------------
See [build_libs.md](@ref build_lib) in the `./docs` directory for build details.
+The linux build makefile now contains options to install the library for a linux environment.
+
How the Library is used in Linux `perf`
---------------------------------------
@@ -88,6 +96,15 @@ with the standard linux perfomance analysis tool `perf`.
See [HOWTO.md](@ref howto_perf) for details.
+How to use the Library, perf and Trace for AutoFDO
+--------------------------------------------------
+Capturing trace using perf and decoding using the library can
+generate profiles for AutoFDO.
+
+See [autofdo.md](@ref AutoFDO) for details and scripts.
+
+(`./tests/auto-fdo/autofdo.md`).
+
Version and Modification Information
====================================
@@ -116,6 +133,39 @@ Version and Modification Information
Library output naming changed from 'cstraced' to 'opencsd'.
- _Version 0.8.1_: Minor updates: Use install tool to copy headers. Changes to HOWTO for perf usage.
- _Version 0.8.2_: Bugfix: C++ init errors fixed for CLANG build process.
+- _Version 0.8.3_: Bugfix: ETMv4 decoder issues fixed.
+- _Version 0.8.4_: build: makefile updates and improvements to get build process compatible with Debian packaging.
+- _Version 0.9.0_: Performance improvements for perf: Additional info in instruction range output packet. Caching memory accesses.
+ Added Programmers guide to documentation.
+- _Version 0.9.1_: Bugfix: Crash during decode when first memory access is to address where no image provided.
+- _Version 0.9.2_: Bugfix: ETMv4: Incorrect Exception number output for Genric exception packets.
+ AutoFDO: update documentation for AutoFDO usage and add in "record.sh" script
+- _Version 0.9.3_: Bugfix: Test snapshot library not handling 'offset' parameters in dump file sections.
+ Install: ocsd_if_version.h moved to opencsd/include to allow installation on OS & use in compiling client apps.
+- _Version 0.10.0_: __Updates__: Add additional information about the last instruction to the generic output packet.
+ __Docs__: update docs for updated output packet.
+ __Bugfix__: typecast removed from OCSD_VER_NUM in ocsd_if_version.h to allow use in C pre-processor.
+ __Bugfix__: ETMV4: Interworking ISA change between A32-T32 occasionally missed during instruction decode.
+- _Version 0.10.1_: __Updates__: Build update - allow multi-thread make (make -j<N>).
+ __Docs__: Minor update to AutoFDO documentation.
+- _Version 0.11.0_: __Update__: ETM v4 decoder updated to support ETM version up to v4.4
+ __Update__: Memory access callback function - added new callback signature to provide TraceID to client when requesting memory.
+ __Update__: Created new example program to demonstrate using memory buffer in APIs.
+ __Bugfix__: Typos in docs and source.
+ __Bugfix__: Memory accessor - validate callback return values.
+- _Version 0.11.1_: __Update__: build:- change -fpic to -fPIC to allow Debian build on sparc.
+ __Bugfix__: build:- remove unused variable
+- _Version 0.11.2_: __Update__: docs:- HOWTO.md update to match new perf build requirements.
+ __Bugfix__: Minor spelling typos fixed.
+- _Version 0.12.0_: __Update__: Frame deformatter - TPIU FSYNC and HSYNC support added.
+ __Update__: ETM v4: Bugfix & clarification on Exception trace handling. Where exception occurs at a branch target before any instructions
+ have been executed, the preferred return address is also the target address of the branch instruction. This case now includes as specific flag in
+ the packet. Additionally any context change associated with this target address was being applied incorrectly.
+ __Update__: Core / Architecture mapping to core names as used by test programs / snapshots updated to include additional recent ARM cores.
+ __Update__: Docs: Update to reflect new exception flag. Update test program example to reflect latest output.
+ __Bugfix__: ETM v4: Valid trace info packet was not handled correctly (0x01, 0x00).
+ __Bugfix__: ETM v4: Error messaging on commit stack overflow.
+
Licence Information
===================
diff --git a/decoder/build/linux/makefile b/decoder/build/linux/makefile
index 330829b77089..6032c2cf7283 100644
--- a/decoder/build/linux/makefile
+++ b/decoder/build/linux/makefile
@@ -33,9 +33,9 @@
# DEBUG=1 create a debug build
#
-# Set project root - relative to build directory
+# Set project root - relative to build makefile
ifeq ($(OCSD_ROOT),)
-OCSD_ROOT := $(shell pwd | sed 's,/build/linux.*,,')
+OCSD_ROOT := $(shell echo $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | sed 's,/build/linux.*,,')
export OCSD_ROOT
endif
@@ -45,14 +45,6 @@ export LIB_BASE_NAME
LIB_CAPI_NAME=$(LIB_BASE_NAME)_c_api
export LIB_CAPI_NAME
-# determine base architecture, heavily borrowed from the Linux kernel v4.4's
-# tools/perf/config/Makefile.arch
-# For example, to compile for arm64 on a X86 PC, you can issue the command:
-# "export ARCH=arm64"
-ifndef ARCH
-ARCH := $(shell uname -m 2>/dev/null || echo not)
-endif
-
# source root directories
export OCSD_LIB_ROOT=$(OCSD_ROOT)/lib
@@ -60,71 +52,61 @@ export OCSD_INCLUDE=$(OCSD_ROOT)/include
export OCSD_SOURCE=$(OCSD_ROOT)/source
export OCSD_TESTS=$(OCSD_ROOT)/tests
-
export LIB_UAPI_INC_DIR=opencsd
# tools
export MASTER_CC=$(CROSS_COMPILE)gcc
-export MASTER_CPP=$(CROSS_COMPILE)g++
+export MASTER_CXX=$(CROSS_COMPILE)g++
export MASTER_LINKER=$(CROSS_COMPILE)g++
export MASTER_LIB=$(CROSS_COMPILE)ar
export INSTALL=install
+
# installation directory
-INSTALL_LIB_DIR=/usr/lib/
-export INSTALL_INCLUDE_DIR=/usr/include/
+PREFIX ?=/usr
+LIB_PATH ?= lib
+INSTALL_LIB_DIR=$(PREFIX)/$(LIB_PATH)
+INSTALL_BIN_DIR=$(PREFIX)/bin
+export INSTALL_INCLUDE_DIR=$(PREFIX)/include/
# compile flags
-MASTER_CC_FLAGS := -c -Wall -DLINUX
-MASTER_CPP_FLAGS := -c -Wall -DLINUX -std=c++11
-MASTER_LINKER_FLAGS := -Wl,-z,defs
-MASTER_LIB_FLAGS := rcs
+CFLAGS += $(CPPFLAGS) -c -Wall -DLINUX -Wno-switch -fPIC
+CXXFLAGS += $(CPPFLAGS) -c -Wall -DLINUX -Wno-switch -fPIC -std=c++11
+LDFLAGS += -Wl,-z,defs
+ARFLAGS ?= rcs
# debug variant
ifdef DEBUG
-MASTER_CC_FLAGS += -g -O0 -DDEBUG
-MASTER_CPP_FLAGS += -g -O0 -DDEBUG
+CFLAGS += -g -O0 -DDEBUG
+CXXFLAGS += -g -O0 -DDEBUG
BUILD_VARIANT=dbg
else
-MASTER_CC_FLAGS += -g -O2 -DNDEBUG
-MASTER_CPP_FLAGS += -g -O2 -DNDEBUG
+CFLAGS += -g -O2 -DNDEBUG
+CXXFLAGS += -g -O2 -DNDEBUG
BUILD_VARIANT=rel
endif
-
-# platform bit size variant
-ifeq ($(ARCH),x86)
- MFLAG:="-m32"
- BIT_VARIANT=32
-else ifeq ($(ARCH),x86_64)
- MFLAG:="-m64"
- BIT_VARIANT=64
-else ifeq ($(ARCH),arm)
- BIT_VARIANT=-arm
-else ifeq ($(ARCH),arm64)
- BIT_VARIANT=-arm64
-else ifeq ($(ARCH),aarch64)
- BIT_VARIANT=-arm64
-else ifeq ($(ARCH),aarch32)
- BIT_VARIANT=-arm
-endif
-
-MASTER_CC_FLAGS += $(MFLAG)
-MASTER_CPP_FLAGS += $(MFLAG)
-MASTER_LINKER_FLAGS += $(MFLAG)
-
# export build flags
-export MASTER_CC_FLAGS
-export MASTER_CPP_FLAGS
-export MASTER_LINKER_FLAGS
-export MASTER_LIB_FLAGS
-
-# target directories
-export PLAT_DIR=linux$(BIT_VARIANT)/$(BUILD_VARIANT)
+export CFLAGS
+export CXXFLAGS
+export LDFLAGS
+export ARFLAGS
+
+# target directories - fixed for default packaging build
+PLAT_DIR ?= builddir
+export PLAT_DIR
export LIB_TARGET_DIR=$(OCSD_LIB_ROOT)/$(PLAT_DIR)
export LIB_TEST_TARGET_DIR=$(OCSD_TESTS)/lib/$(PLAT_DIR)
export BIN_TEST_TARGET_DIR=$(OCSD_TESTS)/bin/$(PLAT_DIR)
+# Fish version out of header file (converting from hex)
+getver:=printf "%d" $$(awk '/\#define VARNAME/ { print $$3 }' $(OCSD_ROOT)/include/opencsd/ocsd_if_version.h)
+export SO_MAJOR_VER := $(shell $(subst VARNAME,OCSD_VER_MAJOR,$(getver)))
+SO_MINOR_VER := $(shell $(subst VARNAME,OCSD_VER_MINOR,$(getver)))
+SO_PATCH_VER := $(shell $(subst VARNAME,OCSD_VER_PATCH,$(getver)))
+export SO_VER := $(SO_MAJOR_VER).$(SO_MINOR_VER).$(SO_PATCH_VER)
+
+
###########################################################
# build targets
@@ -132,10 +114,19 @@ all: libs tests
libs: $(LIB_BASE_NAME)_lib $(LIB_CAPI_NAME)_lib
-install: libs
- $(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).so $(INSTALL_LIB_DIR)/
- $(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).so $(INSTALL_LIB_DIR)/
+install: libs tests
+ mkdir -p $(INSTALL_LIB_DIR) $(INSTALL_INCLUDE_DIR) $(INSTALL_BIN_DIR)
+ cp -d $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).so $(INSTALL_LIB_DIR)/
+ cp -d $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).so.$(SO_MAJOR_VER) $(INSTALL_LIB_DIR)/
+ $(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).so.$(SO_VER) $(INSTALL_LIB_DIR)/
+ cp -d $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).so $(INSTALL_LIB_DIR)/
+ cp -d $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).so.$(SO_MAJOR_VER) $(INSTALL_LIB_DIR)/
+ $(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).so.$(SO_VER) $(INSTALL_LIB_DIR)/
+ $(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).a $(INSTALL_LIB_DIR)/
+ $(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).a $(INSTALL_LIB_DIR)/
cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && make install_inc
+ $(INSTALL) --mode=755 $(BIN_TEST_TARGET_DIR)/trc_pkt_lister $(INSTALL_BIN_DIR)/
+
################################
# build OpenCSD trace decode library
@@ -148,7 +139,7 @@ $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).a: $(LIB_BASE_NAME)_all
# single command builds both .a and .so targets in sub-makefile
$(LIB_BASE_NAME)_all:
mkdir -p $(LIB_TARGET_DIR)
- cd $(OCSD_ROOT)/build/linux/ref_trace_decode_lib && make
+ cd $(OCSD_ROOT)/build/linux/ref_trace_decode_lib && $(MAKE)
################################
# build OpenCSD trace decode C API library
@@ -161,36 +152,49 @@ $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).a: $(LIB_CAPI_NAME)_all
# single command builds both .a and .so targets in sub-makefile
$(LIB_CAPI_NAME)_all: $(LIB_BASE_NAME)_lib
mkdir -p $(LIB_TARGET_DIR)
- cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && make
+ cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && $(MAKE)
#################################
# build tests
.PHONY: tests
tests: libs
- cd $(OCSD_ROOT)/tests/build/linux/echo_test_dcd_lib && make
- cd $(OCSD_ROOT)/tests/build/linux/snapshot_parser_lib && make
- cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && make
- cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && make
+ cd $(OCSD_ROOT)/tests/build/linux/echo_test_dcd_lib && $(MAKE)
+ cd $(OCSD_ROOT)/tests/build/linux/snapshot_parser_lib && $(MAKE)
+ cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && $(MAKE)
+ cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && $(MAKE)
+ cd $(OCSD_ROOT)/tests/build/linux/mem_buffer_eg && $(MAKE)
+
+#
+# build docs
+.PHONY: docs
+docs:
+ (cd $(OCSD_ROOT)/docs; doxygen doxygen_config.dox)
+
#############################################################
# clean targets
#
-clean: clean_libs clean_tests
+clean: clean_libs clean_tests clean_docs
-.PHONY: clean_libs clean_tests
+.PHONY: clean_libs clean_tests clean_docs clean_install
clean_libs:
- cd $(OCSD_ROOT)/build/linux/ref_trace_decode_lib && make clean
- cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && make clean
+ cd $(OCSD_ROOT)/build/linux/ref_trace_decode_lib && $(MAKE) clean
+ cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && $(MAKE) clean
clean_tests:
- cd $(OCSD_ROOT)/tests/build/linux/echo_test_dcd_lib && make clean
- cd $(OCSD_ROOT)/tests/build/linux/snapshot_parser_lib && make clean
- cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && make clean
- cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && make clean
+ cd $(OCSD_ROOT)/tests/build/linux/echo_test_dcd_lib && $(MAKE) clean
+ cd $(OCSD_ROOT)/tests/build/linux/snapshot_parser_lib && $(MAKE) clean
+ cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && $(MAKE) clean
+ cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && $(MAKE) clean
+ cd $(OCSD_ROOT)/tests/build/linux/mem_buffer_eg && $(MAKE) clean
+ -rmdir $(OCSD_TESTS)/lib
+
+clean_docs:
+ -rm -r $(OCSD_ROOT)/docs/html
clean_install:
- rm -f $(INSTALL_LIB_DIR)/lib$(LIB_BASE_NAME).so
- rm -f $(INSTALL_LIB_DIR)/lib$(LIB_CAPI_NAME).so
- rm -rf $(INSTALL_INCLUDE_DIR)/$(LIB_UAPI_INC_DIR)
+ -rm $(INSTALL_LIB_DIR)/lib$(LIB_BASE_NAME).*
+ -rm $(INSTALL_LIB_DIR)/lib$(LIB_CAPI_NAME).*
+ -rm -r $(INSTALL_INCLUDE_DIR)/$(LIB_UAPI_INC_DIR)
diff --git a/decoder/build/linux/makefile.dev b/decoder/build/linux/makefile.dev
new file mode 100644
index 000000000000..7c02328db2a8
--- /dev/null
+++ b/decoder/build/linux/makefile.dev
@@ -0,0 +1,62 @@
+########################################################
+# Copyright 2018 ARM Limited. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors
+# may be used to endorse or promote products derived from this software without
+# specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#################################################################################
+
+## Set up some addtional parameters for development environment builds. ##
+
+## define arch/build sub-dirs for non installed dev builds
+ifndef ARCH
+ARCH := $(shell dpkg-architecture -q DEB_HOST_GNU_CPU || echo not)
+endif
+
+# platform bit size variant
+ifeq ($(ARCH),x86)
+ MFLAG:="-m32"
+ BIT_VARIANT=32
+else ifeq ($(ARCH),x86_64)
+ MFLAG:="-m64"
+ BIT_VARIANT=64
+else ifeq ($(ARCH),arm)
+ BIT_VARIANT=-arm
+else ifeq ($(ARCH),arm64)
+ BIT_VARIANT=-arm64
+else ifeq ($(ARCH),aarch64)
+ BIT_VARIANT=-arm64
+else ifeq ($(ARCH),aarch32)
+ BIT_VARIANT=-arm
+endif
+
+CXXFLAGS += $(MFLAG)
+CFLAGS += $(MFLAG)
+LDFLAGS += $(MFLAG)
+
+PLAT_DIR=linux$(BIT_VARIANT)/$(BUILD_VARIANT)
+
+# include the main makefile
+include makefile
diff --git a/decoder/build/linux/rctdl_c_api_lib/makefile b/decoder/build/linux/rctdl_c_api_lib/makefile
index fb54d3ad8c24..a0bd5a345f2f 100644
--- a/decoder/build/linux/rctdl_c_api_lib/makefile
+++ b/decoder/build/linux/rctdl_c_api_lib/makefile
@@ -30,14 +30,10 @@
# OpenCSD - makefile for C API wrapper library
#
-CPP := $(MASTER_CPP)
+CXX := $(MASTER_CXX)
LINKER := $(MASTER_LINKER)
LIB := $(MASTER_LIB)
-CPP_FLAGS := $(MASTER_CPP_FLAGS) -fpic -Wno-switch
-LIB_FLAGS := $(MASTER_LIB_FLAGS)
-LINKER_FLAGS := $(MASTER_LINKER_FLAGS) -shared
-
LIB_NAME = lib$(LIB_CAPI_NAME)
SO_LIB_DEPS= -L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME)
@@ -45,7 +41,7 @@ BUILD_DIR=./$(PLAT_DIR)
VPATH= $(OCSD_SOURCE)/c_api
-CPP_INCLUDES= \
+CXX_INCLUDES= \
-I$(OCSD_INCLUDE) \
-I$(OCSD_SOURCE)/c_api
@@ -55,14 +51,32 @@ OBJECTS=$(BUILD_DIR)/ocsd_c_api.o \
INST_INC_SRC=$(OCSD_INCLUDE)/$(LIB_UAPI_INC_DIR)
INST_INC_DST=$(INSTALL_INCLUDE_DIR)/$(LIB_UAPI_INC_DIR)
-all: build_dir $(OBJECTS)
- mkdir -p $(LIB_TARGET_DIR)
- $(LIB) $(LIB_FLAGS) $(LIB_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
- $(LINKER) $(LINKER_FLAGS) -o $(LIB_TARGET_DIR)/$(LIB_NAME).so -Wl,-soname,$(LIB_NAME).so $(OBJECTS) $(SO_LIB_DEPS)
+all: links
+
+links: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_TARGET_DIR)/$(LIB_NAME).so
+.PHONY: links
+
+LIBS:= $(LIB_TARGET_DIR)/$(LIB_NAME).a $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER)
-build_dir:
+$(LIB_TARGET_DIR):
+ mkdir -p $(LIB_TARGET_DIR)
+
+$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
+$(LIB_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
+ $(LIB) $(ARFLAGS) $(LIB_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
+
+$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER): $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
+ $(LINKER) $(LDFLAGS) -shared -o $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER) -Wl,-soname,$(LIB_NAME).so.$(SO_MAJOR_VER) $(OBJECTS) $(SO_LIB_DEPS)
+
+$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER): $(LIBS) | $(LIB_TARGET_DIR)
+ ( cd $(LIB_TARGET_DIR); ln -sf $(LIB_NAME).so.$(SO_VER) $(LIB_NAME).so.$(SO_MAJOR_VER) )
+
+$(LIB_TARGET_DIR)/$(LIB_NAME).so: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) | $(LIB_TARGET_DIR)
+ ( cd $(LIB_TARGET_DIR); ln -sf $(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_NAME).so )
+
+
##### build rules
## object dependencies
@@ -71,8 +85,8 @@ DEPS := $(OBJECTS:%.o=%.d)
-include $(DEPS)
## object compile
-$(BUILD_DIR)/%.o : %.cpp
- $(CPP) $(CPP_FLAGS) $(CPP_INCLUDES) -MMD $< -o $@
+$(BUILD_DIR)/%.o : %.cpp | $(BUILD_DIR)
+ $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
#### clean
@@ -81,13 +95,15 @@ clean:
rm -f $(OBJECTS)
rm -f $(DEPS)
rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).a
- rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).so
+ rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).so*
+ -rmdir $(BUILD_DIR)
#### install the necessary include files for the c-api library on linux
install_inc:
$(INSTALL) -d --mode=0755 $(INST_INC_DST)/
$(INSTALL) --mode=0644 $(INST_INC_SRC)/trc_gen_elem_types.h $(INST_INC_DST)/
$(INSTALL) --mode=0644 $(INST_INC_SRC)/ocsd_if_types.h $(INST_INC_DST)/
+ $(INSTALL) --mode=0644 $(INST_INC_SRC)/ocsd_if_version.h $(INST_INC_DST)/
$(INSTALL) --mode=0644 $(INST_INC_SRC)/trc_pkt_types.h $(INST_INC_DST)/
$(INSTALL) -d --mode=0755 $(INST_INC_DST)/ptm
$(INSTALL) --mode=0644 $(INST_INC_SRC)/ptm/trc_pkt_types_ptm.h $(INST_INC_DST)/ptm/
diff --git a/decoder/build/linux/ref_trace_decode_lib/makefile b/decoder/build/linux/ref_trace_decode_lib/makefile
index a356066d009f..373e8248bd6a 100644
--- a/decoder/build/linux/ref_trace_decode_lib/makefile
+++ b/decoder/build/linux/ref_trace_decode_lib/makefile
@@ -30,14 +30,10 @@
# OpenCSD - makefile for main trace decode library
#
-CPP := $(MASTER_CPP)
+CXX := $(MASTER_CXX)
LINKER := $(MASTER_LINKER)
LIB := $(MASTER_LIB)
-CPP_FLAGS := $(MASTER_CPP_FLAGS) -fpic -Wno-switch
-LIB_FLAGS := $(MASTER_LIB_FLAGS)
-LINKER_FLAGS := $(MASTER_LINKER_FLAGS) -shared
-
LIB_NAME= lib$(LIB_BASE_NAME)
BUILD_DIR=./$(PLAT_DIR)
@@ -52,7 +48,7 @@ VPATH= $(OCSD_SOURCE) \
$(OCSD_SOURCE)/pkt_printers
-CPP_INCLUDES= \
+CXX_INCLUDES= \
-I$(OCSD_INCLUDE) \
-I$(OCSD_SOURCE)
@@ -82,7 +78,8 @@ MEMACCOBJ= $(BUILD_DIR)/trc_mem_acc_mapper.o \
$(BUILD_DIR)/trc_mem_acc_bufptr.o \
$(BUILD_DIR)/trc_mem_acc_file.o \
$(BUILD_DIR)/trc_mem_acc_base.o \
- $(BUILD_DIR)/trc_mem_acc_cb.o
+ $(BUILD_DIR)/trc_mem_acc_cb.o \
+ $(BUILD_DIR)/trc_mem_acc_cache.o
STMOBJ= $(BUILD_DIR)/trc_pkt_elem_stm.o \
$(BUILD_DIR)/trc_pkt_proc_stm.o \
@@ -114,14 +111,32 @@ OBJECTS=$(BUILD_DIR)/ocsd_code_follower.o \
$(PTMOBJ) \
$(PKTPRNTOBJ)
-all: build_dir $(OBJECTS)
+all: links
+
+links: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_TARGET_DIR)/$(LIB_NAME).so
+.PHONY: links
+
+LIBS:= $(LIB_TARGET_DIR)/$(LIB_NAME).a $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER)
+
+$(LIB_TARGET_DIR):
mkdir -p $(LIB_TARGET_DIR)
- $(LIB) $(LIB_FLAGS) $(LIB_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
- $(LINKER) $(LINKER_FLAGS) -o $(LIB_TARGET_DIR)/$(LIB_NAME).so -Wl,-soname,$(LIB_NAME).so $(OBJECTS)
-build_dir:
+$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
+$(LIB_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
+ $(LIB) $(ARFLAGS) $(LIB_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
+
+$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER): $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
+ $(LINKER) $(LDFLAGS) -shared -o $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER) -Wl,-soname,$(LIB_NAME).so.$(SO_MAJOR_VER) $(OBJECTS)
+
+$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER): $(LIBS) | $(LIB_TARGET_DIR)
+ ( cd $(LIB_TARGET_DIR); ln -sf $(LIB_NAME).so.$(SO_VER) $(LIB_NAME).so.$(SO_MAJOR_VER) )
+
+$(LIB_TARGET_DIR)/$(LIB_NAME).so: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) | $(LIB_TARGET_DIR)
+ ( cd $(LIB_TARGET_DIR); ln -sf $(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_NAME).so )
+
+
##### build rules
## object dependencies
@@ -130,8 +145,8 @@ DEPS := $(OBJECTS:%.o=%.d)
-include $(DEPS)
## object compile
-$(BUILD_DIR)/%.o : %.cpp
- $(CPP) $(CPP_FLAGS) $(CPP_INCLUDES) -MMD $< -o $@
+$(BUILD_DIR)/%.o : %.cpp | $(BUILD_DIR)
+ $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
#### clean
@@ -140,4 +155,5 @@ clean:
rm -f $(OBJECTS)
rm -f $(DEPS)
rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).a
- rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).so
+ rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).so*
+ -rmdir $(BUILD_DIR)
diff --git a/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.sln b/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.sln
index 94b561a39848..4f3ddebeb324 100644
--- a/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.sln
+++ b/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.sln
@@ -28,6 +28,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ext_dcd_echo_test", "..\..\
{533F929A-A73B-46B6-9D5F-FFCD62F734E3} = {533F929A-A73B-46B6-9D5F-FFCD62F734E3}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mem-buffer-eg", "..\..\..\tests\build\win-vs2015\mem-buffer-eg\mem-buffer-eg.vcxproj", "{BC090130-2C53-4CF6-8AD4-37BF72B8D01A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {7F500891-CC76-405F-933F-F682BC39F923} = {7F500891-CC76-405F-933F-F682BC39F923}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -128,6 +133,22 @@ Global
{46219A32-8178-41C1-B3B1-B5A6E547515F}.Release-dll|Win32.Build.0 = Release|Win32
{46219A32-8178-41C1-B3B1-B5A6E547515F}.Release-dll|x64.ActiveCfg = Release|x64
{46219A32-8178-41C1-B3B1-B5A6E547515F}.Release-dll|x64.Build.0 = Release|x64
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Debug|Win32.Build.0 = Debug|Win32
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Debug|x64.ActiveCfg = Debug|x64
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Debug|x64.Build.0 = Debug|x64
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Debug-dll|Win32.ActiveCfg = Debug|Win32
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Debug-dll|Win32.Build.0 = Debug|Win32
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Debug-dll|x64.ActiveCfg = Debug|x64
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Debug-dll|x64.Build.0 = Debug|x64
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Release|Win32.ActiveCfg = Release|Win32
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Release|Win32.Build.0 = Release|Win32
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Release|x64.ActiveCfg = Release|x64
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Release|x64.Build.0 = Release|x64
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Release-dll|Win32.ActiveCfg = Release|Win32
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Release-dll|Win32.Build.0 = Release|Win32
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Release-dll|x64.ActiveCfg = Release|x64
+ {BC090130-2C53-4CF6-8AD4-37BF72B8D01A}.Release-dll|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj b/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj
index 123fc0061100..095f27b56acc 100644
--- a/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj
+++ b/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj
@@ -337,6 +337,7 @@
<ClInclude Include="..\..\..\include\common\trc_pkt_proc_base.h" />
<ClInclude Include="..\..\..\include\common\trc_printable_elem.h" />
<ClInclude Include="..\..\..\include\common\trc_ret_stack.h" />
+ <ClInclude Include="..\..\..\include\mem_acc\trc_mem_acc_cache.h" />
<ClInclude Include="..\..\..\include\opencsd\etmv3\etmv3_decoder.h" />
<ClInclude Include="..\..\..\include\opencsd\etmv3\trc_cmp_cfg_etmv3.h" />
<ClInclude Include="..\..\..\include\opencsd\etmv3\trc_dcd_mngr_etmv3.h" />
@@ -374,8 +375,8 @@
<ClInclude Include="..\..\..\include\mem_acc\trc_mem_acc_file.h" />
<ClInclude Include="..\..\..\include\mem_acc\trc_mem_acc_mapper.h" />
<ClInclude Include="..\..\..\include\opencsd\ocsd_if_types.h" />
- <ClInclude Include="..\..\..\include\ocsd_if_version.h" />
<ClInclude Include="..\..\..\include\opencsd.h" />
+ <ClInclude Include="..\..\..\include\opencsd\ocsd_if_version.h" />
<ClInclude Include="..\..\..\include\pkt_printers\gen_elem_printer.h" />
<ClInclude Include="..\..\..\include\pkt_printers\item_printer.h" />
<ClInclude Include="..\..\..\include\pkt_printers\pkt_printer_t.h" />
@@ -420,6 +421,7 @@
<ClCompile Include="..\..\..\source\i_dec\trc_i_decode.cpp" />
<ClCompile Include="..\..\..\source\mem_acc\trc_mem_acc_base.cpp" />
<ClCompile Include="..\..\..\source\mem_acc\trc_mem_acc_bufptr.cpp" />
+ <ClCompile Include="..\..\..\source\mem_acc\trc_mem_acc_cache.cpp" />
<ClCompile Include="..\..\..\source\mem_acc\trc_mem_acc_cb.cpp" />
<ClCompile Include="..\..\..\source\mem_acc\trc_mem_acc_file.cpp" />
<ClCompile Include="..\..\..\source\mem_acc\trc_mem_acc_mapper.cpp" />
diff --git a/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj.filters b/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj.filters
index cceb92bd83ff..1ef87207089f 100644
--- a/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj.filters
+++ b/decoder/build/win-vs2015/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj.filters
@@ -320,9 +320,6 @@
<ClInclude Include="..\..\..\include\opencsd\stm\trc_pkt_decode_stm.h">
<Filter>Header Files\stm</Filter>
</ClInclude>
- <ClInclude Include="..\..\..\include\ocsd_if_version.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\..\..\include\pkt_printers\gen_elem_printer.h">
<Filter>Header Files\pkt_printers</Filter>
</ClInclude>
@@ -356,6 +353,12 @@
<ClInclude Include="..\..\..\include\opencsd\trc_pkt_types.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\include\mem_acc\trc_mem_acc_cache.h">
+ <Filter>Header Files\mem_acc</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\include\opencsd\ocsd_if_version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\source\trc_component.cpp">
@@ -484,5 +487,8 @@
<ClCompile Include="..\..\..\source\etmv4\trc_etmv4_stack_elem.cpp">
<Filter>Source Files\etmv4</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\source\mem_acc\trc_mem_acc_cache.cpp">
+ <Filter>Source Files\mem_acc</Filter>
+ </ClCompile>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/decoder/docs/build_libs.md b/decoder/docs/build_libs.md
index b7c8536ca5f0..dc7d85da9401 100644
--- a/decoder/docs/build_libs.md
+++ b/decoder/docs/build_libs.md
@@ -6,47 +6,102 @@ Building and using the Library {#build_lib}
Platform Support
----------------
-The current makefiles and build projects support building the library on Linux and Windows,
-x86 or x64 hosts.
-
-Support is expected for ARM linux and baremetal, AArch32 and AArch64 platforms.
+The current makefiles and build projects support building the library on:
+ - Linux and Windows, x86 or x64 hosts.
+ - ARM linux - AArch32 and AArch64
+ - ARM aarch32 and aarch64 libs, x-compiled on x86/64 hosts.
+In addition to building the library from the project, the library may be installed into the standard
+`/usr/lib/` area in Linux, and will soon be available as a package from Linux Distros.
Building the Library
--------------------
-The library and test programs are built from the library `./build/<platform>` directory.
+The library and test programs are built from the library `./build/<platform>` directory, where
+<platform> is either 'linux' or 'win-vs2015'
See [`./docs/test_progs.md`](@ref test_progs) for further information on use of the test
programs.
-### Linux x86/x64 ###
+### Linux x86/x64/ARM ###
+
+Libraries are built into a <tgt_dir>. This is used as the final output directory for the
+libraries in `decoder/lib/<tgt_dir>`, and also as a sub-directory of the build process for
+intermediate files - `decoder/build/linux/ref_trace_decode_lib/<tgt_dir>`.
+
+For a standard build, go to the `./build/linux/` and run `make` in that directory.
+
+This will set <tgt_dir> to `builddir` for all build variants of the library. Using this only one variant of the library can be built at any one time.
+
+For development, alternatively use `make -f makefile.dev`
+
+This will set <tgt_dir> to `linux<bit-variant>/<dbg|rel>` and therefore build libraries into the
+`decoder/lib/linux<bit-variant>/<dbg|rel>` directories, allowing multiple variants of the library
+to be present during development.
-Go to the `./build/linux/` and run `make` in that directory.
+e.g.
-Options to pass to the makefile are:-
-- `LINUX64=1` : build the 64 bit version of the library
+`./lib/linux64/rel` will contain the linux 64 bit release libraries.
+
+`./lib/linux-arm64/dbg` will contain the linux aarch 64 debug libraries for ARM.
+
+Options to pass to both makefiles are:-
- `DEBUG=1` : build the debug version of the library.
-Libraries are delivered to the `./lib/linux<bitsize>/<dbg\rel>` directories.
-e.g. `./lib/linux64/rel` will contain the linux 64 bit release libraries.
+Options to pass to makefile.dev are:-
+- ARCH=<arch> : sets the bit variant in the delivery directories. Set if cross compilation for ARCH
+ other than host. Otherwise ARCH is auto-detected.
+ <arch> can be x86, x86_64, arm, arm64, aarch64, aarch32
+
+For cross compilation, set the environment variable `CROSS_COMPILE` to the name path/prefix for the
+compiler to use. The following would set the environment to cross-compile for ARM
+
+ export PATH=$PATH:~/work/gcc-x-aarch64-6.2/bin
+ export ARCH=arm64
+ export CROSS_COMPILE=aarch64-linux-gnu-
+
+The makefile will scan the `ocsd_if_version.h` to get the library version numbers and use these
+in the form Major.minor.patch when naming the output .so files.
-The following libraries are built:-
-- `libcstraced.so` : shared library containing the main C++ based decoder library
-- `libcstraced_c_api.so` : shared library containing the C-API wrapper library. Dependent on `libcstraced.so`
+Main C++ library names:
+- `libcstraced.so.M.m.p` : shared library containing the main C++ based decoder library
+- `libcstrace.so.M` : symbolic link name to library - major version only.
+- `libcstrace.so` : symbolic link name to library - no version.
+
+C API wrapper library names:
+- `libcstraced_c_api.so.M.m.p` : shared library containing the C-API wrapper library. Dependent on `libcstraced.so.M`
+- `libcstraced_c_api.so.M` : symbolic link name to library - major version only.
+- `libcstraced_c_api.so` : symbolic link name to library - no version.
+
+Static versions of the libraries:
- `libcstraced.a` : static library containing the main C++ based decoder library.
- `libcstraced_c_api.a` : static library containing the C-API wrapper library.
-Test programs are delivered to the `./tests/bin/linux<bitsize>/<dgb\rel>` directories.
+Test programs are delivered to the `./tests/bin/<tgt_dir>` directories.
The test programs are built to used the .so versions of the libraries.
- `trc_pkt_lister` - dependent on `libcstraced.so`.
- `simple_pkt_print_c_api` - dependent on `libcstraced_c_api.so` & hence `libcstraced.so`.
The test program build for `trc_pkt_lister` also builds an auxiliary library used by this program for test purposes only.
-This is the `libsnapshot_parser.a` library, delivered to the `./tests/lib/linux<bitsize>/<dgb\rel>` directories.
+This is the `libsnapshot_parser.a` library, delivered to the `./tests/lib/<tgt_dir>` directories.
+
+__Installing on Linux__
+
+The libraries can be installed on linux using the `make install` command. This will usually require root privileges. Installation will be the version in the `./lib/<tgt_dir>` directory, according to options chosen.
+
+e.g. ` make -f makefile.dev DEBUG=1 install`
+
+will install from `./lib/linux64/dbg`
+
+The libraries `libopencsd` and `libopencsd_c_api` are installed to `/usr/lib`.
+
+Sufficient header files to build using the C-API library will be installed to `/usr/include/opencsd`.
+
+The installation can be removed using `make clean_install`. No additional options are necessary.
+
-### Windows ###
+### Windows (x86/x64) ###
Use the `.\build\win\ref_trace_decode_lib\ref_trace_decode_lib.sln` file to load a solution
which contains all library and test build projects.
diff --git a/decoder/docs/doxygen_config.dox b/decoder/docs/doxygen_config.dox
index acc6137f4264..0ca0cf7349b0 100644
--- a/decoder/docs/doxygen_config.dox
+++ b/decoder/docs/doxygen_config.dox
@@ -1,4 +1,4 @@
-# Doxyfile 1.8.8
+# Doxyfile 1.8.12
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
@@ -38,7 +38,7 @@ PROJECT_NAME = "OpenCSD - CoreSight Trace Decode Library"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 0.5
+PROJECT_NUMBER = 0.10.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@@ -46,10 +46,10 @@ PROJECT_NUMBER = 0.5
PROJECT_BRIEF =
-# With the PROJECT_LOGO tag one can specify an logo or icon that is included in
-# the documentation. The maximum height of the logo should not exceed 55 pixels
-# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo
-# to the output directory.
+# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
+# in the documentation. The maximum height of the logo should not exceed 55
+# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
+# the logo to the output directory.
PROJECT_LOGO =
@@ -60,7 +60,7 @@ PROJECT_LOGO =
OUTPUT_DIRECTORY = ./.
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
+# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
# will distribute the generated files over these directories. Enabling this
# option can be useful when feeding doxygen a huge amount of source files, where
@@ -93,14 +93,14 @@ ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
-# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member
+# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
# descriptions after the members that are listed in the file and class
# documentation (similar to Javadoc). Set to NO to disable this.
# The default value is: YES.
BRIEF_MEMBER_DESC = YES
-# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief
+# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
# description of a member or function before the detailed description
#
# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
@@ -145,7 +145,7 @@ ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
-# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path
+# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
# before files name in the file list and in the header files. If set to NO the
# shortest path that makes the file name unique will be used
# The default value is: YES.
@@ -215,9 +215,9 @@ MULTILINE_CPP_IS_BRIEF = NO
INHERIT_DOCS = YES
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a
-# new page for each member. If set to NO, the documentation of a member will be
-# part of the file/class/namespace that contains it.
+# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
+# page for each member. If set to NO, the documentation of a member will be part
+# of the file/class/namespace that contains it.
# The default value is: NO.
SEPARATE_MEMBER_PAGES = NO
@@ -286,7 +286,7 @@ OPTIMIZE_OUTPUT_VHDL = NO
# instance to make doxygen treat .inc files as Fortran files (default is PHP),
# and .f files as C (default is Fortran), use: inc=Fortran f=C.
#
-# Note For files without extension you can use no_extension as a placeholder.
+# Note: For files without extension you can use no_extension as a placeholder.
#
# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
# the files are not read by doxygen.
@@ -303,10 +303,19 @@ EXTENSION_MAPPING =
MARKDOWN_SUPPORT = YES
+# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up
+# to that level are automatically included in the table of contents, even if
+# they do not have an id attribute.
+# Note: This feature currently applies only to Markdown headings.
+# Minimum value: 0, maximum value: 99, default value: 0.
+# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
+
+TOC_INCLUDE_HEADINGS = 0
+
# When enabled doxygen tries to link words that correspond to documented
# classes, or namespaces to their corresponding documentation. Such a link can
-# be prevented in individual cases by by putting a % sign in front of the word
-# or globally by setting AUTOLINK_SUPPORT to NO.
+# be prevented in individual cases by putting a % sign in front of the word or
+# globally by setting AUTOLINK_SUPPORT to NO.
# The default value is: YES.
AUTOLINK_SUPPORT = YES
@@ -346,13 +355,20 @@ SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
+# tag is set to YES then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
# The default value is: NO.
DISTRIBUTE_GROUP_DOC = NO
+# If one adds a struct or class to a group and this option is enabled, then also
+# any nested class or struct is added to the same group. By default this option
+# is disabled and one has to add nested compounds explicitly via \ingroup.
+# The default value is: NO.
+
+GROUP_NESTED_COMPOUNDS = NO
+
# Set the SUBGROUPING tag to YES to allow class member groups of the same type
# (for instance a group of public functions) to be put as a subgroup of that
# type (e.g. under the Public Functions section). Set it to NO to prevent
@@ -411,7 +427,7 @@ LOOKUP_CACHE_SIZE = 0
# Build related configuration options
#---------------------------------------------------------------------------
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
# documentation are documented, even if no documentation was available. Private
# class members and static file members will be hidden unless the
# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
@@ -421,35 +437,35 @@ LOOKUP_CACHE_SIZE = 0
EXTRACT_ALL = YES
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will
+# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
# be included in the documentation.
# The default value is: NO.
EXTRACT_PRIVATE = NO
-# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal
+# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
# scope will be included in the documentation.
# The default value is: NO.
EXTRACT_PACKAGE = NO
-# If the EXTRACT_STATIC tag is set to YES all static members of a file will be
+# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
# included in the documentation.
# The default value is: NO.
EXTRACT_STATIC = NO
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined
-# locally in source files will be included in the documentation. If set to NO
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
+# locally in source files will be included in the documentation. If set to NO,
# only classes defined in header files are included. Does not have any effect
# for Java sources.
# The default value is: YES.
EXTRACT_LOCAL_CLASSES = YES
-# This flag is only useful for Objective-C code. When set to YES local methods,
+# This flag is only useful for Objective-C code. If set to YES, local methods,
# which are defined in the implementation section but not in the interface are
-# included in the documentation. If set to NO only methods in the interface are
+# included in the documentation. If set to NO, only methods in the interface are
# included.
# The default value is: NO.
@@ -474,21 +490,21 @@ HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy. If set
-# to NO these classes will be included in the various overviews. This option has
-# no effect if EXTRACT_ALL is enabled.
+# to NO, these classes will be included in the various overviews. This option
+# has no effect if EXTRACT_ALL is enabled.
# The default value is: NO.
HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
-# (class|struct|union) declarations. If set to NO these declarations will be
+# (class|struct|union) declarations. If set to NO, these declarations will be
# included in the documentation.
# The default value is: NO.
HIDE_FRIEND_COMPOUNDS = NO
# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
-# documentation blocks found inside the body of a function. If set to NO these
+# documentation blocks found inside the body of a function. If set to NO, these
# blocks will be appended to the function's detailed documentation block.
# The default value is: NO.
@@ -502,7 +518,7 @@ HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
-# names in lower-case letters. If set to YES upper-case letters are also
+# names in lower-case letters. If set to YES, upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# and Mac users are advised to set this option to NO.
@@ -511,12 +527,19 @@ INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
-# their full class and namespace scopes in the documentation. If set to YES the
+# their full class and namespace scopes in the documentation. If set to YES, the
# scope will be hidden.
# The default value is: NO.
HIDE_SCOPE_NAMES = NO
+# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
+# append additional text to a page's title, such as Class Reference. If set to
+# YES the compound reference will be hidden.
+# The default value is: NO.
+
+HIDE_COMPOUND_REFERENCE= NO
+
# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
# the files that are included by a file in the documentation of that file.
# The default value is: YES.
@@ -544,14 +567,14 @@ INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
# (detailed) documentation of file and class members alphabetically by member
-# name. If set to NO the members will appear in declaration order.
+# name. If set to NO, the members will appear in declaration order.
# The default value is: YES.
SORT_MEMBER_DOCS = YES
# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
# descriptions of file, namespace and class members alphabetically by member
-# name. If set to NO the members will appear in declaration order. Note that
+# name. If set to NO, the members will appear in declaration order. Note that
# this will also influence the order of the classes in the class list.
# The default value is: NO.
@@ -596,27 +619,25 @@ SORT_BY_SCOPE_NAME = NO
STRICT_PROTO_MATCHING = NO
-# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the
-# todo list. This list is created by putting \todo commands in the
-# documentation.
+# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
+# list. This list is created by putting \todo commands in the documentation.
# The default value is: YES.
GENERATE_TODOLIST = YES
-# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the
-# test list. This list is created by putting \test commands in the
-# documentation.
+# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
+# list. This list is created by putting \test commands in the documentation.
# The default value is: YES.
GENERATE_TESTLIST = YES
-# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug
+# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
# list. This list is created by putting \bug commands in the documentation.
# The default value is: YES.
GENERATE_BUGLIST = YES
-# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO)
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
# the deprecated list. This list is created by putting \deprecated commands in
# the documentation.
# The default value is: YES.
@@ -641,8 +662,8 @@ ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
-# the bottom of the documentation of classes and structs. If set to YES the list
-# will mention the files that were used to generate the documentation.
+# the bottom of the documentation of classes and structs. If set to YES, the
+# list will mention the files that were used to generate the documentation.
# The default value is: YES.
SHOW_USED_FILES = YES
@@ -706,7 +727,7 @@ CITE_BIB_FILES =
QUIET = NO
# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES
+# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
# this implies that the warnings are on.
#
# Tip: Turn warnings on while writing the documentation.
@@ -714,7 +735,7 @@ QUIET = NO
WARNINGS = YES
-# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate
+# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
# will automatically be disabled.
# The default value is: YES.
@@ -731,12 +752,18 @@ WARN_IF_DOC_ERROR = YES
# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
# are documented, but have no documentation for their parameters or return
-# value. If set to NO doxygen will only warn about wrong or incomplete parameter
-# documentation, but not about the absence of documentation.
+# value. If set to NO, doxygen will only warn about wrong or incomplete
+# parameter documentation, but not about the absence of documentation.
# The default value is: NO.
WARN_NO_PARAMDOC = NO
+# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
+# a warning is encountered.
+# The default value is: NO.
+
+WARN_AS_ERROR = NO
+
# The WARN_FORMAT tag determines the format of the warning messages that doxygen
# can produce. The string should contain the $file, $line, and $text tags, which
# will be replaced by the file and line number from which the warning originated
@@ -760,22 +787,25 @@ WARN_LOGFILE =
# The INPUT tag is used to specify the files and/or directories that contain
# documented source files. You may enter file names like myfile.cpp or
# directories like /usr/src/myproject. Separate the files or directories with
-# spaces.
+# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
INPUT = ../include \
../include/interfaces \
- ../include/etmv3 \
- ../include/etmv4 \
- ../include/ptm \
- ../include/c_api \
- ../include/stm \
+ ../include/opencsd/etmv3 \
+ ../include/opencsd/etmv4 \
+ ../include/opencsd/ptm \
+ ../include/opencsd/c_api \
+ ../include/opencsd/stm \
../include/mem_acc \
../../README.md \
. \
../../HOWTO.md \
../include/common \
- ../include
+ ./prog_guide \
+ ../include/opencsd \
+ ../include \
+ ../tests/auto-fdo/autofdo.md
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -788,12 +818,17 @@ INPUT_ENCODING = UTF-8
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
-# *.h) to filter out the source-files in the directories. If left blank the
-# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,
-# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,
-# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,
-# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,
-# *.qsf, *.as and *.js.
+# *.h) to filter out the source-files in the directories.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# read by doxygen.
+#
+# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
+# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
+# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
+# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
+# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf.
FILE_PATTERNS = *.c \
*.cc \
@@ -904,7 +939,7 @@ EXAMPLE_RECURSIVE = NO
# that contain images that are to be included in the documentation (see the
# \image command).
-IMAGE_PATH =
+IMAGE_PATH = prog_guide
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
@@ -920,6 +955,10 @@ IMAGE_PATH =
# Note that the filter must not add or remove lines; it is applied before the
# code is scanned, but not when the output code is generated. If lines are added
# or removed, the anchors will not be placed correctly.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
INPUT_FILTER =
@@ -929,11 +968,15 @@ INPUT_FILTER =
# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
# patterns match the file name, INPUT_FILTER is applied.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
FILTER_PATTERNS =
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER ) will also be used to filter the input files that are used for
+# INPUT_FILTER) will also be used to filter the input files that are used for
# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
# The default value is: NO.
@@ -993,7 +1036,7 @@ REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
-# to YES, then the hyperlinks from functions in REFERENCES_RELATION and
+# to YES then the hyperlinks from functions in REFERENCES_RELATION and
# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
# link to the documentation.
# The default value is: YES.
@@ -1040,13 +1083,13 @@ USE_HTAGS = NO
VERBATIM_HEADERS = YES
-# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the
+# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the
# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
# cost of reduced performance. This can be particularly helpful with template
# rich C++ code for which doxygen's built-in parser lacks the necessary type
# information.
# Note: The availability of this option depends on whether or not doxygen was
-# compiled with the --with-libclang option.
+# generated with the -Duse-libclang=ON option for CMake.
# The default value is: NO.
CLANG_ASSISTED_PARSING = NO
@@ -1089,7 +1132,7 @@ IGNORE_PREFIX =
# Configuration options related to the HTML output
#---------------------------------------------------------------------------
-# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output
+# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
# The default value is: YES.
GENERATE_HTML = YES
@@ -1155,10 +1198,10 @@ HTML_STYLESHEET =
# cascading style sheets that are included after the standard style sheets
# created by doxygen. Using this option one can overrule certain style aspects.
# This is preferred over using HTML_STYLESHEET since it does not replace the
-# standard style sheet and is therefor more robust against future updates.
+# standard style sheet and is therefore more robust against future updates.
# Doxygen will copy the style sheet files to the output directory.
-# Note: The order of the extra stylesheet files is of importance (e.g. the last
-# stylesheet in the list overrules the setting of the previous ones in the
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
# list). For an example see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1175,7 +1218,7 @@ HTML_EXTRA_STYLESHEET =
HTML_EXTRA_FILES =
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
-# will adjust the colors in the stylesheet and background images according to
+# will adjust the colors in the style sheet and background images according to
# this color. Hue is specified as an angle on a colorwheel, see
# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
@@ -1206,8 +1249,9 @@ HTML_COLORSTYLE_GAMMA = 80
# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
# page will contain the date and time when the page was generated. Setting this
-# to NO can help when comparing the output of multiple runs.
-# The default value is: YES.
+# to YES can help to show when doxygen was last run and thus if the
+# documentation is up to date.
+# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_TIMESTAMP = YES
@@ -1303,28 +1347,28 @@ GENERATE_HTMLHELP = NO
CHM_FILE =
# The HHC_LOCATION tag can be used to specify the location (absolute path
-# including file name) of the HTML help compiler ( hhc.exe). If non-empty
+# including file name) of the HTML help compiler (hhc.exe). If non-empty,
# doxygen will try to run the HTML help compiler on the generated index.hhp.
# The file has to be specified with full path.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
HHC_LOCATION =
-# The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# The GENERATE_CHI flag controls if a separate .chi index file is generated
+# (YES) or that it should be included in the master .chm file (NO).
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
GENERATE_CHI = NO
-# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc)
+# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
# and project file content.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
CHM_INDEX_ENCODING =
-# The BINARY_TOC flag controls whether a binary table of contents is generated (
-# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it
+# The BINARY_TOC flag controls whether a binary table of contents is generated
+# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
# enables the Previous and Next buttons.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
@@ -1438,7 +1482,7 @@ DISABLE_INDEX = NO
# index structure (just like the one that is generated for HTML Help). For this
# to work a browser that supports JavaScript, DHTML, CSS and frames is required
# (i.e. any modern browser). Windows users are probably better off using the
-# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can
+# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
# further fine-tune the look of the index. As an example, the default style
# sheet generated by doxygen has an example that shows how to put an image at
# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
@@ -1466,7 +1510,7 @@ ENUM_VALUES_PER_LINE = 4
TREEVIEW_WIDTH = 250
-# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to
+# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
# external symbols imported via tag files in a separate window.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1495,7 +1539,7 @@ FORMULA_TRANSPARENT = YES
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
# http://www.mathjax.org) which uses client side Javascript for the rendering
-# instead of using prerendered bitmaps. Use this if you do not have LaTeX
+# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path
# to it using the MATHJAX_RELPATH option.
@@ -1581,7 +1625,7 @@ SERVER_BASED_SEARCH = NO
# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
# search results.
#
-# Doxygen ships with an example indexer ( doxyindexer) and search engine
+# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
# Xapian (see: http://xapian.org/).
#
@@ -1594,7 +1638,7 @@ EXTERNAL_SEARCH = NO
# The SEARCHENGINE_URL should point to a search engine hosted by a web server
# which will return the search results when EXTERNAL_SEARCH is enabled.
#
-# Doxygen ships with an example indexer ( doxyindexer) and search engine
+# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
# Xapian (see: http://xapian.org/). See the section "External Indexing and
# Searching" for details.
@@ -1632,7 +1676,7 @@ EXTRA_SEARCH_MAPPINGS =
# Configuration options related to the LaTeX output
#---------------------------------------------------------------------------
-# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output.
+# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
# The default value is: YES.
GENERATE_LATEX = NO
@@ -1663,7 +1707,7 @@ LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
-# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX
+# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
# documents. This may be useful for small projects and may help to save some
# trees in general.
# The default value is: NO.
@@ -1681,9 +1725,12 @@ COMPACT_LATEX = NO
PAPER_TYPE = a4
# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
-# that should be included in the LaTeX output. To get the times font for
-# instance you can specify
-# EXTRA_PACKAGES=times
+# that should be included in the LaTeX output. The package can be specified just
+# by its name or with the correct syntax as to be used with the LaTeX
+# \usepackage command. To get the times font for instance you can specify :
+# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
+# To use the option intlimits with the amsmath package you can specify:
+# EXTRA_PACKAGES=[intlimits]{amsmath}
# If left blank no extra packages will be included.
# This tag requires that the tag GENERATE_LATEX is set to YES.
@@ -1698,9 +1745,9 @@ EXTRA_PACKAGES =
# Note: Only use a user-defined header if you know what you are doing! The
# following commands have a special meaning inside the header: $title,
# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
-# $projectbrief, $projectlogo. Doxygen will replace $title with the empy string,
-# for the replacement values of the other commands the user is refered to
-# HTML_HEADER.
+# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
+# string, for the replacement values of the other commands the user is referred
+# to HTML_HEADER.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_HEADER =
@@ -1716,6 +1763,17 @@ LATEX_HEADER =
LATEX_FOOTER =
+# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# LaTeX style sheets that are included after the standard style sheets created
+# by doxygen. Using this option one can overrule certain style aspects. Doxygen
+# will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list).
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_STYLESHEET =
+
# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the LATEX_OUTPUT output
# directory. Note that the files will be copied as-is; there are no commands or
@@ -1734,7 +1792,7 @@ LATEX_EXTRA_FILES =
PDF_HYPERLINKS = YES
# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
-# the PDF file directly from the LaTeX files. Set this option to YES to get a
+# the PDF file directly from the LaTeX files. Set this option to YES, to get a
# higher quality PDF documentation.
# The default value is: YES.
# This tag requires that the tag GENERATE_LATEX is set to YES.
@@ -1775,11 +1833,19 @@ LATEX_SOURCE_CODE = NO
LATEX_BIB_STYLE = plain
+# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
+# page will contain the date and time when the page was generated. Setting this
+# to NO can help when comparing the output of multiple runs.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_TIMESTAMP = NO
+
#---------------------------------------------------------------------------
# Configuration options related to the RTF output
#---------------------------------------------------------------------------
-# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The
+# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
# RTF output is optimized for Word 97 and may not look too pretty with other RTF
# readers/editors.
# The default value is: NO.
@@ -1794,7 +1860,7 @@ GENERATE_RTF = NO
RTF_OUTPUT = rtf
-# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF
+# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
# documents. This may be useful for small projects and may help to save some
# trees in general.
# The default value is: NO.
@@ -1831,11 +1897,21 @@ RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
+# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
+# with syntax highlighting in the RTF output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_SOURCE_CODE = NO
+
#---------------------------------------------------------------------------
# Configuration options related to the man page output
#---------------------------------------------------------------------------
-# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for
+# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
# classes and files.
# The default value is: NO.
@@ -1879,7 +1955,7 @@ MAN_LINKS = NO
# Configuration options related to the XML output
#---------------------------------------------------------------------------
-# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that
+# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
# captures the structure of the code including all documentation.
# The default value is: NO.
@@ -1893,7 +1969,7 @@ GENERATE_XML = NO
XML_OUTPUT = xml
-# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
+# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
# listings (including syntax highlighting and cross-referencing information) to
# the XML output. Note that enabling this will significantly increase the size
# of the XML output.
@@ -1906,7 +1982,7 @@ XML_PROGRAMLISTING = YES
# Configuration options related to the DOCBOOK output
#---------------------------------------------------------------------------
-# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files
+# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
# that can be used to generate PDF.
# The default value is: NO.
@@ -1920,7 +1996,7 @@ GENERATE_DOCBOOK = NO
DOCBOOK_OUTPUT = docbook
-# If the DOCBOOK_PROGRAMLISTING tag is set to YES doxygen will include the
+# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
# program listings (including syntax highlighting and cross-referencing
# information) to the DOCBOOK output. Note that enabling this will significantly
# increase the size of the DOCBOOK output.
@@ -1933,10 +2009,10 @@ DOCBOOK_PROGRAMLISTING = NO
# Configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
-# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen
-# Definitions (see http://autogen.sf.net) file that captures the structure of
-# the code including all documentation. Note that this feature is still
-# experimental and incomplete at the moment.
+# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
+# AutoGen Definitions (see http://autogen.sf.net) file that captures the
+# structure of the code including all documentation. Note that this feature is
+# still experimental and incomplete at the moment.
# The default value is: NO.
GENERATE_AUTOGEN_DEF = NO
@@ -1945,7 +2021,7 @@ GENERATE_AUTOGEN_DEF = NO
# Configuration options related to the Perl module output
#---------------------------------------------------------------------------
-# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module
+# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
# file that captures the structure of the code including all documentation.
#
# Note that this feature is still experimental and incomplete at the moment.
@@ -1953,7 +2029,7 @@ GENERATE_AUTOGEN_DEF = NO
GENERATE_PERLMOD = NO
-# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary
+# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
# output from the Perl module output.
# The default value is: NO.
@@ -1961,9 +2037,9 @@ GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely
+# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
# formatted so it can be parsed by a human reader. This is useful if you want to
-# understand what is going on. On the other hand, if this tag is set to NO the
+# understand what is going on. On the other hand, if this tag is set to NO, the
# size of the Perl module output will be much smaller and Perl will parse it
# just the same.
# The default value is: YES.
@@ -1983,14 +2059,14 @@ PERLMOD_MAKEVAR_PREFIX =
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
-# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all
+# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
# C-preprocessor directives found in the sources and include files.
# The default value is: YES.
ENABLE_PREPROCESSING = YES
-# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names
-# in the source code. If set to NO only conditional compilation will be
+# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
+# in the source code. If set to NO, only conditional compilation will be
# performed. Macro expansion can be done in a controlled way by setting
# EXPAND_ONLY_PREDEF to YES.
# The default value is: NO.
@@ -2006,7 +2082,7 @@ MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
-# If the SEARCH_INCLUDES tag is set to YES the includes files in the
+# If the SEARCH_INCLUDES tag is set to YES, the include files in the
# INCLUDE_PATH will be searched if a #include is found.
# The default value is: YES.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
@@ -2082,20 +2158,21 @@ TAGFILES =
GENERATE_TAGFILE =
-# If the ALLEXTERNALS tag is set to YES all external class will be listed in the
-# class index. If set to NO only the inherited external classes will be listed.
+# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
+# the class index. If set to NO, only the inherited external classes will be
+# listed.
# The default value is: NO.
ALLEXTERNALS = NO
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in
-# the modules index. If set to NO, only the current project's groups will be
+# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will be
# listed.
# The default value is: YES.
EXTERNAL_GROUPS = YES
-# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in
+# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
# the related pages index. If set to NO, only the current project's pages will
# be listed.
# The default value is: YES.
@@ -2112,14 +2189,14 @@ PERL_PATH = /usr/bin/perl
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
-# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram
+# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
# NO turns the diagrams off. Note that this option also works with HAVE_DOT
# disabled, but it is recommended to install and use dot, since it yields more
# powerful graphs.
# The default value is: YES.
-CLASS_DIAGRAMS = NO
+CLASS_DIAGRAMS = YES
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see:
@@ -2137,7 +2214,7 @@ MSCGEN_PATH =
DIA_PATH =
-# If set to YES, the inheritance and collaboration graphs will hide inheritance
+# If set to YES the inheritance and collaboration graphs will hide inheritance
# and usage relations if the target is undocumented or is not a class.
# The default value is: YES.
@@ -2210,7 +2287,7 @@ COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
# The default value is: NO.
@@ -2262,7 +2339,8 @@ INCLUDED_BY_GRAPH = YES
#
# Note that enabling this option will significantly increase the time of a run.
# So in most cases it will be better to enable call graphs for selected
-# functions only using the \callgraph command.
+# functions only using the \callgraph command. Disabling a call graph can be
+# accomplished by means of the command \hidecallgraph.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
@@ -2273,7 +2351,8 @@ CALL_GRAPH = YES
#
# Note that enabling this option will significantly increase the time of a run.
# So in most cases it will be better to enable caller graphs for selected
-# functions only using the \callergraph command.
+# functions only using the \callergraph command. Disabling a caller graph can be
+# accomplished by means of the command \hidecallergraph.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
@@ -2296,11 +2375,15 @@ GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot.
+# generated by dot. For an explanation of the image formats see the section
+# output formats in the documentation of the dot tool (Graphviz (see:
+# http://www.graphviz.org/)).
# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
# to make the SVG files visible in IE 9+ (other browsers do not have this
# requirement).
-# Possible values are: png, jpg, gif and svg.
+# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo,
+# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
+# png:gdiplus:gdiplus.
# The default value is: png.
# This tag requires that the tag HAVE_DOT is set to YES.
@@ -2348,10 +2431,14 @@ DIAFILE_DIRS =
# PlantUML is not used or called during a preprocessing step. Doxygen will
# generate a warning when it encounters a \startuml command in this case and
# will not generate output for the diagram.
-# This tag requires that the tag HAVE_DOT is set to YES.
PLANTUML_JAR_PATH =
+# When using plantuml, the specified paths are searched for files specified by
+# the !include statement in a plantuml block.
+
+PLANTUML_INCLUDE_PATH =
+
# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
# that will be shown in the graph. If the number of nodes in a graph becomes
# larger than this value, doxygen will truncate the graph, which is visualized
@@ -2388,7 +2475,7 @@ MAX_DOT_GRAPH_DEPTH = 0
DOT_TRANSPARENT = NO
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
# files in one run (i.e. multiple -o and -T options on the command line). This
# makes dot run faster, but since only newer versions of dot (>1.8.10) support
# this, this feature is disabled by default.
@@ -2405,7 +2492,7 @@ DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
-# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot
+# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
# files that are used to generate the various graphs.
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
diff --git a/decoder/docs/prog_guide/cs_trace_hw.jpg b/decoder/docs/prog_guide/cs_trace_hw.jpg
new file mode 100644
index 000000000000..af88f51455f4
--- /dev/null
+++ b/decoder/docs/prog_guide/cs_trace_hw.jpg
Binary files differ
diff --git a/decoder/docs/prog_guide/decode_data_path_resp.jpg b/decoder/docs/prog_guide/decode_data_path_resp.jpg
new file mode 100644
index 000000000000..eb7edb9e40e3
--- /dev/null
+++ b/decoder/docs/prog_guide/decode_data_path_resp.jpg
Binary files differ
diff --git a/decoder/docs/prog_guide/dt_components.jpg b/decoder/docs/prog_guide/dt_components.jpg
new file mode 100644
index 000000000000..0b0270d995b0
--- /dev/null
+++ b/decoder/docs/prog_guide/dt_components.jpg
Binary files differ
diff --git a/decoder/docs/prog_guide/lib_usage.jpg b/decoder/docs/prog_guide/lib_usage.jpg
new file mode 100644
index 000000000000..6baaa12344b3
--- /dev/null
+++ b/decoder/docs/prog_guide/lib_usage.jpg
Binary files differ
diff --git a/decoder/docs/prog_guide/memacc_objs.jpg b/decoder/docs/prog_guide/memacc_objs.jpg
new file mode 100644
index 000000000000..ad329d4bdf2c
--- /dev/null
+++ b/decoder/docs/prog_guide/memacc_objs.jpg
Binary files differ
diff --git a/decoder/docs/prog_guide/prog_guide_generic_pkts.md b/decoder/docs/prog_guide/prog_guide_generic_pkts.md
new file mode 100644
index 000000000000..9f69aacad44e
--- /dev/null
+++ b/decoder/docs/prog_guide/prog_guide_generic_pkts.md
@@ -0,0 +1,400 @@
+OpenCSD Library - Generic Trace Packet Descriptions {#generic_pkts}
+===================================================
+
+@brief Interpretation of the Generic Trace output packets.
+
+Generic Trace Packets - Collection.
+-----------------------------------
+
+### Packet interface ###
+
+The generic trace packets are the fully decoded output from the trace library.
+
+These are delivered to the client application in the form of a callback function. Packets from all trace sources
+will use the same single callback function, with the CoreSight Trace ID provided to identify the source.
+
+The callback is in the form of an interface class ITrcGenElemIn, which has a single function:
+
+~~~{.cpp}
+virtual ocsd_datapath_resp_t TraceElemIn( const ocsd_trc_index_t index_sop,
+ const uint8_t trc_chan_id,
+ const OcsdTraceElement &elem
+ ) = 0;
+~~~
+
+The client program will create derived class providing this interface to collect trace packets from the library.
+
+The parameters describe the output packet and source channel:
+|Parameter | Description |
+|:--------------------------------|:------------------------------------------------------------------------|
+| `ocsd_trc_index_t index_sop` | Index of the first byte of the trace packet that generated this output. |
+| `uint8_t trc_chan_id` | The source CoreSight Trace ID. |
+| `OcsdTraceElement &elem` | The packet class - wraps the `ocsd_generic_trace_elem` structure. |
+
+_Note_ : `index_sop` may be the same for multiple output packets. This is due to an one byte atom packet which
+can represent multiple atoms and hence multiple ranges.
+
+The C-API provides a similarly specified callback function definition, with an additional opaque `void *` pointer
+that the client application may use.
+
+~~~{.c}
+/** function pointer type for decoder outputs. all protocols, generic data element input */
+typedef ocsd_datapath_resp_t (* FnTraceElemIn)( const void *p_context,
+ const ocsd_trc_index_t index_sop,
+ const uint8_t trc_chan_id,
+ const ocsd_generic_trace_elem *elem);
+~~~
+
+### The Packet Structure ###
+
+~~~{.c}
+typedef struct _ocsd_generic_trace_elem {
+ ocsd_gen_trc_elem_t elem_type; /* Element type - remaining data interpreted according to this value */
+ ocsd_isa isa; /* instruction set for executed instructions */
+ ocsd_vaddr_t st_addr; /* start address for instruction execution range / inaccessible code address / data address */
+ ocsd_vaddr_t en_addr; /* end address (exclusive) for instruction execution range. */
+ ocsd_pe_context context; /* PE Context */
+ uint64_t timestamp; /* timestamp value for TS element type */
+ uint32_t cycle_count; /* cycle count for explicit cycle count element, or count for element with associated cycle count */
+ ocsd_instr_type last_i_type; /* Last instruction type if instruction execution range */
+ ocsd_instr_subtype last_i_subtype; /* sub type for last instruction in range */
+
+ //! per element flags
+ union {
+ struct {
+ uint32_t last_instr_exec:1; /* 1 if last instruction in range was executed; */
+ uint32_t last_instr_sz:3; /* size of last instruction in bytes (2/4) */
+ uint32_t has_cc:1; /* 1 if this packet has a valid cycle count included (e.g. cycle count included as part of instruction range packet, always 1 for pure cycle count packet.*/
+ uint32_t cpu_freq_change:1; /* 1 if this packet indicates a change in CPU frequency */
+ uint32_t excep_ret_addr:1; /* 1 if en_addr is the preferred exception return address on exception packet type */
+ uint32_t excep_data_marker:1; /* 1 if the exception entry packet is a data push marker only, with no address information (used typically in v7M trace for marking data pushed onto stack) */
+ uint32_t extended_data:1; /* 1 if the packet extended data pointer is valid. Allows packet extensions for custom decoders, or additional data payloads for data trace. */
+ uint32_t has_ts:1; /* 1 if the packet has an associated timestamp - e.g. SW/STM trace TS+Payload as a single packet */
+ uint32_t last_instr_cond:1; /* 1 if the last instruction was conditional */
+ uint32_t excep_ret_addr_br_tgt:1; /* 1 if exception return address (en_addr) is also the target of a taken branch addr from the previous range. */
+ };
+ uint32_t flag_bits;
+ };
+
+ //! packet specific payloads
+ union {
+ uint32_t exception_number; /* exception number for exception type packets */
+ trace_event_t trace_event; /* Trace event - trigger etc */
+ trace_on_reason_t trace_on_reason; /* reason for the trace on packet */
+ ocsd_swt_info_t sw_trace_info; /* software trace packet info */
+ uint32_t num_instr_range; /* number of instructions covered by range packet (for T32 this cannot be calculated from en-st/i_size) */
+
+ };
+
+ const void *ptr_extended_data; /* pointer to extended data buffer (data trace, sw trace payload) / custom structure */
+
+} ocsd_generic_trace_elem;
+~~~
+
+The packet structure contains multiple fields and flag bits. The validity of any of these fields or flags
+is dependent on the `elem_type` member. The client program must not assume that field values will persist
+between packets, and must process all valid data during the callback function.
+
+The packet reference guide below defines the fields valid for each packet type.
+
+--------------------------------------------------------------------------------------------------
+
+Generic Trace Packets - Packet Reference.
+-----------------------------------------
+
+This section contains reference descriptions of each of the generic trace packets types define as part of the
+`ocsd_gen_trc_elem_t` enum value that appears as the first `elem_type` field in the packet structure.
+
+The descriptions will include information on which fields in the packets are always valid, optional and any protocol specific information.
+
+The tags used in the reference are:-
+- __packet fields valid__ : fields that are always valid and filled for this packet type.
+- __packet fields optional__ : fields that _may_ be filled for this packet type.
+ The form `flag -> field` indicates a flag that may be set and the value that is valid if the flag is true
+- __protocol specific__ : indicates type or fields may be source protocol specific.
+
+_Note_: while most of the packets are not protocol specific, there are some protocol differences that mean
+certain types and fields will differ slightly across protocols. These differences are highlighted in the
+reference.
+
+### OCSD_GEN_TRC_ELEM_NO_SYNC ###
+__packet fields valid__: None
+
+Element output before the decoder has synchronised with the input stream, or synchronisation is lost.
+
+### OCSD_GEN_TRC_ELEM_INSTR_RANGE ###
+__packet fields valid__: `isa, st_addr, en_addr, last_i_type, last_i_subtype, last_instr_exec, last_instr_sz, num_instr_range, last_instr_cond`
+
+__packet fields optional__: `has_cc -> cycle_count,`
+
+__protocol specific__ : ETMv3, PTM
+
+This should be the most common packet output for full trace decode. Represents a range of instructions of
+a single `isa`, executed by the PE. Instruction byte range is from `st_addr` (inclusive) to `en_addr` (exclusive).
+The total number of instructions executed for the range is given in `num_instr_range`.
+
+Information on the last instruction in the range is provided. `last_i_type` shows if the last instruction
+was a branch or otherwise - which combined with `last_instr_exec` determines if the branch was taken.
+The last instruction size in bytes is given, to allow clients to quickly determine the address of the last
+instruction by subtraction from `en_addr`. This value can be 2 or 4 bytes in the T32 instruction set.
+
+__ETMv3, PTM__ : These protocols can output a cycle count directly as part of the trace packet that generates
+the trace range. In this case `has_cc` will be 1 and `cycle_count` will be valid.
+
+
+### OCSD_GEN_TRC_ELEM_ADDR_NACC ###
+__packet fields valid__: `st_addr`
+
+Trace decoder found address in trace that cannot be accessed in the mapped memory images.
+`st_addr` is the address that cannot be found.
+
+Decoder will wait for new address to appear in trace before attempting to restart decoding.
+
+
+### OCSD_GEN_TRC_ELEM_UNKNOWN ###
+__packet fields valid__: None
+
+Decoder saw invalid packet for protocol being processed. Likely incorrect protocol settings, or corrupted
+trace data.
+
+### OCSD_GEN_TRC_ELEM_TRACE_ON ###
+__packet fields valid__: trace_on_reason
+
+__packet fields optional__: `has_cc -> cycle_count,`
+
+__protocol specific__ : ETMv3, PTM
+
+Notification that trace has started / is synced after a discontinuity or at start of trace decode.
+
+__ETMv3, PTM__ : These protocols can output a cycle count directly as part of the trace packet that generates
+the trace on indicator. In this case `has_cc` will be 1 and `cycle_count` will be valid.
+
+
+### OCSD_GEN_TRC_ELEM_EO_TRACE ###
+__packet fields valid__: None
+
+Marker for end of trace data. Sent once for each CoreSight ID channel.
+
+### OCSD_GEN_TRC_ELEM_PE_CONTEXT ###
+__packet fields valid__: context
+
+__packet fields optional__: `has_cc -> cycle_count,`
+
+__protocol specific__ : ETMv3, PTM
+
+This packet indicates an update to the PE context - which may be the initial context in a trace stream, or a
+change since the trace started.
+
+The context is contained in a `ocsd_pe_context` structure.
+
+~~~{.c}
+typedef struct _ocsd_pe_context {
+ ocsd_sec_level security_level; /* security state */
+ ocsd_ex_level exception_level; /* exception level */
+ uint32_t context_id; /* context ID */
+ uint32_t vmid; /* VMID */
+ struct {
+ uint32_t bits64:1; /* 1 if 64 bit operation */
+ uint32_t ctxt_id_valid:1; /* 1 if context ID value valid */
+ uint32_t vmid_valid:1; /* 1 if VMID value is valid */
+ uint32_t el_valid:1; /* 1 if EL value is valid (ETMv4 traces current EL, other protocols do not) */
+ };
+} ocsd_pe_context;
+~~~
+
+__ETMv3, PTM__ : These protocols can output a cycle count directly as part of the trace packet that generates
+the PE context. In this case `has_cc` will be 1 and `cycle_count` will be valid.
+
+__ETMv3__ : From ETM 3.5 onwards, exception_level can be set to `ocsd_EL2` when tracing through hypervisor code.
+On all other occasions this will be set to `ocsd_EL_unknown`.
+
+
+### OCSD_GEN_TRC_ELEM_ADDR_UNKNOWN ###
+__packet fields optional__: `has_cc -> cycle_count,`
+
+__protocol specific__: ETMv3
+
+This packet will only be seen when decoding an ETMv3 protocol source. This indicates that the decoder
+is waiting for a valid address in order to process trace correctly.
+
+The packet can have a cycle count associated with it which the client must account for when tracking cycles used.
+The packet will be sent once when unknown address occurs. Further `OCSD_GEN_TRC_ELEM_CYCLE_COUNT` packets may follow
+ before the decode receives a valid address to continue decode.
+
+
+### OCSD_GEN_TRC_ELEM_EXCEPTION ###
+__packet fields valid__: `exception_number`
+
+__packet fields optional__: `has_cc -> cycle_count, excep_ret_addr -> en_addr, excep_data_marker, excep_ret_addr_br_tgt`
+
+__protocol specific__: ETMv4, ETMv3, PTM
+
+All protocols will include the exception number in the packet.
+
+__ETMv4__ : This protocol may provide the preferred return address for the exception - this is the address of
+the instruction that could be executed on exception return. This address appears in `en_addr` if `excep_ret_addr` = 1.
+
+Additionally, this address could also represent the target address of a branch, if the exception occured at the branch target, before any further instructions were execute. If htis is the case then the excep_ret_addr_br_tgt flag will be set. This makes explicit what was previously only implied by teh packet ordered. This information could be used for clients such as perf that branch source/target address pairs.
+
+__ETMv3__ : This can set the `excep_data_marker` flag. This indicates that the exception packet is a marker
+to indicate exception entry in a 7M profile core, for the purposes of tracking data. This will __not__ provide
+an exception number in this case.
+
+__PTM__ : Can have an associated cycle count (`has_cc == 1`), and may provide preferred return address in `en_addr`
+if `excep_ret_addr` = 1.
+
+### OCSD_GEN_TRC_ELEM_EXCEPTION_RET ###
+__packet fields valid__: None
+
+Marker that a preceding branch was an exception return.
+
+### OCSD_GEN_TRC_ELEM_TIMESTAMP ###
+__packet fields valid__: `timestamp`
+
+__packet fields optional__: `has_cc -> cycle_count,`
+
+__protocol specific__: ETMv4, PTM
+
+The timestamp packet explicitly provides a timestamp value for the trace stream ID in the callback interface.
+
+__PTM__ : This can have an associated cycle count (`has_cc == 1`). For this protocol, the cycle count __is__ part
+of the cumulative cycle count for the trace session.
+
+__ETMv4__ : This can have an associated cycle count (`has_cc == 1`). For this protocl, the cycle coun represents
+the number of cycles between the previous cycle count packet and this timestamp packet, but __is not__ part of
+the cumulative cycle count for the trace session.
+
+
+### OCSD_GEN_TRC_ELEM_CYCLE_COUNT ###
+__packet fields valid__: `has_cc -> cycle_count`
+
+Packet contains a cycle count value. A cycle count value represents the number of cycles passed since the
+last cycle count value seen. The cycle count value may be associated with a specific packet or instruction
+range preceding the cycle count packet.
+
+Cycle count packets may be added together to build a cumulative count for the trace session.
+
+### OCSD_GEN_TRC_ELEM_EVENT ###
+__packet fields valid__: `trace_event`
+
+This is a hardware event injected into the trace by the ETM/PTM hardware resource programming. See the
+relevent trace hardware reference manuals for the programming of these events.
+
+The `trace_event` is a `trace_event_t` structure that can have an event type - and an event number.
+
+~~~{.c}
+typedef struct _trace_event_t {
+ uint16_t ev_type; /* event type - unknown (0) trigger (1), numbered event (2)*/
+ uint16_t ev_number; /* event number if numbered event type */
+} trace_event_t;
+~~~
+
+The event types depend on the trace hardware:-
+
+__ETMv4__ : produces numbered events. The event number is a bitfield of up to four events that occurred.
+Events 0-3 -> bits 0-3. The bitfield allows a single packet to represent multiple different events occurring.
+
+_Note_: The ETMv4 specification has further information on timing of events and event packets. Event 0
+is also considered a trigger event in ETMv4 hardware, but is not explicitly represented as such in the OCSD protocol.
+
+__PTM__, __ETMv3__ : produce trigger events. Event number always set to 0.
+
+
+### OCSD_GEN_TRC_ELEM_SWTRACE ###
+__packet fields valid__: `sw_trace_info`
+
+__packet fields optional__: `has_ts -> timestamp`, ` extended_data -> ptr_extended_data`
+
+The Software trace packet always has a filled in `sw_trace_info` field to describe the current master and channel ID,
+plus the packet type and size of any payload data.
+
+SW trace packets that have a payload will use the extended_data flag and pointer to deliver this data.
+
+SW trace packets that include timestamp information will us the `has_ts` flag and fill in the timestamp value.
+
+
+### OCSD_GEN_TRC_ELEM_CUSTOM ###
+__packet fields optional__: `extended_data -> ptr_extended_data`,_any others_
+
+Custom protocol decoders can use this packet type to provide protocol specific information.
+
+Standard fields may be used for similar purposes as defined above, or the extended data pointer can reference
+other data.
+
+--------------------------------------------------------------------------------------------------
+
+Generic Trace Packets - Notes on interpretation.
+------------------------------------------------
+
+The interpretation of the trace output should always be done with reference to the underlying protocol
+specifications.
+
+While the output packets are in general protocol agnostic, there are some inevitable
+differences related to the underlying protocol that stem from the development of the trace hardware over time.
+
+### OCSD ranges and Trace Atom Packets ###
+The most common raw trace packet in all the protocols is the Atom packet, and this packet is the basis for most of
+the `OCSD_GEN_TRC_ELEM_INSTR_RANGE` packets output from the library. A trace range will be output for each atom
+in the raw trace stream - the `last_instr_exec` flag taking the value of the Atom - 1 for E, 0 for N.
+
+`OCSD_GEN_TRC_ELEM_INSTR_RANGE` packets can also be generated for non-atom packets, where flow changes - e.g.
+exceptions.
+
+
+### Multi feature OCSD output packets ###
+Where a raw trace packet contains additional information on top of the basic packet data, then this additional
+information will be added to the OCSD output packet and flagged accordingly (in the `flag_bits` union in the
+packet structure).
+
+Typically this will be atom+cycle count packets in ETMv3 and PTM protocols. For efficiency and to retain
+the coupling between the information an `OCSD_GEN_TRC_ELEM_INSTR_RANGE` packet will be output in this case
+with a `has_cc` flag set and the `cycle_count` value filled.
+
+ETMv3 and PTM can add a cycle count to a number of packets, or explicitly emit a cycle count only packet. By
+contrast ETMv4 only emits cycle count only packets.
+
+Clients processing the library output must be aware of these optional additions to the base packet. The
+OCSD packet descriptions above outline where the additional information can occur.
+
+### Cycle counts ###
+
+Cycle counts are cumulative, and represent cycles since the last cycle count output.
+Explicit cycle count packets are associated with the previous range event, otherwise where a
+packet includes a cycle count as additional information, then the count is associated with that
+specific packet - which will often be a range packet.
+
+The only exception to this is where the underlying protocol is ETMv4, and a cycle count is included
+in a timestamp packet. Here the cycle count represents that number of cycles since the last cycle count
+packet that occurred before the timestamp packet was emitted. This cycle count is not part of the cumulative
+count. See the ETMv4 specification for further details.
+
+
+### Correlation - timestamps and cycle counts ###
+
+Different trace streams can be correlated using either timestamps, or timestamps plus cycle counts.
+
+Both timestamps and cycle counts are enabled by programming ETM control registers, and it is also possible
+to control the frequency that timestamps appear, or the threshold at which cycle count packets are emitted by
+additional programming.
+
+The output of timestamps and cycle counts increases the amount of trace generated, very significantly when cycle
+counts are present, so the choice of generating these elements needs to be balanced against the requirement
+for their use.
+
+Decent correlation can be gained by the use of timestamps alone - especially if the source is programmed to
+produce them more frequently than the default timestamp events. More precise correllation can be performed if
+the 'gaps' between timestamps can be resolved using cycle counts.
+
+Correlation is performed by identifying the same/close timestamp values in two separate trace streams. Cycle counts
+if present can then be used to resolve the correlation with additional accuracy.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/decoder/docs/prog_guide/prog_guide_main.md b/decoder/docs/prog_guide/prog_guide_main.md
new file mode 100644
index 000000000000..87afbf0225c6
--- /dev/null
+++ b/decoder/docs/prog_guide/prog_guide_main.md
@@ -0,0 +1,597 @@
+OpenCSD Library - Programmers Guide {#prog_guide}
+===================================
+
+@brief A guide to programming the OpenCSD library.
+
+Introduction and review of Coresight Hardware
+---------------------------------------------
+
+The OpenCSD trace decode library is designed to allow programmers to decode ARM CoreSight trace
+data. This guide will describe the various stages of configuring and programming a decoder instance
+for a given CoreSight system.
+
+The diagram below shows a typical Coresight trace hardware arrangement
+
+![Example CoreSight Trace Capture Hardware](cs_trace_hw.jpg)
+
+The design shown has four Cortex cores, each with an ETM, along with a system STM all of which generate trace into the
+trace funnel. The output of the funnel is fed into a trace sink, which might be an ETB or ETR, saving the trace
+which is multiplexed into CoreSight trace frames in the trace sink memory. The colours represent the sources
+of trace data, each of which will be tagged with a CoreSight Trace ID.
+
+### CoreSight Trace ID ###
+The CoreSight Trace ID - also referred to as the Trace Source Channel ID - is a unique 8 bit number programmed
+into each trace source in a system (ETM,PTM,STM) which identifies the source to both the hardware components
+downstream and the software trace decoders. This ID is used
+
+Overview of Configuration and Decode
+------------------------------------
+
+The OpenCSD library will take the trace data from the trace sink, and when correctly configured and programmed, will
+demultiplex and decode each of the trace sources.
+
+The library supports ETMV3, PTM, ETMv4 and STM trace protocols. The decode occurs in three stages:
+- __Demultiplex__ - the combined trace streams in CoreSight trace frame format are split into their constituent streams according to the CoreSight trace ID.
+- __Packet Processing__ - the individual trace ID streams are resolved into discrete trace packets.
+- __Packet Decode__ - the trace packets are interpreted to produce a decoded representation of instructions executed.
+
+There are input configuration requirements for each stage of the decode process - these allow the decode process to correctly
+interpret the incoming byte stream.
+- __Demultiplex__ - Input flags are set to indicate if the frames are 16 byte aligned or if the stream contains alignment
+bytes between frames.
+- __Packet Processing__ - The hardware configuration of the trace source must be provided. This consists of a sub-set of the
+hardware register values for the source. Each protocol has differing requirements, represented by an input structure of the
+register values.
+- __Packet Decode__ - For ETM/PTM packet decode, this stage requires the memory images of the code executed in order
+to determine the path through the code. These are provided either as memory dumps, or as links to binary code files.
+
+_Note_ : STM, being a largely software generated data trace, does not require memory images to recover the data written by the source
+processors.
+
+The diagram below shows the basic stages of decode for the library when used in a client application:
+
+![Example Library Usage for Trace Decode](lib_usage.jpg)
+
+The DecodeTree object is a representation of the structure of the CoreSight hardware, but in reverse in that the data is pushed into the
+tree, through the demultiplexor and then along the individual trace stream decode paths till the output decode packets are produced.
+
+These outpup packets are referred to as Generic Trace packets, and are at this stage protocol independent. They consist primarily of
+PE context information and address ranges representing the instructions processed.
+
+### Decode Tree ###
+
+The DecodeTree is the principal wrapper for all the decoders the library supports. This provides a programming
+API which allows the creation of protocol packet processors and decoders.
+
+The API allows the client application to configure the de-multiplexor, create and connect packet processors and
+packet decoders to the trace data streams and collect the output generic decoded trace packets. The DecodeTree
+provides a built in instruction decoder to allow correct trace decode, and an additional API through a memory
+access handler to allow the client applications to provide the images of the traced code in file or memory dump
+format.
+
+Once a DecodeTree is configured, then it can be re-used for multiple sets of captured trace data where the same
+set of applications has been traced, or by changing only the supplied memory images, different traced applications
+on the same hardware configuration.
+
+The process for programming a decode tree for a specific set of trace hardware is as follows;-
+1. Create the decode tree and specify the de-multiplexor options.
+2. For each trace protocol of interest, use the API to create a decoder, providing the hardware configuration,
+including the CoreSight trace ID for that trace stream. Specify packet processing only, or full decode. Client
+program must know the correct protocol to use for each trace stream.
+3. Attach callback(s) to receive the decoded generic trace output (ITrcGenElemIn).
+4. Provide the memory images if using full decode.
+
+The DecodeTree can now be used to process the trace data by pushing the captured trace data through the trace
+ data input API call (ITrcDataIn) and analyzing as required the resulting decoded trace (ITrcGenElemIn).
+
+ The objects and connections used for a single trace stream are shown below.
+
+ ![Decode Tree objects - single trace stream](dt_components.jpg)
+
+ All these components can be created and used outside of a DecodeTree, but that is beyond the scope of this
+ guide and expected to be used for custom implementations only.
+
+Programming Examples - decoder configuration.
+---------------------------------------------
+
+The remainder of this programming guide will provide programming exceprts for each of the required stages
+to get a working decode tree, capable of processing trace data.
+
+The guide will be based on an ETMv4 system, similar to the example above, using the C++ interface, but
+equivalent calls from the C-API wrapper library will also be provided.
+
+The source code for the two test applications `trc_pkt_lister` and `c_api_pkt_print_test` may be used as
+further programming guidance.
+
+### Create the decode tree ###
+
+The first step is to create the decode tree. Key choices here are the flags defining expected trace data
+input format and de-mux operations.
+
+~~~{.cpp}
+ uint32_t formatterCfgFlags = OCSD_DFRMTR_FRAME_MEM_ALIGN; /* basic operational mode for on-chip captured trace */
+ DecodeTree *pTree = DecodeTree::CreateDecodeTree(OCSD_TRC_SRC_FRAME_FORMATTED, formatterCfgFlags);
+~~~
+
+This creates a decode tree that is usable in the majority of cases - that is for trace captured in on chip
+RAM via ETB or ETR. Additional flags are available if a TPIU is used that will indicate to the frame de-mux
+that additional frame synchronisation data is present.
+
+In limited cases where the hardware has a single trace source, or only a single source is being used, then
+it is possible to switch off the hardware frame formatter in the ETB/ETR/TPIU. In this case @ref OCSD_TRC_SRC_SINGLE
+ (from enum @ref ocsd_dcd_tree_src_t) may be defined as the first parameter to the function.
+
+C-API version of above code:
+~~~{.c}
+ dcd_tree_handle_t dcdtree_handle = ocsd_create_dcd_tree(OCSD_TRC_SRC_FRAME_FORMATTED, OCSD_DFRMTR_FRAME_MEM_ALIGN);
+~~~
+
+### Error loggers and printers ###
+
+The library defines a standard error logging interface ITraceErrorLog which many of the key components can register
+with to output errors. The process of registering the source means that errors can be tied to a particular component,
+or CoreSight Trace ID. The library provides a standard error logger object - ocsdDefaultErrorLogger - which
+keeps a copy of the last error logged, plus a copy of the last error logged for each data stream associated
+with a CoreSight trace ID.
+
+The error logger can be attached to an output logger - ocsdMsgLogger - which can print text versions of the
+error, or other error messages, out to screen or logging file. Errors can be filtered according to a severity rating,
+defined by @ref ocsd_err_severity_t.
+
+The DecodeTree will use a default error logger from the library - with a message logger
+that will output to `stderr`. Client applications can adjust the configuration of this error logger and
+message logger, or provide their own configured error logger / message logger pair.
+
+The test program `trc_pkt_lister` provides a customised version of an `ocsdMsgLogger` / `ocsdDefaultErrorLogger` pair
+to ensure that messages and errors are logged to the screen and a file of its choice. This logger is eventually
+passed through to the decode tree.
+
+Code excerpts below (trc_pkt_lister.cpp):
+
+~~~{.cpp}
+ static ocsdMsgLogger logger;
+ static int logOpts = ocsdMsgLogger::OUT_STDOUT | ocsdMsgLogger::OUT_FILE;
+ static std::string logfileName = "trc_pkt_lister.ppl";
+
+ // ** other vars
+
+ main() {
+
+ // ** some init code
+
+ logger.setLogOpts(logOpts);
+ logger.setLogFileName(logfileName.c_str());
+
+
+ ocsdDefaultErrorLogger err_log;
+ err_log.initErrorLogger(OCSD_ERR_SEV_INFO);
+ err_log.setOutputLogger(&logger);
+
+ // pass err_log reference into snapshot library code
+ SnapShotReader ss_reader;
+ ss_reader.setErrorLogger(&err_log);
+
+ // ** rest of program
+ }
+~~~
+
+In the library code for the snapshot reader (ss_to_dcd_tree.cpp):
+
+~~~{.cpp}
+ bool CreateDcdTreeFromSnapShot::createDecodeTree()
+ {
+ // ** create a decode tree
+
+ // use our error logger - don't use the tree default.
+ m_pDecodeTree->setAlternateErrorLogger(m_pErrLogInterface);
+ }
+
+~~~
+
+__Note__: The Snapshot reader library is test code designed to allow the test application read trace snapshots
+which are in the form defined by the open specification in `./decoder/docs/specs/ARM Trace and Debug Snapshot file format 0v2.pdf`
+
+This format is used in ARM's DS-5 debugger, and the open source CoreSight Access Library (CSAL).
+
+### Configuring decoders ###
+
+The next task is to configure the requried decoders. The client program must know the type of ETM/PTM in use
+to correctly set the decoder configuration.
+
+Each class of trace source has a specific set of register values that the decoder requires to correctly interpret the
+raw trace data and convert it to packets then fully decode.
+
+Configuration of an ETMv4 decoder requires initialisation of the EtmV4Config class, which is achieved by filling in a
+@ref ocsd_etmv4_cfg structure:-
+
+~~~{.c}
+ typedef struct _ocsd_etmv4_cfg
+ {
+ uint32_t reg_idr0; /**< ID0 register */
+ uint32_t reg_idr1; /**< ID1 register */
+ uint32_t reg_idr2; /**< ID2 register */
+ uint32_t reg_idr8;
+ uint32_t reg_idr9;
+ uint32_t reg_idr10;
+ uint32_t reg_idr11;
+ uint32_t reg_idr12;
+ uint32_t reg_idr13;
+ uint32_t reg_configr; /**< Config Register */
+ uint32_t reg_traceidr; /**< Trace Stream ID register */
+ ocsd_arch_version_t arch_ver; /**< Architecture version */
+ ocsd_core_profile_t core_prof; /**< Core Profile */
+ } ocsd_etmv4_cfg;
+~~~
+
+The structure contains a number of read-only ID registers, and key programmable control registers that define
+the trace output features - such as if the ETM will output timestamps or cycle counts - and the CoreSight Trace ID.
+
+Once this structure is filled in then the decoder can be configured in the decode tree:-
+
+~~~{.cpp}
+ ocsd_etmv4_cfg config;
+
+ // ...
+ // code to fill in config from programmed registers and id registers
+ // ...
+
+ EtmV4Config configObj(&config); // initialise decoder config class
+ std::string decoderName(OCSD_BUILTIN_DCD_ETMV4I); // use built in ETMv4 instruction decoder.
+ int decoderCreateFlags = OCSD_CREATE_FLG_FULL_DECODER; // decoder type to create - OCSD_CREATE_FLG_PACKET_PROC for packet processor only
+ ocsd_err_t err = pDecodeTree->createDecoder(decoderName, decoderCreateFlags,&configObj);
+~~~
+
+This code creates a full trace decoder for an ETMv4 source, which consists of a packet processor and packet decoder pair. The decoder is automatically associated with the
+CoreSight Trace ID programmed into the register provided in the `config` structure.
+
+It is also possible to create a packet processor only decoder if the `OCSD_CREATE_FLG_PACKET_PROC` flag is
+used instead. These packet only decoders can be used to create a dump of the raw trace as discrete trace packets.
+
+All decoders a registered with the library using a name - the standard ARM protocols are considered built in
+decoders and are registered automatically. The library contains defined names for these decoders - `OCSD_BUILTIN_DCD_ETMV4I`
+ being the name used for ETMv4 protocol.
+
+The C-API uses the call create_generic_decoder() with the same configuration structure:-
+
+~~~{.c}
+ ocsd_etmv4_cfg config;
+
+ // ...
+ // code to fill in config from programmed registers and id registers
+ // ...
+
+ const char * decoderName = OCSD_BUILTIN_DCD_ETMV4I); // use built in ETMv4 instruction decoder.
+ int decoderCreateFlags = OCSD_CREATE_FLG_FULL_DECODER; // decoder type to create - OCSD_CREATE_FLG_PACKET_PROC for packet processor only
+ void *p_context = // <some_client_context>
+ ocsd_err_t err = create_generic_decoder(dcdtree_handle,decoderName,(void *)&config,p_context);
+~~~
+
+The configuration must be completed for each trace source in the decode tree which requires decoding.
+
+The different trace source types have different configuration structures, classes and names
+
+| protocol | config struct | class | name define |
+|:----------|:--------------------|:------------|:-----------------------------|
+| __ETMv4__ | @ref ocsd_etmv4_cfg | EtmV4Config | @ref OCSD_BUILTIN_DCD_ETMV4I |
+| __ETMv3__ | @ref ocsd_etmv3_cfg | EtmV3Config | @ref OCSD_BUILTIN_DCD_ETMV3 |
+| __PTM__ | @ref ocsd_ptm_cfg | PtmConfig | @ref OCSD_BUILTIN_DCD_PTM |
+| __STM__ | @ref ocsd_stm_cfg | STMConfig | @ref OCSD_BUILTIN_DCD_STM |
+
+### Adding in Memory Images ###
+
+Memory images are needed when a full trace decode is required. Memory images consist of a base address and length, and
+contain instruction opcodes that may be executed during the operation of the traced program. The images are used by
+the decoder to follow the path of the traced program by interpreting the information contained within the trace that
+defines which program branches are taken and the target addresses of those branches.
+
+The library defined memory image accessor objects, which can be simple memory buffers, files containing the binary
+code image, or a callback that allows the client to handle memory accesses directly. When files are used, the
+ object may contain a set of base addresses and lengths, with offsets into the file - allowing the decoder
+ to directly access multiple code segments in executable image files.
+
+Memory image objects are collated by a memory mapper. This interfaces to the decoder through the ITargetMemAccess interface,
+and selects the correct image object for the address requested by the decoder. The memory mapper will also validate image
+objects as they are added to the decoder, and will not permit overlapping images.
+
+![Memory Mapper and Memory Images](memacc_objs.jpg)
+
+The client can add memory images to the decoder via API calls to the decode tree. These methods add memory image accessors of various
+types to be managed by a memory access mapper:-
+
+~~~{.cpp}
+ class DecodeTree {
+ ///...
+ ocsd_err_t addBufferMemAcc(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t *p_mem_buffer, const uint32_t mem_length);
+ ocsd_err_t addBinFileMemAcc(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const std::string &filepath);
+ ocsd_err_t addBinFileRegionMemAcc(const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const std::string &filepath); */
+ ocsd_err_t addCallbackMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAcc_CB p_cb_func, const void *p_context);
+ ///...
+ }
+~~~
+
+It is further possible to differentiate between memory image access objects by the memory space for which they are valid. If it is known that a certain code image
+is present in secure EL3, then an image can be associated with the @ref ocsd_mem_space_acc_t type value @ref OCSD_MEM_SPACE_EL3, which will allow another image to be
+present at the same address but a different exception level. However, for the majority of systems, such detailed knowledge of the code is not available, or
+overlaps across memory spaces do not occur. In these cases, and for general use (including Linux trace decode), @ref OCSD_MEM_SPACE_ANY should be used.
+
+The C-API contains a similar set of calls to set up memory access objects:-
+
+~~~{.c}
+ OCSD_C_API ocsd_err_t ocsd_dt_add_buffer_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t *p_mem_buffer, const uint32_t mem_length);
+ OCSD_C_API ocsd_err_t ocsd_dt_add_binfile_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const char *filepath);
+ OCSD_C_API ocsd_err_t ocsd_dt_add_binfile_region_mem_acc(const dcd_tree_handle_t handle, const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const char *filepath);
+ OCSD_C_API ocsd_err_t ocsd_dt_add_callback_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAcc_CB p_cb_func, const void *p_context);
+~~~
+
+
+### Adding the output callbacks ###
+
+The decoded trace output ia collect by the client application through callback functions registered with the library.
+
+Depending on the decode configuration chosen, this can be in the form of the fully decoded trace output as generic trace
+packets, or discrete trace packets for each trace stream ID.
+
+__Full Decode__
+
+When full decode is chosen then all output is via the generic packet interface:
+
+~~~{.cpp}
+ class ITrcGenElemIn
+ {
+ ///...
+
+ virtual ocsd_datapath_resp_t TraceElemIn(const ocsd_trc_index_t index_sop,
+ const uint8_t trc_chan_id,
+ const OcsdTraceElement &el);
+ }
+~~~
+
+The client application registers a callback class or function with this signature.
+
+For each output packet the libary calls the registered function, providing the byte index into the raw trace for the first
+byte of the trace protocol packet that resulted in its generation, plus the CoreSight trace ID of the source stream,
+#and the output packet itself.
+
+The client callback must process the packet before returning the call - the reference to the packet data is only
+valid for the duration of the call. This means that the client will either have to copy and buffer packets for later
+processing if required, process immediately, or use an appropriate combination, dependent on the requirements of the
+client.
+
+The client callback provides a ocsd_datapath_resp_t response code to indicate to the input side of the library if decoding is to continue.
+
+~~~{.cpp}
+ DecodeTree *pTree;
+ TrcGenericElementPrinter genElemPrinter; // derived from ITrcGenElemIn, overrides TraceElemIn() to print incoming packet to logger.
+
+ ///...
+
+ pTree->setGenTraceElemOutI(genElemPrinter);
+
+~~~
+
+Alternatively in C-API, the callback function pointer type is defined:-
+
+~~~{.c}
+ typedef ocsd_datapath_resp_t (* FnTraceElemIn)( const void *p_context,
+ const ocsd_trc_index_t index_sop,
+ const uint8_t trc_chan_id,
+ const ocsd_generic_trace_elem *elem);
+~~~
+
+giving API calls to set up:-
+
+~~~{.c}
+ FnTraceElemIn gen_pkt_fn = &gen_trace_elem_analyze; // set to function matching signature.
+ dcd_tree_handle_t dcdtree_handle;
+
+ // ...
+
+ ret = ocsd_dt_set_gen_elem_outfn(dcdtree_handle, gen_pkt_fn, 0);
+~~~
+
+The output packets and their intepretatation are described here [prog_guide_generic_pkts.md](@ref generic_pkts).
+
+__Packet Process only, or Monitor packets in Full Decode__
+
+The client can set up the library for packet processing only, in which case the library output is
+the trace packets only, so these packets need a sink callback for each channel being output.
+
+When full decode is in operation, then the principle output is the generic packets that are output for
+all channels in operation to the single callback mentioned above. Additional callbacks can be added to
+each of the trace channels to monitor the packet processing stage as it happens at point that the packets
+are passed to the full decoder.
+
+Both methods of processing the discrete trace packets require callbacks to be registered on a
+per Trace ID / channel basis. The specifics of the callback and the resulting packet will vary according to
+the protocol of the trace source.
+
+The .cpp interface registers a packet sink / packet monitor object with the relevant decoder object.
+
+This sink object is based on the tempated IPktDataIn interface.
+
+~~~{.cpp}
+template<class P> class IPktDataIn : public ITrcTypedBase {
+ // ...
+ virtual ocsd_datapath_resp_t PacketDataIn( const ocsd_datapath_op_t op,
+ const ocsd_trc_index_t index_sop,
+ const P *p_packet_in) = 0;
+}
+~~~
+
+The template type parameter will be the protocol type for the trace source in question - e.g. EtmV4ITrcPacket.
+This interface contains a method that will be called with trace packets.
+
+The monitor object must be based on the IPktRawDataMon class, with a similarly typed template parameter and callback
+function.
+
+~~~{.cpp}
+template<class P> class IPktRawDataMon : public ITrcTypedBase {
+ // ...
+ virtual void RawPacketDataMon( const ocsd_datapath_op_t op,
+ const ocsd_trc_index_t index_sop,
+ const P *pkt,
+ const uint32_t size,
+ const uint8_t *p_data) = 0;
+}
+~~~
+
+Given a suitable callback object the process for attaching to the decode is as follows:-
+
+~~~{.cpp}
+ // client custom packet sink for ETMv4 - derived from IPktDataIn
+ class MyTracePacketSinkETMv4 : public IPktDataIn<EtmV4ITrcPacket> {
+ // ...
+ };
+
+ uint8_t CSID;
+ DecodeTree *pTree; // pointer to decode tree
+ MyTracePacketSinkETMv4 *pSink;
+
+ // ... obtain CSID and decode tree object
+
+ // decode trees manage decode elements using a tree element object, registered against CSID.
+ DecodeTreeElement *pElement = pTree->getDecoderElement(CSID);
+ pSink = new MyTracePacketSinkETMv4();
+ if (pElement && pSink)
+ err = pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(), pSink);
+
+~~~
+
+The decode tree object is used to obtain the decode tree element associated with the Coresight trace ID.
+The IDecoderMngr interface on this object is used to attach the packet sink object to the required decoder.
+
+For monitor objects use an attachPktMonitor() call with a suitably derived monitor sink object.
+
+The key difference between the packet sink, and the packet monitor is that the monitor is not in the trace decode
+data path, so does not return ocsd_datapath_resp_t values. The monitor callback also provides the raw trace byte
+data for the packet.
+
+Device tree call for registering a callback in C-API and the function signatures for each type of shown below..
+The C-API code contains underlying managment code that connects the callback with the correct packet decoder object.
+
+~~~{.c}
+OCSD_C_API ocsd_err_t ocsd_dt_attach_packet_callback( const dcd_tree_handle_t handle, // decode tree handle
+ const unsigned char CSID, // trace channel ID
+ const ocsd_c_api_cb_types callback_type, // defines packet only processing sink or monitor function signature.
+ void *p_fn_callback_data, // pointer to the callback function for the packet data.
+ const void *p_context); // opaque context to use inside the callback.
+~~~
+
+Callback definition for packet only sink callback type:
+~~~{.c}
+/** function pointer type for packet processor packet output sink, packet analyser/decoder input - generic declaration */
+typedef ocsd_datapath_resp_t (* FnDefPktDataIn)(const void *p_context,
+ const ocsd_datapath_op_t op,
+ const ocsd_trc_index_t index_sop,
+ const void *p_packet_in
+ );
+~~~
+
+Callback definition for packet monitor callback type
+~~~{.c}
+/** function pointer type for packet processor packet monitor sink, raw packet monitor / display input - generic declaration */
+typedef void (* FnDefPktDataMon)(const void *p_context,
+ const ocsd_datapath_op_t op,
+ const ocsd_trc_index_t index_sop,
+ const void *p_packet_in,
+ const uint32_t size,
+ const uint8_t *p_data
+ );
+~~~
+
+As with the `.cpp` code, the monitor callback does not have a return value, but also has the raw trace bytes for the packet as part of
+the monitor.
+
+In both cases in the C-API, the `void *p_packet_in` must be cast to packet structure appropriate to the trace protocol associated with the
+CSID value. e.g. for ETMv4 this would be @ref ocsd_etmv4_i_pkt.
+
+
+Programming Examples - using the configured Decode Tree.
+--------------------------------------------------------
+
+Once the decode tree has been configured then data raw trace data can be processed through the decode tree.
+
+The client program will require two functions to use the library. The first is on the input side of the library
+which must be driven with raw data, until the data is complete, or an error occurs. This processing routine must
+check the library returns and respond appropriately.
+
+The second consists of output callback(s) which process the decoded generic packets, or trace packets.
+This routine will return response codes according to the needs of the client.
+
+![Trace Data call and response path](decode_data_path_resp.jpg)
+
+The diagram shows the data input and response path. The data is driven into the decoding library by the client raw data input
+routine on the left. Processed packets are received by the client packet callback(s) on the right, and push response codes back
+through the library.
+
+The raw data input routine calls the standard ITrcDataIn interface with an operation code, and if appropriate some raw
+trace data. The input operation code will define how the library treats the input parameters.
+
+
+| Operation | Description | Trace Data provided |
+|:-------------------|:-----------------------------------------------------------------|:--------------------|
+| @ref OCSD_OP_DATA | Process data provided by data pointer parameters. | Yes |
+| @ref OCSD_OP_FLUSH | Call after prior wait response - finish processing previous data | No |
+| @ref OCSD_OP_EOT | End of trace data. Library will complete any pending decode. | No |
+| @ref OCSD_OP_RESET | Hard reset of decoder state - use current config for new data | No |
+
+A set of standard responses is used to indicate to the raw data input whether it should continue to push data through the library,
+pause and then flush, or if a fatal processing error has occurred.
+
+The response codes can come from the internal library decoder, or from the part of the client that is handling the processing of the
+output packets on the right of the diagram.
+
+_Response Codes_: The are contained in the @ref _ocsd_datapath_resp_t enum.
+
+- __OCSD_RESP_CONT, OCSD_RESP_CONT_xxx__: Indicates that processing is to continue. Generated either internally by the library if more data
+ is needed to generate an output packet, or by the output packet processors to indicate processing
+ is to continue.
+- __OCSD_RESP_WAIT, OCSD_RESP_WAIT_xxx:__ Sent by the client processors to pause processing. This will freeze the internal state of the library
+ and cause the WAIT response to be propogated through to the input side, with an indication of the number
+ of bytes processed. After a WAIT, the input side must respond with flush operations, until a CONT is
+ seen again and further data can then be input into the library.
+- __OCSR_RESP_FATAL_xxx__: Fatal processing error. No further processing can take place. See error response logger for reason.
+ Normally the result of corrupt or incorrect trace data.
+
+The user should note that the client program controls routines on both the input and output side of the library. The output routine may be buffering
+output packets, and when the buffer is full, returns a WAIT ressponse. This will be propgated through to the input routine. This should now terminate
+data processing, saving state and the client will run a routine to empty / process the full packet buffer. Once the necessary processing is done,
+then the input routine can be restarted, but __must__ follow the FLUSH operational rule described above.
+
+Excerpts from the data input routine used by the `trc_pkt_lister` program are shown below:
+
+~~~{.cpp}
+ // process the current buffer load until buffer done, or fatal error occurs
+ while((nBuffProcessed < nBuffRead) && !OCSD_DATA_RESP_IS_FATAL(dataPathResp))
+ {
+ if(OCSD_DATA_RESP_IS_CONT(dataPathResp))
+ {
+ dataPathResp = dcd_tree->TraceDataIn(
+ OCSD_OP_DATA,
+ trace_index,
+ (uint32_t)(nBuffRead - nBuffProcessed),
+ &(trace_buffer[0])+nBuffProcessed,
+ &nUsedThisTime);
+
+ nBuffProcessed += nUsedThisTime;
+ trace_index += nUsedThisTime;
+
+ }
+ else // last response was _WAIT
+ {
+ // may need to acknowledge a wait from the gen elem printer
+ if(genElemPrinter->needAckWait())
+ genElemPrinter->ackWait();
+
+ // dataPathResp not continue or fatal so must be wait...
+ dataPathResp = dcd_tree->TraceDataIn(OCSD_OP_FLUSH,0,0,0,0);
+ }
+ }
+
+~~~
+
+_Note_: in this test program, the WAIT response is an artificial test condition, so the input routine does not terminate on seeing it - it is cleared down
+and FLUSH is immediately sent. Normal client routines would most likely drop out of the processing loop, take actions to clear the WAIT condition, then
+resume processing with a FLUSH.
+
+See the `trc_pkt_lister` and `c_api_pkt_print_test` test program source code for further examples of driving data through the library.
diff --git a/decoder/docs/test_progs.md b/decoder/docs/test_progs.md
index 51cb526085a7..27194553f230 100644
--- a/decoder/docs/test_progs.md
+++ b/decoder/docs/test_progs.md
@@ -52,8 +52,10 @@ __Command Line Options__
*Decode options*
-- `-id <n>` : Set an ID to list (may be used mutiple times) - default if no id set is for all IDs to be printed.
+- `-id <n>` : Set an ID to list (may be used multiple times) - default if no id set is for all IDs to be printed.
- `-src_name <name>` : List packets from a given snapshot source name (defaults to first source found).
+- `-tpiu` : Input data is from a TPIU source that has TPIU FSYNC packets present.
+- `-tpiu_hsync` : Input data is from a TPIU source that has both TPIU FSYNC and HSYNC packets present.
- `-decode` : Full decode of the packets from the trace snapshot (default is to list undecoded packets only.
- `-decode_only` : Does not list the undecoded packets, just the trace decode.
- `-o_raw_packed` : Output raw packed trace frames.
@@ -140,42 +142,49 @@ Command line:-
`trc_pkt_lister -ss_dir ..\..\..\snapshots\juno_r1_1 -decode -id 0x10`
~~~~~~~~~~~~~~~~
-Idx:17230; ID:10; RCTDL_GEN_TRC_ELEM_TRACE_ON()
-Idx:17232; ID:10; RCTDL_GEN_TRC_ELEM_PE_CONTEXT(EL1N; AArch64; VMID=0x0; CTXTID=0x0; )
-Idx:17248; ID:10; RCTDL_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc000096a00:[0xffffffc000096a10] )
+
+Idx:17204; ID:10; [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 ]; I_ASYNC : Alignment Synchronisation.
+Idx:17218; ID:10; [0x01 0x01 0x00 ]; I_TRACE_INFO : Trace Info.; INFO=0x0
+Idx:17221; ID:10; [0x9d 0x00 0x35 0x09 0x00 0xc0 0xff 0xff 0xff ]; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0xFFFFFFC000096A00;
+Idx:17230; ID:10; [0x04 ]; I_TRACE_ON : Trace On.
+Idx:17232; ID:10; [0x85 0x00 0x35 0x09 0x00 0xc0 0xff 0xff 0xff 0xf1 0x00 0x00 0x00 0x00 0x00 ]; I_ADDR_CTXT_L_64IS0 : Address & Context, Long, 64 bit, IS0.; Addr=0xFFFFFFC000096A00; Ctxt: AArch64,EL1, NS; CID=0x00000000; VMID=0x0000;
+Idx:17248; ID:10; [0xf7 ]; I_ATOM_F1 : Atom format 1.; E
+Idx:17230; ID:10; OCSD_GEN_TRC_ELEM_TRACE_ON( [begin or filter])
+Idx:17232; ID:10; OCSD_GEN_TRC_ELEM_PE_CONTEXT((ISA=A64) EL1N; 64-bit; VMID=0x0; CTXTID=0x0; )
+Idx:17248; ID:10; OCSD_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc000096a00:[0xffffffc000096a10] num_i(4) last_sz(4) (ISA=A64) E ISB )
Idx:17249; ID:10; [0x9d 0x30 0x25 0x59 0x00 0xc0 0xff 0xff 0xff ]; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0xFFFFFFC000594AC0;
Idx:17258; ID:10; [0xf7 ]; I_ATOM_F1 : Atom format 1.; E
-Idx:17258; ID:10; RCTDL_GEN_TRC_ELEM_ADDR_NACC( 0xffffffc000594ac0 )
+Idx:17258; ID:10; OCSD_GEN_TRC_ELEM_ADDR_NACC( 0xffffffc000594ac0 )
Idx:17259; ID:10; [0x95 0xd6 0x95 ]; I_ADDR_S_IS0 : Address, Short, IS0.; Addr=0xFFFFFFC000592B58 ~[0x12B58]
Idx:17262; ID:10; [0xf9 ]; I_ATOM_F3 : Atom format 3.; ENN
-Idx:17262; ID:10; RCTDL_GEN_TRC_ELEM_ADDR_NACC( 0xffffffc000592b58 )
+Idx:17262; ID:10; OCSD_GEN_TRC_ELEM_ADDR_NACC( 0xffffffc000592b58 )
Idx:17264; ID:10; [0xf7 ]; I_ATOM_F1 : Atom format 1.; E
-Idx:17265; ID:10; [0x9a 0x32 0x62 0x5a 0x00 ]; I_ADDR_L_32IS0 : Address, Long, 32 bit, IS0.; Addr=0x005AC4C8;
+Idx:17265; ID:10; [0x9a 0x32 0x62 0x5a 0x00 ]; I_ADDR_L_32IS0 : Address, Long, 32 bit, IS0.; Addr=0xFFFFFFC0005AC4C8;
Idx:17270; ID:10; [0xdb ]; I_ATOM_F2 : Atom format 2.; EE
-Idx:17270; ID:10; RCTDL_GEN_TRC_ELEM_ADDR_NACC( 0xffffffc0005ac4c8 )
-Idx:17271; ID:10; [0x9a 0x62 0x52 0x0e 0x00 ]; I_ADDR_L_32IS0 : Address, Long, 32 bit, IS0.; Addr=0x000EA588;
+Idx:17270; ID:10; OCSD_GEN_TRC_ELEM_ADDR_NACC( 0xffffffc0005ac4c8 )
+Idx:17271; ID:10; [0x9a 0x62 0x52 0x0e 0x00 ]; I_ADDR_L_32IS0 : Address, Long, 32 bit, IS0.; Addr=0xFFFFFFC0000EA588;
Idx:17276; ID:10; [0xfc ]; I_ATOM_F3 : Atom format 3.; NNE
-Idx:17276; ID:10; RCTDL_GEN_TRC_ELEM_ADDR_NACC( 0xffffffc0000ea588 )
-Idx:17277; ID:10; [0x9a 0x58 0x15 0x59 0x00 ]; I_ADDR_L_32IS0 : Address, Long, 32 bit, IS0.; Addr=0x00592B60;
+Idx:17276; ID:10; OCSD_GEN_TRC_ELEM_ADDR_NACC( 0xffffffc0000ea588 )
+Idx:17277; ID:10; [0x9a 0x58 0x15 0x59 0x00 ]; I_ADDR_L_32IS0 : Address, Long, 32 bit, IS0.; Addr=0xFFFFFFC000592B60;
Idx:17283; ID:10; [0x06 0x1d ]; I_EXCEPT : Exception.; IRQ; Ret Addr Follows;
-Idx:17285; ID:10; [0x95 0x59 ]; I_ADDR_S_IS0 : Address, Short, IS0.; Addr=0x00592B64 ~[0x164]
-Idx:17283; ID:10; RCTDL_GEN_TRC_ELEM_EXCEPTION(pref ret addr:0xffffffc000592b64; excep num (0x0e)
-Idx:17287; ID:10; [0x9a 0x20 0x19 0x08 0x00 ]; I_ADDR_L_32IS0 : Address, Long, 32 bit, IS0.; Addr=0x00083280;
+Idx:17285; ID:10; [0x95 0x59 ]; I_ADDR_S_IS0 : Address, Short, IS0.; Addr=0xFFFFFFC000592B64 ~[0x164]
+Idx:17283; ID:10; OCSD_GEN_TRC_ELEM_ADDR_NACC( 0xffffffc000592b60 )
+Idx:17283; ID:10; OCSD_GEN_TRC_ELEM_EXCEPTION(pref ret addr:0xffffffc000592b64; excep num (0x0e) )
+Idx:17287; ID:10; [0x9a 0x20 0x19 0x08 0x00 ]; I_ADDR_L_32IS0 : Address, Long, 32 bit, IS0.; Addr=0xFFFFFFC000083280;
Idx:17292; ID:10; [0xfd ]; I_ATOM_F3 : Atom format 3.; ENE
-Idx:17292; ID:10; RCTDL_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc000083280:[0xffffffc000083284] )
-Idx:17292; ID:10; RCTDL_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc000083d40:[0xffffffc000083d9c] )
-Idx:17292; ID:10; RCTDL_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc000083d9c:[0xffffffc000083dac] )
-Idx:17293; ID:10; [0x95 0xf7 0x09 ]; I_ADDR_S_IS0 : Address, Short, IS0.; Addr=0x000813DC ~[0x13DC]
+Idx:17292; ID:10; OCSD_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc000083280:[0xffffffc000083284] num_i(1) last_sz(4) (ISA=A64) E BR )
+Idx:17292; ID:10; OCSD_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc000083d40:[0xffffffc000083d9c] num_i(23) last_sz(4) (ISA=A64) N BR <cond>)
+Idx:17292; ID:10; OCSD_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc000083d9c:[0xffffffc000083dac] num_i(4) last_sz(4) (ISA=A64) E iBR b+link )
+Idx:17293; ID:10; [0x95 0xf7 0x09 ]; I_ADDR_S_IS0 : Address, Short, IS0.; Addr=0xFFFFFFC0000813DC ~[0x13DC]
Idx:17297; ID:10; [0xdb ]; I_ATOM_F2 : Atom format 2.; EE
-Idx:17297; ID:10; RCTDL_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc0000813dc:[0xffffffc0000813f0] )
-Idx:17297; ID:10; RCTDL_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc00008f2e0:[0xffffffc00008f2e4] )
-Idx:17298; ID:10; [0x95 0x7e ]; I_ADDR_S_IS0 : Address, Short, IS0.; Addr=0x000813F8 ~[0x1F8]
+Idx:17297; ID:10; OCSD_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc0000813dc:[0xffffffc0000813f0] num_i(5) last_sz(4) (ISA=A64) E BR b+link )
+Idx:17297; ID:10; OCSD_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc00008f2e0:[0xffffffc00008f2e4] num_i(1) last_sz(4) (ISA=A64) E iBR A64:ret )
+Idx:17298; ID:10; [0x95 0x7e ]; I_ADDR_S_IS0 : Address, Short, IS0.; Addr=0xFFFFFFC0000813F8 ~[0x1F8]
Idx:17300; ID:10; [0xe0 ]; I_ATOM_F6 : Atom format 6.; EEEN
-Idx:17300; ID:10; RCTDL_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc0000813f8:[0xffffffc00008140c] )
-Idx:17300; ID:10; RCTDL_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc00008141c:[0xffffffc000081434] )
-Idx:17300; ID:10; RCTDL_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc00008140c:[0xffffffc000081414] )
-Idx:17300; ID:10; RCTDL_GEN_TRC_ELEM_ADDR_NACC( 0xffffffc000117cf0 )
-
+Idx:17300; ID:10; OCSD_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc0000813f8:[0xffffffc00008140c] num_i(5) last_sz(4) (ISA=A64) E BR )
+Idx:17300; ID:10; OCSD_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc00008141c:[0xffffffc000081434] num_i(6) last_sz(4) (ISA=A64) E BR <cond>)
+Idx:17300; ID:10; OCSD_GEN_TRC_ELEM_INSTR_RANGE(exec range=0xffffffc00008140c:[0xffffffc000081414] num_i(2) last_sz(4) (ISA=A64) E BR b+link )
+Idx:17300; ID:10; OCSD_GEN_TRC_ELEM_ADDR_NACC( 0xffffffc000117cf0 )
~~~~~~~~~~~~~~~~
diff --git a/decoder/include/common/ocsd_code_follower.h b/decoder/include/common/ocsd_code_follower.h
index 0e8691034a68..b024aa02a368 100644
--- a/decoder/include/common/ocsd_code_follower.h
+++ b/decoder/include/common/ocsd_code_follower.h
@@ -95,6 +95,7 @@ public:
const bool isLink() const; //!< is a link (branch with link etc)
const bool ISAChanged() const; //!< next ISA different from input ISA.
const ocsd_isa nextISA() const; //!< ISA for next instruction
+ const uint8_t getInstrSize() const; //!< Get the last instruction size.
// information on error conditions
const bool isNacc() const; //!< true if Memory Not Accessible (nacc) error occurred
@@ -192,6 +193,11 @@ inline const ocsd_instr_subtype OcsdCodeFollower::getInstrSubType() const
return m_instr_info.sub_type;
}
+inline const uint8_t OcsdCodeFollower::getInstrSize() const
+{
+ return m_instr_info.instr_size;
+}
+
inline const bool OcsdCodeFollower::isCondInstr() const
{
return (bool)(m_instr_info.is_conditional == 1);
diff --git a/decoder/include/common/ocsd_dcd_tree.h b/decoder/include/common/ocsd_dcd_tree.h
index 496f8e5d72e0..e4e74f2bc659 100644
--- a/decoder/include/common/ocsd_dcd_tree.h
+++ b/decoder/include/common/ocsd_dcd_tree.h
@@ -313,6 +313,22 @@ public:
*/
ocsd_err_t addBinFileRegionMemAcc(const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const std::string &filepath);
+
+ /*!
+ * Updates/adds to a memory accessor for a memory block supplied as a one or more memory regions in a binary file.
+ * Region structures are created that describe the memory start address, the offset within the binary file
+ * for that address, and the length of the region. This accessor can be used to point to the code section
+ * in a program file for example.
+ *
+ * @param *region_array : array of valid memory regions in the file.
+ * @param num_regions : number of regions
+ * @param mem_space : Memory space
+ * @param &filepath : Path to the binary data file
+ *
+ * @return ocsd_err_t : Library error code or OCSD_OK if successful.
+ */
+ ocsd_err_t updateBinFileRegionMemAcc(const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const std::string &filepath);
+
/*!
* This memory accessor allows the client to supply a callback function for the region
* defined by the start and end addresses. This can be used to supply a custom memory accessor,
@@ -327,7 +343,8 @@ public:
* @return ocsd_err_t : Library error code or OCSD_OK if successful.
*/
ocsd_err_t addCallbackMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAcc_CB p_cb_func, const void *p_context);
-
+ ocsd_err_t addCallbackIDMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAccID_CB p_cb_func, const void *p_context);
+
/*!
* Remove the memory accessor from the map, that begins at the given address, for the memory space provided.
*
@@ -368,6 +385,9 @@ private:
ocsd_err_t createDecodeElement(const uint8_t CSID);
void destroyDecodeElement(const uint8_t CSID);
void destroyMemAccMapper();
+ ocsd_err_t initCallbackMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address,
+ const ocsd_mem_space_acc_t mem_space, void *p_cb_func, bool IDfn, const void *p_context);
+
ocsd_dcd_tree_src_t m_dcd_tree_type;
diff --git a/decoder/include/common/ocsd_error_logger.h b/decoder/include/common/ocsd_error_logger.h
index d60139726efb..3badd337f655 100644
--- a/decoder/include/common/ocsd_error_logger.h
+++ b/decoder/include/common/ocsd_error_logger.h
@@ -37,7 +37,7 @@
#include <string>
#include <vector>
-#include <fstream>
+//#include <fstream>
#include "interfaces/trc_error_log_i.h"
#include "ocsd_error.h"
@@ -49,7 +49,7 @@ public:
ocsdDefaultErrorLogger();
virtual ~ocsdDefaultErrorLogger();
- bool initErrorLogger(const ocsd_err_severity_t verbosity, bool bCreateOutputLogger = false);
+ bool initErrorLogger(const ocsd_err_severity_t verbosity, bool bCreateOutputLogger = false); //!< Initialise the error logger with a severity filter, optionally create an output logger on stderr.
virtual ocsdMsgLogger *getOutputLogger() { return m_output_logger; };
virtual void setOutputLogger(ocsdMsgLogger *pLogger);
diff --git a/decoder/include/common/ocsd_msg_logger.h b/decoder/include/common/ocsd_msg_logger.h
index c40af9189aa7..d83a0224e176 100644
--- a/decoder/include/common/ocsd_msg_logger.h
+++ b/decoder/include/common/ocsd_msg_logger.h
@@ -53,23 +53,26 @@ public:
ocsdMsgLogger();
~ocsdMsgLogger();
+ /** Typedef enum providing flags to define the output methods for the message logger.
+ */
typedef enum {
- OUT_NONE = 0,
- OUT_FILE = 1,
- OUT_STDERR = 2,
- OUT_STDOUT = 4,
- OUT_STR_CB = 8 /* output to external string callback interface */
+ OUT_NONE = 0, /*!< No output from logger*/
+ OUT_FILE = 1, /*!< Output to file */
+ OUT_STDERR = 2, /*!< Output to stderr */
+ OUT_STDOUT = 4, /*!< Output to stdout */
+ OUT_STR_CB = 8 /*!< output to external string callback interface */
} output_dest;
- void setLogOpts(int logOpts);
- const int getLogOpts() const { return m_outFlags; };
+ void setLogOpts(int logOpts); //!< set the output logging flags.
+ const int getLogOpts() const //! get the current output logging flags value.
+ { return m_outFlags; };
- void setLogFileName(const char *fileName);
- void setStrOutFn(ocsdMsgLogStrOutI *p_IstrOut);
+ void setLogFileName(const char *fileName); //!< Set the output log filename, and enable logging to file.
+ void setStrOutFn(ocsdMsgLogStrOutI *p_IstrOut); //!< Set the output log string callback and enable logging to callback.
- void LogMsg(const std::string &msg);
+ void LogMsg(const std::string &msg); //!< Log a message to the current set output channels.
- const bool isLogging() const;
+ const bool isLogging() const; //!< true if logging active
private:
int m_outFlags;
diff --git a/decoder/include/common/trc_gen_elem.h b/decoder/include/common/trc_gen_elem.h
index 00081b556904..1c4a47b3aa0a 100644
--- a/decoder/include/common/trc_gen_elem.h
+++ b/decoder/include/common/trc_gen_elem.h
@@ -73,9 +73,10 @@ public:
void setTraceOnReason(const trace_on_reason_t reason);
- void setAddrRange(const ocsd_vaddr_t st_addr, const ocsd_vaddr_t en_addr);
- void setLastInstrInfo(const bool exec, const ocsd_instr_type last_i_type, const ocsd_instr_subtype last_i_subtype);
+ void setAddrRange(const ocsd_vaddr_t st_addr, const ocsd_vaddr_t en_addr, const int num_instr = 1);
+ void setLastInstrInfo(const bool exec, const ocsd_instr_type last_i_type, const ocsd_instr_subtype last_i_subtype, const uint8_t size);
void setAddrStart(const ocsd_vaddr_t st_addr) { this->st_addr = st_addr; };
+ void setLastInstrCond(const int is_cond) { this->last_instr_cond = is_cond; };
void setSWTInfo(const ocsd_swt_info_t swt_info) { sw_trace_info = swt_info; };
void setExtendedDataPtr(const void *data_ptr);
@@ -122,15 +123,17 @@ inline void OcsdTraceElement::setEvent(const event_t ev_type, const uint16_t num
trace_event.ev_number = ev_type == EVENT_NUMBERED ? number : 0;
}
-inline void OcsdTraceElement::setAddrRange(const ocsd_vaddr_t st_addr, const ocsd_vaddr_t en_addr)
+inline void OcsdTraceElement::setAddrRange(const ocsd_vaddr_t st_addr, const ocsd_vaddr_t en_addr, const int num_instr /* = 1 */)
{
this->st_addr = st_addr;
this->en_addr = en_addr;
+ this->num_instr_range = num_instr;
}
-inline void OcsdTraceElement::setLastInstrInfo(const bool exec, const ocsd_instr_type last_i_type, const ocsd_instr_subtype last_i_subtype)
+inline void OcsdTraceElement::setLastInstrInfo(const bool exec, const ocsd_instr_type last_i_type, const ocsd_instr_subtype last_i_subtype, const uint8_t size)
{
last_instr_exec = exec ? 1 : 0;
+ last_instr_sz = size & 0x7;
this->last_i_type = last_i_type;
this->last_i_subtype = last_i_subtype;
}
diff --git a/decoder/include/i_dec/trc_i_decode.h b/decoder/include/i_dec/trc_i_decode.h
index ac31a79ded63..0285f4182523 100644
--- a/decoder/include/i_dec/trc_i_decode.h
+++ b/decoder/include/i_dec/trc_i_decode.h
@@ -49,6 +49,7 @@ private:
ocsd_err_t DecodeA32(ocsd_instr_info *instr_info);
ocsd_err_t DecodeA64(ocsd_instr_info *instr_info);
ocsd_err_t DecodeT32(ocsd_instr_info *instr_info);
+ void SetArchVersion(ocsd_instr_info *instr_info);
};
#endif // ARM_TRC_I_DECODE_H_INCLUDED
diff --git a/decoder/include/i_dec/trc_idec_arminst.h b/decoder/include/i_dec/trc_idec_arminst.h
index b15984948d29..8697f68d676c 100644
--- a/decoder/include/i_dec/trc_idec_arminst.h
+++ b/decoder/include/i_dec/trc_idec_arminst.h
@@ -73,7 +73,9 @@ Performance event 0x0D counts these.
*/
int inst_ARM_is_direct_branch(uint32_t inst);
int inst_Thumb_is_direct_branch(uint32_t inst);
+int inst_Thumb_is_direct_branch_link(uint32_t inst, uint8_t *is_link, uint8_t *is_cond);
int inst_A64_is_direct_branch(uint32_t inst);
+int inst_A64_is_direct_branch_link(uint32_t inst, uint8_t *is_link);
/*
Get branch destination for a direct branch.
@@ -83,7 +85,9 @@ int inst_Thumb_branch_destination(uint32_t addr, uint32_t inst, uint32_t *pnpc);
int inst_A64_branch_destination(uint64_t addr, uint32_t inst, uint64_t *pnpc);
int inst_ARM_is_indirect_branch(uint32_t inst);
+int inst_Thumb_is_indirect_branch_link(uint32_t inst, uint8_t *is_link);
int inst_Thumb_is_indirect_branch(uint32_t inst);
+int inst_A64_is_indirect_branch_link(uint32_t inst, uint8_t *is_link);
int inst_A64_is_indirect_branch(uint32_t inst);
int inst_ARM_is_branch_and_link(uint32_t inst);
@@ -109,6 +113,10 @@ arm_barrier_t inst_ARM_barrier(uint32_t inst);
arm_barrier_t inst_Thumb_barrier(uint32_t inst);
arm_barrier_t inst_A64_barrier(uint32_t inst);
+int inst_ARM_wfiwfe(uint32_t inst);
+int inst_Thumb_wfiwfe(uint32_t inst);
+int inst_A64_wfiwfe(uint32_t inst);
+
/*
Test whether an instruction is definitely undefined, e.g. because
allocated to a "permanently UNDEFINED" space (UDF mnemonic).
@@ -125,6 +133,9 @@ int inst_A64_is_UDF(uint32_t inst);
ocsd_instr_subtype get_instr_subtype();
void clear_instr_subtype();
+/* set arch version info. */
+void set_arch_version(uint16_t version);
+
#endif // ARM_TRC_IDEC_ARMINST_H_INCLUDED
/* End of File trc_idec_arminst.h */
diff --git a/decoder/include/interfaces/trc_error_log_i.h b/decoder/include/interfaces/trc_error_log_i.h
index 2fc796f72457..cc65f631e750 100644
--- a/decoder/include/interfaces/trc_error_log_i.h
+++ b/decoder/include/interfaces/trc_error_log_i.h
@@ -56,8 +56,8 @@ class ocsdMsgLogger;
class ITraceErrorLog
{
public:
- ITraceErrorLog() {}; /**< default constructor */
- virtual ~ITraceErrorLog() {}; /**< default destructor */
+ ITraceErrorLog() {};
+ virtual ~ITraceErrorLog() {};
/*!
* Register a named component error source. Allows the logger to associate errors with components.
@@ -111,7 +111,7 @@ public:
* Get the last error associated with the given Trace source channel ID.
* returns a pointer to the error or 0 if no errors associated with the ID.
*
- * @param chan_id : ID.
+ * @param chan_id : Trace Source Channel ID (CoreSight Trace ID).
*
* @return ocsdError *: last error pointer for ID or 0.
*/
diff --git a/decoder/include/mem_acc/trc_mem_acc_base.h b/decoder/include/mem_acc/trc_mem_acc_base.h
index 71b6a816edad..7f17bde125db 100644
--- a/decoder/include/mem_acc/trc_mem_acc_base.h
+++ b/decoder/include/mem_acc/trc_mem_acc_base.h
@@ -123,12 +123,13 @@ public:
*
* @param s_address : Start address of the read.
* @param memSpace : memory space for this access.
+ * @param trcID : Trace ID of trace source.
* @param reqBytes : Number of bytes required.
* @param *byteBuffer : Buffer to copy the bytes into.
*
* @return uint32_t : Number of bytes read, 0 if s_address out of range, or mem space not accessible.
*/
- virtual const uint32_t readBytes(const ocsd_vaddr_t s_address, const ocsd_mem_space_acc_t memSpace, const uint32_t reqBytes, uint8_t *byteBuffer) = 0;
+ virtual const uint32_t readBytes(const ocsd_vaddr_t s_address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer) = 0;
/*!
* Validate the address range - ensure addresses aligned, different, st < en etc.
diff --git a/decoder/include/mem_acc/trc_mem_acc_bufptr.h b/decoder/include/mem_acc/trc_mem_acc_bufptr.h
index 61ec345abe68..bd9ea8ee1e5d 100644
--- a/decoder/include/mem_acc/trc_mem_acc_bufptr.h
+++ b/decoder/include/mem_acc/trc_mem_acc_bufptr.h
@@ -64,7 +64,7 @@ public:
virtual ~TrcMemAccBufPtr() {}; /**< default destructor */
/** Memory access override - allow decoder to read bytes from the buffer. */
- virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint32_t reqBytes, uint8_t *byteBuffer);
+ virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer);
private:
const uint8_t *m_p_buffer; /**< pointer to the memory buffer */
diff --git a/decoder/include/mem_acc/trc_mem_acc_cache.h b/decoder/include/mem_acc/trc_mem_acc_cache.h
new file mode 100644
index 000000000000..5e81c2a2ea34
--- /dev/null
+++ b/decoder/include/mem_acc/trc_mem_acc_cache.h
@@ -0,0 +1,149 @@
+/*!
+* \file trc_mem_acc_cache.h
+* \brief OpenCSD : Memory accessor cache.
+*
+* \copyright Copyright (c) 2018, ARM Limited. All Rights Reserved.
+*/
+
+/*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice,
+* this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software without
+* specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
+* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef ARM_TRC_MEM_ACC_CACHE_H_INCLUDED
+#define ARM_TRC_MEM_ACC_CACHE_H_INCLUDED
+
+#include <string>
+#include "opencsd/ocsd_if_types.h"
+
+#define MEM_ACC_CACHE_PAGE_SIZE 256
+#define MEM_ACC_CACHE_MRU_SIZE 12
+
+class TrcMemAccessorBase;
+class ITraceErrorLog;
+
+typedef struct cache_block {
+ ocsd_vaddr_t st_addr;
+ uint32_t valid_len;
+ uint8_t data[MEM_ACC_CACHE_PAGE_SIZE];
+} cache_block_t;
+
+// enable define to collect stats for debugging / cache performance tests
+//#define LOG_CACHE_STATS
+
+
+/** class TrcMemAccCache - cache small amounts of data from accessors to speed up decode. */
+class TrcMemAccCache
+{
+public:
+ TrcMemAccCache();
+ ~TrcMemAccCache() {};
+
+ void enableCaching(bool bEnable) { m_bCacheEnabled = bEnable; };
+ void invalidateAll();
+ const bool enabled() const { return m_bCacheEnabled; };
+ const bool enabled_for_size(const uint32_t reqSize) const
+ {
+ return (m_bCacheEnabled && (reqSize <= MEM_ACC_CACHE_PAGE_SIZE));
+ }
+
+
+ /** read bytes from cache if possible - load new page if needed, bail out if data not available */
+ ocsd_err_t readBytesFromCache(TrcMemAccessorBase *p_accessor, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t trcID, uint32_t *numBytes, uint8_t *byteBuffer);
+
+ void setErrorLog(ITraceErrorLog *log);
+ void logAndClearCounts();
+
+private:
+ bool blockInCache(const ocsd_vaddr_t address, const uint32_t reqBytes); // run through each page to look for data.
+ bool blockInPage(const ocsd_vaddr_t address, const uint32_t reqBytes);
+ void logMsg(const std::string &szMsg);
+
+ cache_block_t m_mru[MEM_ACC_CACHE_MRU_SIZE];
+ int m_mru_idx = 0; // in use index
+ int m_mru_next_new = 0; // next new page at this index.
+ bool m_bCacheEnabled = false;
+
+#ifdef LOG_CACHE_STATS
+ uint32_t m_hits = 0;
+ uint32_t m_misses = 0;
+ uint32_t m_pages = 0;
+ uint32_t m_hit_rl[MEM_ACC_CACHE_MRU_SIZE];
+ uint32_t m_hit_rl_max[MEM_ACC_CACHE_MRU_SIZE];
+#endif
+
+ ITraceErrorLog *m_err_log = 0;
+};
+
+inline TrcMemAccCache::TrcMemAccCache()
+{
+ for (int i = 0; i < MEM_ACC_CACHE_MRU_SIZE; i++)
+ {
+ m_mru[i].st_addr = 0;
+ m_mru[i].valid_len = 0;
+#ifdef LOG_CACHE_STATS
+ m_hit_rl[i] = 0;
+ m_hit_rl_max[i] = 0;
+#endif
+ }
+}
+
+inline bool TrcMemAccCache::blockInPage(const ocsd_vaddr_t address, const uint32_t reqBytes)
+{
+ if ((m_mru[m_mru_idx].st_addr <= address) &&
+ m_mru[m_mru_idx].st_addr + m_mru[m_mru_idx].valid_len >= (address + reqBytes))
+ return true;
+ return false;
+}
+
+inline bool TrcMemAccCache::blockInCache(const ocsd_vaddr_t address, const uint32_t reqBytes)
+{
+ int tests = MEM_ACC_CACHE_MRU_SIZE;
+ while (tests)
+ {
+ if (blockInPage(address, reqBytes))
+ return true; // found address in page
+ tests--;
+ m_mru_idx++;
+ if (m_mru_idx == MEM_ACC_CACHE_MRU_SIZE)
+ m_mru_idx = 0;
+ }
+ return false;
+}
+
+inline void TrcMemAccCache::invalidateAll()
+{
+ for (int i = 0; i < MEM_ACC_CACHE_MRU_SIZE; i++)
+ {
+ m_mru[i].valid_len = 0;
+ m_mru[i].st_addr = 0;
+ }
+ m_mru_idx = 0;
+ m_mru_next_new = 0;
+}
+
+#endif // ARM_TRC_MEM_ACC_CACHE_H_INCLUDED
+
+/* End of File trc_mem_acc_cache.h */
diff --git a/decoder/include/mem_acc/trc_mem_acc_cb.h b/decoder/include/mem_acc/trc_mem_acc_cb.h
index df6f9930e4fc..e58c6169f171 100644
--- a/decoder/include/mem_acc/trc_mem_acc_cb.h
+++ b/decoder/include/mem_acc/trc_mem_acc_cb.h
@@ -49,32 +49,47 @@ public:
virtual ~TrcMemAccCB() {};
/** Memory access override - allow decoder to read bytes from the buffer. */
- virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint32_t reqBytes, uint8_t *byteBuffer);
+ virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer);
void setCBIfClass(TrcMemAccCBIF *p_if);
void setCBIfFn(Fn_MemAcc_CB p_fn, const void *p_context);
+ void setCBIDIfFn(Fn_MemAccID_CB p_fn, const void *p_context);
private:
+ void clearCBptrs();
TrcMemAccCBIF *m_p_CBclass; //<! callback class.
Fn_MemAcc_CB m_p_CBfn; //<! callback function.
+ Fn_MemAccID_CB m_p_CBIDfn; //<! callback with ID function.
const void *m_p_cbfn_context; //<! context pointer for callback function.
};
+inline void TrcMemAccCB::clearCBptrs()
+{
+ m_p_CBclass = 0;
+ m_p_CBfn = 0;
+ m_p_CBIDfn = 0;
+ m_p_cbfn_context = 0;
+}
+
inline void TrcMemAccCB::setCBIfClass(TrcMemAccCBIF *p_if)
{
+ clearCBptrs(); // only one callback type per accessor.
m_p_CBclass = p_if;
- m_p_CBfn = 0; // only one callback type per accessor.
- m_p_cbfn_context = 0;
}
inline void TrcMemAccCB::setCBIfFn(Fn_MemAcc_CB p_fn, const void *p_context)
{
+ clearCBptrs(); // only one callback type per accessor.
m_p_CBfn = p_fn;
m_p_cbfn_context = p_context;
- m_p_CBclass = 0; // only one callback type per accessor.
}
-
+inline void TrcMemAccCB::setCBIDIfFn(Fn_MemAccID_CB p_fn, const void *p_context)
+{
+ clearCBptrs(); // only one callback type per accessor.
+ m_p_CBIDfn = p_fn;
+ m_p_cbfn_context = p_context;
+}
#endif // ARM_TRC_MEM_ACC_CB_H_INCLUDED
diff --git a/decoder/include/mem_acc/trc_mem_acc_file.h b/decoder/include/mem_acc/trc_mem_acc_file.h
index 7f8d5462cbf5..6c9b537407ea 100644
--- a/decoder/include/mem_acc/trc_mem_acc_file.h
+++ b/decoder/include/mem_acc/trc_mem_acc_file.h
@@ -56,7 +56,7 @@ public:
bool operator<(const FileRegionMemAccessor& rhs) { return this->m_startAddress < rhs.m_startAddress; };
// not going to use these objects to read bytes - defer to the file class for that.
- virtual const uint32_t readBytes(const ocsd_vaddr_t s_address, const ocsd_mem_space_acc_t memSpace, const uint32_t reqBytes, uint8_t *byteBuffer) { return 0; };
+ virtual const uint32_t readBytes(const ocsd_vaddr_t s_address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer) { return 0; };
const ocsd_vaddr_t regionStartAddress() const { return m_startAddress; };
@@ -77,7 +77,7 @@ class TrcMemAccessorFile : public TrcMemAccessorBase
{
public:
/** read bytes override - reads from file */
- virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint32_t reqBytes, uint8_t *byteBuffer);
+ virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer);
protected:
TrcMemAccessorFile(); /**< protected default constructor */
diff --git a/decoder/include/mem_acc/trc_mem_acc_mapper.h b/decoder/include/mem_acc/trc_mem_acc_mapper.h
index 07d044ead81c..a700e9dbd07e 100644
--- a/decoder/include/mem_acc/trc_mem_acc_mapper.h
+++ b/decoder/include/mem_acc/trc_mem_acc_mapper.h
@@ -41,6 +41,7 @@
#include "interfaces/trc_tgt_mem_access_i.h"
#include "interfaces/trc_error_log_i.h"
#include "mem_acc/trc_mem_acc_base.h"
+#include "mem_acc/trc_mem_acc_cache.h"
typedef enum _memacc_mapper_t {
MEMACC_MAP_GLOBAL,
@@ -76,7 +77,7 @@ public:
ocsd_err_t RemoveAccessorByAddress(const ocsd_vaddr_t st_address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id = 0);
// set the error log.
- void setErrorLog(ITraceErrorLog *err_log_i) { m_err_log = err_log_i; };
+ void setErrorLog(ITraceErrorLog *err_log_i);
// print out the ranges in this mapper.
virtual void logMappedRanges() = 0;
@@ -89,11 +90,13 @@ protected:
virtual void clearAccessorList() = 0;
void LogMessage(const std::string &msg);
+ void LogWarn(const ocsd_err_t err, const std::string &msg);
TrcMemAccessorBase *m_acc_curr; // most recently used - try this first.
uint8_t m_trace_id_curr; // trace ID for the current accessor
const bool m_using_trace_id; // true if we are using separate memory spaces by TraceID.
ITraceErrorLog *m_err_log; // error log to print out mappings on request.
+ TrcMemAccCache m_cache; // memory accessor caching.
};
diff --git a/decoder/include/opencsd/c_api/ocsd_c_api_types.h b/decoder/include/opencsd/c_api/ocsd_c_api_types.h
index ca61e0aaed32..cde351fc525f 100644
--- a/decoder/include/opencsd/c_api/ocsd_c_api_types.h
+++ b/decoder/include/opencsd/c_api/ocsd_c_api_types.h
@@ -37,6 +37,7 @@
/* select the library types that are C compatible - the interface data types */
#include "opencsd/ocsd_if_types.h"
+#include "opencsd/ocsd_if_version.h"
#include "opencsd/trc_gen_elem_types.h"
#include "opencsd/trc_pkt_types.h"
diff --git a/decoder/include/opencsd/c_api/opencsd_c_api.h b/decoder/include/opencsd/c_api/opencsd_c_api.h
index f9f4ed4b8613..90201d436e08 100644
--- a/decoder/include/opencsd/c_api/opencsd_c_api.h
+++ b/decoder/include/opencsd/c_api/opencsd_c_api.h
@@ -84,7 +84,7 @@
/** @name Library Version API
@{*/
-/** Get Library version. Return a 32 bit version in form MMMMnnpp - MMMM = major verison, nn = minor version, pp = patch version */
+/** Get Library version. Return a 32 bit version in form MMMMnnpp - MMMM = major version, nn = minor version, pp = patch version */
OCSD_C_API uint32_t ocsd_get_version(void);
/** Get library version string */
@@ -286,6 +286,23 @@ OCSD_C_API ocsd_err_t ocsd_dt_add_buffer_mem_acc(const dcd_tree_handle_t handle,
*/
OCSD_C_API ocsd_err_t ocsd_dt_add_callback_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAcc_CB p_cb_func, const void *p_context);
+
+/*!
+ * Add a memory access callback function. The decoder will call the function for opcode addresses in the
+ * address range supplied for the memory spaces covered.
+ *
+ * @param handle : Handle to decode tree.
+ * @param st_address : Start address of memory area covered by the callback.
+ * @param en_address : End address of the memory area covered by the callback. (inclusive)
+ * @param mem_space : Memory space(s) covered by the callback.
+ * @param p_cb_func : Callback function - Signature for CB with Trace ID passed to client.
+ * @param p_context : opaque context pointer value used in callback function.
+ *
+ * @return OCSD_C_API ocsd_err_t : Library error code - RCDTL_OK if successful.
+ */
+OCSD_C_API ocsd_err_t ocsd_dt_add_callback_trcid_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAccID_CB p_cb_func, const void *p_context);
+
+
/*!
* Remove a memory accessor by address and memory space.
*
diff --git a/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h b/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h
index a3f883540a30..1d72d97afe59 100644
--- a/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h
+++ b/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h
@@ -108,6 +108,7 @@ public:
/* idr 1 */
const uint8_t MajVersion() const;
const uint8_t MinVersion() const;
+ const uint8_t FullVersion() const;
/* idr 2 */
const uint32_t iaSizeMax() const;
@@ -117,6 +118,7 @@ public:
const uint32_t dvSize() const;
const uint32_t ccSize() const;
const bool vmidOpt() const;
+ const bool wfiwfeBranch() const;
/* id regs 8-13*/
const uint32_t MaxSpecDepth() const;
@@ -180,7 +182,11 @@ private:
bool m_condTraceCalc;
CondITrace_t m_CondTrace;
+protected:
ocsd_etmv4_cfg m_cfg;
+ uint8_t m_MajVer;
+ uint8_t m_MinVer;
+
};
/* idr 0 */
@@ -265,14 +271,18 @@ inline const bool EtmV4Config::commitOpt1() const
/* idr 1 */
inline const uint8_t EtmV4Config::MajVersion() const
{
- return (uint8_t)((m_cfg.reg_idr1 >> 8) & 0xF);
+ return m_MajVer;
}
inline const uint8_t EtmV4Config::MinVersion() const
{
- return (uint8_t)((m_cfg.reg_idr1 >> 4) & 0xF);
+ return m_MinVer;
}
+inline const uint8_t EtmV4Config::FullVersion() const
+{
+ return (m_MajVer << 4) | m_MinVer;
+}
/* idr 2 */
inline const uint32_t EtmV4Config::iaSizeMax() const
@@ -320,6 +330,12 @@ inline const bool EtmV4Config::vmidOpt() const
return (bool)((m_cfg.reg_idr2 & 0x20000000) == 0x20000000) && (MinVersion() > 0);
}
+inline const bool EtmV4Config::wfiwfeBranch() const
+{
+ return (bool)((m_cfg.reg_idr2 & 0x80000000) && (FullVersion() >= 0x43));
+}
+
+
/* id regs 8-13*/
inline const uint32_t EtmV4Config::MaxSpecDepth() const
diff --git a/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h b/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h
index 8bf0fb0c0478..15996547163c 100644
--- a/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h
+++ b/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h
@@ -56,7 +56,8 @@ typedef enum _p0_elem_t
P0_TS,
P0_CC,
P0_TS_CC,
- P0_OVERFLOW
+ P0_OVERFLOW,
+ P0_FUNC_RET,
} p0_elem_t;
@@ -250,6 +251,7 @@ public:
~EtmV4P0Stack();
void push_front(TrcStackElem *pElem);
+ void push_back(TrcStackElem *pElem); // insert element when processing
void pop_back();
TrcStackElem *back();
size_t size();
@@ -260,7 +262,7 @@ public:
// creation functions - create and push if successful.
TrcStackElemParam *createParamElem(const p0_elem_t p0_type, const bool isP0, const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const std::vector<uint32_t> &params);
- TrcStackElemParam *createParamElemNoParam(const p0_elem_t p0_type, const bool isP0, const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index);
+ TrcStackElem *createParamElemNoParam(const p0_elem_t p0_type, const bool isP0, const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, bool back = false);
TrcStackElemAtom *createAtomElem (const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const ocsd_pkt_atom &atom);
TrcStackElemExcept *createExceptElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const bool bSame, const uint16_t excepNum);
TrcStackElemCtxt *createContextElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const etmv4_context_t &context);
@@ -284,6 +286,12 @@ inline void EtmV4P0Stack::push_front(TrcStackElem *pElem)
m_P0_stack.push_front(pElem);
}
+// put an element on the back of the stack
+inline void EtmV4P0Stack::push_back(TrcStackElem *pElem)
+{
+ m_P0_stack.push_back(pElem);
+}
+
// pop last element pointer off the stack and stash it for later deletion
inline void EtmV4P0Stack::pop_back()
{
diff --git a/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h b/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
index f27bb45d9fa8..1c06e5ddf03a 100644
--- a/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
+++ b/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
@@ -93,6 +93,8 @@ private:
ocsd_datapath_resp_t returnStackPop(); // pop return stack and update instruction address.
+ ocsd_datapath_resp_t outputTraceRange(const bool executed, ocsd_trc_index_t index);
+
//** intra packet state (see ETMv4 spec 6.2.1);
// timestamping
@@ -152,12 +154,17 @@ private:
EXCEP_POP, // start of processing read exception packets off the stack and analyze
EXCEP_RANGE, // output a range element
EXCEP_NACC, // output a nacc element
+ EXCEP_CTXT, // output a ctxt element
EXCEP_EXCEP, // output an ecxeption element.
} excep_proc_state_t;
- excep_proc_state_t m_excep_proc; //!< state of exception processing
- etmv4_addr_val_t m_excep_addr; //!< excepiton return address.
- ocsd_trc_index_t m_excep_index; //!< trace index for exception element
+ struct {
+ excep_proc_state_t proc; //!< state of exception processing
+ etmv4_addr_val_t addr; //!< excetion return address.
+ uint32_t number; //!< exception number.
+ ocsd_trc_index_t index; //!< trace index for exception element
+ bool addr_b_tgt; //!< return address is also branch tgt address.
+ } m_excep_info; //!< exception info when processing exception packets
ocsd_instr_info m_instr_info; //!< instruction info for code follower - in address is the next to be decoded.
diff --git a/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h b/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h
index e0343c76260c..02adfc51aa75 100644
--- a/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h
+++ b/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h
@@ -115,7 +115,7 @@ public:
void initNextPacket(); //!< clear any single packet only flags / state.
void setType(const ocsd_etmv4_i_pkt_type pkt_type) { type = pkt_type; };
- void updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type);
+ void updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type, const uint8_t val = 0);
void clearTraceInfo(); //!< clear all the trace info data prior to setting for new trace info packet.
void setTraceInfo(const uint32_t infoVal);
@@ -208,11 +208,12 @@ private:
Etmv4PktAddrStack m_addr_stack;
};
-inline void EtmV4ITrcPacket::updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type)
+inline void EtmV4ITrcPacket::updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type, const uint8_t err_val /* = 0 */)
{
// set primary type to incoming error type, set packet err type to previous primary type.
err_type = type;
type = err_pkt_type;
+ err_hdr_val = err_val;
}
inline void EtmV4ITrcPacket::clearTraceInfo()
@@ -223,7 +224,9 @@ inline void EtmV4ITrcPacket::clearTraceInfo()
pkt_valid.bits.spec_depth_valid = 0;
pkt_valid.bits.cc_thresh_valid = 0;
- pkt_valid.bits.ts_valid = 0; // mark TS as invalid - must be re-updated after trace info.
+ // set these as defaults - if they don't appear in TINFO this is the state.
+ setTraceInfo(0);
+ setTraceInfoSpec(0);
}
inline void EtmV4ITrcPacket::setTraceInfo(const uint32_t infoVal)
@@ -444,18 +447,20 @@ inline void EtmV4ITrcPacket::set32BitAddress(const uint32_t addr, const uint8_t
uint64_t mask = OCSD_BIT_MASK(32);
v_addr.pkt_bits = 32;
- if (pkt_valid.bits.context_valid && context.SF)
- v_addr.size = VA_64BIT;
+ if (pkt_valid.bits.context_valid && context.SF)
+ {
+ v_addr.size = VA_64BIT;
+ if (v_addr.valid_bits < 32) // may be updating a 64 bit address so only set 32 if currently less.
+ v_addr.valid_bits = 32;
+ v_addr.val = (v_addr.val & ~mask) | (addr & mask);
+ }
else
{
- v_addr.val &= 0xFFFFFFFF; // ensure vaddr is only 32 bits if not 64 bit
+ v_addr.val = addr;
v_addr.size = VA_32BIT;
- }
-
- if (v_addr.valid_bits < 32) // may be 64 bit address so only set 32 if less
- v_addr.valid_bits = 32;
-
- v_addr.val = (v_addr.val & ~mask) | (addr & mask);
+ v_addr.valid_bits = 32;
+ }
+
v_addr_ISA = IS;
push_vaddr();
}
diff --git a/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h b/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h
index b22a2b939719..dd69a4bf6778 100644
--- a/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h
+++ b/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h
@@ -1,8 +1,8 @@
/*
* \file trc_pkt_types_etmv4.h
- * \brief OpenCSD :
+ * \brief OpenCSD : ETMv4 packet info
*
- * \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved.
+ * \copyright Copyright (c) 2015,2019 ARM Limited. All Rights Reserved.
*/
@@ -56,80 +56,95 @@ typedef enum _ocsd_etmv4_i_pkt_type
ETM4_PKT_I_BAD_SEQUENCE = 0x300, /*!< invalid sequence for packet type. */
ETM4_PKT_I_BAD_TRACEMODE, /*!< invalid packet type for this trace mode. */
ETM4_PKT_I_RESERVED, /*!< packet type reserved. */
+ ETM4_PKT_I_RESERVED_CFG, /*!< packet type reserved for current configuration */
/* I stream packet types. */
/* extension header. */
- ETM4_PKT_I_EXTENSION = 0x00, /*!< b00000000 */
+ ETM4_PKT_I_EXTENSION = 0x00, /*!< b00000000 */
+
+ /* sync */
+ ETM4_PKT_I_TRACE_INFO = 0x01, /*!< b00000001 */
+ // timestamp
+ ETM4_PKT_I_TIMESTAMP = 0x02, /*!< b0000001x */
+ ETM4_PKT_I_TRACE_ON = 0x04, /*!< b00000100 */
+ ETM4_PKT_I_FUNC_RET = 0x05, /*!< b00000101 (V8M only) */
+ // Exceptions
+ ETM4_PKT_I_EXCEPT = 0x06, /*!< b00000110 */
+ ETM4_PKT_I_EXCEPT_RTN = 0x07, /*!< b00000111 */
+
+ /* unused encodings 0x08-0xB b00001000 to b00001011 */
+
+ /* cycle count packets */
+ ETM4_PKT_I_CCNT_F2 = 0x0C, /*!< b0000110x */
+ ETM4_PKT_I_CCNT_F1 = 0x0E, /*!< b0000111x */
+ ETM4_PKT_I_CCNT_F3 = 0x10, /*!< b0001xxxx */
+
+ // data synchronisation markers
+ ETM4_PKT_I_NUM_DS_MKR = 0x20, /*!< b00100xxx */
+ ETM4_PKT_I_UNNUM_DS_MKR = 0x28, /*!< b00101000 to b00101100 0x2C */
+
+ // speculation
+ ETM4_PKT_I_COMMIT = 0x2D, /*!< b00101101 */
+ ETM4_PKT_I_CANCEL_F1 = 0x2E, /*!< b0010111x */
+ ETM4_PKT_I_MISPREDICT = 0x30, /*!< b001100xx */
+ ETM4_PKT_I_CANCEL_F2 = 0x34, /*!< b001101xx */
+ ETM4_PKT_I_CANCEL_F3 = 0x38, /*!< b00111xxx */
- /* address amd context */
- ETM4_PKT_I_ADDR_CTXT_L_32IS0 = 0x82, /*!< b10000010 */
+ /* conditional instruction tracing */
+ ETM4_PKT_I_COND_I_F2 = 0x40, /*!< b01000000 - b01000010 */
+ ETM4_PKT_I_COND_FLUSH = 0x43, /*!< b01000011 */
+ ETM4_PKT_I_COND_RES_F4 = 0x44, /*!< b0100010x, b01000110 */
+ /* unused encoding 0x47 b01000111 */
+ ETM4_PKT_I_COND_RES_F2 = 0x48, /*!< b0100100x, b01001010, b0100110x, b01001110 */
+ /* unused encodings 0x4B,0x4F b01001011, b01001111 */
+ ETM4_PKT_I_COND_RES_F3 = 0x50, /*!< b0101xxxx */
+ /* unused encodings 0x60-0x67 b01100xxx */
+ ETM4_PKT_I_COND_RES_F1 = 0x68, /*!< b011010xx, b0110111x 0x68-0x6B, 0x6e-0x6F */
+ ETM4_PKT_I_COND_I_F1 = 0x6C, /*!< b01101100 */
+ ETM4_PKT_I_COND_I_F3 = 0x6D, /*!< b01101101 */
+
+ // event trace
+ ETM4_PKT_I_IGNORE = 0x70, /*!< b01110000 */
+ ETM4_PKT_I_EVENT = 0x71, /*!< b01110001 to 0x01111111 0x7F */
+
+ /* address and context */
+ ETM4_PKT_I_CTXT = 0x80, /*!< b1000000x */
+ ETM4_PKT_I_ADDR_CTXT_L_32IS0 = 0x82, /*!< b10000010 */
ETM4_PKT_I_ADDR_CTXT_L_32IS1, /*!< b10000011 */
- /* unused encoding b10000100 */
- ETM4_PKT_I_ADDR_CTXT_L_64IS0 = 0x85, /*!< b10000101 */
+ /* unused encoding 0x84 b10000100 */
+ ETM4_PKT_I_ADDR_CTXT_L_64IS0 = 0x85, /*!< b10000101 */
ETM4_PKT_I_ADDR_CTXT_L_64IS1, /*!< b10000110 */
- /* unused encoding b10000111 */
- ETM4_PKT_I_CTXT = 0x80, /*!< b1000000x */
- ETM4_PKT_I_ADDR_MATCH = 0x90, /*!< b10010000 to b10010010 */
- ETM4_PKT_I_ADDR_L_32IS0 = 0x9A, /*!< b10011010 */
+ /* unused encoding 0x87 b10000111 */
+ /* unused encodings 0x88-0x8F b10001xxx */
+ ETM4_PKT_I_ADDR_MATCH = 0x90, /*!< b10010000 to b10010010 0x92 */
+ /* unused encodings 0x93-0x94 b10010011 to b10010010 */
+ ETM4_PKT_I_ADDR_S_IS0 = 0x95, /*!< b10010101 */
+ ETM4_PKT_I_ADDR_S_IS1, /*!< b10010110 */
+ /* unused encodings 0x97 b10010111 to b10011001 0x99 */
+ ETM4_PKT_I_ADDR_L_32IS0 = 0x9A, /*!< b10011010 */
ETM4_PKT_I_ADDR_L_32IS1, /*!< b10011011 */
- /* unused encoding b10011100 */
- ETM4_PKT_I_ADDR_L_64IS0 = 0x9D, /*!< b10011101 */
+ /* unused encoding 0x9C b10011100 */
+ ETM4_PKT_I_ADDR_L_64IS0 = 0x9D, /*!< b10011101 */
ETM4_PKT_I_ADDR_L_64IS1, /*!< b10011110 */
- /* unused encoding b10011111 */
- ETM4_PKT_I_ADDR_S_IS0 = 0x95, /*!< b10010101 */
- ETM4_PKT_I_ADDR_S_IS1, /*!< b10010110 */
- /* unused encoding b10010111
- unused encoding b10011000
- unused encoding b10011001 */
+ /* unused encoding 0x9F b10011111 */
/* Q packets */
ETM4_PKT_I_Q = 0xA0, /*!< b1010xxxx */
- /* Atom packets */
- ETM4_PKT_I_ATOM_F1 = 0xF6, /*!< b1111011x */
- ETM4_PKT_I_ATOM_F2 = 0xD8, /*!< b110110xx */
- ETM4_PKT_I_ATOM_F3 = 0xF8, //!< b11111xxx
- ETM4_PKT_I_ATOM_F4 = 0xDC, //!< b110111xx
- ETM4_PKT_I_ATOM_F5 = 0xD5, //!< b11010101 - b11010111, b11110101
- ETM4_PKT_I_ATOM_F6 = 0xC0, //!< b11000000 - b11010100, b11100000 - b11110100
+ /* unused encodings 0xB0-0xBF b1011xxxx */
- /* conditional instruction tracing */
- ETM4_PKT_I_COND_FLUSH = 0x43, //!< b01000011
- ETM4_PKT_I_COND_I_F1 = 0x6C, //!< b01101100
- ETM4_PKT_I_COND_I_F2 = 0x40, //!< b01000000 - b01000010
- ETM4_PKT_I_COND_I_F3 = 0x6D, //!< b01101101
- ETM4_PKT_I_COND_RES_F1 = 0x68, //!< b0110111x, b011010xx
- ETM4_PKT_I_COND_RES_F2 = 0x48, //!< b0100100x, b01001010, b0100110x, b01001110
- ETM4_PKT_I_COND_RES_F3 = 0x50, //!< b0101xxxx
- ETM4_PKT_I_COND_RES_F4 = 0x44, //!< b0100010x, b01000110
+ /* Atom packets */
+ ETM4_PKT_I_ATOM_F6 = 0xC0, /*!< b11000000 - b11010100 0xC0 - 0xD4, b11100000 - b11110100 0xE0 - 0xF4 */
+ ETM4_PKT_I_ATOM_F5 = 0xD5, /*!< b11010101 - b11010111 0xD5 - 0xD7, b11110101 0xF5 */
+ ETM4_PKT_I_ATOM_F2 = 0xD8, /*!< b110110xx to 0xDB */
+ ETM4_PKT_I_ATOM_F4 = 0xDC, /*!< b110111xx to 0xDF */
+ ETM4_PKT_I_ATOM_F1 = 0xF6, /*!< b1111011x to 0xF7 */
+ ETM4_PKT_I_ATOM_F3 = 0xF8, /*!< b11111xxx to 0xFF */
- /* cycle count packets */
- ETM4_PKT_I_CCNT_F1 = 0x0E, //!< b0000111x
- ETM4_PKT_I_CCNT_F2 = 0x0C, //!< b0000110x
- ETM4_PKT_I_CCNT_F3 = 0x10, //!< b0001xxxx
- // data synchronisation markers
- ETM4_PKT_I_NUM_DS_MKR = 0x20, //!< b00100xxx
- ETM4_PKT_I_UNNUM_DS_MKR = 0x28, //!< b00101000 - b00101100
- // event trace
- ETM4_PKT_I_EVENT = 0x70, //!< b0111xxxx
- // Exceptions
- ETM4_PKT_I_EXCEPT = 0x06, //!< b00000110
- ETM4_PKT_I_EXCEPT_RTN = 0x07, //!< b00000111
- // timestamp
- ETM4_PKT_I_TIMESTAMP = 0x02, //!< b0000001x
- // speculation
- ETM4_PKT_I_CANCEL_F1 = 0x2E, //!< b0010111x
- ETM4_PKT_I_CANCEL_F2 = 0x34, //!< b001101xx
- ETM4_PKT_I_CANCEL_F3 = 0x38, //!< b00111xxx
- ETM4_PKT_I_COMMIT = 0x2D, //!< b00101101
- ETM4_PKT_I_MISPREDICT = 0x30, //!< b001100xx
- // Sync
- ETM4_PKT_I_TRACE_INFO = 0x01, //!< b00000001
- ETM4_PKT_I_TRACE_ON = 0x04, //!< b00000100
// extension packets - follow 0x00 header
ETM4_PKT_I_ASYNC = 0x100, //!< b00000000
ETM4_PKT_I_DISCARD = 0x103, //!< b00000011
- ETM4_PKT_I_OVERFLOW = 0x105 //!< b00000101
+ ETM4_PKT_I_OVERFLOW = 0x105, //!< b00000101
} ocsd_etmv4_i_pkt_type;
@@ -139,7 +154,7 @@ typedef union _etmv4_trace_info_t {
uint32_t cc_enabled:1; //!< 1 if cycle count enabled
uint32_t cond_enabled:3; //!< conditional trace enabeld type
uint32_t p0_load:1; //!< 1 if tracing with P0 load elements (for data trace)
- uint32_t p0_store:1; //1< 1 if tracing with P0 store elements (for data trace)
+ uint32_t p0_store:1; //!< 1 if tracing with P0 store elements (for data trace)
} bits; //!< bitfields for trace info value.
} etmv4_trace_info_t;
@@ -259,6 +274,7 @@ typedef struct _ocsd_etmv4_i_pkt
// original header type when packet type changed to error on decode error.
ocsd_etmv4_i_pkt_type err_type;
+ uint8_t err_hdr_val;
} ocsd_etmv4_i_pkt;
@@ -342,6 +358,7 @@ typedef struct _ocsd_etmv4_cfg
ocsd_core_profile_t core_prof; /**< Core Profile */
} ocsd_etmv4_cfg;
+
/** @}*/
/** @}*/
#endif // ARM_TRC_PKT_TYPES_ETMV4_H_INCLUDED
diff --git a/decoder/include/opencsd/ocsd_if_types.h b/decoder/include/opencsd/ocsd_if_types.h
index def16575f2b2..7d74d77c240b 100644
--- a/decoder/include/opencsd/ocsd_if_types.h
+++ b/decoder/include/opencsd/ocsd_if_types.h
@@ -107,6 +107,7 @@ typedef enum _ocsd_err_t {
OCSD_ERR_DATA_DECODE_FATAL, /**< A decoder in the data path has returned a fatal error. */
/* frame deformatter errors */
OCSD_ERR_DFMTR_NOTCONTTRACE, /**< Trace input to deformatter none-continuous */
+ OCSD_ERR_DFMTR_BAD_FHSYNC, /**< Bad frame or half frame sync in trace deformatter */
/* packet processor errors - protocol issues etc */
OCSD_ERR_BAD_PACKET_SEQ, /**< Bad packet sequence */
OCSD_ERR_INVALID_PCKT_HDR, /**< Invalid packet header */
@@ -126,6 +127,7 @@ typedef enum _ocsd_err_t {
OCSD_ERR_MEM_ACC_FILE_NOT_FOUND, /**< Memory access file could not be opened */
OCSD_ERR_MEM_ACC_FILE_DIFF_RANGE, /**< Attempt to re-use the same memory access file for a different address range */
OCSD_ERR_MEM_ACC_RANGE_INVALID, /**< Address range in accessor set to invalid values */
+ OCSD_ERR_MEM_ACC_BAD_LEN, /**< Memory accessor returned a bad read length value (larger than requested */
/* test errors - errors generated only by the test code, not the library */
OCSD_ERR_TEST_SNAPSHOT_PARSE, /**< test snapshot file parse error */
OCSD_ERR_TEST_SNAPSHOT_PARSE_INFO, /**< test snapshot file parse information */
@@ -137,7 +139,7 @@ typedef enum _ocsd_err_t {
OCSD_ERR_DCDREG_TYPE_UNKNOWN, /**< attempted to find a decoder with a type that is not known in the library */
OCSD_ERR_DCDREG_TOOMANY, /**< attempted to register too many custom decoders */
/* decoder config */
- OCSD_ERR_DCD_INTERFACE_UNUSED, /**< Attempt to connect or use and inteface not supported by this decoder. */
+ OCSD_ERR_DCD_INTERFACE_UNUSED, /**< Attempt to connect or use and interface not supported by this decoder. */
/* end marker*/
OCSD_ERR_LAST
} ocsd_err_t;
@@ -272,11 +274,16 @@ typedef enum _ocsd_dcd_tree_src_t {
/** Core Architecture Version */
typedef enum _ocsd_arch_version {
ARCH_UNKNOWN, /**< unknown architecture */
+ ARCH_CUSTOM, /**< None ARM, custom architecture */
ARCH_V7, /**< V7 architecture */
ARCH_V8, /**< V8 architecture */
- ARCH_CUSTOM, /**< None ARM, custom architecture */
+ ARCH_V8r3, /**< V8.3 architecture */
} ocsd_arch_version_t;
+// macros for arch version comparisons.
+#define OCSD_IS_V8_ARCH(arch) ((arch >= ARCH_V8) && (arch <= ARCH_V8r3))
+#define OCSD_MIN_V8_ARCH(arch) (arch >= ARCH_V8)
+
/** Core Profile */
typedef enum _ocsd_core_profile {
profile_Unknown, /**< Unknown profile */
@@ -351,7 +358,8 @@ typedef enum _ocsd_instr_type {
OCSD_INSTR_BR, /**< Immediate Branch instruction */
OCSD_INSTR_BR_INDIRECT, /**< Indirect Branch instruction */
OCSD_INSTR_ISB, /**< Barrier : ISB instruction */
- OCSD_INSTR_DSB_DMB /**< Barrier : DSB or DMB instruction */
+ OCSD_INSTR_DSB_DMB, /**< Barrier : DSB or DMB instruction */
+ OCSD_INSTR_WFI_WFE, /**< WFI or WFE traced as direct branch */
} ocsd_instr_type;
/** instruction sub types - addiitonal information passed to the output packets
@@ -362,6 +370,7 @@ typedef enum _ocsd_instr_subtype {
OCSD_S_INSTR_BR_LINK, /**< branch with link */
OCSD_S_INSTR_V8_RET, /**< v8 ret instruction - subtype of BR_INDIRECT */
OCSD_S_INSTR_V8_ERET, /**< v8 eret instruction - subtype of BR_INDIRECT */
+ OCSD_S_INSTR_V7_IMPLIED_RET, /**< v7 instruction which could imply return e.g. MOV PC, LR; POP { ,pc} */
} ocsd_instr_subtype;
/** Instruction decode request structure.
@@ -377,6 +386,7 @@ typedef struct _ocsd_instr_info {
ocsd_vaddr_t instr_addr; /**< Input: Instruction address. */
uint32_t opcode; /**< Input: Opcode at address. 16 bit opcodes will use MS 16bits of parameter. */
uint8_t dsb_dmb_waypoints; /**< Input: DMB and DSB are waypoints */
+ uint8_t wfi_wfe_branch; /**< Input: WFI, WFE classed as direct branches */
/* instruction decode info */
ocsd_instr_type type; /**< Decoder: Current instruction type. */
@@ -446,7 +456,31 @@ typedef enum _ocsd_mem_space_acc_t {
*
* @return uint32_t : Number of bytes actually read, or 0 for access error.
*/
-typedef uint32_t (* Fn_MemAcc_CB)(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint32_t reqBytes, uint8_t *byteBuffer);
+typedef uint32_t (* Fn_MemAcc_CB)(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint32_t reqBytes, uint8_t *byteBuffer);
+
+/**
+* Callback function definition for callback function memory accessor type.
+*
+* When using callback memory accessor, the decoder will call this function to obtain the
+* memory at the address for the current opcodes. The memory space will represent the current
+* exception level and security context of the traced code.
+*
+* Return the number of bytes read, which can be less than the amount requested if this would take the
+* access address outside the range of addresses defined when this callback was registered with the decoder.
+*
+* Return 0 bytes if start address out of covered range, or memory space is not one of those defined as supported
+* when the callback was registered.
+*
+* @param p_context : opaque context pointer set by callback client.
+* @param address : start address of memory to be accessed
+* @param mem_space : memory space of accessed memory (current EL & security state)
+* @param trcID : Trace ID for source of trace - allow CB to client to associate mem req with source cpu.
+* @param reqBytes : number of bytes required
+* @param *byteBuffer : buffer for data.
+*
+* @return uint32_t : Number of bytes actually read, or 0 for access error.
+*/
+typedef uint32_t (* Fn_MemAccID_CB)(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer);
/** memory region type for adding multi-region binary files to memory access interface */
diff --git a/decoder/include/ocsd_if_version.h b/decoder/include/opencsd/ocsd_if_version.h
index 7d51ba27bdf2..70c8df41f52b 100644
--- a/decoder/include/ocsd_if_version.h
+++ b/decoder/include/opencsd/ocsd_if_version.h
@@ -43,17 +43,17 @@
/** @name Library Versioning
@{*/
#define OCSD_VER_MAJOR 0x0 /**< Library Major Version */
-#define OCSD_VER_MINOR 0x8 /**< Library Minor Version */
-#define OCSD_VER_PATCH 0x2 /**< Library Patch Version */
+#define OCSD_VER_MINOR 0xC /**< Library Minor Version */
+#define OCSD_VER_PATCH 0x0 /**< Library Patch Version */
/** Library version number - MMMMnnpp format.
MMMM = major version,
nn = minor version,
pp = patch version
*/
-#define OCSD_VER_NUM (((uint32_t)OCSD_VER_MAJOR << 16) | ((uint32_t)OCSD_VER_MINOR << 8) | ((uint32_t)OCSD_VER_PATCH))
+#define OCSD_VER_NUM ((OCSD_VER_MAJOR << 16) | (OCSD_VER_MINOR << 8) | OCSD_VER_PATCH)
-#define OCSD_VER_STRING "0.8.2" /**< Library Version string */
+#define OCSD_VER_STRING "0.12.0" /**< Library Version string */
#define OCSD_LIB_NAME "OpenCSD Library" /**< Library name string */
#define OCSD_LIB_SHORT_NAME "OCSD" /**< Library Short name string */
/** @}*/
diff --git a/decoder/include/opencsd/trc_gen_elem_types.h b/decoder/include/opencsd/trc_gen_elem_types.h
index 3766785dbd6d..1d77b53cf8f9 100644
--- a/decoder/include/opencsd/trc_gen_elem_types.h
+++ b/decoder/include/opencsd/trc_gen_elem_types.h
@@ -58,7 +58,7 @@ typedef enum _ocsd_gen_trc_elem_t
OCSD_GEN_TRC_ELEM_EXCEPTION_RET, /*!< expection return */
OCSD_GEN_TRC_ELEM_TIMESTAMP, /*!< Timestamp - preceding elements happeded before this time. */
OCSD_GEN_TRC_ELEM_CYCLE_COUNT, /*!< Cycle count - cycles since last cycle count value - associated with a preceding instruction range. */
- OCSD_GEN_TRC_ELEM_EVENT, /*!< Event - trigger, (TBC - perhaps have a set of event types - cut down additional processing?) */
+ OCSD_GEN_TRC_ELEM_EVENT, /*!< Event - trigger or numbered event */
OCSD_GEN_TRC_ELEM_SWTRACE, /*!< Software trace packet - may contain data payload. */
OCSD_GEN_TRC_ELEM_CUSTOM, /*!< Fully custom packet type - used by none-ARM architecture decoders */
} ocsd_gen_trc_elem_t;
@@ -90,12 +90,15 @@ typedef struct _ocsd_generic_trace_elem {
union {
struct {
uint32_t last_instr_exec:1; /**< 1 if last instruction in range was executed; */
+ uint32_t last_instr_sz:3; /**< size of last instruction in bytes (2/4) */
uint32_t has_cc:1; /**< 1 if this packet has a valid cycle count included (e.g. cycle count included as part of instruction range packet, always 1 for pure cycle count packet.*/
uint32_t cpu_freq_change:1; /**< 1 if this packet indicates a change in CPU frequency */
uint32_t excep_ret_addr:1; /**< 1 if en_addr is the preferred exception return address on exception packet type */
uint32_t excep_data_marker:1; /**< 1 if the exception entry packet is a data push marker only, with no address information (used typically in v7M trace for marking data pushed onto stack) */
uint32_t extended_data:1; /**< 1 if the packet extended data pointer is valid. Allows packet extensions for custom decoders, or additional data payloads for data trace. */
uint32_t has_ts:1; /**< 1 if the packet has an associated timestamp - e.g. SW/STM trace TS+Payload as a single packet */
+ uint32_t last_instr_cond:1; /**< 1 if the last instruction was conditional */
+ uint32_t excep_ret_addr_br_tgt:1; /**< 1 if exception return address (en_addr) is also the target of a taken branch addr from the previous range. */
};
uint32_t flag_bits;
};
@@ -105,7 +108,8 @@ typedef struct _ocsd_generic_trace_elem {
uint32_t exception_number; /**< exception number for exception type packets */
trace_event_t trace_event; /**< Trace event - trigger etc */
trace_on_reason_t trace_on_reason; /**< reason for the trace on packet */
- ocsd_swt_info_t sw_trace_info; /**< software trace packet info */
+ ocsd_swt_info_t sw_trace_info; /**< software trace packet info */
+ uint32_t num_instr_range; /**< number of instructions covered by range packet (for T32 this cannot be calculated from en-st/i_size) */
};
const void *ptr_extended_data; /**< pointer to extended data buffer (data trace, sw trace payload) / custom structure */
diff --git a/decoder/include/pkt_printers/pkt_printer_t.h b/decoder/include/pkt_printers/pkt_printer_t.h
index fc3ad2a78e57..9eb37f4e2833 100644
--- a/decoder/include/pkt_printers/pkt_printer_t.h
+++ b/decoder/include/pkt_printers/pkt_printer_t.h
@@ -39,7 +39,7 @@
#include <string>
#include <sstream>
-#include <iostream>
+//#include <iostream>
#include <iomanip>
template<class P>
diff --git a/decoder/source/c_api/ocsd_c_api.cpp b/decoder/source/c_api/ocsd_c_api.cpp
index 1a2a74f899bc..4824c427e3d1 100644
--- a/decoder/source/c_api/ocsd_c_api.cpp
+++ b/decoder/source/c_api/ocsd_c_api.cpp
@@ -74,7 +74,7 @@ static std::map<dcd_tree_handle_t, lib_dt_data_list *> s_data_map;
/* C API functions */
/*******************************************************************************/
-/** Get Library version. Return a 32 bit version in form MMMMnnpp - MMMM = major verison, nn = minor version, pp = patch version */
+/** Get Library version. Return a 32 bit version in form MMMMnnpp - MMMM = major version, nn = minor version, pp = patch version */
OCSD_C_API uint32_t ocsd_get_version(void)
{
return ocsdVersion::vers_num();
@@ -404,6 +404,17 @@ OCSD_C_API ocsd_err_t ocsd_dt_add_callback_mem_acc(const dcd_tree_handle_t handl
return err;
}
+OCSD_C_API ocsd_err_t ocsd_dt_add_callback_trcid_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAccID_CB p_cb_func, const void *p_context)
+{
+ ocsd_err_t err = OCSD_OK;
+ DecodeTree *pDT;
+ err = ocsd_check_and_add_mem_acc_mapper(handle, &pDT);
+ if (err == OCSD_OK)
+ err = pDT->addCallbackIDMemAcc(st_address, en_address, mem_space, p_cb_func, p_context);
+ return err;
+}
+
+
OCSD_C_API ocsd_err_t ocsd_dt_remove_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_mem_space_acc_t mem_space)
{
ocsd_err_t err = OCSD_OK;
diff --git a/decoder/source/etmv3/trc_pkt_decode_etmv3.cpp b/decoder/source/etmv3/trc_pkt_decode_etmv3.cpp
index bd7cb60b5b63..0a15a33c42fb 100644
--- a/decoder/source/etmv3/trc_pkt_decode_etmv3.cpp
+++ b/decoder/source/etmv3/trc_pkt_decode_etmv3.cpp
@@ -598,7 +598,8 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV3::processPHdr()
pElem->setAddrRange(m_IAddr,m_code_follower.getRangeEn());
pElem->setLastInstrInfo(atoms.getCurrAtomVal() == ATOM_E,
m_code_follower.getInstrType(),
- m_code_follower.getInstrSubType());
+ m_code_follower.getInstrSubType(),m_code_follower.getInstrSize());
+ pElem->setLastInstrCond(m_code_follower.isCondInstr());
pElem->setISA(isa);
if(m_code_follower.hasNextAddr())
m_IAddr = m_code_follower.getNextAddr();
diff --git a/decoder/source/etmv4/trc_cmp_cfg_etmv4.cpp b/decoder/source/etmv4/trc_cmp_cfg_etmv4.cpp
index 7db0fa61f963..9f5b37396b46 100644
--- a/decoder/source/etmv4/trc_cmp_cfg_etmv4.cpp
+++ b/decoder/source/etmv4/trc_cmp_cfg_etmv4.cpp
@@ -75,6 +75,8 @@ void EtmV4Config::PrivateInit()
m_VMIDSize = 0;
m_condTraceCalc = false;
m_CondTrace = COND_TR_DIS;
+ m_MajVer = (uint8_t)((m_cfg.reg_idr1 >> 8) & 0xF);
+ m_MinVer = (uint8_t)((m_cfg.reg_idr1 >> 4) & 0xF);
}
void EtmV4Config::CalcQSupp()
diff --git a/decoder/source/etmv4/trc_etmv4_stack_elem.cpp b/decoder/source/etmv4/trc_etmv4_stack_elem.cpp
index ace0ac932b76..8916c7dc350d 100644
--- a/decoder/source/etmv4/trc_etmv4_stack_elem.cpp
+++ b/decoder/source/etmv4/trc_etmv4_stack_elem.cpp
@@ -36,11 +36,17 @@
#include "opencsd/etmv4/trc_etmv4_stack_elem.h"
/* implementation of P0 element stack in ETM v4 trace*/
-TrcStackElemParam *EtmV4P0Stack::createParamElemNoParam(const p0_elem_t p0_type, const bool isP0, const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index)
+TrcStackElem *EtmV4P0Stack::createParamElemNoParam(const p0_elem_t p0_type, const bool isP0, const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, bool back /*= false*/)
{
- std::vector<uint32_t> params;
- params.clear();
- return createParamElem(p0_type, isP0, root_pkt, root_index, params);
+ TrcStackElem *pElem = new (std::nothrow) TrcStackElem(p0_type, isP0, root_pkt, root_index);
+ if (pElem)
+ {
+ if (back)
+ push_back(pElem);
+ else
+ push_front(pElem);
+ }
+ return pElem;
}
TrcStackElemParam *EtmV4P0Stack::createParamElem(const p0_elem_t p0_type, const bool isP0, const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const std::vector<uint32_t> &params)
diff --git a/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp b/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp
index 865aacbdb2a5..2eb6cbc3f5bf 100644
--- a/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp
+++ b/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp
@@ -128,7 +128,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::onFlush()
ocsd_datapath_resp_t resp = OCSD_RESP_CONT;
// continue exception processing (can't go through processPacket as elements no longer on stack)
- if(m_excep_proc != EXCEP_POP)
+ if(m_excep_info.proc != EXCEP_POP)
resp = processException();
// continue ongoing output operations on comitted elements.
else if(m_curr_state == COMMIT_ELEM)
@@ -151,6 +151,7 @@ ocsd_err_t TrcPktDecodeEtmV4I::onProtocolConfig()
// set up static trace instruction decode elements
m_instr_info.dsb_dmb_waypoints = 0;
+ m_instr_info.wfi_wfe_branch = m_config->wfiwfeBranch() ? 1 : 0;
m_instr_info.pe_type.arch = m_config->archVersion();
m_instr_info.pe_type.profile = m_config->coreProfile();
@@ -233,7 +234,7 @@ void TrcPktDecodeEtmV4I::resetDecoder()
m_prev_overflow = false;
m_P0_stack.delete_all();
m_output_elem.init();
- m_excep_proc = EXCEP_POP;
+ m_excep_info.proc = EXCEP_POP;
m_flush_EOT = false;
}
@@ -250,6 +251,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::decodePacket(bool &Complete)
switch(m_curr_packet_in->getType())
{
case ETM4_PKT_I_ASYNC: // nothing to do with this packet.
+ case ETM4_PKT_I_IGNORE: // or this one.
break;
case ETM4_PKT_I_TRACE_INFO:
@@ -350,6 +352,21 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::decodePacket(bool &Complete)
bool bV7MProfile = (m_config->archVersion() == ARCH_V7) && (m_config->coreProfile() == profile_CortexM);
if (m_P0_stack.createParamElemNoParam(P0_EXCEP_RET, bV7MProfile, m_curr_packet_in->getType(), m_index_curr_pkt) == 0)
bAllocErr = true;
+ else if (bV7MProfile)
+ m_curr_spec_depth++;
+ }
+ break;
+
+ case ETM4_PKT_I_FUNC_RET:
+ {
+ // P0 element iff V8M profile, otherwise ignore
+ if (OCSD_IS_V8_ARCH(m_config->archVersion()) && (m_config->coreProfile() == profile_CortexM))
+ {
+ if (m_P0_stack.createParamElemNoParam(P0_FUNC_RET, true, m_curr_packet_in->getType(), m_index_curr_pkt) == 0)
+ bAllocErr = true;
+ else
+ m_curr_spec_depth++;
+ }
}
break;
@@ -371,7 +388,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::decodePacket(bool &Complete)
{
std::vector<uint32_t> params = { 0 };
params[0] = m_curr_packet_in->getCC();
- if (m_P0_stack.createParamElem(P0_EVENT, false, m_curr_packet_in->getType(), m_index_curr_pkt, params) == 0)
+ if (m_P0_stack.createParamElem(P0_CC, false, m_curr_packet_in->getType(), m_index_curr_pkt, params) == 0)
bAllocErr = true;
}
@@ -387,7 +404,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::decodePacket(bool &Complete)
params[1] = (uint32_t)((ts >> 32) & 0xFFFFFFFF);
if (bTSwithCC)
params[2] = m_curr_packet_in->getCC();
- if (m_P0_stack.createParamElem(P0_EVENT, false, m_curr_packet_in->getType(), m_index_curr_pkt, params) == 0)
+ if (m_P0_stack.createParamElem(bTSwithCC ? P0_TS_CC : P0_TS, false, m_curr_packet_in->getType(), m_index_curr_pkt, params) == 0)
bAllocErr = true;
}
@@ -490,6 +507,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::commitElements(bool &Complete)
bool bPause = false; // pause commit operation
bool bPopElem = true; // do we remove the element from the stack (multi atom elements may need to stay!)
int num_commit_req = m_P0_commit;
+ ocsd_trc_index_t err_idx = 0;
Complete = true; // assume we exit due to completion of commit operation
@@ -500,8 +518,9 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::commitElements(bool &Complete)
if(m_P0_stack.size() > 0)
{
pElem = m_P0_stack.back(); // get oldest element
-
- switch(pElem->getP0Type())
+ err_idx = pElem->getRootIndex(); // save index in case of error.
+
+ switch (pElem->getP0Type())
{
// indicates a trace restart - beginning of trace or discontinuiuty
case P0_TRC_ON:
@@ -612,7 +631,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::commitElements(bool &Complete)
if ((resp = returnStackPop()) != OCSD_RESP_CONT)
break;
- m_excep_proc = EXCEP_POP; // set state in case we need to stop part way through
+ m_excep_info.proc = EXCEP_POP; // set state in case we need to stop part way through
resp = processException(); // output trace + exception elements.
m_P0_commit--;
break;
@@ -623,6 +642,13 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::commitElements(bool &Complete)
if(pElem->isP0()) // are we on a core that counts ERET as P0?
m_P0_commit--;
break;
+
+ case P0_FUNC_RET:
+ // func ret is V8M - data trace only - hint that data has been popped off the stack.
+ // at this point nothing to do till the decoder starts handling data trace.
+ if (pElem->isP0())
+ m_P0_commit--;
+ break;
}
if(bPopElem)
@@ -637,10 +663,6 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::commitElements(bool &Complete)
else
{
// too few elements for commit operation - decode error.
- ocsd_trc_index_t err_idx = 0;
- if(pElem)
- err_idx = pElem->getRootIndex();
-
resp = OCSD_RESP_FATAL_INVALID_DATA;
LogError(ocsdError(OCSD_ERR_SEV_ERROR,OCSD_ERR_COMMIT_PKT_OVERRUN,err_idx,m_CSID,"Not enough elements to commit"));
bPause = true;
@@ -757,7 +779,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::flushEOT()
ocsd_datapath_resp_t TrcPktDecodeEtmV4I::outputCC(TrcStackElemParam *pParamElem)
{
m_output_elem.setType(OCSD_GEN_TRC_ELEM_CYCLE_COUNT);
- m_output_elem.cycle_count = pParamElem->getParam(0);
+ m_output_elem.setCycleCount(pParamElem->getParam(0));
return outputTraceElementIdx(pParamElem->getRootIndex(),m_output_elem);
}
@@ -778,6 +800,17 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::outputEvent(TrcStackElemParam *pParamEl
return outputTraceElementIdx(pParamElem->getRootIndex(),m_output_elem);
}
+ocsd_datapath_resp_t TrcPktDecodeEtmV4I::outputTraceRange(const bool executed, ocsd_trc_index_t index)
+{
+ m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
+ m_output_elem.setLastInstrInfo(executed, m_instr_info.type, m_instr_info.sub_type, m_instr_info.instr_size);
+ m_output_elem.setISA(m_instr_info.isa);
+ m_output_elem.setLastInstrCond(m_instr_info.is_conditional);
+ if (executed)
+ m_instr_info.isa = m_instr_info.next_isa;
+ return outputTraceElementIdx(index, m_output_elem);
+}
+
ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processAtom(const ocsd_atm_val atom, bool &bCont)
{
ocsd_datapath_resp_t resp = OCSD_RESP_CONT;
@@ -834,10 +867,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processAtom(const ocsd_atm_val atom, bo
}
break;
}
- m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo((atom == ATOM_E),m_instr_info.type, m_instr_info.sub_type);
- m_output_elem.setISA(m_instr_info.isa);
- resp = outputTraceElementIdx(pElem->getRootIndex(),m_output_elem);
+ resp = outputTraceRange((atom == ATOM_E), pElem->getRootIndex());
}
else
@@ -848,10 +878,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processAtom(const ocsd_atm_val atom, bo
if(m_output_elem.st_addr != m_output_elem.en_addr)
{
// some trace before we were out of memory access range
- m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type);
- m_output_elem.setISA(m_instr_info.isa);
- resp = outputTraceElementIdx(pElem->getRootIndex(),m_output_elem);
+ resp = outputTraceRange(true, pElem->getRootIndex());
}
if(m_mem_nacc_pending && OCSD_DATA_RESP_IS_CONT(resp))
@@ -873,11 +900,13 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processAtom(const ocsd_atm_val atom, bo
ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processException()
{
ocsd_datapath_resp_t resp = OCSD_RESP_CONT;
- bool excep_implied_P0 = false; //!< exception implies P0
+ TrcStackElemExcept *pExceptElem;
- if(m_excep_proc == EXCEP_POP)
+ m_excep_info.addr_b_tgt = false;
+
+ if(m_excep_info.proc == EXCEP_POP)
{
- TrcStackElemExcept *pExceptElem = dynamic_cast<TrcStackElemExcept *>(m_P0_stack.back()); // get the exception element
+ pExceptElem = dynamic_cast<TrcStackElemExcept *>(m_P0_stack.back()); // get the exception element
TrcStackElemAddr *pAddressElem = 0;
TrcStackElemCtxt *pCtxtElem = 0;
TrcStackElem *pElem = 0;
@@ -902,32 +931,52 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processException()
// extract address
pAddressElem = static_cast<TrcStackElemAddr *>(pElem);
- m_excep_addr = pAddressElem->getAddr();
+ // fill in exception info for use later
+ m_excep_info.addr = pAddressElem->getAddr();
+ m_excep_info.number = pExceptElem->getExcepNum();
+ m_excep_info.index = pExceptElem->getRootIndex();
+ m_excep_info.addr_b_tgt = pExceptElem->getPrevSame();
- // if we have context, get that.
- if(pCtxtElem)
- updateContext(pCtxtElem);
-
- // record the exception number
- m_output_elem.exception_number = pExceptElem->getExcepNum();
-
- // see if there is an implied P0 element on the exception.
- excep_implied_P0 = pExceptElem->getPrevSame();
-
- // save the trace index.
- m_excep_index = pExceptElem->getRootIndex();
+ // see if there is an address + optional context element implied
+ // prior to the exception.
+ if (m_excep_info.addr_b_tgt)
+ {
+ // this was a branch target address - update current setting
+ bool b64bit = m_instr_info.isa == ocsd_isa_aarch64;
+ if (pCtxtElem) {
+ b64bit = pCtxtElem->getContext().SF;
+ }
+ m_instr_info.instr_addr = m_excep_info.addr.val;
+ m_instr_info.isa = (m_excep_info.addr.isa == 0) ?
+ (b64bit ? ocsd_isa_aarch64 : ocsd_isa_arm) : ocsd_isa_thumb2;
+ m_need_addr = false;
+ }
// figure out next move
- if(m_excep_addr.val == m_instr_info.instr_addr)
- m_excep_proc = EXCEP_EXCEP;
+ if (pCtxtElem) {
+ m_excep_info.proc = EXCEP_CTXT;
+ updateContext(pCtxtElem);
+ }
+ else if(m_excep_info.addr.val == m_instr_info.instr_addr)
+ m_excep_info.proc = EXCEP_EXCEP;
else
- m_excep_proc = EXCEP_RANGE;
+ m_excep_info.proc = EXCEP_RANGE;
}
m_P0_stack.delete_popped();
}
+ // output a context element
+ if (m_excep_info.proc == EXCEP_CTXT)
+ {
+ m_output_elem.setType(OCSD_GEN_TRC_ELEM_PE_CONTEXT);
+ resp = outputTraceElementIdx(m_excep_info.index, m_output_elem);
+ m_excep_info.proc = EXCEP_EXCEP;
+ if (!OCSD_DATA_RESP_IS_CONT(resp))
+ return resp;
+ }
+
// output a range element
- if(m_excep_proc == EXCEP_RANGE)
+ if(m_excep_info.proc == EXCEP_RANGE)
{
bool bWPFound = false;
ocsd_err_t err;
@@ -935,8 +984,8 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processException()
// last instr_info address is the start address
m_output_elem.st_addr = m_instr_info.instr_addr;
- // look for either a WP or match to return address.
- err = traceInstrToWP(bWPFound,!excep_implied_P0,m_excep_addr.val);
+ // look for match to return address.
+ err = traceInstrToWP(bWPFound,true,m_excep_info.addr.val);
if(err != OCSD_OK)
{
@@ -944,37 +993,21 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processException()
{
m_need_addr = true;
m_need_ctxt = true;
- LogError(ocsdError(OCSD_ERR_SEV_WARN,err,m_excep_index,m_CSID,"Warning: unsupported instruction set processing exception packet."));
+ LogError(ocsdError(OCSD_ERR_SEV_WARN,err,m_excep_info.index,m_CSID,"Warning: unsupported instruction set processing exception packet."));
}
else
{
resp = OCSD_RESP_FATAL_INVALID_DATA;
- LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,m_excep_index,m_CSID,"Error processing exception packet."));
- m_excep_proc = EXCEP_POP; // nothing more to do, reset to start of exception handling
+ LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,m_excep_info.index,m_CSID,"Error processing exception packet."));
+ m_excep_info.proc = EXCEP_POP; // nothing more to do, reset to start of exception handling
}
}
if(bWPFound)
{
- // action according to waypoint type and atom value
- if(excep_implied_P0)
- {
- switch(m_instr_info.type)
- {
- case OCSD_INSTR_BR:
- m_instr_info.instr_addr = m_instr_info.branch_addr;
- break;
-
- case OCSD_INSTR_BR_INDIRECT:
- m_instr_info.instr_addr = m_excep_addr.val;
- break;
- }
- }
- m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type);
- m_output_elem.setISA(m_instr_info.isa);
- resp = outputTraceElementIdx(m_excep_index, m_output_elem);
- m_excep_proc = EXCEP_EXCEP;
+ // waypoint address found - output range
+ resp = outputTraceRange(true, m_excep_info.index);
+ m_excep_info.proc = EXCEP_EXCEP;
}
else
{
@@ -984,34 +1017,33 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processException()
if(m_output_elem.st_addr != m_output_elem.en_addr)
{
// some trace before we were out of memory access range
- m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type);
- m_output_elem.setISA(m_instr_info.isa);
- resp = outputTraceElementIdx(m_excep_index,m_output_elem);
+ resp = outputTraceRange(true, m_excep_info.index);
}
- m_excep_proc = m_mem_nacc_pending ? EXCEP_NACC : EXCEP_EXCEP;
+ m_excep_info.proc = m_mem_nacc_pending ? EXCEP_NACC : EXCEP_EXCEP;
}
}
- if((m_excep_proc == EXCEP_NACC) && OCSD_DATA_RESP_IS_CONT(resp))
+ if((m_excep_info.proc == EXCEP_NACC) && OCSD_DATA_RESP_IS_CONT(resp))
{
m_output_elem.setType(OCSD_GEN_TRC_ELEM_ADDR_NACC);
m_output_elem.st_addr = m_nacc_addr;
- resp = outputTraceElementIdx(m_excep_index,m_output_elem);
- m_excep_proc = EXCEP_EXCEP;
+ resp = outputTraceElementIdx(m_excep_info.index,m_output_elem);
+ m_excep_info.proc = EXCEP_EXCEP;
m_mem_nacc_pending = false;
}
- if((m_excep_proc == EXCEP_EXCEP) && OCSD_DATA_RESP_IS_CONT(resp))
+ if((m_excep_info.proc == EXCEP_EXCEP) && OCSD_DATA_RESP_IS_CONT(resp))
{
// output element.
m_output_elem.setType(OCSD_GEN_TRC_ELEM_EXCEPTION);
// add end address as preferred return address to end addr in element
- m_output_elem.en_addr = m_excep_addr.val;
+ m_output_elem.en_addr = m_excep_info.addr.val;
m_output_elem.excep_ret_addr = 1;
- resp = outputTraceElementIdx(m_excep_index,m_output_elem);
- m_excep_proc = EXCEP_POP;
+ m_output_elem.excep_ret_addr_br_tgt = m_excep_info.addr_b_tgt;
+ m_output_elem.exception_number = m_excep_info.number;
+ resp = outputTraceElementIdx(m_excep_info.index,m_output_elem);
+ m_excep_info.proc = EXCEP_POP;
}
return resp;
}
@@ -1036,6 +1068,7 @@ ocsd_err_t TrcPktDecodeEtmV4I::traceInstrToWP(bool &bWPFound, const bool traceTo
ocsd_mem_space_acc_t mem_space = m_is_secure ? OCSD_MEM_SPACE_S : OCSD_MEM_SPACE_N;
m_output_elem.st_addr = m_output_elem.en_addr = m_instr_info.instr_addr;
+ m_output_elem.num_instr_range = 0;
bWPFound = false;
@@ -1057,6 +1090,7 @@ ocsd_err_t TrcPktDecodeEtmV4I::traceInstrToWP(bool &bWPFound, const bool traceTo
// update the range decoded address in the output packet.
m_output_elem.en_addr = m_instr_info.instr_addr;
+ m_output_elem.num_instr_range++;
// either walking to match the next instruction address or a real watchpoint
if(traceToAddrNext)
@@ -1068,7 +1102,7 @@ ocsd_err_t TrcPktDecodeEtmV4I::traceInstrToWP(bool &bWPFound, const bool traceTo
{
// not enough memory accessible.
m_mem_nacc_pending = true;
- m_nacc_addr = m_instr_info.instr_addr;
+ m_nacc_addr = m_instr_info.instr_addr;
}
}
return err;
diff --git a/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp b/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp
index 0761f7aa64f4..3f9d534db82c 100644
--- a/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp
+++ b/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp
@@ -91,6 +91,7 @@ void EtmV4ITrcPacket::toString(std::string &str) const
{
case ETM4_PKT_I_BAD_SEQUENCE:
case ETM4_PKT_I_INCOMPLETE_EOT:
+ case ETM4_PKT_I_RESERVED_CFG:
name = packetTypeName(err_type, 0);
str += "[" + (std::string)name + "]";
break;
@@ -185,18 +186,26 @@ void EtmV4ITrcPacket::toStringFmt(const uint32_t fmtFlags, std::string &str) con
const char *EtmV4ITrcPacket::packetTypeName(const ocsd_etmv4_i_pkt_type type, const char **ppDesc) const
{
- const char *pName = "I_RESERVED";
- const char *pDesc = "Reserved Packet Header";
+ const char *pName = "I_UNKNOWN";
+ const char *pDesc = "Unknown Packet Header";
switch(type)
{
- case ETM4_PKT_I_RESERVED: break; // default;
-
case ETM4_PKT_I_NOTSYNC:
pName = "I_NOT_SYNC";
pDesc = "I Stream not synchronised";
break;
+ case ETM4_PKT_I_INCOMPLETE_EOT:
+ pName = "I_INCOMPLETE_EOT";
+ pDesc = "Incomplete packet at end of trace.";
+ break;
+
+ case ETM4_PKT_I_NO_ERR_TYPE:
+ pName = "I_NO_ERR_TYPE";
+ pDesc = "No Error Type.";
+ break;
+
case ETM4_PKT_I_BAD_SEQUENCE:
pName = "I_BAD_SEQUENCE";
pDesc = "Invalid Sequence in packet.";
@@ -207,119 +216,129 @@ const char *EtmV4ITrcPacket::packetTypeName(const ocsd_etmv4_i_pkt_type type, co
pDesc = "Invalid Packet for trace mode.";
break;
- case ETM4_PKT_I_INCOMPLETE_EOT:
- pName = "I_INCOMPLETE_EOT";
- pDesc = "Incomplete packet at end of trace.";
+ case ETM4_PKT_I_RESERVED:
+ pName = "I_RESERVED";
+ pDesc = "Reserved Packet Header";
break;
- case ETM4_PKT_I_NO_ERR_TYPE:
- pName = "I_NO_ERR_TYPE";
- pDesc = "No Error Type.";
+ case ETM4_PKT_I_RESERVED_CFG:
+ pName = "I_RESERVED_CFG";
+ pDesc = "Reserved header for current configuration.";
break;
case ETM4_PKT_I_EXTENSION:
pName = "I_EXTENSION";
- pDesc = "Extention packet header.";
+ pDesc = "Extension packet header.";
break;
- case ETM4_PKT_I_ADDR_CTXT_L_32IS0:
- pName = "I_ADDR_CTXT_L_32IS0";
- pDesc = "Address & Context, Long, 32 bit, IS0.";
+ case ETM4_PKT_I_TRACE_INFO:
+ pName = "I_TRACE_INFO";
+ pDesc = "Trace Info.";
break;
- case ETM4_PKT_I_ADDR_CTXT_L_32IS1:
- pName = "I_ADDR_CTXT_L_32IS1";
- pDesc = "Address & Context, Long, 32 bit, IS0.";
+ case ETM4_PKT_I_TIMESTAMP:
+ pName = "I_TIMESTAMP";
+ pDesc = "Timestamp.";
break;
- case ETM4_PKT_I_ADDR_CTXT_L_64IS0:
- pName = "I_ADDR_CTXT_L_64IS0";
- pDesc = "Address & Context, Long, 64 bit, IS0.";
+ case ETM4_PKT_I_TRACE_ON:
+ pName = "I_TRACE_ON";
+ pDesc = "Trace On.";
break;
- case ETM4_PKT_I_ADDR_CTXT_L_64IS1:
- pName = "I_ADDR_CTXT_L_64IS1";
- pDesc = "Address & Context, Long, 64 bit, IS1.";
+ case ETM4_PKT_I_FUNC_RET:
+ pName = "I_FUNC_RET";
+ pDesc = "V8M - function return.";
break;
- case ETM4_PKT_I_CTXT:
- pName = "I_CTXT";
- pDesc = "Context Packet.";
+ case ETM4_PKT_I_EXCEPT:
+ pName = "I_EXCEPT";
+ pDesc = "Exception.";
break;
- case ETM4_PKT_I_ADDR_MATCH:
- pName = "I_ADDR_MATCH";
- pDesc = "Exact Address Match.";
+ case ETM4_PKT_I_EXCEPT_RTN:
+ pName = "I_EXCEPT_RTN";
+ pDesc = "Exception Return.";
break;
- case ETM4_PKT_I_ADDR_L_32IS0:
- pName = "I_ADDR_L_32IS0";
- pDesc = "Address, Long, 32 bit, IS0.";
+ case ETM4_PKT_I_CCNT_F1:
+ pName = "I_CCNT_F1";
+ pDesc = "Cycle Count format 1.";
break;
- case ETM4_PKT_I_ADDR_L_32IS1:
- pName = "I_ADDR_L_32IS1";
- pDesc = "Address, Long, 32 bit, IS1.";
+ case ETM4_PKT_I_CCNT_F2:
+ pName = "I_CCNT_F2";
+ pDesc = "Cycle Count format 2.";
break;
- case ETM4_PKT_I_ADDR_L_64IS0:
- pName = "I_ADDR_L_64IS0";
- pDesc = "Address, Long, 64 bit, IS0.";
+ case ETM4_PKT_I_CCNT_F3:
+ pName = "I_CCNT_F3";
+ pDesc = "Cycle Count format 3.";
break;
- case ETM4_PKT_I_ADDR_L_64IS1:
- pName = "I_ADDR_L_64IS1";
- pDesc = "Address, Long, 64 bit, IS1.";
+ case ETM4_PKT_I_NUM_DS_MKR:
+ pName = "I_NUM_DS_MKR";
+ pDesc = "Data Synchronisation Marker - Numbered.";
break;
- case ETM4_PKT_I_ADDR_S_IS0:
- pName = "I_ADDR_S_IS0";
- pDesc = "Address, Short, IS0.";
+ case ETM4_PKT_I_UNNUM_DS_MKR:
+ pName = "I_UNNUM_DS_MKR";
+ pDesc = "Data Synchronisation Marker - Unnumbered.";
break;
- case ETM4_PKT_I_ADDR_S_IS1:
- pName = "I_ADDR_S_IS1";
- pDesc = "Address, Short, IS1.";
+ case ETM4_PKT_I_COMMIT:
+ pName = "I_COMMIT";
+ pDesc = "Commit";
break;
- case ETM4_PKT_I_Q:
- pName = "I_Q";
- pDesc = "Q Packet.";
+ case ETM4_PKT_I_CANCEL_F1:
+ pName = "I_CANCEL_F1";
+ pDesc = "Cancel Format 1.";
break;
- case ETM4_PKT_I_ATOM_F1:
- pName = "I_ATOM_F1";
- pDesc = "Atom format 1.";
+ case ETM4_PKT_I_MISPREDICT:
+ pName = "I_MISPREDICT";
+ pDesc = "Mispredict.";
break;
- case ETM4_PKT_I_ATOM_F2:
- pName = "I_ATOM_F2";
- pDesc = "Atom format 2.";
+ case ETM4_PKT_I_CANCEL_F2:
+ pName = "I_CANCEL_F2";
+ pDesc = "Cancel Format 2.";
break;
- case ETM4_PKT_I_ATOM_F3:
- pName = "I_ATOM_F3";
- pDesc = "Atom format 3.";
+ case ETM4_PKT_I_CANCEL_F3:
+ pName = "I_CANCEL_F3";
+ pDesc = "Cancel Format 3.";
break;
- case ETM4_PKT_I_ATOM_F4:
- pName = "I_ATOM_F4";
- pDesc = "Atom format 4.";
+ case ETM4_PKT_I_COND_I_F2:
+ pName = "I_COND_I_F2";
+ pDesc = "Conditional Instruction, format 2.";
break;
- case ETM4_PKT_I_ATOM_F5:
- pName = "I_ATOM_F5";
- pDesc = "Atom format 5.";
+ case ETM4_PKT_I_COND_FLUSH:
+ pName = "I_COND_FLUSH";
+ pDesc = "Conditional Flush.";
break;
- case ETM4_PKT_I_ATOM_F6:
- pName = "I_ATOM_F6";
- pDesc = "Atom format 6.";
+ case ETM4_PKT_I_COND_RES_F4:
+ pName = "I_COND_RES_F4";
+ pDesc = "Conditional Result, format 4.";
break;
- case ETM4_PKT_I_COND_FLUSH:
- pName = "I_COND_FLUSH";
- pDesc = "Conditional Flush.";
+ case ETM4_PKT_I_COND_RES_F2:
+ pName = "I_COND_RES_F2";
+ pDesc = "Conditional Result, format 2.";
+ break;
+
+ case ETM4_PKT_I_COND_RES_F3:
+ pName = "I_COND_RES_F3";
+ pDesc = "Conditional Result, format 3.";
+ break;
+
+ case ETM4_PKT_I_COND_RES_F1:
+ pName = "I_COND_RES_F1";
+ pDesc = "Conditional Result, format 1.";
break;
case ETM4_PKT_I_COND_I_F1:
@@ -327,113 +346,114 @@ const char *EtmV4ITrcPacket::packetTypeName(const ocsd_etmv4_i_pkt_type type, co
pDesc = "Conditional Instruction, format 1.";
break;
- case ETM4_PKT_I_COND_I_F2:
- pName = "I_COND_I_F2";
- pDesc = "Conditional Instruction, format 2.";
- break;
-
case ETM4_PKT_I_COND_I_F3:
pName = "I_COND_I_F3";
pDesc = "Conditional Instruction, format 3.";
break;
- case ETM4_PKT_I_COND_RES_F1:
- pName = "I_COND_RES_F1";
- pDesc = "Conditional Result, format 1.";
+ case ETM4_PKT_I_IGNORE:
+ pName = "I_IGNORE";
+ pDesc = "Ignore.";
break;
- case ETM4_PKT_I_COND_RES_F2:
- pName = "I_COND_RES_F2";
- pDesc = "Conditional Result, format 2.";
+ case ETM4_PKT_I_EVENT:
+ pName = "I_EVENT";
+ pDesc = "Trace Event.";
break;
- case ETM4_PKT_I_COND_RES_F3:
- pName = "I_COND_RES_F3";
- pDesc = "Conditional Result, format 3.";
+ case ETM4_PKT_I_CTXT:
+ pName = "I_CTXT";
+ pDesc = "Context Packet.";
break;
- case ETM4_PKT_I_COND_RES_F4:
- pName = "I_COND_RES_F4";
- pDesc = "Conditional Result, format 4.";
+ case ETM4_PKT_I_ADDR_CTXT_L_32IS0:
+ pName = "I_ADDR_CTXT_L_32IS0";
+ pDesc = "Address & Context, Long, 32 bit, IS0.";
break;
- case ETM4_PKT_I_CCNT_F1:
- pName = "I_CCNT_F1";
- pDesc = "Cycle Count format 1.";
+ case ETM4_PKT_I_ADDR_CTXT_L_32IS1:
+ pName = "I_ADDR_CTXT_L_32IS1";
+ pDesc = "Address & Context, Long, 32 bit, IS0.";
break;
- case ETM4_PKT_I_CCNT_F2:
- pName = "I_CCNT_F2";
- pDesc = "Cycle Count format 2.";
+ case ETM4_PKT_I_ADDR_CTXT_L_64IS0:
+ pName = "I_ADDR_CTXT_L_64IS0";
+ pDesc = "Address & Context, Long, 64 bit, IS0.";
break;
- case ETM4_PKT_I_CCNT_F3:
- pName = "I_CCNT_F3";
- pDesc = "Cycle Count format 3.";
+ case ETM4_PKT_I_ADDR_CTXT_L_64IS1:
+ pName = "I_ADDR_CTXT_L_64IS1";
+ pDesc = "Address & Context, Long, 64 bit, IS1.";
break;
- case ETM4_PKT_I_NUM_DS_MKR:
- pName = "I_NUM_DS_MKR";
- pDesc = "Data Synchronisation Marker - Numbered.";
+ case ETM4_PKT_I_ADDR_MATCH:
+ pName = "I_ADDR_MATCH";
+ pDesc = "Exact Address Match.";
break;
- case ETM4_PKT_I_UNNUM_DS_MKR:
- pName = "I_UNNUM_DS_MKR";
- pDesc = "Data Synchronisation Marker - Unnumbered.";
+ case ETM4_PKT_I_ADDR_S_IS0:
+ pName = "I_ADDR_S_IS0";
+ pDesc = "Address, Short, IS0.";
break;
- case ETM4_PKT_I_EVENT:
- pName = "I_EVENT";
- pDesc = "Trace Event.";
+ case ETM4_PKT_I_ADDR_S_IS1:
+ pName = "I_ADDR_S_IS1";
+ pDesc = "Address, Short, IS1.";
break;
- case ETM4_PKT_I_EXCEPT:
- pName = "I_EXCEPT";
- pDesc = "Exception.";
+ case ETM4_PKT_I_ADDR_L_32IS0:
+ pName = "I_ADDR_L_32IS0";
+ pDesc = "Address, Long, 32 bit, IS0.";
break;
- case ETM4_PKT_I_EXCEPT_RTN:
- pName = "I_EXCEPT_RTN";
- pDesc = "Exception Return.";
+ case ETM4_PKT_I_ADDR_L_32IS1:
+ pName = "I_ADDR_L_32IS1";
+ pDesc = "Address, Long, 32 bit, IS1.";
break;
- case ETM4_PKT_I_TIMESTAMP:
- pName = "I_TIMESTAMP";
- pDesc = "Timestamp.";
+ case ETM4_PKT_I_ADDR_L_64IS0:
+ pName = "I_ADDR_L_64IS0";
+ pDesc = "Address, Long, 64 bit, IS0.";
break;
- case ETM4_PKT_I_CANCEL_F1:
- pName = "I_CANCEL_F1";
- pDesc = "Cancel Format 1.";
+ case ETM4_PKT_I_ADDR_L_64IS1:
+ pName = "I_ADDR_L_64IS1";
+ pDesc = "Address, Long, 64 bit, IS1.";
break;
- case ETM4_PKT_I_CANCEL_F2:
- pName = "I_CANCEL_F2";
- pDesc = "Cancel Format 2.";
+
+ case ETM4_PKT_I_Q:
+ pName = "I_Q";
+ pDesc = "Q Packet.";
break;
- case ETM4_PKT_I_CANCEL_F3:
- pName = "I_CANCEL_F3";
- pDesc = "Cancel Format 3.";
+ case ETM4_PKT_I_ATOM_F6:
+ pName = "I_ATOM_F6";
+ pDesc = "Atom format 6.";
break;
- case ETM4_PKT_I_COMMIT:
- pName = "I_COMMIT";
- pDesc = "Commit";
+ case ETM4_PKT_I_ATOM_F5:
+ pName = "I_ATOM_F5";
+ pDesc = "Atom format 5.";
break;
- case ETM4_PKT_I_MISPREDICT:
- pName = "I_MISPREDICT";
- pDesc = "Mispredict.";
+ case ETM4_PKT_I_ATOM_F2:
+ pName = "I_ATOM_F2";
+ pDesc = "Atom format 2.";
break;
- case ETM4_PKT_I_TRACE_INFO:
- pName = "I_TRACE_INFO";
- pDesc = "Trace Info.";
+ case ETM4_PKT_I_ATOM_F4:
+ pName = "I_ATOM_F4";
+ pDesc = "Atom format 4.";
break;
- case ETM4_PKT_I_TRACE_ON:
- pName = "I_TRACE_ON";
- pDesc = "Trace On.";
+ case ETM4_PKT_I_ATOM_F1:
+ pName = "I_ATOM_F1";
+ pDesc = "Atom format 1.";
+ break;
+
+ case ETM4_PKT_I_ATOM_F3:
+ pName = "I_ATOM_F3";
+ pDesc = "Atom format 3.";
break;
case ETM4_PKT_I_ASYNC:
@@ -450,6 +470,9 @@ const char *EtmV4ITrcPacket::packetTypeName(const ocsd_etmv4_i_pkt_type type, co
pName = "I_OVERFLOW";
pDesc = "Overflow.";
break;
+
+ default:
+ break;
}
if(ppDesc) *ppDesc = pDesc;
diff --git a/decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.cpp b/decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.cpp
index 8d17d8386eba..0607c192f879 100644
--- a/decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.cpp
+++ b/decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.cpp
@@ -34,12 +34,46 @@
#include "trc_pkt_proc_etmv4i_impl.h"
+/* Trace raw input buffer class */
+TraceRawBuffer::TraceRawBuffer()
+{
+ m_bufSize = 0;
+ m_bufProcessed = 0;
+ m_pBuffer = 0;
+ pkt = 0;
+}
+
+// init the buffer
+void TraceRawBuffer::init(const uint32_t size, const uint8_t *rawtrace, std::vector<uint8_t> *out_packet)
+{
+ m_bufSize = size;
+ m_bufProcessed = 0;
+ m_pBuffer = rawtrace;
+ pkt = out_packet;
+}
+
+void TraceRawBuffer::copyByteToPkt()
+{
+ if (!empty()) {
+ pkt->push_back(m_pBuffer[m_bufProcessed]);
+ m_bufProcessed++;
+ }
+}
+uint8_t TraceRawBuffer::peekNextByte()
+{
+ uint8_t val = 0;
+ if (!empty())
+ val = m_pBuffer[m_bufProcessed];
+ return val;
+}
+
+/* trace etmv4 packet processing class */
EtmV4IPktProcImpl::EtmV4IPktProcImpl() :
m_isInit(false),
m_interface(0),
m_first_trace_info(false)
{
- BuildIPacketTable();
+
}
EtmV4IPktProcImpl::~EtmV4IPktProcImpl()
@@ -62,6 +96,7 @@ ocsd_err_t EtmV4IPktProcImpl::Configure(const EtmV4Config *p_config)
if(p_config != 0)
{
m_config = *p_config;
+ BuildIPacketTable(); // packet table based on config
}
else
{
@@ -78,64 +113,81 @@ ocsd_datapath_resp_t EtmV4IPktProcImpl::processData( const ocsd_trc_index_t ind
uint32_t *numBytesProcessed)
{
ocsd_datapath_resp_t resp = OCSD_RESP_CONT;
- m_blockBytesProcessed = 0;
+ m_trcIn.init(dataBlockSize, pDataBlock, &m_currPacketData);
m_blockIndex = index;
- uint8_t currByte;
- while( ( (m_blockBytesProcessed < dataBlockSize) ||
- ((m_blockBytesProcessed == dataBlockSize) && (m_process_state == SEND_PKT)) ) &&
- OCSD_DATA_RESP_IS_CONT(resp))
+ bool done = false;
+ uint8_t nextByte;
+
+ do
{
- currByte = pDataBlock[m_blockBytesProcessed];
try
{
- switch(m_process_state)
+ /* while (((m_blockBytesProcessed < dataBlockSize) ||
+ ((m_blockBytesProcessed == dataBlockSize) && (m_process_state == SEND_PKT))) &&
+ OCSD_DATA_RESP_IS_CONT(resp))*/
+ while ( (!m_trcIn.empty() || (m_process_state == SEND_PKT)) &&
+ OCSD_DATA_RESP_IS_CONT(resp)
+ )
{
- case PROC_HDR:
- m_packet_index = m_blockIndex + m_blockBytesProcessed;
- if(m_is_sync)
- {
- m_pIPktFn = m_i_table[currByte].pptkFn;
- m_curr_packet.type = m_i_table[currByte].pkt_type;
- }
- else
+ switch (m_process_state)
{
- // unsynced - process data until we see a sync point
- m_pIPktFn = &EtmV4IPktProcImpl::iNotSync;
- m_curr_packet.type = ETM4_PKT_I_NOTSYNC;
+ case PROC_HDR:
+ m_packet_index = m_blockIndex + m_trcIn.processed();
+ if (m_is_sync)
+ {
+ nextByte = m_trcIn.peekNextByte();
+ m_pIPktFn = m_i_table[nextByte].pptkFn;
+ m_curr_packet.type = m_i_table[nextByte].pkt_type;
+ }
+ else
+ {
+ // unsynced - process data until we see a sync point
+ m_pIPktFn = &EtmV4IPktProcImpl::iNotSync;
+ m_curr_packet.type = ETM4_PKT_I_NOTSYNC;
+ }
+ m_process_state = PROC_DATA;
+
+ case PROC_DATA:
+ // loop till full packet or no more data...
+ while (!m_trcIn.empty() && (m_process_state == PROC_DATA))
+ {
+ nextByte = m_trcIn.peekNextByte();
+ m_trcIn.copyByteToPkt(); // move next byte into the packet
+ // m_currPacketData.push_back(pDataBlock[m_blockBytesProcessed]);
+ // m_blockBytesProcessed++;
+ (this->*m_pIPktFn)(nextByte);
+ }
+ break;
+
+ case SEND_PKT:
+ resp = outputPacket();
+ InitPacketState();
+ m_process_state = PROC_HDR;
+ break;
+
+ case SEND_UNSYNCED:
+ resp = outputUnsyncedRawPacket();
+ if (m_update_on_unsync_packet_index != 0)
+ {
+ m_packet_index = m_update_on_unsync_packet_index;
+ m_update_on_unsync_packet_index = 0;
+ }
+ m_process_state = PROC_DATA; // after dumping unsynced data, still in data mode.
+ break;
}
- m_process_state = PROC_DATA;
-
- case PROC_DATA:
- m_currPacketData.push_back(pDataBlock[m_blockBytesProcessed]);
- m_blockBytesProcessed++;
- (this->*m_pIPktFn)();
- break;
-
- case SEND_PKT:
- resp = outputPacket();
- InitPacketState();
- m_process_state = PROC_HDR;
- break;
-
- case SEND_UNSYNCED:
- resp = outputUnsyncedRawPacket();
- if(m_update_on_unsync_packet_index != 0)
- {
- m_packet_index = m_update_on_unsync_packet_index;
- m_update_on_unsync_packet_index = 0;
- }
- m_process_state = PROC_DATA; // after dumping unsynced data, still in data mode.
- break;
}
+ done = true;
}
catch(ocsdError &err)
{
+ done = true;
m_interface->LogError(err);
if( (err.getErrorCode() == OCSD_ERR_BAD_PACKET_SEQ) ||
(err.getErrorCode() == OCSD_ERR_INVALID_PCKT_HDR))
{
// send invalid packets up the pipe to let the next stage decide what to do.
m_process_state = SEND_PKT;
+ done = false;
}
else
{
@@ -145,14 +197,15 @@ ocsd_datapath_resp_t EtmV4IPktProcImpl::processData( const ocsd_trc_index_t ind
}
catch(...)
{
+ done = true;
/// vv bad at this point.
resp = OCSD_RESP_FATAL_SYS_ERR;
const ocsdError &fatal = ocsdError(OCSD_ERR_SEV_ERROR,OCSD_ERR_FAIL,m_packet_index,m_config.getTraceID(),"Unknown System Error decoding trace.");
m_interface->LogError(fatal);
}
- }
+ } while (!done);
- *numBytesProcessed = m_blockBytesProcessed;
+ *numBytesProcessed = m_trcIn.processed();
return resp;
}
@@ -230,38 +283,35 @@ ocsd_datapath_resp_t EtmV4IPktProcImpl::outputUnsyncedRawPacket()
return resp;
}
-void EtmV4IPktProcImpl::iNotSync()
+void EtmV4IPktProcImpl::iNotSync(const uint8_t lastByte)
{
- uint8_t lastByte = m_currPacketData.back(); // peek at the byte being processed...
-
// is it an extension byte?
- if(lastByte == 0x00) // TBD : add check for forced sync in here?
+ if (lastByte == 0x00) // TBD : add check for forced sync in here?
{
- if(m_currPacketData.size() > 1)
+ if (m_currPacketData.size() > 1)
{
m_dump_unsynced_bytes = m_currPacketData.size() - 1;
m_process_state = SEND_UNSYNCED;
// outputting some data then update packet index after so output indexes accurate
- m_update_on_unsync_packet_index = m_blockIndex + m_blockBytesProcessed - 1;
+ m_update_on_unsync_packet_index = m_blockIndex + m_trcIn.processed() - 1;
}
else
- m_packet_index = m_blockIndex + m_blockBytesProcessed - 1; // set it up now otherwise.
+ m_packet_index = m_blockIndex + m_trcIn.processed() - 1; // set it up now otherwise.
- m_pIPktFn = m_i_table[lastByte].pptkFn;
+ m_pIPktFn = m_i_table[lastByte].pptkFn;
}
- else if(m_currPacketData.size() >= 8)
+ else if (m_currPacketData.size() >= 8)
{
m_dump_unsynced_bytes = m_currPacketData.size();
m_process_state = SEND_UNSYNCED;
// outputting some data then update packet index after so output indexes accurate
- m_update_on_unsync_packet_index = m_blockIndex + m_blockBytesProcessed;
+ m_update_on_unsync_packet_index = m_blockIndex + m_trcIn.processed();
}
}
-void EtmV4IPktProcImpl::iPktNoPayload()
+void EtmV4IPktProcImpl::iPktNoPayload(const uint8_t lastByte)
{
// some expansion may be required...
- uint8_t lastByte = m_currPacketData.back();
switch(m_curr_packet.type)
{
case ETM4_PKT_I_ADDR_MATCH:
@@ -281,20 +331,27 @@ void EtmV4IPktProcImpl::iPktNoPayload()
case ETM4_PKT_I_COND_FLUSH:
case ETM4_PKT_I_EXCEPT_RTN:
case ETM4_PKT_I_TRACE_ON:
+ case ETM4_PKT_I_FUNC_RET:
+ case ETM4_PKT_I_IGNORE:
default: break;
}
m_process_state = SEND_PKT; // now just send it....
}
-void EtmV4IPktProcImpl::iPktReserved()
+void EtmV4IPktProcImpl::iPktReserved(const uint8_t lastByte)
{
- m_curr_packet.updateErrType(ETM4_PKT_I_RESERVED); // swap type for err type
+ m_curr_packet.updateErrType(ETM4_PKT_I_RESERVED, lastByte); // swap type for err type
throw ocsdError(OCSD_ERR_SEV_ERROR, OCSD_ERR_INVALID_PCKT_HDR,m_packet_index,m_config.getTraceID());
}
-void EtmV4IPktProcImpl::iPktExtension()
+void EtmV4IPktProcImpl::iPktInvalidCfg(const uint8_t lastByte)
+{
+ m_curr_packet.updateErrType(ETM4_PKT_I_RESERVED_CFG, lastByte); // swap type for err type
+ throw ocsdError(OCSD_ERR_SEV_ERROR, OCSD_ERR_INVALID_PCKT_HDR, m_packet_index, m_config.getTraceID());
+}
+
+void EtmV4IPktProcImpl::iPktExtension(const uint8_t lastByte)
{
- uint8_t lastByte = m_currPacketData.back();
if(m_currPacketData.size() == 2)
{
// not sync and not next by 0x00 - not sync sequence
@@ -331,9 +388,8 @@ void EtmV4IPktProcImpl::iPktExtension()
}
}
-void EtmV4IPktProcImpl::iPktASync()
+void EtmV4IPktProcImpl::iPktASync(const uint8_t lastByte)
{
- uint8_t lastByte = m_currPacketData.back();
if(lastByte != 0x00)
{
// not sync and not next by 0x00 - not sync sequence if < 12
@@ -372,9 +428,8 @@ void EtmV4IPktProcImpl::iPktASync()
}
}
-void EtmV4IPktProcImpl::iPktTraceInfo()
+void EtmV4IPktProcImpl::iPktTraceInfo(const uint8_t lastByte)
{
- uint8_t lastByte = m_currPacketData.back();
if(m_currPacketData.size() == 1) // header
{
//clear flags
@@ -445,11 +500,8 @@ void EtmV4IPktProcImpl::iPktTraceInfo()
}
-void EtmV4IPktProcImpl::iPktTimestamp()
+void EtmV4IPktProcImpl::iPktTimestamp(const uint8_t lastByte)
{
- // save the latest byte
- uint8_t lastByte = m_currPacketData.back();
-
// process the header byte
if(m_currPacketData.size() == 1)
{
@@ -498,9 +550,9 @@ void EtmV4IPktProcImpl::iPktTimestamp()
}
}
-void EtmV4IPktProcImpl::iPktException()
+void EtmV4IPktProcImpl::iPktException(const uint8_t lastByte)
{
- uint8_t lastByte = m_currPacketData.back();
+ uint16_t excep_type = 0;
switch(m_currPacketData.size())
{
@@ -512,7 +564,7 @@ void EtmV4IPktProcImpl::iPktException()
if(m_currPacketData.size() == (unsigned)m_excep_size)
{
- uint16_t excep_type = (m_currPacketData[1] >> 1) & 0x1F;
+ excep_type = (m_currPacketData[1] >> 1) & 0x1F;
uint8_t addr_interp = (m_currPacketData[1] & 0x40) >> 5 | (m_currPacketData[1] & 0x1);
uint8_t m_fault_pending = 0;
uint8_t m_type = (m_config.coreProfile() == profile_CortexM) ? 1 : 0;
@@ -530,11 +582,10 @@ void EtmV4IPktProcImpl::iPktException()
}
}
-void EtmV4IPktProcImpl::iPktCycleCntF123()
+void EtmV4IPktProcImpl::iPktCycleCntF123(const uint8_t lastByte)
{
ocsd_etmv4_i_pkt_type format = m_curr_packet.type;
- uint8_t lastByte = m_currPacketData.back();
if( m_currPacketData.size() == 1)
{
m_count_done = m_commit_done = false;
@@ -606,9 +657,8 @@ void EtmV4IPktProcImpl::iPktCycleCntF123()
}
}
-void EtmV4IPktProcImpl::iPktSpeclRes()
-{
- uint8_t lastByte = m_currPacketData.back();
+void EtmV4IPktProcImpl::iPktSpeclRes(const uint8_t lastByte)
+{
if(m_currPacketData.size() == 1)
{
switch(m_curr_packet.getType())
@@ -650,9 +700,8 @@ void EtmV4IPktProcImpl::iPktSpeclRes()
}
}
-void EtmV4IPktProcImpl::iPktCondInstr()
+void EtmV4IPktProcImpl::iPktCondInstr(const uint8_t lastByte)
{
- uint8_t lastByte = m_currPacketData.back();
bool bF1Done = false;
if(m_currPacketData.size() == 1)
@@ -691,10 +740,8 @@ void EtmV4IPktProcImpl::iPktCondInstr()
}
}
-void EtmV4IPktProcImpl::iPktCondResult()
+void EtmV4IPktProcImpl::iPktCondResult(const uint8_t lastByte)
{
- //static ocsd_etmv4_i_pkt_type format = ETM4_PKT_I_COND_RES_F1; // conditional result formats F1-F4
- uint8_t lastByte = m_currPacketData.back();
if(m_currPacketData.size() == 1)
{
m_F1P1_done = false; // F1 payload 1 done
@@ -763,10 +810,10 @@ void EtmV4IPktProcImpl::iPktCondResult()
}
}
-void EtmV4IPktProcImpl::iPktContext()
+void EtmV4IPktProcImpl::iPktContext(const uint8_t lastByte)
{
bool bSendPacket = false;
- uint8_t lastByte = m_currPacketData.back();
+
if(m_currPacketData.size() == 1)
{
if((lastByte & 0x1) == 0)
@@ -840,10 +887,8 @@ void EtmV4IPktProcImpl::extractAndSetContextInfo(const std::vector<uint8_t> &buf
}
}
-void EtmV4IPktProcImpl::iPktAddrCtxt()
+void EtmV4IPktProcImpl::iPktAddrCtxt(const uint8_t lastByte)
{
- uint8_t lastByte = m_currPacketData.back();
-
if( m_currPacketData.size() == 1)
{
m_addrIS = 0;
@@ -910,13 +955,14 @@ void EtmV4IPktProcImpl::iPktAddrCtxt()
}
}
-void EtmV4IPktProcImpl::iPktShortAddr()
+void EtmV4IPktProcImpl::iPktShortAddr(const uint8_t lastByte)
{
- uint8_t lastByte = m_currPacketData.back();
- if(m_currPacketData.size() == 1)
+ if (m_currPacketData.size() == 1)
{
m_addr_done = false;
- m_addrIS = (lastByte == ETM4_PKT_I_ADDR_S_IS0) ? 0 : 1;
+ m_addrIS = 0;
+ if (lastByte == ETM4_PKT_I_ADDR_S_IS1)
+ m_addrIS = 1;
}
else if(!m_addr_done)
{
@@ -954,7 +1000,7 @@ int EtmV4IPktProcImpl::extractShortAddr(const std::vector<uint8_t> &buffer, cons
return idx;
}
-void EtmV4IPktProcImpl::iPktLongAddr()
+void EtmV4IPktProcImpl::iPktLongAddr(const uint8_t lastByte)
{
if(m_currPacketData.size() == 1)
{
@@ -998,10 +1044,8 @@ void EtmV4IPktProcImpl::iPktLongAddr()
}
}
-void EtmV4IPktProcImpl::iPktQ()
+void EtmV4IPktProcImpl::iPktQ(const uint8_t lastByte)
{
- uint8_t lastByte = m_currPacketData.back();
-
if(m_currPacketData.size() == 1)
{
m_Q_type = lastByte & 0xF;
@@ -1112,7 +1156,7 @@ void EtmV4IPktProcImpl::iPktQ()
}
-void EtmV4IPktProcImpl::iAtom()
+void EtmV4IPktProcImpl::iAtom(const uint8_t lastByte)
{
// patterns lsbit = oldest atom, ms bit = newest.
static const uint32_t f4_patterns[] = {
@@ -1122,7 +1166,6 @@ void EtmV4IPktProcImpl::iAtom()
0x5 // NENE
};
- uint8_t lastByte = m_currPacketData.back();
uint8_t pattIdx = 0, pattCount = 0;
uint32_t pattern;
@@ -1212,13 +1255,23 @@ void EtmV4IPktProcImpl::BuildIPacketTable()
m_i_table[0x04].pkt_type = ETM4_PKT_I_TRACE_ON;
m_i_table[0x04].pptkFn = &EtmV4IPktProcImpl::iPktNoPayload;
+
+ // b0000 0101 - Funct ret V8M
+ m_i_table[0x05].pkt_type = ETM4_PKT_I_FUNC_RET;
+ if ((m_config.coreProfile() == profile_CortexM) &&
+ (OCSD_IS_V8_ARCH(m_config.archVersion())) &&
+ (m_config.FullVersion() >= 0x42))
+ {
+ m_i_table[0x05].pptkFn = &EtmV4IPktProcImpl::iPktNoPayload;
+ }
+
// b0000 0110 - exception
m_i_table[0x06].pkt_type = ETM4_PKT_I_EXCEPT;
m_i_table[0x06].pptkFn = &EtmV4IPktProcImpl::iPktException;
// b0000 0111 - exception return
m_i_table[0x07].pkt_type = ETM4_PKT_I_EXCEPT_RTN;
- m_i_table[0x07].pptkFn = &EtmV4IPktProcImpl::iPktNoPayload;
+ m_i_table[0x07].pptkFn = &EtmV4IPktProcImpl::iPktNoPayload;
// b0000 110x - cycle count f2
// b0000 111x - cycle count f1
@@ -1238,22 +1291,27 @@ void EtmV4IPktProcImpl::BuildIPacketTable()
// b0010 0xxx - NDSM
for(int i = 0; i < 8; i++)
{
- m_i_table[0x20+i].pkt_type = ETM4_PKT_I_NUM_DS_MKR;
- m_i_table[0x20+i].pptkFn = &EtmV4IPktProcImpl::iPktNoPayload;
+ m_i_table[0x20 + i].pkt_type = ETM4_PKT_I_NUM_DS_MKR;
+ if (m_config.enabledDataTrace())
+ m_i_table[0x20+i].pptkFn = &EtmV4IPktProcImpl::iPktNoPayload;
+ else
+ m_i_table[0x20+i].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
}
// b0010 10xx, b0010 1100 - UDSM
for(int i = 0; i < 5; i++)
{
m_i_table[0x28+i].pkt_type = ETM4_PKT_I_UNNUM_DS_MKR;
- m_i_table[0x28+i].pptkFn = &EtmV4IPktProcImpl::iPktNoPayload;
+ if (m_config.enabledDataTrace())
+ m_i_table[0x28+i].pptkFn = &EtmV4IPktProcImpl::iPktNoPayload;
+ else
+ m_i_table[0x28+i].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
}
// b0010 1101 - commit
m_i_table[0x2D].pkt_type = ETM4_PKT_I_COMMIT;
m_i_table[0x2D].pptkFn = &EtmV4IPktProcImpl::iPktSpeclRes;
-
// b0010 111x - cancel f1
for(int i = 0; i < 2; i++)
{
@@ -1284,68 +1342,107 @@ void EtmV4IPktProcImpl::BuildIPacketTable()
m_i_table[0x38+i].pptkFn = &EtmV4IPktProcImpl::iPktSpeclRes;
}
+ bool bCondValid = m_config.hasCondTrace() && m_config.enabledCondITrace();
+
// b0100 000x, b0100 0010 - cond I f2
- for(int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
{
- m_i_table[0x40+i].pkt_type = ETM4_PKT_I_COND_I_F2;
- m_i_table[0x40+i].pptkFn = &EtmV4IPktProcImpl::iPktCondInstr;
+ m_i_table[0x40 + i].pkt_type = ETM4_PKT_I_COND_I_F2;
+ if (bCondValid)
+ m_i_table[0x40 + i].pptkFn = &EtmV4IPktProcImpl::iPktCondInstr;
+ else
+ m_i_table[0x40 + i].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
}
// b0100 0011 - cond flush
m_i_table[0x43].pkt_type = ETM4_PKT_I_COND_FLUSH;
- m_i_table[0x43].pptkFn = &EtmV4IPktProcImpl::iPktNoPayload;
+ if (bCondValid)
+ m_i_table[0x43].pptkFn = &EtmV4IPktProcImpl::iPktNoPayload;
+ else
+ m_i_table[0x43].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
// b0100 010x, b0100 0110 - cond res f4
- for(int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
{
- m_i_table[0x44+i].pkt_type = ETM4_PKT_I_COND_RES_F4;
- m_i_table[0x44+i].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ m_i_table[0x44 + i].pkt_type = ETM4_PKT_I_COND_RES_F4;
+ if (bCondValid)
+ m_i_table[0x44 + i].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ else
+ m_i_table[0x44 + i].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
}
// b0100 100x, b0100 0110 - cond res f2
// b0100 110x, b0100 1110 - cond res f2
- for(int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
{
- m_i_table[0x48+i].pkt_type = ETM4_PKT_I_COND_RES_F2;
- m_i_table[0x48+i].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ m_i_table[0x48 + i].pkt_type = ETM4_PKT_I_COND_RES_F2;
+ if (bCondValid)
+ m_i_table[0x48 + i].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ else
+ m_i_table[0x48 + i].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
}
- for(int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
{
- m_i_table[0x4C+i].pkt_type = ETM4_PKT_I_COND_RES_F2;
- m_i_table[0x4C+i].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ m_i_table[0x4C + i].pkt_type = ETM4_PKT_I_COND_RES_F2;
+ if (bCondValid)
+ m_i_table[0x4C + i].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ else
+ m_i_table[0x4C + i].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
}
// b0101xxxx - cond res f3
- for(int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++)
{
- m_i_table[0x50+i].pkt_type = ETM4_PKT_I_COND_RES_F3;
- m_i_table[0x50+i].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ m_i_table[0x50 + i].pkt_type = ETM4_PKT_I_COND_RES_F3;
+ if (bCondValid)
+ m_i_table[0x50 + i].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ else
+ m_i_table[0x50 + i].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
}
// b011010xx - cond res f1
- for(int i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
{
- m_i_table[0x68+i].pkt_type = ETM4_PKT_I_COND_RES_F1;
- m_i_table[0x68+i].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ m_i_table[0x68 + i].pkt_type = ETM4_PKT_I_COND_RES_F1;
+ if (bCondValid)
+ m_i_table[0x68 + i].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ else
+ m_i_table[0x68 + i].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
}
// b0110 1100 - cond instr f1
m_i_table[0x6C].pkt_type = ETM4_PKT_I_COND_I_F1;
- m_i_table[0x6C].pptkFn = &EtmV4IPktProcImpl::iPktCondInstr;
+ if (bCondValid)
+ m_i_table[0x6C].pptkFn = &EtmV4IPktProcImpl::iPktCondInstr;
+ else
+ m_i_table[0x6C].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
// b0110 1101 - cond instr f3
m_i_table[0x6D].pkt_type = ETM4_PKT_I_COND_I_F3;
- m_i_table[0x6D].pptkFn = &EtmV4IPktProcImpl::iPktCondInstr;
+ if (bCondValid)
+ m_i_table[0x6D].pptkFn = &EtmV4IPktProcImpl::iPktCondInstr;
+ else
+ m_i_table[0x6D].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
// b0110111x - cond res f1
- for(int i = 0; i < 2; i++)
+ for (int i = 0; i < 2; i++)
{
// G++ cannot understand [0x6E+i] so change these round
- m_i_table[i+0x6E].pkt_type = ETM4_PKT_I_COND_RES_F1;
- m_i_table[i+0x6E].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ m_i_table[i + 0x6E].pkt_type = ETM4_PKT_I_COND_RES_F1;
+ if (bCondValid)
+ m_i_table[i + 0x6E].pptkFn = &EtmV4IPktProcImpl::iPktCondResult;
+ else
+ m_i_table[i + 0x6E].pptkFn = &EtmV4IPktProcImpl::iPktInvalidCfg;
+ }
+
+ // ETM 4.3 introduces ignore packets
+ if (m_config.FullVersion() >= 0x43)
+ {
+ m_i_table[0x70].pkt_type = ETM4_PKT_I_IGNORE;
+ m_i_table[0x70].pptkFn = &EtmV4IPktProcImpl::iPktNoPayload;
}
- // b01110001 - b01111111 - cond res f1
+ // b01110001 - b01111111 - event trace
for(int i = 0; i < 15; i++)
{
m_i_table[0x71+i].pkt_type = ETM4_PKT_I_EVENT;
@@ -1399,12 +1496,27 @@ void EtmV4IPktProcImpl::BuildIPacketTable()
m_i_table[0x9D+i].pkt_type = (i == 0) ? ETM4_PKT_I_ADDR_L_64IS0 : ETM4_PKT_I_ADDR_L_64IS1;
m_i_table[0x9D+i].pptkFn = &EtmV4IPktProcImpl::iPktLongAddr;
}
-
+
// b1010xxxx - Q packet
- for(int i = 0; i < 16; i++)
- {
- m_i_table[0xA0+i].pkt_type = ETM4_PKT_I_Q;
- m_i_table[0xA0+i].pptkFn = &EtmV4IPktProcImpl::iPktQ;
+ for (int i = 0; i < 16; i++)
+ {
+ m_i_table[0xA0 + i].pkt_type = ETM4_PKT_I_Q;
+ // certain Q type codes are reserved.
+ switch (i) {
+ case 0x3:
+ case 0x4:
+ case 0x7:
+ case 0x8:
+ case 0x9:
+ case 0xD:
+ case 0xE:
+ // don't update pkt fn - leave at default reserved.
+ break;
+ default:
+ // if this config supports Q elem - otherwise reserved again.
+ if (m_config.hasQElem())
+ m_i_table[0xA0 + i].pptkFn = &EtmV4IPktProcImpl::iPktQ;
+ }
}
// Atom Packets - all no payload but have specific pattern generation fn
diff --git a/decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.h b/decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.h
index 5c79c256967a..429f32711f3e 100644
--- a/decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.h
+++ b/decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.h
@@ -39,6 +39,31 @@
#include "opencsd/etmv4/trc_cmp_cfg_etmv4.h"
#include "opencsd/etmv4/trc_pkt_elem_etmv4i.h"
+class TraceRawBuffer
+{
+public:
+ TraceRawBuffer();
+ ~TraceRawBuffer() {};
+
+ // init the buffer
+ void init(const uint32_t size, const uint8_t *rawtrace, std::vector<uint8_t> *out_packet);
+ void copyByteToPkt(); // move a byte to the packet buffer
+ uint8_t peekNextByte(); // value of next byte in buffer.
+
+ bool empty() { return m_bufProcessed == m_bufSize; };
+ // bytes processed.
+ uint32_t processed() { return m_bufProcessed; };
+ // buffer size;
+ uint32_t size() { return m_bufSize; }
+
+private:
+ uint32_t m_bufSize;
+ uint32_t m_bufProcessed;
+ const uint8_t *m_pBuffer;
+ std::vector<uint8_t> *pkt;
+
+};
+
class EtmV4IPktProcImpl
{
public:
@@ -81,11 +106,12 @@ protected:
EtmV4Config m_config;
/** packet data **/
- std::vector<uint8_t> m_currPacketData; // raw data
+ TraceRawBuffer m_trcIn; // trace data in buffer
+ std::vector<uint8_t> m_currPacketData; // raw data packet
int m_currPktIdx; // index into raw packet when expanding
EtmV4ITrcPacket m_curr_packet; // expanded packet
ocsd_trc_index_t m_packet_index; // index of the start of the current packet
- uint32_t m_blockBytesProcessed; // number of bytes processed in the current data block
+// uint32_t m_blockBytesProcessed; // number of bytes processed in the current data block
ocsd_trc_index_t m_blockIndex; // index at the start of the current data block being processed
// searching for sync
@@ -110,9 +136,9 @@ private:
#define TINFO_KEY_SECT 0x02
#define TINFO_SPEC_SECT 0x04
#define TINFO_CYCT_SECT 0x08
- #define TINFO_CTRL 0x10
- #define TINFO_ALL_SECT 0x0F
- #define TINFO_ALL 0x1F
+ #define TINFO_CTRL 0x20
+ #define TINFO_ALL_SECT 0x1F
+ #define TINFO_ALL 0x3F
// address and context packets
@@ -152,24 +178,25 @@ private:
ocsd_datapath_resp_t outputPacket();
ocsd_datapath_resp_t outputUnsyncedRawPacket();
- void iNotSync(); // not synced yet
- void iPktNoPayload(); // process a single byte packet
- void iPktReserved(); // deal with reserved header value
- void iPktExtension();
- void iPktASync();
- void iPktTraceInfo();
- void iPktTimestamp();
- void iPktException();
- void iPktCycleCntF123();
- void iPktSpeclRes();
- void iPktCondInstr();
- void iPktCondResult();
- void iPktContext();
- void iPktAddrCtxt();
- void iPktShortAddr();
- void iPktLongAddr();
- void iPktQ();
- void iAtom();
+ void iNotSync(const uint8_t lastByte); // not synced yet
+ void iPktNoPayload(const uint8_t lastByte); // process a single byte packet
+ void iPktReserved(const uint8_t lastByte); // deal with reserved header value
+ void iPktExtension(const uint8_t lastByte);
+ void iPktASync(const uint8_t lastByte);
+ void iPktTraceInfo(const uint8_t lastByte);
+ void iPktTimestamp(const uint8_t lastByte);
+ void iPktException(const uint8_t lastByte);
+ void iPktCycleCntF123(const uint8_t lastByte);
+ void iPktSpeclRes(const uint8_t lastByte);
+ void iPktCondInstr(const uint8_t lastByte);
+ void iPktCondResult(const uint8_t lastByte);
+ void iPktContext(const uint8_t lastByte);
+ void iPktAddrCtxt(const uint8_t lastByte);
+ void iPktShortAddr(const uint8_t lastByte);
+ void iPktLongAddr(const uint8_t lastByte);
+ void iPktQ(const uint8_t lastByte);
+ void iAtom(const uint8_t lastByte);
+ void iPktInvalidCfg(const uint8_t lastByte); // packet invalid in current config.
unsigned extractContField(const std::vector<uint8_t> &buffer, const unsigned st_idx, uint32_t &value, const unsigned byte_limit = 5);
unsigned extractContField64(const std::vector<uint8_t> &buffer, const unsigned st_idx, uint64_t &value, const unsigned byte_limit = 9);
@@ -180,7 +207,7 @@ private:
int extractShortAddr(const std::vector<uint8_t> &buffer, const int st_idx, const uint8_t IS, uint32_t &value, int &bits);
// packet processing is table driven.
- typedef void (EtmV4IPktProcImpl::*PPKTFN)(void);
+ typedef void (EtmV4IPktProcImpl::*PPKTFN)(uint8_t);
PPKTFN m_pIPktFn;
struct _pkt_i_table_t {
diff --git a/decoder/source/i_dec/trc_i_decode.cpp b/decoder/source/i_dec/trc_i_decode.cpp
index 47b4867e6c5c..ab93284848bb 100644
--- a/decoder/source/i_dec/trc_i_decode.cpp
+++ b/decoder/source/i_dec/trc_i_decode.cpp
@@ -40,6 +40,8 @@ ocsd_err_t TrcIDecode::DecodeInstruction(ocsd_instr_info *instr_info)
{
ocsd_err_t err = OCSD_OK;
clear_instr_subtype();
+ SetArchVersion(instr_info);
+
switch(instr_info->isa)
{
case ocsd_isa_arm:
@@ -65,6 +67,22 @@ ocsd_err_t TrcIDecode::DecodeInstruction(ocsd_instr_info *instr_info)
return err;
}
+void TrcIDecode::SetArchVersion(ocsd_instr_info *instr_info)
+{
+ uint16_t arch = 0x0700;
+
+ switch (instr_info->pe_type.arch)
+ {
+ case ARCH_V8: arch = 0x0800; break;
+ case ARCH_V8r3: arch = 0x0803; break;
+ case ARCH_V7:
+ default:
+ break;
+ }
+ set_arch_version(arch);
+}
+
+
ocsd_err_t TrcIDecode::DecodeA32(ocsd_instr_info *instr_info)
{
uint32_t branchAddr = 0;
@@ -107,7 +125,13 @@ ocsd_err_t TrcIDecode::DecodeA32(ocsd_instr_info *instr_info)
break;
}
}
-
+ else if (instr_info->wfi_wfe_branch)
+ {
+ if (inst_ARM_wfiwfe(instr_info->opcode))
+ {
+ instr_info->type = OCSD_INSTR_WFI_WFE;
+ }
+ }
instr_info->is_conditional = inst_ARM_is_conditional(instr_info->opcode);
return OCSD_OK;
@@ -123,17 +147,17 @@ ocsd_err_t TrcIDecode::DecodeA64(ocsd_instr_info *instr_info)
instr_info->next_isa = instr_info->isa; // assume same ISA
instr_info->is_link = 0;
- if(inst_A64_is_indirect_branch(instr_info->opcode))
+ if(inst_A64_is_indirect_branch_link(instr_info->opcode, &instr_info->is_link))
{
instr_info->type = OCSD_INSTR_BR_INDIRECT;
- instr_info->is_link = inst_A64_is_branch_and_link(instr_info->opcode);
+// instr_info->is_link = inst_A64_is_branch_and_link(instr_info->opcode);
}
- else if(inst_A64_is_direct_branch(instr_info->opcode))
+ else if(inst_A64_is_direct_branch_link(instr_info->opcode, &instr_info->is_link))
{
inst_A64_branch_destination(instr_info->instr_addr,instr_info->opcode,&branchAddr);
instr_info->type = OCSD_INSTR_BR;
instr_info->branch_addr = (ocsd_vaddr_t)branchAddr;
- instr_info->is_link = inst_A64_is_branch_and_link(instr_info->opcode);
+// instr_info->is_link = inst_A64_is_branch_and_link(instr_info->opcode);
}
else if((barrier = inst_A64_barrier(instr_info->opcode)) != ARM_BARRIER_NONE)
{
@@ -150,6 +174,13 @@ ocsd_err_t TrcIDecode::DecodeA64(ocsd_instr_info *instr_info)
break;
}
}
+ else if (instr_info->wfi_wfe_branch)
+ {
+ if (inst_A64_wfiwfe(instr_info->opcode))
+ {
+ instr_info->type = OCSD_INSTR_WFI_WFE;
+ }
+ }
instr_info->is_conditional = inst_A64_is_conditional(instr_info->opcode);
@@ -172,20 +203,20 @@ ocsd_err_t TrcIDecode::DecodeT32(ocsd_instr_info *instr_info)
instr_info->type = OCSD_INSTR_OTHER; // default type
instr_info->next_isa = instr_info->isa; // assume same ISA
instr_info->is_link = 0;
+ instr_info->is_conditional = 0;
- if(inst_Thumb_is_indirect_branch(instr_info->opcode))
- {
- instr_info->type = OCSD_INSTR_BR_INDIRECT;
- instr_info->is_link = inst_Thumb_is_branch_and_link(instr_info->opcode);
- }
- else if(inst_Thumb_is_direct_branch(instr_info->opcode))
+
+ if(inst_Thumb_is_direct_branch_link(instr_info->opcode,&instr_info->is_link, &instr_info->is_conditional))
{
inst_Thumb_branch_destination((uint32_t)instr_info->instr_addr,instr_info->opcode,&branchAddr);
instr_info->type = OCSD_INSTR_BR;
instr_info->branch_addr = (ocsd_vaddr_t)(branchAddr & ~0x1);
if((branchAddr & 0x1) == 0)
instr_info->next_isa = ocsd_isa_arm;
- instr_info->is_link = inst_Thumb_is_branch_and_link(instr_info->opcode);
+ }
+ else if (inst_Thumb_is_indirect_branch_link(instr_info->opcode, &instr_info->is_link))
+ {
+ instr_info->type = OCSD_INSTR_BR_INDIRECT;
}
else if((barrier = inst_Thumb_barrier(instr_info->opcode)) != ARM_BARRIER_NONE)
{
@@ -202,7 +233,13 @@ ocsd_err_t TrcIDecode::DecodeT32(ocsd_instr_info *instr_info)
break;
}
}
-
+ else if (instr_info->wfi_wfe_branch)
+ {
+ if (inst_Thumb_wfiwfe(instr_info->opcode))
+ {
+ instr_info->type = OCSD_INSTR_WFI_WFE;
+ }
+ }
instr_info->is_conditional = inst_Thumb_is_conditional(instr_info->opcode);
instr_info->thumb_it_conditions = inst_Thumb_is_IT(instr_info->opcode);
diff --git a/decoder/source/i_dec/trc_idec_arminst.cpp b/decoder/source/i_dec/trc_idec_arminst.cpp
index ed7eb247d3be..09964a15e7b3 100644
--- a/decoder/source/i_dec/trc_idec_arminst.cpp
+++ b/decoder/source/i_dec/trc_idec_arminst.cpp
@@ -5,7 +5,6 @@
* \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved.
*/
-
/*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -40,13 +39,15 @@ block identification and trace decode.
#include "i_dec/trc_idec_arminst.h"
-
#include <stddef.h> /* for NULL */
#include <assert.h>
static ocsd_instr_subtype instr_sub_type = OCSD_S_INSTR_NONE;
+/* need to spot the architecture version for certain instructions */
+static uint16_t arch_version = 0x70;
+
ocsd_instr_subtype get_instr_subtype()
{
return instr_sub_type;
@@ -57,6 +58,11 @@ void clear_instr_subtype()
instr_sub_type = OCSD_S_INSTR_NONE;
}
+void set_arch_version(uint16_t version)
+{
+ arch_version = version;
+}
+
int inst_ARM_is_direct_branch(uint32_t inst)
{
int is_direct_branch = 1;
@@ -75,6 +81,15 @@ int inst_ARM_is_direct_branch(uint32_t inst)
return is_direct_branch;
}
+int inst_ARM_wfiwfe(uint32_t inst)
+{
+ if ( ((inst & 0xf0000000) != 0xf0000000) &&
+ ((inst & 0x0ffffffe) == 0x0320f002)
+ )
+ /* WFI & WFE may be traced as branches in etm4.3 ++ */
+ return 1;
+ return 0;
+}
int inst_ARM_is_indirect_branch(uint32_t inst)
{
@@ -88,14 +103,24 @@ int inst_ARM_is_indirect_branch(uint32_t inst)
}
} else if ((inst & 0x0ff000d0) == 0x01200010) {
/* BLX (register), BX */
+ if ((inst & 0xFF) == 0x1E)
+ instr_sub_type = OCSD_S_INSTR_V7_IMPLIED_RET; /* BX LR */
+ } else if ((inst & 0x0ff000f0) == 0x01200020) {
+ /* BXJ: in v8 this behaves like BX */
} else if ((inst & 0x0e108000) == 0x08108000) {
/* POP {...,pc} or LDMxx {...,pc} */
+ if ((inst & 0x0FFFA000) == 0x08BD8000) /* LDMIA SP!,{...,pc} */
+ instr_sub_type = OCSD_S_INSTR_V7_IMPLIED_RET;
} else if ((inst & 0x0e50f000) == 0x0410f000) {
/* LDR PC,imm... inc. POP {PC} */
+ if ( (inst & 0x01ff0000) == 0x009D0000)
+ instr_sub_type = OCSD_S_INSTR_V7_IMPLIED_RET; /* LDR PC, [SP], #imm */
} else if ((inst & 0x0e50f010) == 0x0610f000) {
/* LDR PC,reg */
} else if ((inst & 0x0fe0f000) == 0x01a0f000) {
/* MOV PC,rx */
+ if ((inst & 0x00100FFF) == 0x00E) /* ensure the S=0, LSL #0 variant - i.e plain MOV */
+ instr_sub_type = OCSD_S_INSTR_V7_IMPLIED_RET; /* MOV PC, R14 */
} else if ((inst & 0x0f900080) == 0x01000000) {
/* "Miscellaneous instructions" - in DP space */
is_indirect_branch = 0;
@@ -119,39 +144,88 @@ int inst_ARM_is_indirect_branch(uint32_t inst)
return is_indirect_branch;
}
-
int inst_Thumb_is_direct_branch(uint32_t inst)
{
+ uint8_t link, cond;
+ return inst_Thumb_is_direct_branch_link(inst, &link, &cond);
+}
+
+int inst_Thumb_is_direct_branch_link(uint32_t inst, uint8_t *is_link, uint8_t *is_cond)
+{
int is_direct_branch = 1;
+
if ((inst & 0xf0000000) == 0xd0000000 && (inst & 0x0e000000) != 0x0e000000) {
/* B<c> (encoding T1) */
+ *is_cond = 1;
} else if ((inst & 0xf8000000) == 0xe0000000) {
/* B (encoding T2) */
} else if ((inst & 0xf800d000) == 0xf0008000 && (inst & 0x03800000) != 0x03800000) {
/* B (encoding T3) */
+ *is_cond = 1;
} else if ((inst & 0xf8009000) == 0xf0009000) {
/* B (encoding T4); BL (encoding T1) */
+ if (inst & 0x00004000) {
+ *is_link = 1;
+ instr_sub_type = OCSD_S_INSTR_BR_LINK;
+ }
} else if ((inst & 0xf800d001) == 0xf000c000) {
/* BLX (imm) (encoding T2) */
+ *is_link = 1;
+ instr_sub_type = OCSD_S_INSTR_BR_LINK;
} else if ((inst & 0xf5000000) == 0xb1000000) {
/* CB(NZ) */
+ *is_cond = 1;
} else {
is_direct_branch = 0;
}
return is_direct_branch;
}
+int inst_Thumb_wfiwfe(uint32_t inst)
+{
+ int is_wfiwfe = 1;
+ /* WFI, WFE may be branches in etm4.3++ */
+ if ((inst & 0xfffffffe) == 0xf3af8002) {
+ /* WFI & WFE (encoding T2) */
+ }
+ else if ((inst & 0xffef0000) == 0xbf200000) {
+ /* WFI & WFE (encoding T1) */
+ }
+ else {
+ is_wfiwfe = 0;
+ }
+ return is_wfiwfe;
+}
int inst_Thumb_is_indirect_branch(uint32_t inst)
{
+ uint8_t link;
+ return inst_Thumb_is_indirect_branch_link(inst, &link);
+}
+
+int inst_Thumb_is_indirect_branch_link(uint32_t inst, uint8_t *is_link)
+{
/* See e.g. PFT Table 2-3 and Table 2-5 */
int is_branch = 1;
+
if ((inst & 0xff000000) == 0x47000000) {
- /* BX, BLX (reg) */
+ /* BX, BLX (reg) [v8M includes BXNS, BLXNS] */
+ if (inst & 0x00800000) {
+ *is_link = 1;
+ instr_sub_type = OCSD_S_INSTR_BR_LINK;
+ }
+ else if ((inst & 0x00780000) == 0x00700000) {
+ instr_sub_type = OCSD_S_INSTR_V7_IMPLIED_RET; /* BX LR */
+ }
+ } else if ((inst & 0xfff0d000) == 0xf3c08000) {
+ /* BXJ: in v8 this behaves like BX */
} else if ((inst & 0xff000000) == 0xbd000000) {
/* POP {pc} */
+ instr_sub_type = OCSD_S_INSTR_V7_IMPLIED_RET;
} else if ((inst & 0xfd870000) == 0x44870000) {
/* MOV PC,reg or ADD PC,reg */
+ if ((inst & 0xffff0000) == 0x46f700000)
+ instr_sub_type = OCSD_S_INSTR_V7_IMPLIED_RET; /* MOV PC,LR */
} else if ((inst & 0xfff0ffe0) == 0xe8d0f000) {
/* TBB/TBH */
} else if ((inst & 0xffd00000) == 0xe8100000) {
@@ -166,19 +240,28 @@ int inst_Thumb_is_indirect_branch(uint32_t inst)
/* LDR PC,literal (T2) */
} else if ((inst & 0xfff0f800) == 0xf850f800) {
/* LDR PC,imm (T4) */
+ if((inst & 0x000f0f00) == 0x000d0b00)
+ instr_sub_type = OCSD_S_INSTR_V7_IMPLIED_RET; /* LDR PC, [SP], #imm*/
} else if ((inst & 0xfff0ffc0) == 0xf850f000) {
/* LDR PC,reg (T2) */
} else if ((inst & 0xfe508000) == 0xe8108000) {
/* LDM PC */
+ if ((inst & 0x0FFF0000) == 0x08BD0000) /* LDMIA [SP]!, */
+ instr_sub_type = OCSD_S_INSTR_V7_IMPLIED_RET; /* POP {...,pc} */
} else {
is_branch = 0;
}
return is_branch;
}
-
int inst_A64_is_direct_branch(uint32_t inst)
{
+ uint8_t link = 0;
+ return inst_A64_is_direct_branch_link(inst, &link);
+}
+
+int inst_A64_is_direct_branch_link(uint32_t inst, uint8_t *is_link)
+{
int is_direct_branch = 1;
if ((inst & 0x7c000000) == 0x34000000) {
/* CB, TB */
@@ -186,31 +269,75 @@ int inst_A64_is_direct_branch(uint32_t inst)
/* B<cond> */
} else if ((inst & 0x7c000000) == 0x14000000) {
/* B, BL imm */
+ if (inst & 0x80000000) {
+ *is_link = 1;
+ instr_sub_type = OCSD_S_INSTR_BR_LINK;
+ }
} else {
is_direct_branch = 0;
}
return is_direct_branch;
}
+int inst_A64_wfiwfe(uint32_t inst)
+{
+ /* WFI, WFE may be traced as branches in etm 4.3++ */
+ if ((inst & 0xffffffdf) == 0xd503205f)
+ return 1;
+ return 0;
+}
int inst_A64_is_indirect_branch(uint32_t inst)
{
+ uint8_t link = 0;
+ return inst_A64_is_indirect_branch_link(inst, &link);
+}
+
+int inst_A64_is_indirect_branch_link(uint32_t inst, uint8_t *is_link)
+{
int is_indirect_branch = 1;
+
if ((inst & 0xffdffc1f) == 0xd61f0000) {
/* BR, BLR */
+ if (inst & 0x00200000) {
+ *is_link = 1;
+ instr_sub_type = OCSD_S_INSTR_BR_LINK;
+ }
} else if ((inst & 0xfffffc1f) == 0xd65f0000) {
instr_sub_type = OCSD_S_INSTR_V8_RET;
/* RET */
} else if ((inst & 0xffffffff) == 0xd69f03e0) {
/* ERET */
instr_sub_type = OCSD_S_INSTR_V8_ERET;
+ } else if (arch_version >= 0x0803) {
+ /* new pointer auth instr for v8.3 arch */
+ if ((inst & 0xffdff800) == 0xd61f0800) {
+ /* BRAA, BRAB, BLRAA, BLRBB */
+ if (inst & 0x00200000) {
+ *is_link = 1;
+ instr_sub_type = OCSD_S_INSTR_BR_LINK;
+ }
+ } else if ((inst & 0xffdff81F) == 0xd71f081F) {
+ /* BRAAZ, BRABZ, BLRAAZ, BLRBBZ */
+ if (inst & 0x00200000) {
+ *is_link = 1;
+ instr_sub_type = OCSD_S_INSTR_BR_LINK;
+ }
+ } else if ((inst & 0xfffffbff) == 0xd69f0bff) {
+ /* ERETAA, ERETAB */
+ instr_sub_type = OCSD_S_INSTR_V8_ERET;
+ } else if ((inst & 0xfffffbff) == 0xd65f0bff) {
+ /* RETAA, RETAB */
+ instr_sub_type = OCSD_S_INSTR_V8_RET;
+ } else {
+ is_indirect_branch = 0;
+ }
} else {
is_indirect_branch = 0;
}
return is_indirect_branch;
}
-
int inst_ARM_branch_destination(uint32_t addr, uint32_t inst, uint32_t *pnpc)
{
uint32_t npc;
@@ -235,7 +362,6 @@ int inst_ARM_branch_destination(uint32_t addr, uint32_t inst, uint32_t *pnpc)
return is_direct_branch;
}
-
int inst_Thumb_branch_destination(uint32_t addr, uint32_t inst, uint32_t *pnpc)
{
uint32_t npc;
@@ -290,7 +416,6 @@ int inst_Thumb_branch_destination(uint32_t addr, uint32_t inst, uint32_t *pnpc)
return is_direct_branch;
}
-
int inst_A64_branch_destination(uint64_t addr, uint32_t inst, uint64_t *pnpc)
{
uint64_t npc;
@@ -322,21 +447,18 @@ int inst_ARM_is_branch(uint32_t inst)
inst_ARM_is_direct_branch(inst);
}
-
int inst_Thumb_is_branch(uint32_t inst)
{
return inst_Thumb_is_indirect_branch(inst) ||
inst_Thumb_is_direct_branch(inst);
}
-
int inst_A64_is_branch(uint32_t inst)
{
return inst_A64_is_indirect_branch(inst) ||
inst_A64_is_direct_branch(inst);
}
-
int inst_ARM_is_branch_and_link(uint32_t inst)
{
int is_branch = 1;
@@ -359,7 +481,6 @@ int inst_ARM_is_branch_and_link(uint32_t inst)
return is_branch;
}
-
int inst_Thumb_is_branch_and_link(uint32_t inst)
{
int is_branch = 1;
@@ -375,7 +496,6 @@ int inst_Thumb_is_branch_and_link(uint32_t inst)
return is_branch;
}
-
int inst_A64_is_branch_and_link(uint32_t inst)
{
int is_branch = 1;
@@ -385,19 +505,28 @@ int inst_A64_is_branch_and_link(uint32_t inst)
} else if ((inst & 0xfc000000) == 0x94000000) {
/* BL */
instr_sub_type = OCSD_S_INSTR_BR_LINK;
+ } else if (arch_version >= 0x0803) {
+ /* new pointer auth instr for v8.3 arch */
+ if ((inst & 0xfffff800) == 0xd73f0800) {
+ /* BLRAA, BLRBB */
+ instr_sub_type = OCSD_S_INSTR_BR_LINK;
+ } else if ((inst & 0xfffff81F) == 0xd63f081F) {
+ /* BLRAAZ, BLRBBZ */
+ instr_sub_type = OCSD_S_INSTR_BR_LINK;
+ } else {
+ is_branch = 0;
+ }
} else {
is_branch = 0;
}
return is_branch;
}
-
int inst_ARM_is_conditional(uint32_t inst)
{
return (inst & 0xe0000000) != 0xe0000000;
}
-
int inst_Thumb_is_conditional(uint32_t inst)
{
if ((inst & 0xf0000000) == 0xd0000000 && (inst & 0x0e000000) != 0x0e000000) {
@@ -413,7 +542,6 @@ int inst_Thumb_is_conditional(uint32_t inst)
return 0;
}
-
unsigned int inst_Thumb_is_IT(uint32_t inst)
{
if ((inst & 0xff000000) == 0xbf000000 &&
@@ -433,7 +561,6 @@ unsigned int inst_Thumb_is_IT(uint32_t inst)
}
}
-
/*
Test whether an A64 instruction is conditional.
@@ -454,7 +581,6 @@ int inst_A64_is_conditional(uint32_t inst)
return 0;
}
-
arm_barrier_t inst_ARM_barrier(uint32_t inst)
{
if ((inst & 0xfff00000) == 0xf5700000) {
@@ -484,7 +610,6 @@ arm_barrier_t inst_ARM_barrier(uint32_t inst)
}
}
-
arm_barrier_t inst_Thumb_barrier(uint32_t inst)
{
if ((inst & 0xffffff00) == 0xf3bf8f00) {
@@ -516,7 +641,6 @@ arm_barrier_t inst_Thumb_barrier(uint32_t inst)
}
}
-
arm_barrier_t inst_A64_barrier(uint32_t inst)
{
if ((inst & 0xfffff09f) == 0xd503309f) {
@@ -535,20 +659,17 @@ arm_barrier_t inst_A64_barrier(uint32_t inst)
}
}
-
int inst_ARM_is_UDF(uint32_t inst)
{
return (inst & 0xfff000f0) == 0xe7f000f0;
}
-
int inst_Thumb_is_UDF(uint32_t inst)
{
return (inst & 0xff000000) == 0xde000000 || /* T1 */
(inst & 0xfff0f000) == 0xf7f0a000; /* T2 */
}
-
int inst_A64_is_UDF(uint32_t inst)
{
/* No A64 encodings are formally allocated as permanently undefined,
diff --git a/decoder/source/mem_acc/trc_mem_acc_bufptr.cpp b/decoder/source/mem_acc/trc_mem_acc_bufptr.cpp
index fee663b30d06..25c736387c0b 100644
--- a/decoder/source/mem_acc/trc_mem_acc_bufptr.cpp
+++ b/decoder/source/mem_acc/trc_mem_acc_bufptr.cpp
@@ -42,7 +42,7 @@ TrcMemAccBufPtr::TrcMemAccBufPtr(const ocsd_vaddr_t s_address, const uint8_t *p_
{
}
-const uint32_t TrcMemAccBufPtr::readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint32_t reqBytes, uint8_t *byteBuffer)
+const uint32_t TrcMemAccBufPtr::readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer)
{
// mapper wlll filter memory spaces.
uint32_t bytesRead = bytesInRange(address,reqBytes); // check bytes available
diff --git a/decoder/source/mem_acc/trc_mem_acc_cache.cpp b/decoder/source/mem_acc/trc_mem_acc_cache.cpp
new file mode 100644
index 000000000000..444314ee9da6
--- /dev/null
+++ b/decoder/source/mem_acc/trc_mem_acc_cache.cpp
@@ -0,0 +1,176 @@
+/*!
+* \file trc_mem_acc_cache.cpp
+* \brief OpenCSD : Memory accessor cache.
+*
+* \copyright Copyright (c) 2018, ARM Limited. All Rights Reserved.
+*/
+
+/*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice,
+* this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software without
+* specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
+* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <cstring>
+#include <sstream>
+#include <iomanip>
+#include "mem_acc/trc_mem_acc_cache.h"
+#include "mem_acc/trc_mem_acc_base.h"
+#include "interfaces/trc_error_log_i.h"
+
+#ifdef LOG_CACHE_STATS
+#define INC_HITS_RL(idx) m_hits++; m_hit_rl[m_mru_idx]++;
+#define INC_MISS() m_misses++;
+#define INC_PAGES() m_pages++;
+#define SET_MAX_RL(idx) \
+ { \
+ if (m_hit_rl_max[idx] < m_hit_rl[idx]) \
+ m_hit_rl_max[idx] = m_hit_rl[idx]; \
+ m_hit_rl[idx] = 0; \
+ }
+#define INC_RL(idx) m_hit_rl[m_mru_idx]++;
+#else
+#define INC_HITS_RL(idx)
+#define INC_MISS()
+#define INC_PAGES()
+#define SET_MAX_RL(idx)
+#define INC_RL(idx)
+#endif
+
+// uncomment to log cache ops
+//#define LOG_CACHE_OPS
+
+ocsd_err_t TrcMemAccCache::readBytesFromCache(TrcMemAccessorBase *p_accessor, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t trcID, uint32_t *numBytes, uint8_t *byteBuffer)
+{
+ uint32_t bytesRead = 0, reqBytes = *numBytes;
+ ocsd_err_t err = OCSD_OK;
+
+#ifdef LOG_CACHE_OPS
+ std::ostringstream oss;
+#endif
+
+ if (m_bCacheEnabled)
+ {
+ if (blockInCache(address, reqBytes))
+ {
+ bytesRead = reqBytes;
+ memcpy(byteBuffer, &m_mru[m_mru_idx].data[address - m_mru[m_mru_idx].st_addr], reqBytes);
+#ifdef LOG_CACHE_OPS
+ oss << "TrcMemAccCache:: hit [page: " << std::dec << m_mru_idx << "[addr:0x" << std::hex << address << ", bytes: " << std::dec << reqBytes << "]\n";
+ logMsg(oss.str());
+#endif
+ INC_HITS_RL(m_mru_idx);
+ }
+ else
+ {
+ INC_MISS();
+#ifdef LOG_CACHE_OPS
+ oss << "TrcMemAccCache:: miss [addr:0x" << std::hex << address << ", bytes: " << std::dec << reqBytes << "]\n";
+ logMsg(oss.str());
+#endif
+ /* need a new cache page - check the underlying accessor for the data */
+ m_mru_idx = m_mru_next_new;
+ m_mru[m_mru_idx].valid_len = p_accessor->readBytes(address, mem_space, trcID, MEM_ACC_CACHE_PAGE_SIZE, &m_mru[m_mru_idx].data[0]);
+
+ /* check return length valid - v bad if return length more than request */
+ if (m_mru[m_mru_idx].valid_len > MEM_ACC_CACHE_PAGE_SIZE)
+ {
+ m_mru[m_mru_idx].valid_len = 0; // set to nothing returned.
+ err = OCSD_ERR_MEM_ACC_BAD_LEN;
+ }
+
+ if (m_mru[m_mru_idx].valid_len > 0)
+ {
+ // got some data - so save the
+ m_mru[m_mru_idx].st_addr = address;
+
+ // log the run length hit counts
+ SET_MAX_RL(m_mru_idx);
+
+#ifdef LOG_CACHE_OPS
+ oss.str("");
+ oss << "TrcMemAccCache:: load [page: " << std::dec << m_mru_idx << "[addr:0x" << std::hex << address << ", bytes: " << std::dec << m_mru[m_mru_idx].valid_len << "]\n";
+ logMsg(oss.str());
+#endif
+ INC_PAGES();
+
+ // increment the next new page counter.
+ m_mru_next_new++;
+ if (m_mru_next_new == MEM_ACC_CACHE_MRU_SIZE)
+ m_mru_next_new = 0;
+
+ if (blockInPage(address, reqBytes)) /* check we got the data we needed */
+ {
+ bytesRead = reqBytes;
+ memcpy(byteBuffer, &m_mru[m_mru_idx].data[address - m_mru[m_mru_idx].st_addr], reqBytes);
+ INC_RL(m_mru_idx);
+ }
+ else
+ {
+#ifdef LOG_CACHE_OPS
+ oss.str("");
+ oss << "TrcMemAccCache:: miss-after-load [page: " << std::dec << m_mru_idx << "[addr:0x" << std::hex << address << ", bytes: " << std::dec << m_mru[m_mru_idx].valid_len << "]\n";
+ logMsg(oss.str());
+#endif
+ INC_MISS();
+ }
+ }
+ }
+ }
+ *numBytes = bytesRead;
+ return err;
+}
+
+void TrcMemAccCache::logMsg(const std::string &szMsg)
+{
+ if (m_err_log)
+ m_err_log->LogMessage(ITraceErrorLog::HANDLE_GEN_INFO, OCSD_ERR_SEV_INFO, szMsg);
+}
+
+void TrcMemAccCache::setErrorLog(ITraceErrorLog *log)
+{
+ m_err_log = log;
+}
+
+void TrcMemAccCache::logAndClearCounts()
+{
+#ifdef LOG_CACHE_STATS
+ std::ostringstream oss;
+
+ oss << "TrcMemAccCache:: cache performance: hits(" << std::dec << m_hits << "), miss(" << m_misses << "), pages(" << m_pages << ")\n";
+ logMsg(oss.str());
+ for (int i = 0; i < MEM_ACC_CACHE_MRU_SIZE; i++)
+ {
+ if (m_hit_rl_max[i] < m_hit_rl[i])
+ m_hit_rl_max[i] = m_hit_rl[i];
+ oss.str("");
+ oss << "Run length max page " << std::dec << i << ": " << m_hit_rl_max[i] << "\n";
+ logMsg(oss.str());
+ }
+ m_hits = m_misses = m_pages = 0;
+#endif
+}
+
+
+/* End of File trc_mem_acc_cache.cpp */
diff --git a/decoder/source/mem_acc/trc_mem_acc_cb.cpp b/decoder/source/mem_acc/trc_mem_acc_cb.cpp
index 28dedcb0fba6..1a1565bff038 100644
--- a/decoder/source/mem_acc/trc_mem_acc_cb.cpp
+++ b/decoder/source/mem_acc/trc_mem_acc_cb.cpp
@@ -19,13 +19,15 @@ TrcMemAccCB::TrcMemAccCB(const ocsd_vaddr_t s_address,
}
/** Memory access override - allow decoder to read bytes from the buffer. */
-const uint32_t TrcMemAccCB::readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint32_t reqBytes, uint8_t *byteBuffer)
+const uint32_t TrcMemAccCB::readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer)
{
// if we have a callback object, use it to call back.
if(m_p_CBclass)
return m_p_CBclass->readBytes(address,memSpace,reqBytes,byteBuffer);
if(m_p_CBfn)
return m_p_CBfn(m_p_cbfn_context, address,memSpace,reqBytes,byteBuffer);
+ if (m_p_CBIDfn)
+ return m_p_CBIDfn(m_p_cbfn_context, address, memSpace, trcID, reqBytes, byteBuffer);
return 0;
}
diff --git a/decoder/source/mem_acc/trc_mem_acc_file.cpp b/decoder/source/mem_acc/trc_mem_acc_file.cpp
index 87901c83dcee..25b718ea589c 100644
--- a/decoder/source/mem_acc/trc_mem_acc_file.cpp
+++ b/decoder/source/mem_acc/trc_mem_acc_file.cpp
@@ -199,7 +199,7 @@ TrcMemAccessorFile * TrcMemAccessorFile::getExistingFileAccessor(const std::stri
/***************************************************/
/* accessor instance functions */
/***************************************************/
-const uint32_t TrcMemAccessorFile::readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint32_t reqBytes, uint8_t *byteBuffer)
+const uint32_t TrcMemAccessorFile::readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer)
{
if(!m_mem_file.is_open())
return 0;
diff --git a/decoder/source/mem_acc/trc_mem_acc_mapper.cpp b/decoder/source/mem_acc/trc_mem_acc_mapper.cpp
index 6d4f085c6fa0..53edfe1a1616 100644
--- a/decoder/source/mem_acc/trc_mem_acc_mapper.cpp
+++ b/decoder/source/mem_acc/trc_mem_acc_mapper.cpp
@@ -34,17 +34,23 @@
#include "mem_acc/trc_mem_acc_mapper.h"
#include "mem_acc/trc_mem_acc_file.h"
+#include "common/ocsd_error.h"
/************************************************************************************/
/* mappers base class */
/************************************************************************************/
+#define USING_MEM_ACC_CACHE
+
TrcMemAccMapper::TrcMemAccMapper() :
m_acc_curr(0),
m_trace_id_curr(0),
m_using_trace_id(false),
m_err_log(0)
{
+#ifdef USING_MEM_ACC_CACHE
+ m_cache.enableCaching(true);
+#endif
}
TrcMemAccMapper::TrcMemAccMapper(bool using_trace_id) :
@@ -53,27 +59,64 @@ TrcMemAccMapper::TrcMemAccMapper(bool using_trace_id) :
m_using_trace_id(using_trace_id),
m_err_log(0)
{
+#ifdef USING_MEM_ACC_CACHE
+ m_cache.enableCaching(true);
+#endif
}
TrcMemAccMapper::~TrcMemAccMapper()
{
}
+void TrcMemAccMapper::setErrorLog(ITraceErrorLog *err_log_i)
+{
+ m_err_log = err_log_i;
+ m_cache.setErrorLog(err_log_i);
+}
+
// memory access interface
ocsd_err_t TrcMemAccMapper::ReadTargetMemory(const ocsd_vaddr_t address, const uint8_t cs_trace_id, const ocsd_mem_space_acc_t mem_space, uint32_t *num_bytes, uint8_t *p_buffer)
{
bool bReadFromCurr = true;
+ uint32_t readBytes = 0;
+ ocsd_err_t err = OCSD_OK;
/* see if the address is in any range we know */
- if(!readFromCurrent(address, mem_space, cs_trace_id))
- bReadFromCurr = findAccessor(address, mem_space, cs_trace_id);
+ if (!readFromCurrent(address, mem_space, cs_trace_id))
+ {
+ bReadFromCurr = findAccessor(address, mem_space, cs_trace_id);
+
+ // found a new accessor - invalidate any cache entries used by the previous one.
+ if (m_cache.enabled() && bReadFromCurr)
+ m_cache.invalidateAll();
+ }
/* if bReadFromCurr then we know m_acc_curr is set */
- if(bReadFromCurr)
- *num_bytes = m_acc_curr->readBytes(address, mem_space, *num_bytes,p_buffer);
- else
- *num_bytes = 0;
- return OCSD_OK;
+ if (bReadFromCurr)
+ {
+ // use cache if enabled and the amount fits into a cache page
+ if (m_cache.enabled_for_size(*num_bytes))
+ {
+ // read from cache - or load a new cache page and read....
+ readBytes = *num_bytes;
+ err = m_cache.readBytesFromCache(m_acc_curr, address, mem_space, cs_trace_id, &readBytes, p_buffer);
+ if (err != OCSD_OK)
+ LogWarn(err, "Mem Acc: Cache access error");
+ }
+ else
+ {
+ readBytes = m_acc_curr->readBytes(address, mem_space, cs_trace_id, *num_bytes, p_buffer);
+ // guard against bad accessor returns (e.g. callback not obeying the rules for return values)
+ if (readBytes > *num_bytes)
+ {
+ err = OCSD_ERR_MEM_ACC_BAD_LEN;
+ LogWarn(err,"Mem acc: bad return length");
+ }
+ }
+ }
+
+ *num_bytes = readBytes;
+ return err;
}
void TrcMemAccMapper::RemoveAllAccessors()
@@ -84,8 +127,12 @@ void TrcMemAccMapper::RemoveAllAccessors()
{
TrcMemAccFactory::DestroyAccessor(pAcc);
pAcc = getNextAccessor();
+ if (m_cache.enabled())
+ m_cache.invalidateAll();
}
clearAccessorList();
+ if (m_cache.enabled())
+ m_cache.logAndClearCounts();
}
ocsd_err_t TrcMemAccMapper::RemoveAccessorByAddress(const ocsd_vaddr_t st_address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id /* = 0 */)
@@ -95,9 +142,13 @@ ocsd_err_t TrcMemAccMapper::RemoveAccessorByAddress(const ocsd_vaddr_t st_addres
{
err = RemoveAccessor(m_acc_curr);
m_acc_curr = 0;
+ if (m_cache.enabled())
+ m_cache.invalidateAll();
}
else
err = OCSD_ERR_INVALID_PARAM_VAL;
+ if (m_cache.enabled())
+ m_cache.logAndClearCounts();
return err;
}
@@ -107,6 +158,16 @@ void TrcMemAccMapper::LogMessage(const std::string &msg)
m_err_log->LogMessage(ITraceErrorLog::HANDLE_GEN_INFO,OCSD_ERR_SEV_INFO,msg);
}
+void TrcMemAccMapper::LogWarn(const ocsd_err_t err, const std::string &msg)
+{
+ if (m_err_log)
+ {
+ ocsdError err_ocsd(OCSD_ERR_SEV_WARN,err,msg);
+ m_err_log->LogError(ITraceErrorLog::HANDLE_GEN_INFO, &err_ocsd);
+ }
+}
+
+
/************************************************************************************/
/* mappers global address space class - no differentiation in core trace IDs */
/************************************************************************************/
diff --git a/decoder/source/ocsd_code_follower.cpp b/decoder/source/ocsd_code_follower.cpp
index 229859e4733a..4386eb4c1d93 100644
--- a/decoder/source/ocsd_code_follower.cpp
+++ b/decoder/source/ocsd_code_follower.cpp
@@ -41,6 +41,7 @@ OcsdCodeFollower::OcsdCodeFollower()
m_instr_info.pe_type.profile = profile_Unknown;
m_instr_info.isa = ocsd_isa_unknown;
m_instr_info.dsb_dmb_waypoints = 0;
+ m_instr_info.wfi_wfe_branch = 0;
m_instr_info.instr_addr = 0;
m_instr_info.opcode = 0;
m_pMemAccess = 0;
diff --git a/decoder/source/ocsd_dcd_tree.cpp b/decoder/source/ocsd_dcd_tree.cpp
index 0cce1340c759..cf75e569d72a 100644
--- a/decoder/source/ocsd_dcd_tree.cpp
+++ b/decoder/source/ocsd_dcd_tree.cpp
@@ -105,6 +105,7 @@ DecodeTree::DecodeTree() :
DecodeTree::~DecodeTree()
{
+ destroyMemAccMapper();
for(uint8_t i = 0; i < 0x80; i++)
{
destroyDecodeElement(i);
@@ -314,7 +315,36 @@ ocsd_err_t DecodeTree::addBinFileRegionMemAcc(const ocsd_file_mem_region_t *regi
return err;
}
-ocsd_err_t DecodeTree::addCallbackMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAcc_CB p_cb_func, const void *p_context)
+ocsd_err_t DecodeTree::updateBinFileRegionMemAcc(const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const std::string &filepath)
+{
+ if (!hasMemAccMapper())
+ return OCSD_ERR_NOT_INIT;
+
+ if ((region_array == 0) || (num_regions == 0) || (filepath.length() == 0))
+ return OCSD_ERR_INVALID_PARAM_VAL;
+
+ TrcMemAccessorFile *pAcc = TrcMemAccessorFile::getExistingFileAccessor(filepath);
+ if (!pAcc)
+ return OCSD_ERR_INVALID_PARAM_VAL;
+
+ int curr_region_idx = 0;
+ while (curr_region_idx < num_regions)
+ {
+ // check "new" range
+ if (!pAcc->addrStartOfRange(region_array[curr_region_idx].start_address))
+ {
+ // ensure adds cleanly
+ if (!pAcc->AddOffsetRange(region_array[curr_region_idx].start_address,
+ region_array[curr_region_idx].region_size,
+ region_array[curr_region_idx].file_offset))
+ return OCSD_ERR_INVALID_PARAM_VAL; // otherwise bail out
+ }
+ curr_region_idx++;
+ }
+ return OCSD_OK;
+}
+ocsd_err_t DecodeTree::initCallbackMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address,
+ const ocsd_mem_space_acc_t mem_space, void *p_cb_func, bool IDfn, const void *p_context)
{
if(!hasMemAccMapper())
return OCSD_ERR_NOT_INIT;
@@ -329,7 +359,11 @@ ocsd_err_t DecodeTree::addCallbackMemAcc(const ocsd_vaddr_t st_address, const oc
TrcMemAccCB *pCBAcc = dynamic_cast<TrcMemAccCB *>(p_accessor);
if(pCBAcc)
{
- pCBAcc->setCBIfFn(p_cb_func, p_context);
+ if (IDfn)
+ pCBAcc->setCBIDIfFn((Fn_MemAccID_CB)p_cb_func, p_context);
+ else
+ pCBAcc->setCBIfFn((Fn_MemAcc_CB)p_cb_func, p_context);
+
err = m_default_mapper->AddAccessor(p_accessor,0);
}
else
@@ -341,6 +375,16 @@ ocsd_err_t DecodeTree::addCallbackMemAcc(const ocsd_vaddr_t st_address, const oc
return err;
}
+ocsd_err_t DecodeTree::addCallbackMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAcc_CB p_cb_func, const void *p_context)
+{
+ return initCallbackMemAcc(st_address, en_address, mem_space, (void *)p_cb_func, false, p_context);
+}
+
+ocsd_err_t DecodeTree::addCallbackIDMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAccID_CB p_cb_func, const void *p_context)
+{
+ return initCallbackMemAcc(st_address, en_address, mem_space, (void *)p_cb_func, true, p_context);
+}
+
ocsd_err_t DecodeTree::removeMemAccByAddress(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space)
{
if(!hasMemAccMapper())
diff --git a/decoder/source/ocsd_error.cpp b/decoder/source/ocsd_error.cpp
index cd417a2212c9..251964b7a4b0 100644
--- a/decoder/source/ocsd_error.cpp
+++ b/decoder/source/ocsd_error.cpp
@@ -61,6 +61,7 @@ static const char *s_errorCodeDescs[][2] = {
{"OCSD_ERR_DATA_DECODE_FATAL", "A decoder in the data path has returned a fatal error."},
/* frame deformatter errors */
{"OCSD_ERR_DFMTR_NOTCONTTRACE", "Trace input to deformatter none-continuous"},
+ {"OCSD_ERR_DFMTR_BAD_FHSYNC", "Bad frame or half frame sync in trace deformatter"},
/* packet processor errors - protocol issues etc */
{"OCSD_ERR_BAD_PACKET_SEQ","Bad packet sequence"},
{"OCSD_ERR_INVALID_PCKT_HDR","Invalid packet header"},
@@ -79,6 +80,7 @@ static const char *s_errorCodeDescs[][2] = {
{"OCSD_ERR_MEM_ACC_OVERLAP","Attempted to set an overlapping range in memory access map."},
{"OCSD_ERR_MEM_ACC_FILE_NOT_FOUND","Memory access file could not be opened."},
{"OCSD_ERR_MEM_ACC_FILE_DIFF_RANGE","Attempt to re-use the same memory access file for a different address range."},
+ {"OCSD_ERR_MEM_ACC_BAD_LEN","Memory accessor returned a bad read length value (larger than requested."},
{"OCSD_ERR_MEM_ACC_RANGE_INVALID","Address range in accessor set to invalid values."},
/* test errors - errors generated only by the test code, not the library */
{"OCSD_ERR_TEST_SNAPSHOT_PARSE", "Test snapshot file parse error"},
@@ -90,7 +92,7 @@ static const char *s_errorCodeDescs[][2] = {
{"OCSD_ERR_DCDREG_NAME_UNKNOWN","Attempted to find a decoder with a name that is not known in the library."},
{"OCSD_ERR_DCDREG_TYPE_UNKNOWN","Attempted to find a decoder with a type that is not known in the library."},
/* decoder config */
- {"OCSD_ERR_DCD_INTERFACE_UNUSED","Attempt to connect or use and inteface not supported by this decoder."},
+ {"OCSD_ERR_DCD_INTERFACE_UNUSED","Attempt to connect or use and interface not supported by this decoder."},
/* end marker*/
{"OCSD_ERR_LAST", "No error - error code end marker"}
};
diff --git a/decoder/source/ocsd_error_logger.cpp b/decoder/source/ocsd_error_logger.cpp
index 2b109d605b05..42794a784311 100644
--- a/decoder/source/ocsd_error_logger.cpp
+++ b/decoder/source/ocsd_error_logger.cpp
@@ -35,7 +35,7 @@
#include "common/ocsd_error_logger.h"
-#include <iostream>
+//#include <iostream>
#include <sstream>
ocsdDefaultErrorLogger::ocsdDefaultErrorLogger() :
diff --git a/decoder/source/ocsd_version.cpp b/decoder/source/ocsd_version.cpp
index 33990a02c999..6dd3f2c7069e 100644
--- a/decoder/source/ocsd_version.cpp
+++ b/decoder/source/ocsd_version.cpp
@@ -32,7 +32,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "ocsd_if_version.h"
+#include "opencsd/ocsd_if_version.h"
#include "common/ocsd_version.h"
const uint32_t ocsdVersion::vers_num()
diff --git a/decoder/source/ptm/trc_pkt_decode_ptm.cpp b/decoder/source/ptm/trc_pkt_decode_ptm.cpp
index aa426889fd52..94ed5acc243a 100644
--- a/decoder/source/ptm/trc_pkt_decode_ptm.cpp
+++ b/decoder/source/ptm/trc_pkt_decode_ptm.cpp
@@ -179,6 +179,7 @@ ocsd_err_t TrcPktDecodePtm::onProtocolConfig()
m_instr_info.pe_type.profile = m_config->coreProfile();
m_instr_info.pe_type.arch = m_config->archVersion();
m_instr_info.dsb_dmb_waypoints = m_config->dmsbWayPt() ? 1 : 0;
+ m_instr_info.wfi_wfe_branch = 0;
return err;
}
@@ -576,10 +577,11 @@ ocsd_datapath_resp_t TrcPktDecodePtm::processAtomRange(const ocsd_atm_val A, con
}
m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo((A == ATOM_E),m_instr_info.type, m_instr_info.sub_type);
+ m_output_elem.setLastInstrInfo((A == ATOM_E),m_instr_info.type, m_instr_info.sub_type,m_instr_info.instr_size);
m_output_elem.setISA(m_curr_pe_state.isa);
if(m_curr_packet_in->hasCC())
m_output_elem.setCycleCount(m_curr_packet_in->getCCVal());
+ m_output_elem.setLastInstrCond(m_instr_info.is_conditional);
resp = outputTraceElementIdx(m_index_curr_pkt,m_output_elem);
m_curr_pe_state.instr_addr = m_instr_info.instr_addr;
@@ -594,8 +596,9 @@ ocsd_datapath_resp_t TrcPktDecodePtm::processAtomRange(const ocsd_atm_val A, con
{
// some trace before we were out of memory access range
m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type);
+ m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type,m_instr_info.instr_size);
m_output_elem.setISA(m_curr_pe_state.isa);
+ m_output_elem.setLastInstrCond(m_instr_info.is_conditional);
resp = outputTraceElementIdx(m_index_curr_pkt,m_output_elem);
}
}
@@ -612,6 +615,7 @@ ocsd_err_t TrcPktDecodePtm::traceInstrToWP(bool &bWPFound, const waypoint_trace_
ocsd_mem_space_acc_t mem_space = (m_pe_context.security_level == ocsd_sec_secure) ? OCSD_MEM_SPACE_S : OCSD_MEM_SPACE_N;
m_output_elem.st_addr = m_output_elem.en_addr = m_instr_info.instr_addr;
+ m_output_elem.num_instr_range = 0;
bWPFound = false;
@@ -634,6 +638,7 @@ ocsd_err_t TrcPktDecodePtm::traceInstrToWP(bool &bWPFound, const waypoint_trace_
// update the range decoded address in the output packet.
m_output_elem.en_addr = m_instr_info.instr_addr;
+ m_output_elem.num_instr_range++;
m_output_elem.last_i_type = m_instr_info.type;
// either walking to match the next instruction address or a real waypoint
diff --git a/decoder/source/trc_core_arch_map.cpp b/decoder/source/trc_core_arch_map.cpp
index 66513113d4b8..70a25eef0359 100644
--- a/decoder/source/trc_core_arch_map.cpp
+++ b/decoder/source/trc_core_arch_map.cpp
@@ -39,9 +39,17 @@ static struct _ap_map_elements {
ocsd_arch_profile_t ap;
} ap_map_array[] =
{
+ { "Cortex-A77", { ARCH_V8r3, profile_CortexA } },
+ { "Cortex-A76", { ARCH_V8r3, profile_CortexA } },
+ { "Cortex-A75", { ARCH_V8r3, profile_CortexA } },
+ { "Cortex-A73", { ARCH_V8, profile_CortexA } },
{ "Cortex-A72", { ARCH_V8, profile_CortexA } },
+ { "Cortex-A65", { ARCH_V8r3, profile_CortexA } },
{ "Cortex-A57", { ARCH_V8, profile_CortexA } },
+ { "Cortex-A55", { ARCH_V8r3, profile_CortexA } },
{ "Cortex-A53", { ARCH_V8, profile_CortexA } },
+ { "Cortex-A35", { ARCH_V8, profile_CortexA } },
+ { "Cortex-A32", { ARCH_V8, profile_CortexA } },
{ "Cortex-A17", { ARCH_V7, profile_CortexA } },
{ "Cortex-A15", { ARCH_V7, profile_CortexA } },
{ "Cortex-A12", { ARCH_V7, profile_CortexA } },
@@ -49,9 +57,13 @@ static struct _ap_map_elements {
{ "Cortex-A8", { ARCH_V7, profile_CortexA } },
{ "Cortex-A7", { ARCH_V7, profile_CortexA } },
{ "Cortex-A5", { ARCH_V7, profile_CortexA } },
+ { "Cortex-R52", { ARCH_V8, profile_CortexR } },
+ { "Cortex-R8", { ARCH_V7, profile_CortexR } },
{ "Cortex-R7", { ARCH_V7, profile_CortexR } },
{ "Cortex-R5", { ARCH_V7, profile_CortexR } },
{ "Cortex-R4", { ARCH_V7, profile_CortexR } },
+ { "Cortex-M33", { ARCH_V8, profile_CortexM } },
+ { "Cortex-M23", { ARCH_V8, profile_CortexM } },
{ "Cortex-M0", { ARCH_V7, profile_CortexM } },
{ "Cortex-M0+", { ARCH_V7, profile_CortexM } },
{ "Cortex-M3", { ARCH_V7, profile_CortexM } },
diff --git a/decoder/source/trc_frame_deformatter.cpp b/decoder/source/trc_frame_deformatter.cpp
index b4f40a2f9b44..4d46854a655b 100644
--- a/decoder/source/trc_frame_deformatter.cpp
+++ b/decoder/source/trc_frame_deformatter.cpp
@@ -393,9 +393,21 @@ bool TraceFmtDcdImpl::checkForSync()
uint32_t TraceFmtDcdImpl::findfirstFSync()
{
- uint32_t unsynced = m_in_block_size; // consider entire block as unsynced at present.
- //**TBD - handle fsync patterns in TPIU captured code
- return unsynced;
+ uint32_t processed = 0;
+ const uint32_t FSYNC_PATTERN = 0x7FFFFFFF; // LE host pattern for FSYNC
+ const uint8_t *dataPtr = m_in_block_base;
+
+ while (processed < (m_in_block_size - 3))
+ {
+ if (*((uint32_t *)(dataPtr)) == FSYNC_PATTERN)
+ {
+ m_frame_synced = true;
+ break;
+ }
+ processed++;
+ dataPtr++;
+ }
+ return processed;
}
void TraceFmtDcdImpl::outputUnsyncedBytes(uint32_t /*num_bytes*/)
@@ -453,7 +465,7 @@ bool TraceFmtDcdImpl::extractFrame()
bool cont_process = true; // continue processing after extraction.
uint32_t f_sync_bytes = 0; // skipped f sync bytes
uint32_t h_sync_bytes = 0; // skipped h sync bytes
- uint32_t ex_bytes = 0; // extracted bytes
+ uint32_t ex_bytes = 0; // extracted this pass (may be filling out part frame)
// memory aligned sources are always multiples of frames, aligned to start.
if( m_cfgFlags & OCSD_DFRMTR_FRAME_MEM_ALIGN)
@@ -512,8 +524,6 @@ bool TraceFmtDcdImpl::extractFrame()
f_sync_bytes += 4;
dataPtr += 4;
cont_process = (bool)(dataPtr < eodPtr);
-
- // TBD: output raw FSYNC data on raw frame channel.
}
}
@@ -526,6 +536,7 @@ bool TraceFmtDcdImpl::extractFrame()
if(*((uint32_t *)(dataPtr)) == FSYNC_PATTERN)
{
// throw an illegal FSYNC error
+ throw ocsdError(OCSD_ERR_SEV_ERROR, OCSD_ERR_DFMTR_BAD_FHSYNC, m_trc_curr_idx, "Bad FSYNC in frame.");
}
}
@@ -546,12 +557,11 @@ bool TraceFmtDcdImpl::extractFrame()
m_ex_frm_n_bytes-=2;
ex_bytes -= 2;
h_sync_bytes+=2;
-
- // TBD: output raw HSYNC data on raw frame channel.
}
else
{
// throw illegal HSYNC error.
+ throw ocsdError(OCSD_ERR_SEV_ERROR, OCSD_ERR_DFMTR_BAD_FHSYNC, m_trc_curr_idx, "Bad HSYNC in frame.");
}
}
@@ -565,22 +575,25 @@ bool TraceFmtDcdImpl::extractFrame()
cont_process = true;
}
+ // total bytes processed this pass
+ uint32_t total_processed = ex_bytes + f_sync_bytes + h_sync_bytes;
+
// output raw data on raw frame channel - packed raw.
- if ((m_ex_frm_n_bytes == OCSD_DFRMTR_FRAME_SIZE) && m_b_output_packed_raw)
+ if (((m_ex_frm_n_bytes == OCSD_DFRMTR_FRAME_SIZE) || !cont_process) && m_b_output_packed_raw)
{
outputRawMonBytes( OCSD_OP_DATA,
m_trc_curr_idx,
OCSD_FRM_PACKED,
- ex_bytes + f_sync_bytes + h_sync_bytes,
+ total_processed,
m_in_block_base+m_in_block_processed,
0);
}
// update the processed count for the buffer
- m_in_block_processed += m_ex_frm_n_bytes + f_sync_bytes + h_sync_bytes;
+ m_in_block_processed += total_processed;
// update index past the processed data
- m_trc_curr_idx += m_ex_frm_n_bytes + f_sync_bytes + h_sync_bytes;
+ m_trc_curr_idx += total_processed;
return cont_process;
}
@@ -817,7 +830,7 @@ ocsd_err_t TraceFormatterFrameDecoder::Configure(uint32_t cfg_flags)
m_pDecoder = new (std::nothrow) TraceFmtDcdImpl();
if(!m_pDecoder) return OCSD_ERR_MEM;
}
- m_pDecoder->m_cfgFlags = cfg_flags;
+ m_pDecoder->DecodeConfigure(cfg_flags);
return OCSD_OK;
}
diff --git a/decoder/source/trc_gen_elem.cpp b/decoder/source/trc_gen_elem.cpp
index d2536f5758a0..b3ec75f059d4 100644
--- a/decoder/source/trc_gen_elem.cpp
+++ b/decoder/source/trc_gen_elem.cpp
@@ -49,7 +49,7 @@ static const char *s_elem_descs[][2] =
{"OCSD_GEN_TRC_ELEM_ADDR_NACC","Tracing in inaccessible memory area."},
{"OCSD_GEN_TRC_ELEM_ADDR_UNKNOWN","Tracing unknown address area."},
{"OCSD_GEN_TRC_ELEM_EXCEPTION","Exception"},
- {"OCSD_GEN_TRC_ELEM_EXCEPTION_RET","Expection return"},
+ {"OCSD_GEN_TRC_ELEM_EXCEPTION_RET","Exception return"},
{"OCSD_GEN_TRC_ELEM_TIMESTAMP","Timestamp - preceding elements happeded before this time."},
{"OCSD_GEN_TRC_ELEM_CYCLE_COUNT","Cycle count - cycles since last cycle count value - associated with a preceding instruction range."},
{"OCSD_GEN_TRC_ELEM_EVENT","Event - numbered event or trigger"},
@@ -71,7 +71,8 @@ static const char *instr_sub_type[] = {
"--- ",
"b+link ",
"A64:ret ",
- "A64:eret "
+ "A64:eret ",
+ "V7:impl ret",
};
#define ST_SIZE (sizeof(instr_sub_type) / sizeof(const char *))
@@ -105,12 +106,16 @@ void OcsdTraceElement::toString(std::string &str) const
{
case OCSD_GEN_TRC_ELEM_INSTR_RANGE:
oss << "exec range=0x" << std::hex << st_addr << ":[0x" << en_addr << "] ";
+ oss << "num_i(" << std::dec << num_instr_range << ") ";
+ oss << "last_sz(" << last_instr_sz << ") ";
oss << "(ISA=" << s_isa_str[(int)isa] << ") ";
oss << ((last_instr_exec == 1) ? "E " : "N ");
if((int)last_i_type < T_SIZE)
oss << instr_type[last_i_type];
if((last_i_subtype != OCSD_S_INSTR_NONE) && ((int)last_i_subtype < ST_SIZE))
oss << instr_sub_type[last_i_subtype];
+ if (last_instr_cond)
+ oss << " <cond>";
break;
case OCSD_GEN_TRC_ELEM_ADDR_NACC:
@@ -118,9 +123,14 @@ void OcsdTraceElement::toString(std::string &str) const
break;
case OCSD_GEN_TRC_ELEM_EXCEPTION:
- if(excep_ret_addr == 1)
+ if (excep_ret_addr == 1)
{
- oss << "pref ret addr:0x" << std::hex << en_addr << "; ";
+ oss << "pref ret addr:0x" << std::hex << en_addr;
+ if (excep_ret_addr_br_tgt)
+ {
+ oss << " [addr also prev br tgt]";
+ }
+ oss << "; ";
}
oss << "excep num (0x" << std::setfill('0') << std::setw(2) << std::hex << exception_number << ") ";
break;
@@ -150,6 +160,13 @@ void OcsdTraceElement::toString(std::string &str) const
printSWInfoPkt(oss);
break;
+ case OCSD_GEN_TRC_ELEM_EVENT:
+ if(trace_event.ev_type == EVENT_TRIGGER)
+ oss << " Trigger; ";
+ else if(trace_event.ev_type == EVENT_NUMBERED)
+ oss << " Numbered:" << std::dec << trace_event.ev_number << "; ";
+ break;
+
default: break;
}
if(has_cc)
diff --git a/decoder/source/trc_printable_elem.cpp b/decoder/source/trc_printable_elem.cpp
index 2fd49d973579..88c7bb226f41 100644
--- a/decoder/source/trc_printable_elem.cpp
+++ b/decoder/source/trc_printable_elem.cpp
@@ -63,12 +63,15 @@ void trcPrintableElem::getValStr(std::string &valStr, const int valTotalBitSize,
int validChars = valValidBits / 4;
if((valValidBits % 4) > 0) validChars++;
- int QM = numHexChars - validChars;
- while(QM)
- {
- QM--;
- valStr += "?";
- }
+ if (validChars < numHexChars)
+ {
+ int QM = numHexChars - validChars;
+ while (QM)
+ {
+ QM--;
+ valStr += "?";
+ }
+ }
if(valValidBits > 32)
{
sprintf(szFormatBuffer,"%%0%dllX",validChars); // create the format
diff --git a/decoder/tests/auto-fdo/autofdo.md b/decoder/tests/auto-fdo/autofdo.md
new file mode 100644
index 000000000000..b1f22417b50e
--- /dev/null
+++ b/decoder/tests/auto-fdo/autofdo.md
@@ -0,0 +1,523 @@
+AutoFDO and ARM Trace {#AutoFDO}
+=====================
+
+@brief Using CoreSight trace and perf with OpenCSD for AutoFDO.
+
+## Introduction
+
+Feedback directed optimization (FDO, also know as profile guided
+optimization - PGO) uses a profile of a program's execution to guide the
+optmizations performed by the compiler. Traditionally, this involves
+building an instrumented version of the program, which records a profile of
+execution as it runs. The instrumentation adds significant runtime
+overhead, possibly changing the behaviour of the program and it may not be
+possible to run the instrumented program in a production environment
+(e.g. where performance criteria must be met).
+
+AutoFDO uses facilities in the hardware to sample the behaviour of the
+program in the production environment and generate the execution profile.
+An improved profile can be obtained by including the branch history
+(i.e. a record of the last branches taken) when generating an instruction
+samples. On Arm systems, the ETM can be used to generate such records.
+
+The process can be broken down into the following steps:
+
+* Record execution trace of the program
+* Convert the execution trace to instruction samples with branch histories
+* Convert the instruction samples to source level profiles
+* Use the source level profile with the compiler
+
+This article describes how to enable ETM trace on Arm targets running Linux
+and use the ETM trace to generate AutoFDO profiles and compile an optimized
+program.
+
+
+## Execution trace on Arm targets
+
+Debug and trace of Arm targets is provided by CoreSight. This consists of
+a set of components that allow access to debug logic, record (trace) the
+execution of a processor and route this data through the system, collecting
+it into a store.
+
+To record the execution of a processor, we require the following
+components:
+
+* A trace source. The core contains a trace unit, called an ETM that emits
+ data describing the instructions executed by the core.
+* Trace links. The trace data generated by the ETM must be moved through
+ the system to the component that collects the data (sink). Links
+ include:
+ * Funnels: merge multiple streams of data
+ * FIFOs: buffer data to smooth out bursts
+ * Replicators: send a stream of data to multiple components
+* Sinks. These receive the trace data and store it or send it to an
+ external device:
+ * ETB: A small circular buffer (64-128 kilobytes) that stores the most
+ recent data
+ * ETR: A larger (several megabytes) buffer that uses system RAM to
+ store data
+ * TPIU: Sends data to an off-chip capture device (e.g. Arm DSTREAM)
+
+Each Arm SoC design may have a different layout (topology) of components.
+This topology is described to the OS drivers by the platform's devicetree
+or (in future) ACPI firmware.
+
+For application profiling, we need to store several megabytes of data
+within the system, so will use ETR with the capture tool (perf)
+periodically draining the buffer to a file.
+
+Even though we have a large capture buffer, the ETM can still generate a
+lot of data very quickly - typically an ETM will generate ~1 bit of data
+per instruction (depending on the workload), which results in 256Mbytes per
+second for a core running at 2GHz. This leads to problems storing and
+decoding such large volumes of data. AutoFDO uses samples of program
+execution, so we can avoid this problem by using the ETM's features to
+only record small slices of execution - e.g. collect ~5000 cycles of data
+every 50M cycles. This reduces the data rate to a manageable level - a few
+megabytes per minute. This technique is known as 'strobing'.
+
+
+## Enabling trace
+
+### Driver support
+
+To collect ETM trace, the CoreSight drivers must be included in the
+kernel. Some of the driver support is not yet included in the mainline
+kernel and many targets are using older kernels. To enable CoreSight trace
+on these targets, Arm have provided backports of the latest CoreSight
+drivers and ETM strobing patch at:
+
+ <http://linux-arm.org/git?p=linux-coresight-backports.git>
+
+This repository can be cloned with:
+
+```
+git clone git://linux-arm.org/linux-coresight-backports.git
+```
+
+You can include these backports in your kernel by either merging the
+appropriate branch using git or generating patches (using `git
+format-patch`).
+
+For 4.9 based kernels, use the `coresight-4.9-etr-etm_strobe` branch:
+
+```
+git merge coresight-4.9-etr-etm_strobe
+```
+
+or
+
+```
+git format-patch --output-directory /output/dir v4.9..coresight-4.9-etr-etm_strobe
+cd my_kernel
+git am /output/dir/*.patch # or patch -p1 /output/dir/*.patch if not using git
+```
+
+For 4.14 based kernels, use the `coresight-4.14-etm_strobe` branch:
+
+```
+git merge coresight-4.14-etm_strobe
+```
+
+or
+
+```
+git format-patch --output-directory /output/dir v4.14..coresight-4.14-etm_strobe
+cd my_kernel
+git am /output/dir/*.patch # or patch -p1 /output/dir/*.patch if not using git
+```
+
+The CoreSight trace drivers must also be enabled in the kernel
+configuration. This can be done using the configuration menu (`make
+menuconfig`), selecting `Kernel hacking` / `CoreSight Tracing Support` and
+enabling all options, or by setting the following in the configuration
+file:
+
+```
+CONFIG_CORESIGHT=y
+CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y
+CONFIG_CORESIGHT_SINK_TPIU=y
+CONFIG_CORESIGHT_SOURCE_ETM4X=y
+CONFIG_CORESIGHT_DYNAMIC_REPLICATOR=y
+CONFIG_CORESIGHT_STM=y
+CONFIG_CORESIGHT_CATU=y
+```
+
+Compile the kernel for your target in the usual way, e.g.
+
+```
+make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
+```
+
+Each target may have a different layout of CoreSight components. To
+collect trace into a sink, the kernel drivers need to know which other
+devices need to be configured to route data from the source to the sink.
+This is described in the devicetree (and in future, the ACPI tables). The
+device tree will define which CoreSight devices are present in the system,
+where they are located and how they are connected together. The devicetree
+for some platforms includes a description of the platform's CoreSight
+components, but in other cases you may have to ask the platform/SoC vendor
+to supply it or create it yourself (see Appendix: Describing CoreSight in
+Devicetree).
+
+Once the target has been booted with the devicetree describing the
+CoreSight devices, you should find the devices in sysfs:
+
+```
+# ls /sys/bus/coresight/devices/
+28440000.etm 28540000.etm 28640000.etm 28740000.etm
+28c03000.funnel 28c04000.etf 28c05000.replicator 28c06000.etr
+28c07000.tpiu
+```
+
+### Perf tools
+
+The perf tool is used to capture execution trace, configuring the trace
+sources to generate trace, routing the data to the sink and collecting the
+data from the sink.
+
+Arm recommends to use the perf version corresponding to the kernel running
+on the target. This can be built from the same kernel sources with
+
+```
+make -C tools/perf ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
+```
+
+If the post-processing (`perf inject`) of the captured data is not being
+done on the target, then the OpenCSD library is not required for this build
+of perf.
+
+Trace is captured by collecting the `cs_etm` event from perf. The sink
+to collect data into is specified as a parameter of this event. Trace can
+also be restricted to user space or kernel space with 'u' or 'k'
+parameters. For example:
+
+```
+perf record -e cs_etm/@28c06000.etr/u --per-thread -- /bin/ls
+```
+
+Will record the userspace execution of '/bin/ls' into the ETR located at
+0x28c06000. Note the `--per-thread` option is required - perf currently
+only supports trace of a single thread of execution. CPU wide trace is a
+work in progresss.
+
+
+## Processing trace and profiles
+
+perf is also used to convert the execution trace an instruction profile.
+This requires a different build of perf, using the version of perf from
+Linux v4.17 or later, as the trace processing code isn't included in the
+driver backports. Trace decode is provided by the OpenCSD library
+(<https://github.com/Linaro/OpenCSD>), v0.9.1 or later. This is packaged
+for debian testing (install the libopencsd0, libopencsd-dev packages) or
+can be compiled from source and installed.
+
+The autoFDO tool <https://github.com/google/autofdo> is used to convert the
+instruction profiles to source profiles for the GCC and clang/llvm
+compilers.
+
+
+## Recording and profiling
+
+Once trace collection using perf is working, we can now use it to profile
+an application.
+
+The application must be compiled to include sufficient debug information to
+map instructions back to source lines. For GCC, use the `-g1` or `-gmlt`
+options. For clang/llvm, also add the `-fdebug-info-for-profiling` option.
+
+perf identifies the active program or library using the build identifier
+stored in the elf file. This should be added at link time with the compiler
+flag `-Wl,--build-id=sha1`.
+
+The next step is to record the execution trace of the application using the
+perf tool. The ETM strobing should be configured before running the perf
+tool. There are two parameters:
+
+ * window size: A number of CPU cycles (W)
+ * period: Trace is enabled for W cycle every _period_ * W cycles.
+
+For example, a typical configuration is to use a window size of 5000 cycles
+and a period of 10000 - this will collect 5000 cycles of trace every 50M
+cycles. With these proof-of-concept patches, the strobe parameters are
+configured via sysfs - each ETM will have `strobe_window` and
+`strobe_period` parameters in `/sys/bus/coresight/devices/NNNNNNNN.etm` and
+these values will have to be written to each (In a future version, this
+will be integrated into the drivers and perf tool). The `record.sh`
+script in this directory [`<opencsd>/decoder/tests/auto-fdo`] automates this process.
+
+To collect trace from an application using ETM strobing, run:
+
+```
+taskset -c 0 ./record.sh --strobe 5000 10000 28c06000.etr ./my_application arg1 arg2
+```
+
+The taskset command is used to ensure the process stays on the same CPU
+during execution.
+
+The raw trace can be examined using the `perf report` command:
+
+```
+perf report -D -i perf.data --stdio
+```
+
+For example:
+
+```
+0x1d370 [0x30]: PERF_RECORD_AUXTRACE size: 0x2003c0 offset: 0 ref: 0x39ba881d145f8639 idx: 0 tid: 4551 cpu: -1
+
+. ... CoreSight ETM Trace data: size 2098112 bytes
+ Idx:0; ID:12; I_ASYNC : Alignment Synchronisation.
+ Idx:12; ID:12; I_TRACE_INFO : Trace Info.; INFO=0x0
+ Idx:17; ID:12; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0xFFFF000008A4991C;
+ Idx:48; ID:14; I_ASYNC : Alignment Synchronisation.
+ Idx:60; ID:14; I_TRACE_INFO : Trace Info.; INFO=0x0
+ Idx:65; ID:14; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0xFFFF000008A4991C;
+ Idx:96; ID:14; I_ASYNC : Alignment Synchronisation.
+ Idx:108; ID:14; I_TRACE_INFO : Trace Info.; INFO=0x0
+ Idx:113; ID:14; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0xFFFF000008A4991C;
+ Idx:122; ID:14; I_TRACE_ON : Trace On.
+ Idx:123; ID:14; I_ADDR_CTXT_L_64IS0 : Address & Context, Long, 64 bit, IS0.; Addr=0x0000000000407B00; Ctxt: AArch64,EL0, NS;
+ Idx:134; ID:14; I_ATOM_F3 : Atom format 3.; ENN
+ Idx:135; ID:14; I_ATOM_F5 : Atom format 5.; NENEN
+ Idx:136; ID:14; I_ATOM_F5 : Atom format 5.; ENENE
+ Idx:137; ID:14; I_ATOM_F5 : Atom format 5.; NENEN
+ Idx:138; ID:14; I_ATOM_F3 : Atom format 3.; ENN
+ Idx:139; ID:14; I_ATOM_F3 : Atom format 3.; NNE
+ Idx:140; ID:14; I_ATOM_F1 : Atom format 1.; E
+.....
+```
+
+The execution trace is then converted to an instruction profile using
+the perf build with trace decode support. This may be done on a different
+machine than that which collected the trace (e.g. when cross compiling for
+an embedded target). The `perf inject` command
+decodes the execution trace and generates periodic instruction samples,
+with branch histories:
+
+```
+perf inject -i perf.data -o inj.data --itrace=i100000il
+```
+
+The `--itrace` option configures the instruction sample behaviour:
+
+* `i100000i` generates an instruction sample every 100000 instructions
+ (only instruction count periods are currently supported, future versions
+ may support time or cycle count periods)
+* `l` includes the branch histories on each sample
+* `b` generates a sample on each branch (not used here)
+
+Perf requires the original program binaries to decode the execution trace.
+If running the `inject` command on a different system than the trace was
+captured on, then the binary and any shared libraries must be added to
+perf's cache with:
+
+```
+perf buildid-cache -a /path/to/binary_or_library
+```
+
+`perf report` can also be used to show the instruction samples:
+
+```
+perf report -D -i inj.data --stdio
+.......
+0x1528 [0x630]: PERF_RECORD_SAMPLE(IP, 0x2): 4551/4551: 0x434b98 period: 3093 addr: 0
+... branch stack: nr:64
+..... 0: 0000000000434b58 -> 0000000000434b68 0 cycles P 0
+..... 1: 0000000000436a88 -> 0000000000434b4c 0 cycles P 0
+..... 2: 0000000000436a64 -> 0000000000436a78 0 cycles P 0
+..... 3: 00000000004369d0 -> 0000000000436a60 0 cycles P 0
+..... 4: 000000000043693c -> 00000000004369cc 0 cycles P 0
+..... 5: 00000000004368a8 -> 0000000000436928 0 cycles P 0
+..... 6: 000000000042d070 -> 00000000004368a8 0 cycles P 0
+..... 7: 000000000042d108 -> 000000000042d070 0 cycles P 0
+.......
+..... 57: 0000000000448ee0 -> 0000000000448f24 0 cycles P 0
+..... 58: 0000000000448ea4 -> 0000000000448ebc 0 cycles P 0
+..... 59: 0000000000448e20 -> 0000000000448e94 0 cycles P 0
+..... 60: 0000000000448da8 -> 0000000000448ddc 0 cycles P 0
+..... 61: 00000000004486f4 -> 0000000000448da8 0 cycles P 0
+..... 62: 00000000004480fc -> 00000000004486d4 0 cycles P 0
+..... 63: 0000000000448658 -> 00000000004480ec 0 cycles P 0
+ ... thread: program1:4551
+ ...... dso: /home/root/program1
+.......
+```
+
+The instruction samples produced by `perf inject` is then passed to the
+autofdo tool to generate source level profiles for the compiler. For
+clang/LLVM:
+
+```
+create_llvm_prof -binary=/path/to/binary -profile=inj.data -out=program.llvmprof
+```
+
+And for GCC:
+
+```
+create_gcov -binary=/path/to/binary -profile=inj.data -gcov_version=1 -gcov=program.gcov
+```
+
+The profiles can be viewed with:
+
+```
+llvm-profdata show -sample program.llvmprof
+```
+
+Or, for GCC:
+
+```
+dump_gcov -gcov_version=1 program.gcov
+```
+
+## Using profile in the compiler
+
+The profile produced by the above steps can then be passed to the compiler
+to optimize the next build of the program.
+
+For GCC, use the `-fauto-profile` option:
+
+```
+gcc -O2 -fauto-profile=program.gcov -o program program.c
+```
+
+For Clang, use the `-fprofile-sample-use` option:
+
+```
+clang -O2 -fprofile-sample-use=program.llvmprof -o program program.c
+```
+
+
+## Summary
+
+The basic commands to run an application and create a compiler profile are:
+
+```
+taskset -c 0 ./record.sh --strobe 5000 10000 28c06000.etr ./my_application arg1 arg2
+perf inject -i perf.data -o inj.data --itrace=i100000il
+create_llvm_prof -binary=/path/to/binary -profile=inj.data -out=program.llvmprof
+```
+
+Use `create_gcov` for gcc.
+
+
+## References
+
+* AutoFDO tool: <https://github.com/google/autofdo>
+* GCC's wiki on autofdo: <https://gcc.gnu.org/wiki/AutoFDO>, <https://gcc.gnu.org/wiki/AutoFDO/Tutorial>
+* Google paper: <https://ai.google/research/pubs/pub45290>
+* CoreSight kernel docs: Documentation/trace/coresight.txt
+
+
+## Appendix: Describing CoreSight in Devicetree
+
+
+Each component has an entry in the device tree that describes its:
+
+* type: The `compatible` field defines which driver to use
+* location: A `reg` defines the component's address and size on the bus
+* clocks: The `clocks` and `clock-names` fields state which clock provides
+ the `apb_pclk` clock.
+* connections to other components: `port` and `ports` field link the
+ component to ports of other components
+
+To create the device tree, some information about the platform is required:
+
+* The memory address of the CoreSight components. This is the address in
+ the CPU's address space where the CPU can access each CoreSight
+ component.
+* The connections between the components.
+
+This information can be found in the SoC's reference manual or you may need
+to ask the platform/SoC vendor to supply it.
+
+An ETMv4 source is declared with a section like this:
+
+```
+ etm0: etm@22040000 {
+ compatible = "arm,coresight-etm4x", "arm,primecell";
+ reg = <0 0x22040000 0 0x1000>;
+
+ cpu = <&A72_0>;
+ clocks = <&soc_smc50mhz>;
+ clock-names = "apb_pclk";
+ port {
+ cluster0_etm0_out_port: endpoint {
+ remote-endpoint = <&cluster0_funnel_in_port0>;
+ };
+ };
+ };
+```
+
+This describes an ETMv4 attached to core A72_0, located at 0x22040000, with
+its output linked to port 0 of a funnel. The funnel is described with:
+
+```
+ funnel@220c0000 { /* cluster0 funnel */
+ compatible = "arm,coresight-funnel", "arm,primecell";
+ reg = <0 0x220c0000 0 0x1000>;
+
+ clocks = <&soc_smc50mhz>;
+ clock-names = "apb_pclk";
+ power-domains = <&scpi_devpd 0>;
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ reg = <0>;
+ cluster0_funnel_out_port: endpoint {
+ remote-endpoint = <&main_funnel_in_port0>;
+ };
+ };
+
+ port@1 {
+ reg = <0>;
+ cluster0_funnel_in_port0: endpoint {
+ slave-mode;
+ remote-endpoint = <&cluster0_etm0_out_port>;
+ };
+ };
+
+ port@2 {
+ reg = <1>;
+ cluster0_funnel_in_port1: endpoint {
+ slave-mode;
+ remote-endpoint = <&cluster0_etm1_out_port>;
+ };
+ };
+ };
+ };
+```
+
+This describes a funnel located at 0x220c0000, receiving data from 2 ETMs
+and sending the merged data to another funnel. We continue describing
+components with similar blocks until we reach the sink (an ETR):
+
+```
+ etr@20070000 {
+ compatible = "arm,coresight-tmc", "arm,primecell";
+ reg = <0 0x20070000 0 0x1000>;
+ iommus = <&smmu_etr 0>;
+
+ clocks = <&soc_smc50mhz>;
+ clock-names = "apb_pclk";
+ power-domains = <&scpi_devpd 0>;
+ port {
+ etr_in_port: endpoint {
+ slave-mode;
+ remote-endpoint = <&replicator_out_port1>;
+ };
+ };
+ };
+```
+
+Full descriptions of the properties of each component can be found in the
+Linux source at Documentation/devicetree/bindings/arm/coresight.txt.
+The Arm Juno platform's devicetree (arch/arm64/boot/dts/arm) provides an example
+description of CoreSight description.
+
+Many systems include a TPIU for off-chip trace. While this isn't required
+for self-hosted trace, it should still be included in the devicetree. This
+allows the drivers to access it to ensure it is put into a disabled state,
+otherwise it may limit the trace bandwidth causing data loss.
diff --git a/decoder/tests/auto-fdo/record.sh b/decoder/tests/auto-fdo/record.sh
new file mode 100755
index 000000000000..16d4ba22db3c
--- /dev/null
+++ b/decoder/tests/auto-fdo/record.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+BUFFER_ETF_A53=ec802000.etf
+BUFFER_ETF_A73=ed002000.etf
+BUFFER_ETF_SYS=ec036000.etf
+BUFFER_ETR=ec033000.etr
+
+OUT_FILE=perf.data
+
+STROBE=
+
+while :; do
+ case $1 in
+ --strobe)
+ STROBE=y
+ WINDOW=$2
+ PERIOD=$3
+ shift 3
+ ;;
+
+ *)
+ break ;;
+ esac
+done
+
+case $1 in
+ etr)
+ BUFFER=$BUFFER_ETR
+ ;;
+
+ etf-sys)
+ BUFFER=$BUFFER_ETF_SYS
+ ;;
+
+ "")
+ BUFFER=$BUFFER_ETR
+ ;;
+
+ *)
+ BUFFER=$1
+ ;;
+esac
+
+shift 1
+
+case $0 in
+ /*) F=$0 ;;
+ *) F=$(pwd)/$0 ;;
+esac
+
+SCRIPT_DIR=$(dirname $F)
+
+if [ "$STROBE" ]; then
+ for e in /sys/bus/coresight/devices/*.etm/; do
+ printf "%x" $WINDOW | sudo tee $e/strobe_window > /dev/null
+ printf "%x" $PERIOD | sudo tee $e/strobe_period > /dev/null
+ done
+fi
+
+PERF=$SCRIPT_DIR/perf
+
+export LD_LIBRARY_PATH=$SCRIPT_DIR:$LD_LIBRARY_PATH
+
+sudo LD_LIBRARY_PATH=$SCRIPT_DIR:$LD_LIBRARY_PATH $PERF record $PERF_ARGS -e cs_etm/@$BUFFER/u --per-thread "$@"
+
+sudo chown $(id -u):$(id -g) $OUT_FILE
+
+
diff --git a/decoder/tests/build/linux/c_api_pkt_print_test/makefile b/decoder/tests/build/linux/c_api_pkt_print_test/makefile
index 9fe72477249c..b0b56044e032 100644
--- a/decoder/tests/build/linux/c_api_pkt_print_test/makefile
+++ b/decoder/tests/build/linux/c_api_pkt_print_test/makefile
@@ -33,9 +33,7 @@
#
CC := $(MASTER_CC)
-CC_FLAGS := $(MASTER_CC_FLAGS) -Wno-switch
LINKER := $(MASTER_LINKER)
-LINKER_FLAGS := $(MASTER_LINKER_FLAGS)
PROG = c_api_pkt_print_test
@@ -53,22 +51,21 @@ OBJECTS = $(BUILD_DIR)/c_api_pkt_print_test.o
LIBS = -L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME) -l$(LIB_CAPI_NAME) \
-L$(LIB_TEST_TARGET_DIR) -l_echo_test_dcd
-all: build_dir test_app copy_libs
+all: build_dir copy_libs
-test_app: $(OBJECTS) $(BIN_TEST_TARGET_DIR)/$(PROG)
+test_app: $(BIN_TEST_TARGET_DIR)/$(PROG)
- $(BIN_TEST_TARGET_DIR)/$(PROG):
+ $(BIN_TEST_TARGET_DIR)/$(PROG): $(OBJECTS)
mkdir -p $(BIN_TEST_TARGET_DIR)
- $(LINKER) $(LINKER_FLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG)
+ $(LINKER) $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG)
cp $(LIB_TARGET_DIR)/*.so .
build_dir:
mkdir -p $(BUILD_DIR)
.PHONY: copy_libs
-
-copy_libs:
+copy_libs: $(BIN_TEST_TARGET_DIR)/$(PROG)
cp $(LIB_TARGET_DIR)/*.so $(BIN_TEST_TARGET_DIR)/.
@@ -81,12 +78,14 @@ DEPS := $(OBJECTS:%.o=%.d)
## object compile
$(BUILD_DIR)/%.o : %.c
- $(CC) $(CC_FLAGS) $(CC_INCLUDES) -MMD $< -o $@
+ $(CC) $(CFLAGS) $(CC_INCLUDES) -MMD $< -o $@
#### clean
.PHONY: clean
clean :
- rm -f $(BIN_TEST_TARGET_DIR)/$(PROG) $(OBJECTS)
- rm -f $(DEPS)
+ -rm $(BIN_TEST_TARGET_DIR)/$(PROG) $(OBJECTS)
+ -rm $(DEPS)
+ -rm ./*.so
+ -rmdir $(BUILD_DIR)
# end of file makefile
diff --git a/decoder/tests/build/linux/echo_test_dcd_lib/makefile b/decoder/tests/build/linux/echo_test_dcd_lib/makefile
index 2483170dc0d6..31ca38fe12ed 100644
--- a/decoder/tests/build/linux/echo_test_dcd_lib/makefile
+++ b/decoder/tests/build/linux/echo_test_dcd_lib/makefile
@@ -31,13 +31,8 @@
#
CC := $(MASTER_CC)
-LINKER := $(MASTER_LINKER)
LIB := $(MASTER_LIB)
-CC_FLAGS := $(MASTER_CC_FLAGS) -fpic -Wno-switch
-LIB_FLAGS := $(MASTER_LIB_FLAGS)
-LINKER_FLAGS := $(MASTER_LINKER_FLAGS) -shared
-
LIB_NAME = lib_echo_test_dcd
BUILD_DIR=./$(PLAT_DIR)
@@ -53,21 +48,15 @@ CC_INCLUDES = \
OBJECTS = $(BUILD_DIR)/ext_dcd_echo_test.o \
$(BUILD_DIR)/ext_dcd_echo_test_fact.o
-all: build_dir $(OBJECTS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
+all: build_dir $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
-$(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a:
+$(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS)
mkdir -p $(LIB_TEST_TARGET_DIR)
- $(LIB) $(LIB_FLAGS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
+ $(LIB) $(ARFLAGS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
build_dir:
mkdir -p $(BUILD_DIR)
-.PHONY: copy_libs
-
-copy_libs:
- cp $(LIB_TARGET_DIR)/*.so $(BIN_TEST_TARGET_DIR)/.
-
-
#### build rules
## object dependencies
DEPS := $(OBJECTS:%.o=%.d)
@@ -76,13 +65,14 @@ DEPS := $(OBJECTS:%.o=%.d)
## object compile
$(BUILD_DIR)/%.o : %.c
- $(CC) $(CC_FLAGS) $(CC_INCLUDES) -MMD $< -o $@
+ $(CC) $(CFLAGS) $(CC_INCLUDES) -MMD $< -o $@
#### clean
.PHONY: clean
clean:
- rm -f $(OBJECTS)
- rm -f $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
- rm -f $(DEPS)
+ -rm $(OBJECTS)
+ -rm $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
+ -rm $(DEPS)
+ -rmdir $(BUILD_DIR) $(LIB_TEST_TARGET_DIR)
# end of file makefile
diff --git a/decoder/tests/build/linux/mem_buffer_eg/makefile b/decoder/tests/build/linux/mem_buffer_eg/makefile
new file mode 100644
index 000000000000..850ed497dafa
--- /dev/null
+++ b/decoder/tests/build/linux/mem_buffer_eg/makefile
@@ -0,0 +1,90 @@
+########################################################
+# Copyright 2019 ARM Limited. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors
+# may be used to endorse or promote products derived from this software without
+# specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#################################################################################
+
+########
+# RCTDL - test makefile for snapshot lister test.
+#
+
+CXX := $(MASTER_CXX)
+LINKER := $(MASTER_LINKER)
+
+PROG = mem-buffer-eg
+
+BUILD_DIR=./$(PLAT_DIR)
+
+VPATH = $(OCSD_TESTS)/source
+
+CXX_INCLUDES = \
+ -I$(OCSD_TESTS)/source \
+ -I$(OCSD_INCLUDE) \
+ -I$(OCSD_TESTS)/snapshot_parser_lib/include
+
+OBJECTS = $(BUILD_DIR)/mem_buff_demo.o
+
+LIBS = -L$(LIB_TEST_TARGET_DIR) -lsnapshot_parser \
+ -L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME)
+
+all: build_dir copy_libs
+
+test_app: $(BIN_TEST_TARGET_DIR)/$(PROG)
+
+
+ $(BIN_TEST_TARGET_DIR)/$(PROG): $(OBJECTS)
+ mkdir -p $(BIN_TEST_TARGET_DIR)
+ $(LINKER) $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG)
+
+build_dir:
+ mkdir -p $(BUILD_DIR)
+
+.PHONY: copy_libs
+copy_libs: $(BIN_TEST_TARGET_DIR)/$(PROG)
+ cp $(LIB_TARGET_DIR)/*.so* $(BIN_TEST_TARGET_DIR)/.
+
+
+
+#### build rules
+## object dependencies
+DEPS := $(OBJECTS:%.o=%.d)
+
+-include $(DEPS)
+
+## object compile
+$(BUILD_DIR)/%.o : %.cpp
+ $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
+
+#### clean
+.PHONY: clean
+clean :
+ -rm $(BIN_TEST_TARGET_DIR)/$(PROG) $(OBJECTS)
+ -rm $(DEPS)
+ -rm $(BIN_TEST_TARGET_DIR)/*.so*
+ -rmdir $(BUILD_DIR)
+
+# end of file makefile
diff --git a/decoder/tests/build/linux/snapshot_parser_lib/makefile b/decoder/tests/build/linux/snapshot_parser_lib/makefile
index ae3863f3932b..295bab61780e 100644
--- a/decoder/tests/build/linux/snapshot_parser_lib/makefile
+++ b/decoder/tests/build/linux/snapshot_parser_lib/makefile
@@ -32,15 +32,14 @@
#
########################################################################
-CPP := $(MASTER_CPP)
+CXX := $(MASTER_CXX)
LINKER := $(MASTER_LINKER)
LIB := $(MASTER_LIB)
# avoid build warnings in donated test code
WSUPPRESS= -Wno-deprecated-declarations -Wno-unused-variable -Wno-reorder
-CPP_FLAGS := $(MASTER_CPP_FLAGS) -fpic -Wno-switch $(WSUPPRESS)
-LIB_FLAGS := $(MASTER_LIB_FLAGS)
+CXXFLAGS += $(WSUPPRESS)
LIB_NAME = libsnapshot_parser
@@ -53,7 +52,7 @@ PARSER_INCLUDE=$(PARSER_ROOT)/include
VPATH= $(PARSER_SOURCE)
-CPP_INCLUDES= \
+CXX_INCLUDES= \
-I$(PARSER_INCLUDE) \
-I$(OCSD_INCLUDE)
@@ -64,11 +63,11 @@ OBJECTS=$(BUILD_DIR)/device_info.o \
$(BUILD_DIR)/snapshot_reader.o \
$(BUILD_DIR)/ss_to_dcdtree.o
-all: build_dir $(OBJECTS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
+all: build_dir $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
-$(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a:
+$(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS)
mkdir -p $(LIB_TEST_TARGET_DIR)
- $(LIB) $(LIB_FLAGS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
+ $(LIB) $(ARFLAGS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
build_dir:
mkdir -p $(BUILD_DIR)
@@ -82,11 +81,12 @@ DEPS := $(OBJECTS:%.o=%.d)
## object compile
$(BUILD_DIR)/%.o : %.cpp
- $(CPP) $(CPP_FLAGS) $(CPP_INCLUDES) -MMD $< -o $@
+ $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
### clean
.PHONY: clean
clean:
- rm -f $(OBJECTS)
- rm -f $(DEPS)
- rm -f $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
+ -rm $(OBJECTS)
+ -rm $(DEPS)
+ -rm $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
+ -rmdir $(BUILD_DIR) $(LIB_TEST_TARGET_DIR)
diff --git a/decoder/tests/build/linux/trc_pkt_lister/makefile b/decoder/tests/build/linux/trc_pkt_lister/makefile
index 3447b930c9c9..54ce27d351a6 100644
--- a/decoder/tests/build/linux/trc_pkt_lister/makefile
+++ b/decoder/tests/build/linux/trc_pkt_lister/makefile
@@ -32,10 +32,8 @@
# RCTDL - test makefile for snapshot lister test.
#
-CPP := $(MASTER_CPP)
-CPP_FLAGS := $(MASTER_CPP_FLAGS) -Wno-switch
+CXX := $(MASTER_CXX)
LINKER := $(MASTER_LINKER)
-LINKER_FLAGS := $(MASTER_LINKER_FLAGS)
PROG = trc_pkt_lister
@@ -43,7 +41,7 @@ BUILD_DIR=./$(PLAT_DIR)
VPATH = $(OCSD_TESTS)/source
-CPP_INCLUDES = \
+CXX_INCLUDES = \
-I$(OCSD_TESTS)/source \
-I$(OCSD_INCLUDE) \
-I$(OCSD_TESTS)/snapshot_parser_lib/include
@@ -53,22 +51,21 @@ OBJECTS = $(BUILD_DIR)/trc_pkt_lister.o
LIBS = -L$(LIB_TEST_TARGET_DIR) -lsnapshot_parser \
-L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME)
-all: build_dir test_app copy_libs
+all: build_dir copy_libs
-test_app: $(OBJECTS) $(BIN_TEST_TARGET_DIR)/$(PROG)
+test_app: $(BIN_TEST_TARGET_DIR)/$(PROG)
- $(BIN_TEST_TARGET_DIR)/$(PROG):
+ $(BIN_TEST_TARGET_DIR)/$(PROG): $(OBJECTS)
mkdir -p $(BIN_TEST_TARGET_DIR)
- $(LINKER) $(LINKER_FLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG)
+ $(LINKER) $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG)
build_dir:
mkdir -p $(BUILD_DIR)
.PHONY: copy_libs
-
-copy_libs:
- cp $(LIB_TARGET_DIR)/*.so $(BIN_TEST_TARGET_DIR)/.
+copy_libs: $(BIN_TEST_TARGET_DIR)/$(PROG)
+ cp $(LIB_TARGET_DIR)/*.so* $(BIN_TEST_TARGET_DIR)/.
@@ -80,12 +77,14 @@ DEPS := $(OBJECTS:%.o=%.d)
## object compile
$(BUILD_DIR)/%.o : %.cpp
- $(CPP) $(CPP_FLAGS) $(CPP_INCLUDES) -MMD $< -o $@
+ $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
#### clean
.PHONY: clean
clean :
- rm -f $(BIN_TEST_TARGET_DIR)/$(PROG) $(OBJECTS)
- rm -f $(DEPS)
+ -rm $(BIN_TEST_TARGET_DIR)/$(PROG) $(OBJECTS)
+ -rm $(DEPS)
+ -rm $(BIN_TEST_TARGET_DIR)/*.so*
+ -rmdir $(BUILD_DIR)
# end of file makefile
diff --git a/decoder/tests/build/win-vs2015/mem-buffer-eg/mem-buffer-eg.vcxproj b/decoder/tests/build/win-vs2015/mem-buffer-eg/mem-buffer-eg.vcxproj
new file mode 100644
index 000000000000..08f93d47d08c
--- /dev/null
+++ b/decoder/tests/build/win-vs2015/mem-buffer-eg/mem-buffer-eg.vcxproj
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\source\mem_buff_demo.cpp" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{BC090130-2C53-4CF6-8AD4-37BF72B8D01A}</ProjectGuid>
+ <RootNamespace>membuffereg</RootNamespace>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\build\win-vs2015\opencsd.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\build\win-vs2015\opencsd.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\build\win-vs2015\opencsd.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\build\win-vs2015\opencsd.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>..\..\..\bin\win$(PlatformArchitecture)\dbg\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>..\..\..\bin\win$(PlatformArchitecture)\dbg\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <OutDir>..\..\..\bin\win$(PlatformArchitecture)\rel\</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <OutDir>..\..\..\bin\win$(PlatformArchitecture)\dbg\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>
+ </SDLCheck>
+ <AdditionalIncludeDirectories>..\..\..\..\include</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\..\..\lib\win$(PlatformArchitecture)\dbg\;..\..\..\..\tests\lib\win$(PlatformArchitecture)\dbg\</AdditionalLibraryDirectories>
+ <AdditionalDependencies>lib$(LIB_BASE_NAME).lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\..\..\include</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\..\..\lib\win$(PlatformArchitecture)\dbg\;..\..\..\..\tests\lib\win$(PlatformArchitecture)\dbg\</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\..\..\include</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\..\..\lib\win$(PlatformArchitecture)\rel\;..\..\..\..\tests\lib\win$(PlatformArchitecture)\rel\</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\..\..\include</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\..\..\lib\win$(PlatformArchitecture)\rel\;..\..\..\..\tests\lib\win$(PlatformArchitecture)\rel\</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/decoder/tests/build/win-vs2015/mem-buffer-eg/mem-buffer-eg.vcxproj.filters b/decoder/tests/build/win-vs2015/mem-buffer-eg/mem-buffer-eg.vcxproj.filters
new file mode 100644
index 000000000000..ce99a9eb1d73
--- /dev/null
+++ b/decoder/tests/build/win-vs2015/mem-buffer-eg/mem-buffer-eg.vcxproj.filters
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\source\mem_buff_demo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/decoder/tests/ext_dcd_test_eg/c_api_echo_test/ext_dcd_echo_test.c b/decoder/tests/ext_dcd_test_eg/c_api_echo_test/ext_dcd_echo_test.c
index 32365efb216b..e2ad0454e4e2 100644
--- a/decoder/tests/ext_dcd_test_eg/c_api_echo_test/ext_dcd_echo_test.c
+++ b/decoder/tests/ext_dcd_test_eg/c_api_echo_test/ext_dcd_echo_test.c
@@ -330,7 +330,7 @@ void print_test_cov_results(echo_decoder_t *decoder)
if (coverage[TEST_COV_MSGLOG_CB] == TEST_RES_OK) /* check we can use the msg logger for outputting the results */
lib_cb_LogMsg(p_fns, OCSD_ERR_SEV_ERROR, coverage_message);
else
- printf(coverage_message);
+ printf("%s", coverage_message);
}
}
diff --git a/decoder/tests/run_pkt_decode_tests.bash b/decoder/tests/run_pkt_decode_tests.bash
new file mode 100755
index 000000000000..56b1cbfd38be
--- /dev/null
+++ b/decoder/tests/run_pkt_decode_tests.bash
@@ -0,0 +1,78 @@
+#!/bin/bash
+#################################################################################
+# Copyright 2018 ARM. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors
+# may be used to endorse or promote products derived from this software without
+# specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#################################################################################
+# OpenCSD library: Test script.
+#
+# Test script to run packet lister on each of the snapshots retained with the repository.
+# No attempt is made to compare output results to previous versions, (output formatting
+# may change due to bugfix / enhancements) or assess the validity of the trace output.
+#
+#################################################################################
+
+OUT_DIR=./results
+SNAPSHOT_DIR=./snapshots
+BIN_DIR=./bin/linux64/rel
+
+# directories for tests using full decode
+declare -a test_dirs_decode=( "juno-ret-stck"
+ "a57_single_step"
+ "bugfix-exact-match"
+ "juno-uname-001"
+ "juno-uname-002"
+ "juno_r1_1"
+ "tc2-ptm-rstk-t32"
+ "trace_cov_a15"
+ "stm_only"
+ "stm_only-2"
+ "stm_only-juno"
+ "TC2"
+ "Snowball"
+ "test-file-mem-offsets"
+ )
+
+
+echo "Running trc_pkt_lister on snapshot directories."
+
+mkdir -p ${OUT_DIR}
+
+# === test the decode set ===
+export LD_LIBRARY_PATH=${BIN_DIR}/.
+
+for test_dir in "${test_dirs_decode[@]}"
+do
+ echo "Testing $test_dir..."
+ ${BIN_DIR}/trc_pkt_lister -ss_dir "${SNAPSHOT_DIR}/$test_dir" -decode -logfilename "${OUT_DIR}/$test_dir.ppl"
+ echo "Done : Return $?"
+done
+
+# === test the TPIU deformatter ===
+echo "Testing a55-test-tpiu..."
+${BIN_DIR}/trc_pkt_lister -ss_dir "${SNAPSHOT_DIR}/a55-test-tpiu" -dstream_format -o_raw_packed -o_raw_unpacked -logfilename "${OUT_DIR}/a55-test-tpiu.ppl"
+echo "Done : Return $?"
diff --git a/decoder/tests/snapshot_parser_lib/source/ss_to_dcdtree.cpp b/decoder/tests/snapshot_parser_lib/source/ss_to_dcdtree.cpp
index 81ae82ba815c..4eeec732c15b 100644
--- a/decoder/tests/snapshot_parser_lib/source/ss_to_dcdtree.cpp
+++ b/decoder/tests/snapshot_parser_lib/source/ss_to_dcdtree.cpp
@@ -79,15 +79,19 @@ bool CreateDcdTreeFromSnapShot::createDecodeTree(const std::string &SourceName,
if(m_pReader->getTraceBufferSourceTree(SourceName, tree))
{
int numDecodersCreated = 0; // count how many we create - if none then give up.
+ uint32_t formatter_flags = OCSD_DFRMTR_FRAME_MEM_ALIGN;
/* make a note of the trace binary file name + path to ss directory */
m_BufferFileName = m_pReader->getSnapShotDir() + tree.buffer_info.dataFileName;
ocsd_dcd_tree_src_t src_format = tree.buffer_info.dataFormat == "source_data" ? OCSD_TRC_SRC_SINGLE : OCSD_TRC_SRC_FRAME_FORMATTED;
+ if (tree.buffer_info.dataFormat == "dstream_coresight")
+ formatter_flags = OCSD_DFRMTR_HAS_FSYNCS;
+
/* create the initial device tree */
// TBD: handle syncs / hsyncs data from TPIU
- m_pDecodeTree = DecodeTree::CreateDecodeTree(src_format,OCSD_DFRMTR_FRAME_MEM_ALIGN);
+ m_pDecodeTree = DecodeTree::CreateDecodeTree(src_format, formatter_flags);
if(m_pDecodeTree == 0)
{
LogError("Failed to create decode tree object\n");
@@ -507,15 +511,24 @@ void CreateDcdTreeFromSnapShot::processDumpfiles(std::vector<Parser::DumpDef> &d
while(it != dumps.end())
{
dumpFilePathName = m_pReader->getSnapShotDir() + it->path;
- if(!TrcMemAccessorFile::isExistingFileAccessor(dumpFilePathName))
- {
- ocsd_err_t err = m_pDecodeTree->addBinFileMemAcc(it->address,OCSD_MEM_SPACE_ANY,dumpFilePathName);
- if(err != OCSD_OK)
- {
- std::ostringstream oss;
- oss << "Failed to create memory accessor for file " << dumpFilePathName << ".";
- LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,oss.str()));
- }
+ ocsd_file_mem_region_t region;
+ ocsd_err_t err = OCSD_OK;
+
+ region.start_address = it->address;
+ region.file_offset = it->offset;
+ region.region_size = it->length;
+
+ // ensure we respect optional length and offset parameter and
+ // allow multiple dump entries with same file name to define regions
+ if (!TrcMemAccessorFile::isExistingFileAccessor(dumpFilePathName))
+ err = m_pDecodeTree->addBinFileRegionMemAcc(&region, 1, OCSD_MEM_SPACE_ANY, dumpFilePathName);
+ else
+ err = m_pDecodeTree->updateBinFileRegionMemAcc(&region, 1, OCSD_MEM_SPACE_ANY, dumpFilePathName);
+ if(err != OCSD_OK)
+ {
+ std::ostringstream oss;
+ oss << "Failed to create memory accessor for file " << dumpFilePathName << ".";
+ LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,oss.str()));
}
it++;
}
diff --git a/decoder/tests/source/c_api_pkt_print_test.c b/decoder/tests/source/c_api_pkt_print_test.c
index 85bd9bf258b6..02c589e4f275 100644
--- a/decoder/tests/source/c_api_pkt_print_test.c
+++ b/decoder/tests/source/c_api_pkt_print_test.c
@@ -63,12 +63,17 @@
/* path to test snapshots, relative to tests/bin/<plat>/<dbg|rel> build output dir */
#ifdef _WIN32
-const char *default_path_to_snapshot = "..\\..\\..\\snapshots\\juno_r1_1\\";
-const char *tc2_snapshot = "..\\..\\..\\snapshots\\TC2\\";
+const char *default_base_snapshot_path="..\\..\\..\\snapshots";
+const char *juno_snapshot = "\\juno_r1_1\\";
+const char *tc2_snapshot = "\\TC2\\";
#else
-const char *default_path_to_snapshot = "../../../snapshots/juno_r1_1/";
-const char *tc2_snapshot = "../../../snapshots/TC2/";
+const char *default_base_snapshot_path = "../../snapshots";
+const char *juno_snapshot = "/juno_r1_1/";
+const char *tc2_snapshot = "/TC2/";
#endif
+static const char *selected_snapshot;
+static const char *usr_snapshot_path = 0;
+#define MAX_TRACE_FILE_PATH_LEN 512
/* trace data and memory file dump names and values - taken from snapshot metadata */
const char *trace_data_filename = "cstrace.bin";
@@ -80,6 +85,7 @@ const ocsd_vaddr_t mem_dump_address_tc2=0xC0008000;
/* test variables - set by command line to feature test API */
static int using_mem_acc_cb = 0; /* test the memory access callback function */
static int use_region_file = 0; /* test multi region memory files */
+static int using_mem_acc_cb_id = 0; /* test the mem acc callback with trace ID parameter */
/* buffer to handle a packet string */
#define PACKET_STR_LEN 1024
@@ -114,6 +120,7 @@ static int test_lib_printers = 0;
static int process_cmd_line(int argc, char *argv[])
{
int idx = 1;
+ int len = 0;
while(idx < argc)
{
@@ -137,13 +144,13 @@ static int process_cmd_line(int argc, char *argv[])
else if(strcmp(argv[idx],"-etmv3") == 0)
{
test_protocol = OCSD_PROTOCOL_ETMV3;
- default_path_to_snapshot = tc2_snapshot;
+ selected_snapshot = tc2_snapshot;
mem_dump_address = mem_dump_address_tc2;
}
else if(strcmp(argv[idx],"-ptm") == 0)
{
test_protocol = OCSD_PROTOCOL_PTM;
- default_path_to_snapshot = tc2_snapshot;
+ selected_snapshot = tc2_snapshot;
mem_dump_address = mem_dump_address_tc2;
}
else if(strcmp(argv[idx],"-stm") == 0)
@@ -156,6 +163,12 @@ static int process_cmd_line(int argc, char *argv[])
using_mem_acc_cb = 1;
use_region_file = 0;
}
+ else if (strcmp(argv[idx], "-test_cb_id") == 0)
+ {
+ using_mem_acc_cb = 1;
+ use_region_file = 0;
+ using_mem_acc_cb_id = 1;
+ }
else if(strcmp(argv[idx],"-test_region_file") == 0)
{
use_region_file = 1;
@@ -181,6 +194,26 @@ static int process_cmd_line(int argc, char *argv[])
{
test_lib_printers = 1;
}
+ else if(strcmp(argv[idx],"-ss_path") == 0)
+ {
+ idx++;
+ if((idx >= argc) || (strlen(argv[idx]) == 0))
+ {
+ printf("-ss_path: Missing path parameter or zero length\n");
+ return -1;
+ }
+ else
+ {
+ len = strlen(argv[idx]);
+ if(len > (MAX_TRACE_FILE_PATH_LEN - 32))
+ {
+ printf("-ss_path: path too long\n");
+ return -1;
+ }
+ usr_snapshot_path = argv[idx];
+ }
+
+ }
else if(strcmp(argv[idx],"-help") == 0)
{
return -1;
@@ -199,7 +232,8 @@ static void print_cmd_line_help()
printf("-decode | -decode_only : full decode + trace packets / full decode packets only (default trace packets only)\n");
printf("-raw / -raw_packed: print raw unpacked / packed data;\n");
printf("-test_printstr | -test_libprint : ttest lib printstr callback | test lib based packet printers\n");
- printf("-test_region_file | -test_cb : mem accessor - test multi region file API | test callback API (default single memory file)\n\n");
+ printf("-test_region_file | -test_cb | -test_cb_id : mem accessor - test multi region file API | test callback API [with trcid] (default single memory file)\n\n");
+ printf("-ss_path <path> : path from cwd to /snapshots/ directory. Test prog will append required test subdir\n");
}
/************************************************************************/
@@ -211,11 +245,13 @@ static ocsd_mem_space_acc_t dump_file_mem_space = OCSD_MEM_SPACE_ANY; /* memor
static long mem_file_size = 0; /* size of the memory file */
static ocsd_vaddr_t mem_file_en_address = 0; /* end address last inclusive address in file. */
+/* log the memacc output */
+/* #define LOG_MEMACC_CB */
/* decode memory access using a CallBack function
* tests CB API and add / remove mem acc API.
*/
-static uint32_t mem_acc_cb(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint32_t reqBytes, uint8_t *byteBuffer)
+static uint32_t do_mem_acc_cb(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t trc_id, const uint32_t reqBytes, uint8_t *byteBuffer)
{
uint32_t read_bytes = 0;
size_t file_read_bytes;
@@ -248,9 +284,24 @@ static uint32_t mem_acc_cb(const void *p_context, const ocsd_vaddr_t address, c
if(file_read_bytes < read_bytes)
read_bytes = file_read_bytes;
}
+#ifdef LOG_MEMACC_CB
+ sprintf(packet_str, "mem_acc_cb(addr 0x%08llX, size %d, trcID 0x%02X)\n", address, reqBytes, trc_id);
+ ocsd_def_errlog_msgout(packet_str);
+#endif
return read_bytes;
}
+static uint32_t mem_acc_cb(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint32_t reqBytes, uint8_t *byteBuffer)
+{
+ return do_mem_acc_cb(p_context, address, mem_space, 0xff, reqBytes, byteBuffer);
+}
+
+static uint32_t mem_acc_id_cb(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t trc_id, const uint32_t reqBytes, uint8_t *byteBuffer)
+{
+ return do_mem_acc_cb(p_context, address, mem_space, trc_id, reqBytes, byteBuffer);
+}
+
+
/* Create the memory accessor using the callback function and attach to decode tree */
static ocsd_err_t create_mem_acc_cb(dcd_tree_handle_t dcd_tree_h, const char *mem_file_path)
{
@@ -262,8 +313,12 @@ static ocsd_err_t create_mem_acc_cb(dcd_tree_handle_t dcd_tree_h, const char *me
mem_file_size = ftell(dump_file);
mem_file_en_address = mem_dump_address + mem_file_size - 1;
- err = ocsd_dt_add_callback_mem_acc(dcd_tree_h,
- mem_dump_address,mem_file_en_address,dump_file_mem_space,&mem_acc_cb,0);
+ if (using_mem_acc_cb_id)
+ err = ocsd_dt_add_callback_trcid_mem_acc(dcd_tree_h, mem_dump_address,
+ mem_file_en_address, dump_file_mem_space, &mem_acc_id_cb, 0);
+ else
+ err = ocsd_dt_add_callback_mem_acc(dcd_tree_h, mem_dump_address,
+ mem_file_en_address, dump_file_mem_space, &mem_acc_cb, 0);
if(err != OCSD_OK)
{
fclose(dump_file);
@@ -290,15 +345,19 @@ static void destroy_mem_acc_cb(dcd_tree_handle_t dcd_tree_h)
static ocsd_err_t create_test_memory_acc(dcd_tree_handle_t handle)
{
ocsd_err_t ret = OCSD_OK;
- char mem_file_path[512];
+ char mem_file_path[MAX_TRACE_FILE_PATH_LEN];
uint32_t i0adjust = 0x100;
int i = 0;
-
+
/* region list to test multi region memory file API */
ocsd_file_mem_region_t region_list[4];
/* path to the file containing the memory image traced - raw binary data in the snapshot */
- strcpy(mem_file_path,default_path_to_snapshot);
+ if(usr_snapshot_path != 0)
+ strcpy(mem_file_path,usr_snapshot_path);
+ else
+ strcpy(mem_file_path,default_base_snapshot_path);
+ strcat(mem_file_path,selected_snapshot);
strcat(mem_file_path,memory_dump_filename);
/*
@@ -899,10 +958,13 @@ int process_trace_data(FILE *pf)
int main(int argc, char *argv[])
{
FILE *trace_data;
- char trace_file_path[512];
+ char trace_file_path[MAX_TRACE_FILE_PATH_LEN];
int ret = 0, i, len;
char message[512];
+ /* default to juno */
+ selected_snapshot = juno_snapshot;
+
/* command line params */
if(process_cmd_line(argc,argv) != 0)
{
@@ -911,8 +973,13 @@ int main(int argc, char *argv[])
}
/* trace data file path */
- strcpy(trace_file_path,default_path_to_snapshot);
+ if(usr_snapshot_path != 0)
+ strcpy(trace_file_path,usr_snapshot_path);
+ else
+ strcpy(trace_file_path,default_base_snapshot_path);
+ strcat(trace_file_path,selected_snapshot);
strcat(trace_file_path,trace_data_filename);
+ printf("opening %s trace data file\n",trace_file_path);
trace_data = fopen(trace_file_path,"rb");
if(trace_data != NULL)
diff --git a/decoder/tests/source/mem_buff_demo.cpp b/decoder/tests/source/mem_buff_demo.cpp
new file mode 100644
index 000000000000..cacc227e941f
--- /dev/null
+++ b/decoder/tests/source/mem_buff_demo.cpp
@@ -0,0 +1,416 @@
+/*
+* \file mem_buff_demo.cpp
+* \brief OpenCSD: using the library with memory buffers for data.
+*
+* \copyright Copyright (c) 2018, ARM Limited. All Rights Reserved.
+*/
+
+/*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice,
+* this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software without
+* specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
+* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* Example showing techniques to drive library using only memory buffers as input data
+ * and image data, avoiding file i/o in main processing routines. (File I/O used to
+ * initially populate buffers but this can be replaced if data is generated by a client
+ * environment running live.)
+ */
+
+#include <cstdio>
+#include <string>
+#include <iostream>
+#include <sstream>
+#include <cstring>
+
+#include "opencsd.h" // the library
+
+// uncomment below to use callback function for program memory image
+// #define EXAMPLE_USE_MEM_CALLBACK
+
+/* Input trace buffer */
+static uint8_t *input_trace_data = 0;
+static uint32_t input_trace_data_size = 0;
+
+/* program memory image for decode */
+static uint8_t *program_image_buffer = 0; // buffer for image data.
+static uint32_t program_image_size = 0; // size of program image data.
+static ocsd_vaddr_t program_image_address = 0; // load address on target of program image.
+
+/* a message logger to pass to the error logger / decoder. */
+static ocsdMsgLogger logger;
+
+/* logger callback function - print out error strings */
+class logCallback : public ocsdMsgLogStrOutI
+{
+public:
+ logCallback() {};
+ virtual ~logCallback() {};
+ virtual void printOutStr(const std::string &outStr)
+ {
+ std::cout << outStr.c_str();
+ }
+};
+static logCallback logCB;
+
+/* Decode tree is the main decoder framework - contains the frame unpacker,
+ packet and trace stream decoders, plus memory image references */
+static DecodeTree *pDecoder = 0;
+
+/* an error logger - Decode tree registers all components with the error logger
+so that errors can be correctly attributed and printed if required
+*/
+static ocsdDefaultErrorLogger err_log;
+
+/* callbacks used by the library */
+#ifdef EXAMPLE_USE_MEM_CALLBACK
+// program memory image callback definition
+uint32_t mem_access_callback_fn(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint32_t reqBytes, uint8_t *byteBuffer);
+#endif
+
+// callback for the decoder output elements
+class DecoderOutputProcessor : public ITrcGenElemIn
+{
+public:
+ DecoderOutputProcessor() {};
+ virtual ~DecoderOutputProcessor() {};
+
+ virtual ocsd_datapath_resp_t TraceElemIn(const ocsd_trc_index_t index_sop,
+ const uint8_t trc_chan_id,
+ const OcsdTraceElement &elem)
+ {
+ // must fully process or make a copy of data in here.
+ // element reference only valid for scope of call.
+
+ // for the example program we will stringise and print -
+ // but this is a client program implmentation dependent.
+ std::string elemStr;
+ std::ostringstream oss;
+ oss << "Idx:" << index_sop << "; ID:" << std::hex << (uint32_t)trc_chan_id << "; ";
+ elem.toString(elemStr);
+ oss << elemStr << std::endl;
+ logger.LogMsg(oss.str());
+ return OCSD_RESP_CONT;
+ }
+};
+static DecoderOutputProcessor output;
+
+/* for test purposes we are initialising from files, but this could be generated test data as
+ part of a larger program and / or compiled in memory images.
+
+ We have hardcoded in one of the snapshots supplied with the library
+ */
+static int initDataBuffers()
+{
+ FILE *fp;
+ std::string filename;
+ long size;
+
+ /* the file names to create the data buffers */
+#ifdef _WIN32
+ static const char *default_base_snapshot_path = "..\\..\\..\\snapshots";
+ static const char *juno_snapshot = "\\juno_r1_1\\";
+#else
+ static const char *default_base_snapshot_path = "../../../snapshots";
+ static const char *juno_snapshot = "/juno_r1_1/";
+#endif
+
+ /* trace data and memory file dump names and values - taken from snapshot metadata */
+ static const char *trace_data_filename = "cstrace.bin";
+ static const char *memory_dump_filename = "kernel_dump.bin";
+ static ocsd_vaddr_t mem_dump_address = 0xFFFFFFC000081000;
+
+ /* load up the trace data */
+ filename = default_base_snapshot_path;
+ filename += (std::string)juno_snapshot;
+ filename += (std::string)trace_data_filename;
+
+ fp = fopen(filename.c_str(), "rb");
+ if (!fp)
+ return OCSD_ERR_FILE_ERROR;
+ fseek(fp, 0, SEEK_END);
+ size = ftell(fp);
+ input_trace_data_size = (uint32_t)size;
+ input_trace_data = new (std::nothrow) uint8_t[input_trace_data_size];
+ if (!input_trace_data) {
+ fclose(fp);
+ return OCSD_ERR_MEM;
+ }
+ rewind(fp);
+ fread(input_trace_data, 1, input_trace_data_size, fp);
+ fclose(fp);
+
+ /* load up a memory image */
+ filename = default_base_snapshot_path;
+ filename += (std::string)juno_snapshot;
+ filename += (std::string)memory_dump_filename;
+
+ fp = fopen(filename.c_str(), "rb");
+ if (!fp)
+ return OCSD_ERR_FILE_ERROR;
+ fseek(fp, 0, SEEK_END);
+ size = ftell(fp);
+ program_image_size = (uint32_t)size;
+ program_image_buffer = new (std::nothrow) uint8_t[program_image_size];
+ if (!program_image_buffer) {
+ fclose(fp);
+ return OCSD_ERR_MEM;
+ }
+ rewind(fp);
+ fread(program_image_buffer, 1, program_image_size, fp);
+ fclose(fp);
+ program_image_address = mem_dump_address;
+ return OCSD_OK;
+}
+
+static ocsd_err_t createETMv4StreamDecoder()
+{
+ ocsd_etmv4_cfg trace_config;
+ ocsd_err_t err = OCSD_OK;
+ EtmV4Config *pCfg = 0;
+
+ /*
+ * populate the ETMv4 configuration structure with
+ * hard coded values from snapshot .ini files.
+ */
+
+ trace_config.arch_ver = ARCH_V8;
+ trace_config.core_prof = profile_CortexA;
+
+ trace_config.reg_configr = 0x000000C1;
+ trace_config.reg_traceidr = 0x00000010; /* this is the trace ID -> 0x10, change this to analyse other streams in snapshot.*/
+ trace_config.reg_idr0 = 0x28000EA1;
+ trace_config.reg_idr1 = 0x4100F403;
+ trace_config.reg_idr2 = 0x00000488;
+ trace_config.reg_idr8 = 0x0;
+ trace_config.reg_idr9 = 0x0;
+ trace_config.reg_idr10 = 0x0;
+ trace_config.reg_idr11 = 0x0;
+ trace_config.reg_idr12 = 0x0;
+ trace_config.reg_idr13 = 0x0;
+
+ pCfg = new (std::nothrow) EtmV4Config(&trace_config);
+ if (!pCfg)
+ return OCSD_ERR_MEM;
+
+ err = pDecoder->createDecoder(OCSD_BUILTIN_DCD_ETMV4I, /* etm v4 decoder */
+ OCSD_CREATE_FLG_FULL_DECODER, /* full trace decode */
+ pCfg);
+ delete pCfg;
+ return err;
+}
+
+/* Create the decode tree and add the error logger, stream decoder, memory image data to it.
+ Also register the output callback that processes the decoded trace packets. */
+static ocsd_err_t initialiseDecoder()
+{
+ ocsd_err_t ret = OCSD_OK;
+
+ /* use the creation function to get the type of decoder we want
+ either OCSD_TRC_SRC_SINGLE : single trace source - not frame formatted
+ OCSD_TRC_SRC_FRAME_FORMATTED :multi source - CoreSight trace frame
+ and set the config flags for operation
+ OCSD_DFRMTR_FRAME_MEM_ALIGN: input data mem aligned -> no syncs
+
+ For this test we create a decode that can unpack frames and is not expecting sync packets.
+ */
+ pDecoder = DecodeTree::CreateDecodeTree(OCSD_TRC_SRC_FRAME_FORMATTED, OCSD_DFRMTR_FRAME_MEM_ALIGN);
+ if (!pDecoder)
+ return OCSD_ERR_MEM;
+
+ /* set up decoder logging - the message logger for output, and the error logger for the library */
+ logger.setLogOpts(ocsdMsgLogger::OUT_STR_CB); /* no IO from the logger, just a string callback. */
+ logger.setStrOutFn(&logCB); /* set the callback - in this example it will go to stdio but this is up to the implementor. */
+
+ // for debugging - stdio and file
+// logger.setLogOpts(ocsdMsgLogger::OUT_FILE | ocsdMsgLogger::OUT_STDOUT);
+
+ err_log.initErrorLogger(OCSD_ERR_SEV_INFO);
+ err_log.setOutputLogger(&logger); /* pass the output logger to the error logger. */
+
+ pDecoder->setAlternateErrorLogger(&err_log); /* pass the error logger to the decoder, do not use the library version. */
+
+ /* now set up the elements that the decoder needs */
+
+ /* we will decode one of the streams in this example
+ create a Full decode ETMv4 stream decoder */
+ ret = createETMv4StreamDecoder();
+ if (ret != OCSD_OK)
+ return ret;
+
+ /* as this has full decode we must supply a memory image. */
+
+ ret = pDecoder->createMemAccMapper(); // the mapper is needed to add code images to.
+ if (ret != OCSD_OK)
+ return ret;
+
+#ifdef EXAMPLE_USE_MEM_CALLBACK
+ // in this example we have a single buffer so we demonstrate how to use a callback.
+ // we are passing the buffer pointer as context as we only have one buffer, but this
+ // could be a structure that is a list of memory image buffers. Context is entirely
+ // client defined.
+ // Always use OCSD_MEM_SPACE_ANY unless there is a reason to restrict the image to a specific
+ // memory space.
+ pDecoder->addCallbackMemAcc(program_image_address, program_image_address + program_image_size-1,
+ OCSD_MEM_SPACE_ANY,mem_access_callback_fn, program_image_buffer);
+#else
+ // or we can use the built in memory buffer interface - split our one buffer into two to
+ // demonstrate the addition of multiple regions
+ ocsd_vaddr_t block1_st, block2_st;
+ uint32_t block1_sz, block2_sz;
+ uint8_t *p_block1, *p_block2;
+
+ // break our single buffer into 2 buffers for demo purposes
+ block1_sz = program_image_size / 2;
+ block1_sz &= ~0x3; // align
+ block2_sz = program_image_size - block1_sz;
+ block1_st = program_image_address; // loaded program memory start address of program
+ block2_st = program_image_address + block1_sz;
+ p_block1 = program_image_buffer;
+ p_block2 = program_image_buffer + block1_sz;
+
+ /* how to add 2 "separate" buffers to the decoder */
+ // Always use OCSD_MEM_SPACE_ANY unless there is a reason to restrict the image to a specific
+ // memory space.
+ ret = pDecoder->addBufferMemAcc(block1_st, OCSD_MEM_SPACE_ANY, p_block1, block1_sz);
+ if (ret != OCSD_OK)
+ return ret;
+
+ ret = pDecoder->addBufferMemAcc(block2_st, OCSD_MEM_SPACE_ANY, p_block2, block2_sz);
+ if (ret != OCSD_OK)
+ return ret;
+#endif
+
+ /* finally we need to provide an output callback to recieve the decoded information */
+ pDecoder->setGenTraceElemOutI(&output);
+ return ret;
+}
+
+/* get rid of the objects we created */
+static void destroyDecoder()
+{
+ delete pDecoder;
+ delete [] input_trace_data;
+ delete [] program_image_buffer;
+}
+
+#ifdef EXAMPLE_USE_MEM_CALLBACK
+/* if we set up to use a callback to access memory image then this is what will be called. */
+/* In this case the client must do all the work in determining if the requested address is in the
+ memory area. */
+uint32_t mem_access_callback_fn(const void *p_context, const ocsd_vaddr_t address,
+ const ocsd_mem_space_acc_t mem_space, const uint32_t reqBytes, uint8_t *byteBuffer)
+{
+ ocsd_vaddr_t buf_end_address = program_image_address + program_image_size - 1;
+ uint32_t read_bytes = reqBytes;
+
+ /* context should be our memory image buffer - if not return 0 bytes read */
+ if (p_context != program_image_buffer)
+ return 0;
+
+ /* not concerned with memory spaces - assume all global */
+ if ((address < program_image_address) || (address > buf_end_address))
+ return 0; // requested address not in our buffer.
+
+ // if requested bytes from address more than we have, only read to end of buffer
+ if ((address + reqBytes - 1) > buf_end_address)
+ read_bytes = (uint32_t)(buf_end_address - (address - 1));
+
+ // copy the requested data.
+ memcpy(byteBuffer, program_image_buffer + (address - program_image_address), read_bytes);
+
+ return read_bytes;
+}
+#endif
+
+/* use the decoder to process the global trace data buffer */
+static ocsd_datapath_resp_t processTraceData(uint32_t *bytes_done)
+{
+ /* process in blocks of fixed size. */
+ #define DATA_CHUNK_SIZE 2048
+
+ ocsd_datapath_resp_t resp = OCSD_RESP_CONT;
+ uint32_t block_size, buff_offset, bytes_to_do = input_trace_data_size, bytes_processed;
+ ocsd_trc_index_t index = 0;
+
+ /* process the data in chunks, until either all done or
+ * error occurs.
+ */
+ while ((resp == OCSD_RESP_CONT) && (bytes_to_do))
+ {
+ /* size up a block of input data */
+ block_size = (bytes_to_do >= DATA_CHUNK_SIZE) ? DATA_CHUNK_SIZE : bytes_to_do;
+ buff_offset = input_trace_data_size - bytes_to_do;
+
+ /* push it through the decoder */
+ resp = pDecoder->TraceDataIn(OCSD_OP_DATA, index, block_size,
+ input_trace_data + buff_offset, &bytes_processed);
+
+ /* adjust counter per bytes processed */
+ bytes_to_do -= bytes_processed;
+ index += bytes_processed;
+ }
+
+ /* if all done then signal end of trace - flushes out any remaining data */
+ if (!bytes_to_do)
+ resp = pDecoder->TraceDataIn(OCSD_OP_EOT, 0, 0, 0, 0);
+
+ /* return amount processed */
+ *bytes_done = input_trace_data_size - bytes_to_do;
+ return resp;
+}
+
+/* main routine - init input data, decode, finish ... */
+int main(int argc, char* argv[])
+{
+ int ret = OCSD_OK;
+ ocsd_datapath_resp_t retd;
+ char msg[256];
+ uint32_t bytes_done;
+
+ /* initialise all the data needed for decode */
+ if ((ret = initDataBuffers()) != OCSD_OK)
+ {
+ logger.LogMsg("Failed to create trace data buffers\n");
+ return ret;
+ }
+ /* initialise a decoder object */
+ if ((ret = initialiseDecoder()) == OCSD_OK)
+ {
+ retd = processTraceData(&bytes_done);
+ if (!OCSD_DATA_RESP_IS_CONT(retd))
+ {
+ ret = OCSD_ERR_DATA_DECODE_FATAL;
+ logger.LogMsg("Processing failed with data error\n");
+ }
+
+ /* get rid of the decoder and print a brief result. */
+ destroyDecoder();
+ sprintf(msg, "Processed %u bytes out of %u\n", bytes_done, input_trace_data_size);
+ logger.LogMsg(msg);
+ }
+ else
+ logger.LogMsg("Failed to create decoder for trace processing\n");
+ return ret;
+}
diff --git a/decoder/tests/source/trc_pkt_lister.cpp b/decoder/tests/source/trc_pkt_lister.cpp
index 854f15817b95..50260a5f8b9b 100644
--- a/decoder/tests/source/trc_pkt_lister.cpp
+++ b/decoder/tests/source/trc_pkt_lister.cpp
@@ -70,6 +70,9 @@ static bool decode = false;
static bool no_undecoded_packets = false;
static bool pkt_mon = false;
static int test_waits = 0;
+static bool dstream_format = false;
+static bool tpiu_format = false;
+static bool has_hsync = false;
int main(int argc, char* argv[])
{
@@ -180,8 +183,11 @@ void print_help()
oss << "-ss_dir <dir> Set the directory path to a trace snapshot\n";
oss << "-ss_verbose Verbose output when reading the snapshot\n";
oss << "\nDecode:\n\n";
- oss << "-id <n> Set an ID to list (may be used mutiple times) - default if no id set is for all IDs to be printed\n";
+ oss << "-id <n> Set an ID to list (may be used multiple times) - default if no id set is for all IDs to be printed\n";
oss << "-src_name <name> List packets from a given snapshot source name (defaults to first source found)\n";
+ oss << "-dstream_format Input is DSTREAM framed.";
+ oss << "-tpiu Input from TPIU - sync by FSYNC.";
+ oss << "-tpiu_hsync Input from TPIU - sync by FSYNC and HSYNC.";
oss << "-decode Full decode of the packets from the trace snapshot (default is to list undecoded packets only\n";
oss << "-decode_only Does not list the undecoded packets, just the trace decode.\n";
oss << "-o_raw_packed Output raw packed trace frames\n";
@@ -401,6 +407,19 @@ bool process_cmd_line_opts(int argc, char* argv[])
optIdx++;
}
}
+ else if (strcmp(argv[optIdx], "-dstream_format") == 0)
+ {
+ dstream_format = true;
+ }
+ else if (strcmp(argv[optIdx], "-tpiu") == 0)
+ {
+ tpiu_format = true;
+ }
+ else if (strcmp(argv[optIdx], "-tpiu_hsync") == 0)
+ {
+ has_hsync = true;
+ tpiu_format = true;
+ }
else
{
std::ostringstream errstr;
@@ -488,9 +507,19 @@ void ConfigureFrameDeMux(DecodeTree *dcd_tree, RawFramePrinter **framePrinter)
if(pDeformatter != 0)
{
// configuration - memory alinged buffer
- uint32_t configFlags = OCSD_DFRMTR_FRAME_MEM_ALIGN;
+ uint32_t configFlags = pDeformatter->getConfigFlags();
+
+ // check for TPIU FSYNC & HSYNC
+ if (tpiu_format) configFlags |= OCSD_DFRMTR_HAS_FSYNCS;
+ if (has_hsync) configFlags |= OCSD_DFRMTR_HAS_HSYNCS;
+ // if FSYNC (& HSYNC) - cannot be mem frame aligned.
+ if (tpiu_format) configFlags &= ~OCSD_DFRMTR_FRAME_MEM_ALIGN;
- pDeformatter->Configure(configFlags);
+ if (!configFlags)
+ {
+ configFlags = OCSD_DFRMTR_FRAME_MEM_ALIGN;
+ pDeformatter->Configure(configFlags);
+ }
if (outRawPacked || outRawUnpacked)
{
if (outRawPacked) configFlags |= OCSD_DFRMTR_PACKED_RAW_OUT;
@@ -554,7 +583,12 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader
// process the file, a buffer load at a time
while(!in.eof() && !OCSD_DATA_RESP_IS_FATAL(dataPathResp))
{
- in.read((char *)&trace_buffer[0],bufferSize); // load a block of data into the buffer
+ if (dstream_format)
+ {
+ in.read((char *)&trace_buffer[0], 512 - 8);
+ }
+ else
+ in.read((char *)&trace_buffer[0],bufferSize); // load a block of data into the buffer
std::streamsize nBuffRead = in.gcount(); // get count of data loaded.
std::streamsize nBuffProcessed = 0; // amount processed in this buffer.
@@ -597,6 +631,22 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader
dataPathResp = dcd_tree->TraceDataIn(OCSD_OP_FLUSH,0,0,0,0);
}
}
+
+ /* dump dstream footers */
+ if (dstream_format) {
+ in.read((char *)&trace_buffer[0], 8);
+ if (outRawPacked)
+ {
+ std::ostringstream oss;
+ oss << "DSTREAM footer [";
+ for (int i = 0; i < 8; i++)
+ {
+ oss << "0x" << std::hex << (int)trace_buffer[i] << " ";
+ }
+ oss << "]\n";
+ logger.LogMsg(oss.str());
+ }
+ }
}
// fatal error - no futher processing