This patch set provides the following additional features:- i) Support for the FSYNC barrier packets inserted by perf. ii) Moves the packet printers from the test code into the main library to allow use by client programs. Additional APIs provided to create and use this packet printers.
Plus additional minor fixes and docs changes.
Mathieu Poirier (1): opencsd: update content to work with any kernel version
Mike Leach (10): opencsd: remove deprecated C-API functions opencsd: Allow FSYNCs to be used as special frames. opencsd: Update message logger for string print callback. opencsd: Move packet printer classes from test code to main library. opencsd: Update C-API to for addtional features. opencsd: tests: Add command line print to test log opencsd: etmv4: Minor print string mod for trace info packet. opencsd: Update error logger interface. opencsd: Add packet printer API to decode tree and C-API opencsd: update README, HOWTO and versions for v0.6
HOWTO.md | 43 +- README.md | 4 +- TODO | 16 +- decoder/build/linux/makefile | 2 - decoder/build/linux/rctdl_c_api_lib/makefile | 1 - decoder/build/linux/ref_trace_decode_lib/makefile | 10 +- .../rctdl_c_api_lib/rctdl_c_api_lib.vcxproj | 2 - .../rctdl_c_api_lib.vcxproj.filters | 6 - .../ref_trace_decode_lib/ref_trace_decode_lib.sln | 21 - .../ref_trace_decode_lib.vcxproj | 8 + .../ref_trace_decode_lib.vcxproj.filters | 30 + decoder/include/c_api/ocsd_c_api_deprc_fn.h | 233 ------ decoder/include/c_api/ocsd_c_api_types.h | 2 + decoder/include/c_api/opencsd_c_api.h | 59 +- decoder/include/common/ocsd_dcd_tree.h | 18 +- decoder/include/common/ocsd_error_logger.h | 4 +- decoder/include/common/ocsd_msg_logger.h | 18 +- decoder/include/common/trc_frame_deformatter.h | 1 + decoder/include/common/trc_pkt_proc_base.h | 10 +- decoder/include/interfaces/trc_error_log_i.h | 3 + decoder/include/ocsd_if_types.h | 3 +- decoder/include/ocsd_if_version.h | 6 +- decoder/include/opencsd.h | 4 + decoder/include/pkt_printers/gen_elem_printer.h | 95 +++ decoder/include/pkt_printers/item_printer.h | 94 +++ decoder/include/pkt_printers/pkt_printer_t.h | 189 +++++ decoder/include/pkt_printers/raw_frame_printer.h | 69 ++ decoder/include/pkt_printers/trc_pkt_printers.h | 43 + decoder/include/pkt_printers/trc_print_fact.h | 60 ++ decoder/source/c_api/ocsd_c_api.cpp | 48 ++ decoder/source/c_api/ocsd_c_api_deprc_fn.cpp | 200 ----- decoder/source/c_api/ocsd_c_api_obj.h | 35 +- decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp | 2 +- decoder/source/ocsd_dcd_tree.cpp | 111 ++- decoder/source/ocsd_msg_logger.cpp | 34 +- decoder/source/pkt_printers/raw_frame_printer.cpp | 104 +++ decoder/source/pkt_printers/trc_print_fact.cpp | 123 +++ decoder/source/trc_frame_deformatter.cpp | 108 ++- decoder/source/trc_frame_deformatter_impl.h | 3 +- .../build/linux/simple_pkt_print_c_api/makefile | 82 -- decoder/tests/build/linux/trc_pkt_lister/makefile | 3 +- .../simple_pkt_print_c_api.vcxproj | 333 -------- .../simple_pkt_print_c_api.vcxproj.filters | 22 - .../trc_pkt_lister/trc_pkt_lister.vcxproj | 6 +- .../trc_pkt_lister/trc_pkt_lister.vcxproj.filters | 14 +- decoder/tests/source/c_api_pkt_print_test.c | 100 ++- decoder/tests/source/gen_elem_printer.h | 96 --- decoder/tests/source/item_printer.h | 94 --- decoder/tests/source/pkt_printer_t.h | 188 ----- decoder/tests/source/raw_frame_printer.cpp | 96 --- decoder/tests/source/raw_frame_printer.h | 71 -- decoder/tests/source/simple_pkt_c_api.c | 923 --------------------- decoder/tests/source/trc_pkt_lister.cpp | 179 +--- 53 files changed, 1413 insertions(+), 2616 deletions(-) delete mode 100644 decoder/include/c_api/ocsd_c_api_deprc_fn.h create mode 100644 decoder/include/pkt_printers/gen_elem_printer.h create mode 100644 decoder/include/pkt_printers/item_printer.h create mode 100644 decoder/include/pkt_printers/pkt_printer_t.h create mode 100644 decoder/include/pkt_printers/raw_frame_printer.h create mode 100644 decoder/include/pkt_printers/trc_pkt_printers.h create mode 100644 decoder/include/pkt_printers/trc_print_fact.h delete mode 100644 decoder/source/c_api/ocsd_c_api_deprc_fn.cpp create mode 100644 decoder/source/pkt_printers/raw_frame_printer.cpp create mode 100644 decoder/source/pkt_printers/trc_print_fact.cpp delete mode 100644 decoder/tests/build/linux/simple_pkt_print_c_api/makefile delete mode 100644 decoder/tests/build/win-vs2015/simple_pkt_print_c_api/simple_pkt_print_c_api.vcxproj delete mode 100644 decoder/tests/build/win-vs2015/simple_pkt_print_c_api/simple_pkt_print_c_api.vcxproj.filters delete mode 100644 decoder/tests/source/gen_elem_printer.h delete mode 100644 decoder/tests/source/item_printer.h delete mode 100644 decoder/tests/source/pkt_printer_t.h delete mode 100644 decoder/tests/source/raw_frame_printer.cpp delete mode 100644 decoder/tests/source/raw_frame_printer.h delete mode 100644 decoder/tests/source/simple_pkt_c_api.c
Remove source for deprecated C-API functions along with test API projects and source.
Remove deprecated C-API tests and source from linux library build.
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/build/linux/makefile | 2 - decoder/build/linux/rctdl_c_api_lib/makefile | 1 - .../rctdl_c_api_lib/rctdl_c_api_lib.vcxproj | 2 - .../rctdl_c_api_lib.vcxproj.filters | 6 - .../ref_trace_decode_lib/ref_trace_decode_lib.sln | 21 - decoder/include/c_api/ocsd_c_api_deprc_fn.h | 233 ------ decoder/include/c_api/opencsd_c_api.h | 5 - decoder/source/c_api/ocsd_c_api_deprc_fn.cpp | 200 ----- .../build/linux/simple_pkt_print_c_api/makefile | 82 -- .../simple_pkt_print_c_api.vcxproj | 333 -------- .../simple_pkt_print_c_api.vcxproj.filters | 22 - decoder/tests/source/simple_pkt_c_api.c | 923 --------------------- 12 files changed, 1830 deletions(-) delete mode 100644 decoder/include/c_api/ocsd_c_api_deprc_fn.h delete mode 100644 decoder/source/c_api/ocsd_c_api_deprc_fn.cpp delete mode 100644 decoder/tests/build/linux/simple_pkt_print_c_api/makefile delete mode 100644 decoder/tests/build/win-vs2015/simple_pkt_print_c_api/simple_pkt_print_c_api.vcxproj delete mode 100644 decoder/tests/build/win-vs2015/simple_pkt_print_c_api/simple_pkt_print_c_api.vcxproj.filters delete mode 100644 decoder/tests/source/simple_pkt_c_api.c
diff --git a/decoder/build/linux/makefile b/decoder/build/linux/makefile index 79b0090..d578bbd 100644 --- a/decoder/build/linux/makefile +++ b/decoder/build/linux/makefile @@ -159,7 +159,6 @@ 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/simple_pkt_print_c_api && make cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && make
############################################################# @@ -177,5 +176,4 @@ 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/simple_pkt_print_c_api && make clean cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && make clean diff --git a/decoder/build/linux/rctdl_c_api_lib/makefile b/decoder/build/linux/rctdl_c_api_lib/makefile index 6f4c0e7..c0ebdf5 100644 --- a/decoder/build/linux/rctdl_c_api_lib/makefile +++ b/decoder/build/linux/rctdl_c_api_lib/makefile @@ -50,7 +50,6 @@ CPP_INCLUDES= \ -I$(OCSD_SOURCE)/c_api
OBJECTS=$(BUILD_DIR)/ocsd_c_api.o \ - $(BUILD_DIR)/ocsd_c_api_deprc_fn.o \ $(BUILD_DIR)/ocsd_c_api_custom_obj.o
diff --git a/decoder/build/win-vs2015/rctdl_c_api_lib/rctdl_c_api_lib.vcxproj b/decoder/build/win-vs2015/rctdl_c_api_lib/rctdl_c_api_lib.vcxproj index b68a642..ece6ff0 100644 --- a/decoder/build/win-vs2015/rctdl_c_api_lib/rctdl_c_api_lib.vcxproj +++ b/decoder/build/win-vs2015/rctdl_c_api_lib/rctdl_c_api_lib.vcxproj @@ -307,7 +307,6 @@ <ClInclude Include="..\..\..\include\c_api\ocsd_c_api_custom.h" /> <ClInclude Include="..\..\..\include\c_api\ocsd_c_api_cust_fact.h" /> <ClInclude Include="..\..\..\include\c_api\ocsd_c_api_cust_impl.h" /> - <ClInclude Include="..\..\..\include\c_api\ocsd_c_api_deprc_fn.h" /> <ClInclude Include="..\..\..\include\c_api\ocsd_c_api_types.h" /> <ClInclude Include="..\..\..\include\c_api\opencsd_c_api.h" /> <ClInclude Include="..\..\..\source\c_api\ocsd_c_api_custom_obj.h" /> @@ -321,7 +320,6 @@ <ItemGroup> <ClCompile Include="..\..\..\source\c_api\ocsd_c_api.cpp" /> <ClCompile Include="..\..\..\source\c_api\ocsd_c_api_custom_obj.cpp" /> - <ClCompile Include="..\..\..\source\c_api\ocsd_c_api_deprc_fn.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/decoder/build/win-vs2015/rctdl_c_api_lib/rctdl_c_api_lib.vcxproj.filters b/decoder/build/win-vs2015/rctdl_c_api_lib/rctdl_c_api_lib.vcxproj.filters index b905bab..405a85d 100644 --- a/decoder/build/win-vs2015/rctdl_c_api_lib/rctdl_c_api_lib.vcxproj.filters +++ b/decoder/build/win-vs2015/rctdl_c_api_lib/rctdl_c_api_lib.vcxproj.filters @@ -24,9 +24,6 @@ <ClInclude Include="..\..\..\source\c_api\ocsd_c_api_obj.h"> <Filter>Source Files</Filter> </ClInclude> - <ClInclude Include="..\..\..\include\c_api\ocsd_c_api_deprc_fn.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="..\..\..\include\c_api\ocsd_c_api_custom.h"> <Filter>Header Files</Filter> </ClInclude> @@ -44,9 +41,6 @@ <ClCompile Include="..\..\..\source\c_api\ocsd_c_api.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="..\..\..\source\c_api\ocsd_c_api_deprc_fn.cpp"> - <Filter>Source Files</Filter> - </ClCompile> <ClCompile Include="..\..\..\source\c_api\ocsd_c_api_custom_obj.cpp"> <Filter>Source Files</Filter> </ClCompile> 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 2731a39..94b561a 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 @@ -17,11 +17,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "trc_pkt_lister", "......\ {7F500891-CC76-405F-933F-F682BC39F923} = {7F500891-CC76-405F-933F-F682BC39F923} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simple_pkt_print_c_api", "......\tests\build\win-vs2015\simple_pkt_print_c_api\simple_pkt_print_c_api.vcxproj", "{D18112ED-E2D7-4D49-B1F0-15E98967AC0A}" - ProjectSection(ProjectDependencies) = postProject - {533F929A-A73B-46B6-9D5F-FFCD62F734E3} = {533F929A-A73B-46B6-9D5F-FFCD62F734E3} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c_api_pkt_print_test", "......\tests\build\win-vs2015\c_api_pkt_print_test\c_api_pkt_print_test.vcxproj", "{3AC169DA-E156-4D16-95DF-73D7302A5606}" ProjectSection(ProjectDependencies) = postProject {46219A32-8178-41C1-B3B1-B5A6E547515F} = {46219A32-8178-41C1-B3B1-B5A6E547515F} @@ -101,22 +96,6 @@ Global {18ABC652-AB11-4993-9491-1A7FB7117339}.Release|x64.Build.0 = Release|x64 {18ABC652-AB11-4993-9491-1A7FB7117339}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {18ABC652-AB11-4993-9491-1A7FB7117339}.Release-dll|x64.ActiveCfg = Release-dll|x64 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Debug|Win32.ActiveCfg = Debug|Win32 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Debug|Win32.Build.0 = Debug|Win32 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Debug|x64.ActiveCfg = Debug|x64 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Debug|x64.Build.0 = Debug|x64 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Debug-dll|x64.Build.0 = Debug-dll|x64 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Release|Win32.ActiveCfg = Release|Win32 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Release|Win32.Build.0 = Release|Win32 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Release|x64.ActiveCfg = Release|x64 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Release|x64.Build.0 = Release|x64 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Release-dll|Win32.Build.0 = Release-dll|Win32 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Release-dll|x64.ActiveCfg = Release-dll|x64 - {D18112ED-E2D7-4D49-B1F0-15E98967AC0A}.Release-dll|x64.Build.0 = Release-dll|x64 {3AC169DA-E156-4D16-95DF-73D7302A5606}.Debug|Win32.ActiveCfg = Debug|Win32 {3AC169DA-E156-4D16-95DF-73D7302A5606}.Debug|Win32.Build.0 = Debug|Win32 {3AC169DA-E156-4D16-95DF-73D7302A5606}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/decoder/include/c_api/ocsd_c_api_deprc_fn.h b/decoder/include/c_api/ocsd_c_api_deprc_fn.h deleted file mode 100644 index 463f4af..0000000 --- a/decoder/include/c_api/ocsd_c_api_deprc_fn.h +++ /dev/null @@ -1,233 +0,0 @@ -/*! - * \file ocsd_c_api_deprc_fn.h - * \brief OpenCSD : Deprecated C-API functions - * - * \copyright Copyright (c) 2016, 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_OCSD_C_API_DEPRC_FN_H_INCLUDED -#define ARM_OCSD_C_API_DEPRC_FN_H_INCLUDED - -/** @defgroup depr_lib_c_api OpenCSD Library : Deprecated "C" API functions and types - - @brief "C" API functions and types that have been deprecated after API changes. - - Retained for regression testing for a few library versions - Will be removed completely in a later library version - - To use these functions define the macro OPENCSD_INC_DEPRECATED_API -@{*/ - -/** function pointer type for ETMv4 instruction packet processor output, packet analyser/decoder input */ -typedef ocsd_datapath_resp_t (* FnEtmv4IPacketDataIn)(const void *p_context, const ocsd_datapath_op_t op, const ocsd_trc_index_t index_sop, const ocsd_etmv4_i_pkt *p_packet_in); - -/** function pointer type for ETMv4 instruction packet processor monitor output, raw packet monitor / display input */ -typedef void (* FnEtmv4IPktMonDataIn)( const void *p_context, - const ocsd_datapath_op_t op, - const ocsd_trc_index_t index_sop, - const ocsd_etmv4_i_pkt *p_packet_in, - const uint32_t size, - const uint8_t *p_data); - -/** function pointer type for ETMv3 packet processor output, packet analyser/decoder input */ -typedef ocsd_datapath_resp_t (* FnEtmv3PacketDataIn)(const void *p_context, const ocsd_datapath_op_t op, const ocsd_trc_index_t index_sop, const ocsd_etmv3_pkt *p_packet_in); - -/** function pointer type for ETMv3 packet processor monitor output, raw packet monitor / display input */ -typedef void (* FnEtmv3PktMonDataIn)( const void *p_context, - const ocsd_datapath_op_t op, - const ocsd_trc_index_t index_sop, - const ocsd_etmv3_pkt *p_packet_in, - const uint32_t size, - const uint8_t *p_data); - - -/** function pointer type for PTM packet processor output, packet analyser/decoder input */ -typedef ocsd_datapath_resp_t (* FnPtmPacketDataIn)(const void *p_context, const ocsd_datapath_op_t op, const ocsd_trc_index_t index_sop, const ocsd_ptm_pkt *p_packet_in); - -/** function pointer type for PTM packet processor monitor output, raw packet monitor / display input */ -typedef void (* FnPtmPktMonDataIn)( const void *p_context, - const ocsd_datapath_op_t op, - const ocsd_trc_index_t index_sop, - const ocsd_ptm_pkt *p_packet_in, - const uint32_t size, - const uint8_t *p_data); - - -/** function pointer type for STM packet processor output, packet analyser/decoder input */ -typedef ocsd_datapath_resp_t (* FnStmPacketDataIn)(const void *p_context, const ocsd_datapath_op_t op, const ocsd_trc_index_t index_sop, const ocsd_stm_pkt *p_packet_in); - -/** function pointer type for STM packet processor monitor output, raw packet monitor / display input */ -typedef void (* FnStmPktMonDataIn)( const void *p_context, - const ocsd_datapath_op_t op, - const ocsd_trc_index_t index_sop, - const ocsd_stm_pkt *p_packet_in, - const uint32_t size, - const uint8_t *p_data); - - -/*---------------------- ETMv4 Trace ----------------------------------------------------------------------------------*/ -/*! - * Create an ETMv4 instruction trace packet processor only for the supplied configuration. - * Must supply an output callback function which handles the etmv4 packet types, to attach to the packet processor. - * - * @param handle : handle a decode tree to create the packet processsor. - * @param *etmv4_cfg : pointer to valid Etmv4 configuration structure. - * @param pPktFn : pointer to a packet handling callback function. - * @param p_context : opaque context pointer value used in callback function.. - * - * @return ocsd_err_t : Library error code - RCDTL_OK if successful. - */ -OCSD_C_API ocsd_err_t ocsd_dt_create_etmv4i_pkt_proc(const dcd_tree_handle_t handle, const void *etmv4_cfg, FnEtmv4IPacketDataIn pPktFn, const void *p_context); - -/*! - * Creates a packet processor + packet decoder pair for the supplied configuration structure. - * Uses the output function set in ocsd_dt_set_gen_elem_outfn() as the output sink. - * - * @param handle : Handle to decode tree. - * @param *etmv4_cfg : pointer to valid Etmv4 configuration structure. - * - * @return ocsd_err_t : Library error code - RCDTL_OK if successful. - */ -OCSD_C_API ocsd_err_t ocsd_dt_create_etmv4i_decoder(const dcd_tree_handle_t handle, const void *etmv4_cfg); - -/*! - * Attach a callback function to the packet processor monitor point defined by the CoreSight ID. - * - * @param handle : Handle to decode tree. - * @param trc_chan_id : CoreSight Trace ID for packet processor - * @param pPktFn : Function to attach to monitor point. - * @param p_context : opaque context pointer value used in callback function. - * - * @return ocsd_err_t : Library error code - RCDTL_OK if successful. - */ -OCSD_C_API ocsd_err_t ocsd_dt_attach_etmv4i_pkt_mon(const dcd_tree_handle_t handle, const uint8_t trc_chan_id, FnEtmv4IPktMonDataIn pPktFn, const void *p_context); - -/*---------------------- ETMv3 trace ----------------------------------------------------------------------------------*/ -/*! - * Create an ETMv3 trace packet processor only for the supplied configuration. - * Must supply an output callback function which handles the etmv3 packet types, to attach to the packet processor. - * - * @param handle : handle a decode tree to create the packet processsor. - * @param *etmv3_cfg : pointer to valid Etmv3 configuration structure. - * @param pPktFn : pointer to a packet handling callback function. - * @param p_context : opaque context pointer value used in callback function. - * - * @return ocsd_err_t : Library error code - RCDTL_OK if successful. - */ -OCSD_C_API ocsd_err_t ocsd_dt_create_etmv3_pkt_proc(const dcd_tree_handle_t handle, const void *etmv3_cfg, FnEtmv3PacketDataIn pPktFn, const void *p_context); - - -/*! - * Creates a packet processor + packet decoder pair for the supplied configuration structure. - * Uses the output function set in ocsd_dt_set_gen_elem_outfn() as the output sink. - * - * @param handle : Handle to decode tree. - * @param *etmv3_cfg : pointer to valid Etmv4 configuration structure. - * - * @return ocsd_err_t : Library error code - RCDTL_OK if successful. - */ -OCSD_C_API ocsd_err_t ocsd_dt_create_etmv3_decoder(const dcd_tree_handle_t handle, const void *etmv3_cfg); - - - -/*! - * Attach a callback function to the packet processor monitor point defined by the CoreSight ID. - * Packet processor must exist for the trace ID and be an ETMv3 processor. - * - * @param handle : Handle to decode tree. - * @param trc_chan_id : CoreSight Trace ID for packet processor - * @param pPktFn : Function to attach to monitor point. - * @param p_context : opaque context pointer value used in callback function. - * - * @return ocsd_err_t : Library error code - RCDTL_OK if successful. - */ -OCSD_C_API ocsd_err_t ocsd_dt_attach_etmv3_pkt_mon(const dcd_tree_handle_t handle, const uint8_t trc_chan_id, FnEtmv3PktMonDataIn pPktFn, const void *p_context); - -/*---------------------- PTM Trace ----------------------------------------------------------------------------------*/ -/*! - * Create an PTM instruction trace packet processor only for the supplied configuration. - * Must supply an output callback function which handles the ptm packet types, to attach to the packet processor. - * - * @param handle : handle a decode tree to create the packet processsor. - * @param *ptm_cfg : pointer to valid Ptm configuration structure. - * @param pPktFn : pointer to a packet handling callback function. - * @param p_context : opaque context pointer value used in callback function.. - * - * @return ocsd_err_t : Library error code - RCDTL_OK if successful. - */ -OCSD_C_API ocsd_err_t ocsd_dt_create_ptm_pkt_proc(const dcd_tree_handle_t handle, const void *ptm_cfg, FnPtmPacketDataIn pPktFn, const void *p_context); - -/*! - * Creates a packet processor + packet decoder pair for the supplied configuration structure. - * Uses the output function set in ocsd_dt_set_gen_elem_outfn() as the output sink. - * - * @param handle : Handle to decode tree. - * @param *ptm_cfg : pointer to valid Ptm configuration structure. - * - * @return ocsd_err_t : Library error code - RCDTL_OK if successful. - */ -OCSD_C_API ocsd_err_t ocsd_dt_create_ptm_decoder(const dcd_tree_handle_t handle, const void *ptm_cfg); - -/*! - * Attach a callback function to the packet processor monitor point defined by the CoreSight ID. - * - * @param handle : Handle to decode tree. - * @param trc_chan_id : CoreSight Trace ID for packet processor - * @param pPktFn : Function to attach to monitor point. - * @param p_context : opaque context pointer value used in callback function. - * - * @return ocsd_err_t : Library error code - RCDTL_OK if successful. - */ -OCSD_C_API ocsd_err_t ocsd_dt_attach_ptm_pkt_mon(const dcd_tree_handle_t handle, const uint8_t trc_chan_id, FnPtmPktMonDataIn pPktFn, const void *p_context); - - -/*---------------------- STM Trace ----------------------------------------------------------------------------------*/ -/*! - * Create an STM trace packet processor only for the supplied configuration. - * Must supply an output callback function which handles the stm packet types, to attach to the packet processor. - * - * @param handle : handle a decode tree to create the packet processsor. - * @param *stm_cfg : pointer to valid Stm configuration structure. - * @param pPktFn : pointer to a packet handling callback function. - * @param p_context : opaque context pointer value used in callback function. - * - * @return ocsd_err_t : Library error code - RCDTL_OK if successful. - */ -OCSD_C_API ocsd_err_t ocsd_dt_create_stm_pkt_proc(const dcd_tree_handle_t handle, const void *stm_cfg, FnStmPacketDataIn pPktFn, const void *p_context); - - - -/** deprecated memory region type for adding multi-region binary files to memory access interface */ -typedef ocsd_file_mem_region_t file_mem_region_t; -/** @}*/ - -#endif // ARM_OCSD_C_API_DEPRC_FN_H_INCLUDED - -/* End of File ocsd_c_api_deprc_fn.h */ diff --git a/decoder/include/c_api/opencsd_c_api.h b/decoder/include/c_api/opencsd_c_api.h index 0fee736..2795955 100644 --- a/decoder/include/c_api/opencsd_c_api.h +++ b/decoder/include/c_api/opencsd_c_api.h @@ -426,11 +426,6 @@ OCSD_C_API ocsd_err_t ocsd_cust_protocol_to_str(const ocsd_trace_protocol_t pkt_
/** @}*/
-#ifdef OPENCSD_INC_DEPRECATED_API -#include "ocsd_c_api_deprc_fn.h" -#endif - #endif // ARM_OPENCSD_C_API_H_INCLUDED
- /* End of File opencsd_c_api.h */ diff --git a/decoder/source/c_api/ocsd_c_api_deprc_fn.cpp b/decoder/source/c_api/ocsd_c_api_deprc_fn.cpp deleted file mode 100644 index 959ef0b..0000000 --- a/decoder/source/c_api/ocsd_c_api_deprc_fn.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * \file ocsd_c_api_deprc_fn.cpp - * \brief OpenCSD : Deprecated C-API functions. - * - * \copyright Copyright (c) 2016, 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. - */ - -/* pull in the C++ decode library */ -#include "opencsd.h" - -/* C-API and wrapper objects */ -#define OPENCSD_INC_DEPRECATED_API -#include "c_api/opencsd_c_api.h" -#include "ocsd_c_api_obj.h" - -#ifdef OPENCSD_INC_DEPRECATED_API - -OCSD_C_API ocsd_err_t ocsd_dt_create_etmv4i_pkt_proc(const dcd_tree_handle_t handle, const void *etmv4_cfg, FnEtmv4IPacketDataIn pPktFn, const void *p_context) -{ - ocsd_err_t err = OCSD_OK; - uint8_t CSID = 0; - if(handle != C_API_INVALID_TREE_HANDLE) - { - err = ocsd_dt_create_decoder(handle,OCSD_BUILTIN_DCD_ETMV4I,OCSD_CREATE_FLG_PACKET_PROC,etmv4_cfg,&CSID); - if(err == OCSD_OK) - { - err = ocsd_dt_attach_packet_callback(handle,CSID, OCSD_C_API_CB_PKT_SINK,(void *)pPktFn,p_context); - if(err != OCSD_OK) - ocsd_dt_remove_decoder(handle,CSID); - } - } - else - err = OCSD_ERR_INVALID_PARAM_VAL; - return err; -} - -OCSD_C_API ocsd_err_t ocsd_dt_create_etmv4i_decoder(const dcd_tree_handle_t handle, const void *etmv4_cfg) -{ - ocsd_err_t err = OCSD_OK; - if(handle != C_API_INVALID_TREE_HANDLE) - { - uint8_t CSID = 0; - err = ocsd_dt_create_decoder(handle,OCSD_BUILTIN_DCD_ETMV4I,OCSD_CREATE_FLG_FULL_DECODER,etmv4_cfg,&CSID); - } - else - err = OCSD_ERR_INVALID_PARAM_VAL; - return err; -} - -OCSD_C_API ocsd_err_t ocsd_dt_attach_etmv4i_pkt_mon(const dcd_tree_handle_t handle, const uint8_t trc_chan_id, FnEtmv4IPktMonDataIn pPktFn, const void *p_context) -{ - ocsd_err_t err = OCSD_OK; - if(handle != C_API_INVALID_TREE_HANDLE) - { - err = ocsd_dt_attach_packet_callback(handle,trc_chan_id,OCSD_C_API_CB_PKT_MON,(void *)pPktFn,p_context); - } - else - err = OCSD_ERR_INVALID_PARAM_VAL; - return err; -} - -OCSD_C_API ocsd_err_t ocsd_dt_create_etmv3_pkt_proc(const dcd_tree_handle_t handle, const void *etmv3_cfg, FnEtmv3PacketDataIn pPktFn, const void *p_context) -{ - ocsd_err_t err = OCSD_OK; - uint8_t CSID = 0; - if(handle != C_API_INVALID_TREE_HANDLE) - { - err = ocsd_dt_create_decoder(handle,OCSD_BUILTIN_DCD_ETMV3,OCSD_CREATE_FLG_PACKET_PROC,etmv3_cfg,&CSID); - if(err == OCSD_OK) - { - err = ocsd_dt_attach_packet_callback(handle,CSID, OCSD_C_API_CB_PKT_SINK,(void *)pPktFn,p_context); - if(err != OCSD_OK) - ocsd_dt_remove_decoder(handle,CSID); - } - } - else - err = OCSD_ERR_INVALID_PARAM_VAL; - return err; -} - -OCSD_C_API ocsd_err_t ocsd_dt_create_etmv3_decoder(const dcd_tree_handle_t handle, const void *etmv3_cfg) -{ - ocsd_err_t err = OCSD_OK; - if(handle != C_API_INVALID_TREE_HANDLE) - { - uint8_t CSID = 0; - err = ocsd_dt_create_decoder(handle,OCSD_BUILTIN_DCD_ETMV3,OCSD_CREATE_FLG_FULL_DECODER,etmv3_cfg,&CSID); - } - else - err = OCSD_ERR_INVALID_PARAM_VAL; - return err; -} - -OCSD_C_API ocsd_err_t ocsd_dt_attach_etmv3_pkt_mon(const dcd_tree_handle_t handle, const uint8_t trc_chan_id, FnEtmv3PktMonDataIn pPktFn, const void *p_context) -{ - ocsd_err_t err = OCSD_OK; - if(handle != C_API_INVALID_TREE_HANDLE) - { - err = ocsd_dt_attach_packet_callback(handle,trc_chan_id,OCSD_C_API_CB_PKT_MON,(void *)pPktFn,p_context); - } - else - err = OCSD_ERR_INVALID_PARAM_VAL; - return err; -} - - -OCSD_C_API ocsd_err_t ocsd_dt_create_ptm_pkt_proc(const dcd_tree_handle_t handle, const void *ptm_cfg, FnPtmPacketDataIn pPktFn, const void *p_context) -{ - ocsd_err_t err = OCSD_OK; - uint8_t CSID = 0; - if(handle != C_API_INVALID_TREE_HANDLE) - { - err = ocsd_dt_create_decoder(handle,OCSD_BUILTIN_DCD_PTM,OCSD_CREATE_FLG_PACKET_PROC,ptm_cfg,&CSID); - if(err == OCSD_OK) - { - err = ocsd_dt_attach_packet_callback(handle,CSID, OCSD_C_API_CB_PKT_SINK,(void *)pPktFn,p_context); - if(err != OCSD_OK) - ocsd_dt_remove_decoder(handle,CSID); - } - } - else - err = OCSD_ERR_INVALID_PARAM_VAL; - return err; - -} - -OCSD_C_API ocsd_err_t ocsd_dt_create_ptm_decoder(const dcd_tree_handle_t handle, const void *ptm_cfg) -{ - ocsd_err_t err = OCSD_OK; - if(handle != C_API_INVALID_TREE_HANDLE) - { - uint8_t CSID = 0; - err = ocsd_dt_create_decoder(handle,OCSD_BUILTIN_DCD_PTM,OCSD_CREATE_FLG_FULL_DECODER,ptm_cfg,&CSID); - } - else - err = OCSD_ERR_INVALID_PARAM_VAL; - return err; -} - -OCSD_C_API ocsd_err_t ocsd_dt_attach_ptm_pkt_mon(const dcd_tree_handle_t handle, const uint8_t trc_chan_id, FnPtmPktMonDataIn pPktFn, const void *p_context) -{ - ocsd_err_t err = OCSD_OK; - if(handle != C_API_INVALID_TREE_HANDLE) - { - err = ocsd_dt_attach_packet_callback(handle,trc_chan_id,OCSD_C_API_CB_PKT_MON,(void *)pPktFn,p_context); - } - else - err = OCSD_ERR_INVALID_PARAM_VAL; - return err; -} - -OCSD_C_API ocsd_err_t ocsd_dt_create_stm_pkt_proc(const dcd_tree_handle_t handle, const void *stm_cfg, FnStmPacketDataIn pPktFn, const void *p_context) -{ - ocsd_err_t err = OCSD_OK; - uint8_t CSID = 0; - if(handle != C_API_INVALID_TREE_HANDLE) - { - err = ocsd_dt_create_decoder(handle,OCSD_BUILTIN_DCD_STM,OCSD_CREATE_FLG_PACKET_PROC,stm_cfg,&CSID); - if(err == OCSD_OK) - { - err = ocsd_dt_attach_packet_callback(handle,CSID, OCSD_C_API_CB_PKT_SINK,(void *)pPktFn,p_context); - if(err != OCSD_OK) - ocsd_dt_remove_decoder(handle,CSID); - } - } - else - err = OCSD_ERR_INVALID_PARAM_VAL; - return err; -} - -#endif - -/* End of File ocsd_c_api_deprc_fn.cpp */ diff --git a/decoder/tests/build/linux/simple_pkt_print_c_api/makefile b/decoder/tests/build/linux/simple_pkt_print_c_api/makefile deleted file mode 100644 index a1e4612..0000000 --- a/decoder/tests/build/linux/simple_pkt_print_c_api/makefile +++ /dev/null @@ -1,82 +0,0 @@ -######################################################## -# Copyright 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: -# -# 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 simple c api packet list test. -# - -CC := $(MASTER_CC) -CC_FLAGS := $(MASTER_CC_FLAGS) -Wno-switch -LINKER := $(MASTER_LINKER) -LINKER_FLAGS := $(MASTER_LINKER_FLAGS) - -PROG = simple_pkt_print_c_api - -BUILD_DIR=./$(PLAT_DIR) - -VPATH = $(OCSD_TESTS)/source - -CC_INCLUDES = \ - -I$(OCSD_TESTS)/source \ - -I$(OCSD_INCLUDE) - -OBJECTS = $(BUILD_DIR)/simple_pkt_c_api.o - -LIBS = -L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME) -l$(LIB_CAPI_NAME) - -all: build_dir test_app copy_libs - -test_app: $(OBJECTS) $(BIN_TEST_TARGET_DIR)/$(PROG) - - - $(BIN_TEST_TARGET_DIR)/$(PROG): - mkdir -p $(BIN_TEST_TARGET_DIR) - $(LINKER) $(LINKER_FLAGS) $(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: - cp $(LIB_TARGET_DIR)/*.so $(BIN_TEST_TARGET_DIR)/. - - -#### build rules -$(BUILD_DIR)/%.o : %.c - $(CC) $(CC_FLAGS) $(CC_INCLUDES) $< -o $@ - -#### clean -.PHONY: clean -clean : - rm -f $(BIN_TEST_TARGET_DIR)/$(PROG) $(OBJECTS) - -# end of file makefile diff --git a/decoder/tests/build/win-vs2015/simple_pkt_print_c_api/simple_pkt_print_c_api.vcxproj b/decoder/tests/build/win-vs2015/simple_pkt_print_c_api/simple_pkt_print_c_api.vcxproj deleted file mode 100644 index d361e9c..0000000 --- a/decoder/tests/build/win-vs2015/simple_pkt_print_c_api/simple_pkt_print_c_api.vcxproj +++ /dev/null @@ -1,333 +0,0 @@ -<?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-dll|Win32"> - <Configuration>Debug-dll</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug-dll|x64"> - <Configuration>Debug-dll</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release-dll|Win32"> - <Configuration>Release-dll</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release-dll|x64"> - <Configuration>Release-dll</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <ItemGroup> - <ClCompile Include="..\..\..\source\simple_pkt_c_api.c" /> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{D18112ED-E2D7-4D49-B1F0-15E98967AC0A}</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <RootNamespace>simple_pkt_print_c_api</RootNamespace> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>MultiByte</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-dll|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>MultiByte</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>MultiByte</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-dll|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>MultiByte</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>MultiByte</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-dll|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>MultiByte</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>MultiByte</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-dll|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>MultiByte</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </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 Condition="'$(Configuration)|$(Platform)'=='Debug-dll|Win32'" Label="PropertySheets"> - <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 Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> - <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 Condition="'$(Configuration)|$(Platform)'=='Debug-dll|x64'" Label="PropertySheets"> - <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 Condition="'$(Configuration)|$(Platform)'=='Release-dll|Win32'" Label="PropertySheets"> - <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 Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> - <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 Condition="'$(Configuration)|$(Platform)'=='Release-dll|x64'" Label="PropertySheets"> - <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'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>......\bin\win$(PlatformArchitecture)\dbg</OutDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-dll|Win32'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>......\bin\win$(PlatformArchitecture)\dbg</OutDir> - <TargetName>$(ProjectName)-dl</TargetName> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>......\bin\win$(PlatformArchitecture)\dbg</OutDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-dll|x64'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>......\bin\win$(PlatformArchitecture)\dbg</OutDir> - <TargetName>$(ProjectName)-dl</TargetName> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>......\bin\win$(PlatformArchitecture)\rel</OutDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-dll|Win32'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>......\bin\win$(PlatformArchitecture)\rel</OutDir> - <TargetName>$(ProjectName)-dl</TargetName> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>......\bin\win$(PlatformArchitecture)\rel</OutDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-dll|x64'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>......\bin\win$(PlatformArchitecture)\rel</OutDir> - <TargetName>$(ProjectName)-dl</TargetName> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;OCSD_USE_STATIC_C_API;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>........\include</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalLibraryDirectories>........\lib\win$(PlatformArchitecture)\dbg</AdditionalLibraryDirectories> - <AdditionalDependencies>lib$(LIB_CAPI_NAME).lib;lib$(LIB_BASE_NAME).lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - <PostBuildEvent> - <Command> - </Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-dll|Win32'"> - <ClCompile> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>........\include</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalLibraryDirectories>........\lib\win$(PlatformArchitecture)\dbg</AdditionalLibraryDirectories> - <AdditionalDependencies>$(LIB_CAPI_NAME).lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - <PostBuildEvent> - <Command>copy ........\lib\win32\dbg*.dll ......\bin\win32\dbg.</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;OCSD_USE_STATIC_C_API;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>........\include</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalDependencies>lib$(LIB_CAPI_NAME).lib;lib$(LIB_BASE_NAME).lib;%(AdditionalDependencies)</AdditionalDependencies> - <AdditionalLibraryDirectories>........\lib\win$(PlatformArchitecture)\dbg</AdditionalLibraryDirectories> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-dll|x64'"> - <ClCompile> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>........\include</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalLibraryDirectories>........\lib\win$(PlatformArchitecture)\dbg</AdditionalLibraryDirectories> - <AdditionalDependencies>$(LIB_CAPI_NAME).lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - <PostBuildEvent> - <Command>copy ........\lib\win64\dbg*.dll ......\bin\win64\dbg.</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader> - </PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;OCSD_USE_STATIC_C_API;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>........\include</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <AdditionalLibraryDirectories>........\lib\win$(PlatformArchitecture)\rel</AdditionalLibraryDirectories> - <AdditionalDependencies>lib$(LIB_CAPI_NAME).lib;lib$(LIB_BASE_NAME).lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-dll|Win32'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader> - </PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>........\include</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <AdditionalLibraryDirectories>........\lib\win$(PlatformArchitecture)\rel</AdditionalLibraryDirectories> - <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;$(LIB_CAPI_NAME).lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - <PostBuildEvent> - <Command>copy ........\lib\win32\rel*.dll ......\bin\win32\rel.</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader> - </PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;OCSD_USE_STATIC_C_API;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>........\include</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <AdditionalLibraryDirectories>........\lib\win$(PlatformArchitecture)\rel</AdditionalLibraryDirectories> - <AdditionalDependencies>lib$(LIB_CAPI_NAME).lib;lib$(LIB_BASE_NAME).lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-dll|x64'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader> - </PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>........\include</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <AdditionalLibraryDirectories>........\lib\win$(PlatformArchitecture)\rel</AdditionalLibraryDirectories> - <AdditionalDependencies>$(LIB_CAPI_NAME).lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - <PostBuildEvent> - <Command>copy ........\lib\win64\rel*.dll ......\bin\win64\rel.</Command> - </PostBuildEvent> - </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/simple_pkt_print_c_api/simple_pkt_print_c_api.vcxproj.filters b/decoder/tests/build/win-vs2015/simple_pkt_print_c_api/simple_pkt_print_c_api.vcxproj.filters deleted file mode 100644 index 8d50471..0000000 --- a/decoder/tests/build/win-vs2015/simple_pkt_print_c_api/simple_pkt_print_c_api.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ -<?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;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\simple_pkt_c_api.c"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> -</Project> \ No newline at end of file diff --git a/decoder/tests/source/simple_pkt_c_api.c b/decoder/tests/source/simple_pkt_c_api.c deleted file mode 100644 index 86a3f74..0000000 --- a/decoder/tests/source/simple_pkt_c_api.c +++ /dev/null @@ -1,923 +0,0 @@ -/* - * \file simple_pkt_c_api.c - * \brief OpenCSD : - * - * \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: - * - * 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 of using the library with the C-API - * - * Simple test program to print packets from a single trace source stream. - * Hard coded configuration based on the Juno r1-1 test snapshot for ETMv4 and - * STM, TC2 test snapshot for ETMv3, PTM - * - */ - -#include <stdio.h> -#include <string.h> -#include <stdint.h> -#include <stdlib.h> - -#define OPENCSD_INC_DEPRECATED_API -/* include the C-API library header */ -#include "c_api/opencsd_c_api.h" - -/* path to juno snapshot, 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\"; -#else -const char *default_path_to_snapshot = "../../../snapshots/juno_r1_1/"; -const char *tc2_snapshot = "../../../snapshots/TC2/"; -#endif - -/* trace data and memory file dump names */ -const char *trace_data_filename = "cstrace.bin"; -const char *stmtrace_data_filename = "cstraceitm.bin"; -const char *memory_dump_filename = "kernel_dump.bin"; -ocsd_vaddr_t mem_dump_address=0xFFFFFFC000081000; -const ocsd_vaddr_t mem_dump_address_tc2=0xC0008000; - -static int using_mem_acc_cb = 0; -static int use_region_file = 0; - -/* region list to test region file API */ -file_mem_region_t region_list[4]; - -/* trace configuration structures - contains programmed register values of trace hardware */ -static ocsd_etmv4_cfg trace_config; -static ocsd_etmv3_cfg trace_config_etmv3; -static ocsd_stm_cfg trace_config_stm; -static ocsd_ptm_cfg trace_config_ptm; - -/* buffer to handle a packet string */ -#define PACKET_STR_LEN 1024 -static char packet_str[PACKET_STR_LEN]; - -/* decide if we decode & monitor, decode only or packet print */ -typedef enum _test_op { - TEST_PKT_PRINT, - TEST_PKT_DECODE, - TEST_PKT_DECODEONLY -} test_op_t; - -static test_op_t op = TEST_PKT_PRINT; -static ocsd_trace_protocol_t test_protocol = OCSD_PROTOCOL_ETMV4I; -static uint8_t test_trc_id_override = 0x00; - -static int print_data_array(const uint8_t *p_array, const int array_size, char *p_buffer, int buf_size) -{ - int chars_printed = 0; - int bytes_processed; - p_buffer[0] = 0; - - if(buf_size > 9) - { - /* set up the header */ - strcat(p_buffer,"[ "); - chars_printed+=2; - - for(bytes_processed = 0; bytes_processed < array_size; bytes_processed++) - { - sprintf(p_buffer+chars_printed,"0x%02X ", p_array[bytes_processed]); - chars_printed += 5; - if((chars_printed + 5) > buf_size) - break; - } - - strcat(p_buffer,"];"); - chars_printed+=2; - } - else if(buf_size >= 4) - { - sprintf(p_buffer,"[];"); - chars_printed+=3; - } - return chars_printed; -} - -/* choose the operation to use for the test. */ -static void process_cmd_line(int argc, char *argv[]) -{ - int idx = 1; - - while(idx < argc) - { - if(strcmp(argv[idx],"-decode_only") == 0) - { - op = TEST_PKT_DECODEONLY; - } - else if(strcmp(argv[idx],"-decode") == 0) - { - op = TEST_PKT_DECODE; - } - else if(strcmp(argv[idx],"-id") == 0) - { - idx++; - if(idx < argc) - { - test_trc_id_override = (uint8_t)(strtoul(argv[idx],0,0)); - printf("ID override = 0x%02X\n",test_trc_id_override); - } - } - else if(strcmp(argv[idx],"-etmv3") == 0) - { - test_protocol = OCSD_PROTOCOL_ETMV3; - default_path_to_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; - mem_dump_address = mem_dump_address_tc2; - } - else if(strcmp(argv[idx],"-stm") == 0) - { - test_protocol = OCSD_PROTOCOL_STM; - trace_data_filename = stmtrace_data_filename; - } - else if(strcmp(argv[idx],"-test_cb") == 0) - { - using_mem_acc_cb = 1; - } - else if(strcmp(argv[idx],"-test_region_file") == 0) - { - use_region_file = 1; - } - else - printf("Ignored unknown argument %s\n", argv[idx]); - idx++; - } -} - -/* Callback function to process the packets in the stream - - simply print them out in this case - */ -ocsd_datapath_resp_t packet_handler(const ocsd_datapath_op_t op, const ocsd_trc_index_t index_sop, const void *p_packet_in) -{ - ocsd_datapath_resp_t resp = OCSD_RESP_CONT; - int offset = 0; - - switch(op) - { - default: break; - case OCSD_OP_DATA: - sprintf(packet_str,"Idx:%" OCSD_TRC_IDX_STR "; ", index_sop); - offset = strlen(packet_str); - - /* got a packet - convert to string and use the libraries' message output to print to file and stdoout */ - if(ocsd_pkt_str(test_protocol,p_packet_in,packet_str+offset,PACKET_STR_LEN-offset) == OCSD_OK) - { - /* add in <CR> */ - if(strlen(packet_str) == PACKET_STR_LEN - 1) /* maximum length */ - packet_str[PACKET_STR_LEN-2] = '\n'; - else - strcat(packet_str,"\n"); - - /* print it using the library output logger. */ - ocsd_def_errlog_msgout(packet_str); - } - else - resp = OCSD_RESP_FATAL_INVALID_PARAM; /* mark fatal error */ - break; - - case OCSD_OP_EOT: - sprintf(packet_str,"**** END OF TRACE ****\n"); - ocsd_def_errlog_msgout(packet_str); - break; - } - - return resp; -} - -/* decode memory access using a CB function -* tests CB API and add / remove mem acc API. -*/ -static FILE *dump_file = NULL; -static ocsd_mem_space_acc_t dump_file_mem_space = OCSD_MEM_SPACE_ANY; -static long mem_file_size = 0; -static ocsd_vaddr_t mem_file_en_address = 0; /* end address last inclusive address in file. */ - -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) -{ - uint32_t read_bytes = 0; - size_t file_read_bytes; - - if(dump_file == NULL) - return 0; - - /* bitwise & the incoming mem space and supported mem space to confirm coverage */ - if(((uint8_t)mem_space & (uint8_t)dump_file_mem_space ) == 0) - return 0; - - /* calculate the bytes that can be read */ - if((address >= mem_dump_address) && (address <= mem_file_en_address)) - { - /* some bytes in our range */ - read_bytes = reqBytes; - - if((address + reqBytes - 1) > mem_file_en_address) - { - /* more than are available - just read the available */ - read_bytes = (uint32_t)(mem_file_en_address - (address - 1)); - } - } - - /* read some bytes if more than 0 to read. */ - if(read_bytes != 0) - { - fseek(dump_file,(long)(address-mem_dump_address),SEEK_SET); - file_read_bytes = fread(byteBuffer,sizeof(uint8_t),read_bytes,dump_file); - if(file_read_bytes < read_bytes) - read_bytes = file_read_bytes; - } - return read_bytes; -} - -static ocsd_err_t create_mem_acc_cb(dcd_tree_handle_t dcd_tree_h, const char *mem_file_path) -{ - ocsd_err_t err = OCSD_OK; - dump_file = fopen(mem_file_path,"rb"); - if(dump_file != NULL) - { - fseek(dump_file,0,SEEK_END); - 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(err != OCSD_OK) - { - fclose(dump_file); - dump_file = NULL; - } - } - else - err = OCSD_ERR_MEM_ACC_FILE_NOT_FOUND; - return err; -} - -static void destroy_mem_acc_cb(dcd_tree_handle_t dcd_tree_h) -{ - if(dump_file != NULL) - { - ocsd_dt_remove_mem_acc(dcd_tree_h,mem_dump_address,dump_file_mem_space); - fclose(dump_file); - dump_file = NULL; - } -} - -void packet_monitor(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) -{ - int offset = 0; - - switch(op) - { - default: break; - case OCSD_OP_DATA: - sprintf(packet_str,"Idx:%" OCSD_TRC_IDX_STR ";", index_sop); - offset = strlen(packet_str); - offset+= print_data_array(p_data,size,packet_str+offset,PACKET_STR_LEN-offset); - - /* got a packet - convert to string and use the libraries' message output to print to file and stdoout */ - if(ocsd_pkt_str(test_protocol,p_packet_in,packet_str+offset,PACKET_STR_LEN-offset) == OCSD_OK) - { - /* add in <CR> */ - if(strlen(packet_str) == PACKET_STR_LEN - 1) /* maximum length */ - packet_str[PACKET_STR_LEN-2] = '\n'; - else - strcat(packet_str,"\n"); - - /* print it using the library output logger. */ - ocsd_def_errlog_msgout(packet_str); - } - break; - - case OCSD_OP_EOT: - sprintf(packet_str,"**** END OF TRACE ****\n"); - ocsd_def_errlog_msgout(packet_str); - break; - } -} - -ocsd_datapath_resp_t gen_trace_elem_print(const void *p_context, const ocsd_trc_index_t index_sop, const uint8_t trc_chan_id, const ocsd_generic_trace_elem *elem) -{ - ocsd_datapath_resp_t resp = OCSD_RESP_CONT; - int offset = 0; - - sprintf(packet_str,"Idx:%" OCSD_TRC_IDX_STR "; TrcID:0x%02X; ", index_sop, trc_chan_id); - offset = strlen(packet_str); - - if(ocsd_gen_elem_str(elem, packet_str+offset,PACKET_STR_LEN - offset) == OCSD_OK) - { - /* add in <CR> */ - if(strlen(packet_str) == PACKET_STR_LEN - 1) /* maximum length */ - packet_str[PACKET_STR_LEN-2] = '\n'; - else - strcat(packet_str,"\n"); - } - else - { - strcat(packet_str,"Unable to create element string\n"); - } - - /* print it using the library output logger. */ - ocsd_def_errlog_msgout(packet_str); - - return resp; -} - -/************************************************************************/ -/*** ETMV4 ***/ -/************************************************************************/ - -/* hard coded values from snapshot .ini files */ -void set_config_struct_etmv4() -{ - 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.*/ - - if(test_trc_id_override != 0) - { - trace_config.reg_traceidr = (uint32_t)test_trc_id_override; - } - - 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; -} - -ocsd_datapath_resp_t etm_v4i_packet_handler(const void *p_context, const ocsd_datapath_op_t op, const ocsd_trc_index_t index_sop, const ocsd_etmv4_i_pkt *p_packet_in) -{ - return packet_handler(op,index_sop,(const void *)p_packet_in); -} - - -void etm_v4i_packet_monitor( const void *p_context, - const ocsd_datapath_op_t op, - const ocsd_trc_index_t index_sop, - const ocsd_etmv4_i_pkt *p_packet_in, - const uint32_t size, - const uint8_t *p_data) -{ - packet_monitor(op,index_sop,(void *)p_packet_in,size,p_data); -} - -static ocsd_err_t create_decoder_etmv4(dcd_tree_handle_t dcd_tree_h) -{ - ocsd_err_t ret = OCSD_OK; - char mem_file_path[512]; - int i; - uint32_t i0adjust = 0x100; - - /* populate the ETMv4 configuration structure */ - set_config_struct_etmv4(); - - if(op == TEST_PKT_PRINT) /* packet printing only */ - { - /* Create a packet processor on the decode tree for the ETM v4 configuration we have. - We need to supply the configuration, and a packet handling callback. - */ - ret = ocsd_dt_create_etmv4i_pkt_proc(dcd_tree_h,&trace_config,&etm_v4i_packet_handler,0); - } - else - { - /* Full decode - need decoder, and memory dump */ - - /* create the packet decoder and packet processor pair */ - ret = ocsd_dt_create_etmv4i_decoder(dcd_tree_h,&trace_config); - if(ret == OCSD_OK) - { - if((op != TEST_PKT_DECODEONLY) && (ret == OCSD_OK)) - { - /* print the packets as well as the decode. */ - ret = ocsd_dt_attach_etmv4i_pkt_mon(dcd_tree_h, (uint8_t)(trace_config.reg_traceidr & 0xFF), etm_v4i_packet_monitor,0); - } - } - - /* trace data file path */ - strcpy(mem_file_path,default_path_to_snapshot); - strcat(mem_file_path,memory_dump_filename); - - if(ret == OCSD_OK) - { - if(using_mem_acc_cb) - { - ret = create_mem_acc_cb(dcd_tree_h,mem_file_path); - } - else - { - if(use_region_file) - { - dump_file = fopen(mem_file_path,"rb"); - if(dump_file != NULL) - { - fseek(dump_file,0,SEEK_END); - mem_file_size = ftell(dump_file); - fclose(dump_file); - - - /* populate the region list - split existing file into four regions */ - for(i = 0; i < 4; i++) - { - if(i != 0) - i0adjust = 0; - region_list[i].start_address = mem_dump_address + (i * mem_file_size/4) + i0adjust; - region_list[i].region_size = (mem_file_size/4) - i0adjust; - region_list[i].file_offset = (i * mem_file_size/4) + i0adjust; - } - - /* create a memory file accessor - full binary file */ - ret = ocsd_dt_add_binfile_region_mem_acc(dcd_tree_h,®ion_list[0],4,OCSD_MEM_SPACE_ANY,mem_file_path); - - } - else - ret = OCSD_ERR_MEM_ACC_FILE_NOT_FOUND; - } - else - { - /* create a memory file accessor - full binary file */ - ret = ocsd_dt_add_binfile_mem_acc(dcd_tree_h,mem_dump_address,OCSD_MEM_SPACE_ANY,mem_file_path); - } - } - } - } - return ret; -} - -/************************************************************************/ -/*** ETMV3 ***/ -/************************************************************************/ - -static void set_config_struct_etmv3() -{ - trace_config_etmv3.arch_ver = ARCH_V7; - trace_config_etmv3.core_prof = profile_CortexA; - trace_config_etmv3.reg_ccer = 0x344008F2; - trace_config_etmv3.reg_ctrl = 0x10001860; - trace_config_etmv3.reg_idr = 0x410CF250; - trace_config_etmv3.reg_trc_id = 0x010; - if(test_trc_id_override != 0) - { - trace_config_etmv3.reg_trc_id = (uint32_t)test_trc_id_override; - } -} - -ocsd_datapath_resp_t etm_v3_packet_handler(const void *p_context, const ocsd_datapath_op_t op, const ocsd_trc_index_t index_sop, const ocsd_etmv3_pkt *p_packet_in) -{ - return packet_handler(op,index_sop,(const void *)p_packet_in); -} - -void etm_v3_packet_monitor( const void *p_context, - const ocsd_datapath_op_t op, - const ocsd_trc_index_t index_sop, - const ocsd_etmv3_pkt *p_packet_in, - const uint32_t size, - const uint8_t *p_data) -{ - packet_monitor(op,index_sop,(void *)p_packet_in,size,p_data); -} - -static ocsd_err_t create_decoder_etmv3(dcd_tree_handle_t dcd_tree_h) -{ - ocsd_err_t ret = OCSD_OK; - char mem_file_path[512]; - - /* populate the ETMv3 configuration structure */ - set_config_struct_etmv3(); - - - if(op == TEST_PKT_PRINT) /* packet printing only */ - { - /* Create a packet processor on the decode tree for the ETM v4 configuration we have. - We need to supply the configuration, and a packet handling callback. - */ - ret = ocsd_dt_create_etmv3_pkt_proc(dcd_tree_h,&trace_config_etmv3,&etm_v3_packet_handler,0); - } - else - { - /* Full decode - need decoder, and memory dump */ - /* not supported in library at present */ - - - /* create the packet decoder and packet processor pair */ - ret = ocsd_dt_create_etmv3_decoder(dcd_tree_h,&trace_config_etmv3); - if(ret == OCSD_OK) - { - if((op != TEST_PKT_DECODEONLY) && (ret == OCSD_OK)) - { - ret = ocsd_dt_attach_etmv3_pkt_mon(dcd_tree_h, (uint8_t)(trace_config_etmv3.reg_trc_id & 0x7F), etm_v3_packet_monitor,0); - } - } - - /* trace data file path */ - strcpy(mem_file_path,tc2_snapshot); - strcat(mem_file_path,memory_dump_filename); - - if(ret == OCSD_OK) - { - /* create a memory file accessor */ - ret = ocsd_dt_add_binfile_mem_acc(dcd_tree_h,mem_dump_address,OCSD_MEM_SPACE_ANY,mem_file_path); - } - } - return ret; -} - -/************************************************************************/ -/*** PTM ***/ -/************************************************************************/ -/* hard coded values from snapshot .ini files */ -void set_config_struct_ptm() -{ - trace_config_ptm.arch_ver = ARCH_V7; - trace_config_ptm.core_prof = profile_CortexA; - trace_config_ptm.reg_ccer = 0x34C01AC2; - trace_config_ptm.reg_ctrl = 0x10001000; - trace_config_ptm.reg_idr = 0x411CF312; - trace_config_ptm.reg_trc_id = 0x013; - if(test_trc_id_override != 0) - { - trace_config_ptm.reg_trc_id = (uint32_t)test_trc_id_override; - } -} - -ocsd_datapath_resp_t ptm_packet_handler(const void *p_context, const ocsd_datapath_op_t op, const ocsd_trc_index_t index_sop, const ocsd_ptm_pkt *p_packet_in) -{ - return packet_handler(op,index_sop,(const void *)p_packet_in); -} - -void ptm_packet_monitor( const void *p_context, - const ocsd_datapath_op_t op, - const ocsd_trc_index_t index_sop, - const ocsd_ptm_pkt *p_packet_in, - const uint32_t size, - const uint8_t *p_data) -{ - packet_monitor(op,index_sop,(void *)p_packet_in,size,p_data); -} - -static ocsd_err_t create_decoder_ptm(dcd_tree_handle_t dcd_tree_h) -{ - ocsd_err_t ret = OCSD_OK; - char mem_file_path[512]; - int i; - uint32_t i0adjust = 0x100; - - /* populate the PTM configuration structure */ - set_config_struct_ptm(); - - if(op == TEST_PKT_PRINT) /* packet printing only */ - { - /* Create a packet processor on the decode tree for the PTM configuration we have. - We need to supply the configuration, and a packet handling callback. - */ - ret = ocsd_dt_create_ptm_pkt_proc(dcd_tree_h,&trace_config_ptm,&ptm_packet_handler,0); - } - else - { - /* Full decode - need decoder, and memory dump */ - - /* create the packet decoder and packet processor pair */ - ret = ocsd_dt_create_ptm_decoder(dcd_tree_h,&trace_config_ptm); - if(ret == OCSD_OK) - { - if((op != TEST_PKT_DECODEONLY) && (ret == OCSD_OK)) - { - /* print the packets as well as the decode. */ - ret = ocsd_dt_attach_ptm_pkt_mon(dcd_tree_h, (uint8_t)(trace_config_ptm.reg_trc_id & 0xFF), ptm_packet_monitor,0); - } - } - - /* trace data file path */ - strcpy(mem_file_path,default_path_to_snapshot); - strcat(mem_file_path,memory_dump_filename); - - if(ret == OCSD_OK) - { - if(using_mem_acc_cb) - { - ret = create_mem_acc_cb(dcd_tree_h,mem_file_path); - } - else - { - if(use_region_file) - { - dump_file = fopen(mem_file_path,"rb"); - if(dump_file != NULL) - { - fseek(dump_file,0,SEEK_END); - mem_file_size = ftell(dump_file); - fclose(dump_file); - - - /* populate the region list - split existing file into four regions */ - for(i = 0; i < 4; i++) - { - if(i != 0) - i0adjust = 0; - region_list[i].start_address = mem_dump_address + (i * mem_file_size/4) + i0adjust; - region_list[i].region_size = (mem_file_size/4) - i0adjust; - region_list[i].file_offset = (i * mem_file_size/4) + i0adjust; - } - - /* create a memory file accessor - full binary file */ - ret = ocsd_dt_add_binfile_region_mem_acc(dcd_tree_h,®ion_list[0],4,OCSD_MEM_SPACE_ANY,mem_file_path); - - } - else - ret = OCSD_ERR_MEM_ACC_FILE_NOT_FOUND; - } - else - { - /* create a memory file accessor - full binary file */ - ret = ocsd_dt_add_binfile_mem_acc(dcd_tree_h,mem_dump_address,OCSD_MEM_SPACE_ANY,mem_file_path); - } - } - } - } - return ret; -} - - -/************************************************************************/ -/*** STM ***/ -/************************************************************************/ - -#define STMTCSR_TRC_ID_MASK 0x007F0000 -#define STMTCSR_TRC_ID_SHIFT 16 -static void set_config_struct_stm() -{ - trace_config_stm.reg_tcsr = 0x00A00005; - if(test_trc_id_override != 0) - { - trace_config_stm.reg_tcsr &= ~STMTCSR_TRC_ID_MASK; - trace_config_stm.reg_tcsr |= ((((uint32_t)test_trc_id_override) << STMTCSR_TRC_ID_SHIFT) & STMTCSR_TRC_ID_MASK); - } - trace_config_stm.reg_feat3r = 0x10000; /* channel default */ - trace_config_stm.reg_devid = 0xFF; /* master default */ - - /* not using hw event trace decode */ - trace_config_stm.reg_hwev_mast = 0; - trace_config_stm.reg_feat1r = 0; - trace_config_stm.hw_event = HwEvent_Unknown_Disabled; -} - -ocsd_datapath_resp_t stm_packet_handler(const void *p_context, const ocsd_datapath_op_t op, const ocsd_trc_index_t index_sop, const ocsd_stm_pkt *p_packet_in) -{ - return packet_handler(op,index_sop,(const void *)p_packet_in); -} - -void stm_packet_monitor( const ocsd_datapath_op_t op, - const ocsd_trc_index_t index_sop, - const ocsd_stm_pkt *p_packet_in, - const uint32_t size, - const uint8_t *p_data) -{ - packet_monitor(op,index_sop,(void *)p_packet_in,size,p_data); -} - -static ocsd_err_t create_decoder_stm(dcd_tree_handle_t dcd_tree_h) -{ - ocsd_err_t ret = OCSD_OK; - /*char mem_file_path[512];*/ - - /* populate the STM configuration structure */ - set_config_struct_stm(); - - - if(op == TEST_PKT_PRINT) /* packet printing only */ - { - /* Create a packet processor on the decode tree for the ETM v4 configuration we have. - We need to supply the configuration, and a packet handling callback. - */ - ret = ocsd_dt_create_stm_pkt_proc(dcd_tree_h,&trace_config_stm,&stm_packet_handler,0); - } - else - { - /* Full decode */ - /* not supported in library at present */ - - printf("STM Full decode not supported in library at present. Packet print only\n"); - ret = OCSD_ERR_RDR_NO_DECODER; - } - return ret; -} - - - -/************************************************************************/ - -/* create a decoder according to options */ -static ocsd_err_t create_decoder(dcd_tree_handle_t dcd_tree_h) -{ - ocsd_err_t err = OCSD_OK; - switch(test_protocol) - { - case OCSD_PROTOCOL_ETMV4I: - err = create_decoder_etmv4(dcd_tree_h); - break; - - case OCSD_PROTOCOL_ETMV3: - err = create_decoder_etmv3(dcd_tree_h); - break; - - case OCSD_PROTOCOL_STM: - err = create_decoder_stm(dcd_tree_h); - break; - - case OCSD_PROTOCOL_PTM: - err = create_decoder_ptm(dcd_tree_h); - break; - - default: - err = OCSD_ERR_NO_PROTOCOL; - break; - } - return err; -} - -#define INPUT_BLOCK_SIZE 1024 - -/* process buffer until done or error */ -ocsd_err_t process_data_block(dcd_tree_handle_t dcd_tree_h, int block_index, uint8_t *p_block, const int block_size) -{ - ocsd_err_t ret = OCSD_OK; - uint32_t bytes_done = 0; - ocsd_datapath_resp_t dp_ret = OCSD_RESP_CONT; - uint32_t bytes_this_time = 0; - - while((bytes_done < (uint32_t)block_size) && (ret == OCSD_OK)) - { - if(OCSD_DATA_RESP_IS_CONT(dp_ret)) - { - dp_ret = ocsd_dt_process_data(dcd_tree_h, - OCSD_OP_DATA, - block_index+bytes_done, - block_size-bytes_done, - ((uint8_t *)p_block)+bytes_done, - &bytes_this_time); - bytes_done += bytes_this_time; - } - else if(OCSD_DATA_RESP_IS_WAIT(dp_ret)) - { - dp_ret = ocsd_dt_process_data(dcd_tree_h, OCSD_OP_FLUSH,0,0,NULL,NULL); - } - else - ret = OCSD_ERR_DATA_DECODE_FATAL; /* data path responded with an error - stop processing */ - } - return ret; -} - -int process_trace_data(FILE *pf) -{ - ocsd_err_t ret = OCSD_OK; - dcd_tree_handle_t dcdtree_handle = C_API_INVALID_TREE_HANDLE; - uint8_t data_buffer[INPUT_BLOCK_SIZE]; - ocsd_trc_index_t index = 0; - size_t data_read; - - - /* Create a decode tree for this source data. - source data is frame formatted, memory aligned from an ETR (no frame syncs) so create tree accordingly - */ - dcdtree_handle = ocsd_create_dcd_tree(OCSD_TRC_SRC_FRAME_FORMATTED, OCSD_DFRMTR_FRAME_MEM_ALIGN); - - if(dcdtree_handle != C_API_INVALID_TREE_HANDLE) - { - - ret = create_decoder(dcdtree_handle); - ocsd_tl_log_mapped_mem_ranges(dcdtree_handle); - - if(ret == OCSD_OK) - /* attach the generic trace element output callback */ - ret = ocsd_dt_set_gen_elem_outfn(dcdtree_handle,gen_trace_elem_print,0); - - /* now push the trace data through the packet processor */ - while(!feof(pf) && (ret == OCSD_OK)) - { - /* read from file */ - data_read = fread(data_buffer,1,INPUT_BLOCK_SIZE,pf); - if(data_read > 0) - { - /* process a block of data - any packets from the trace stream - we have configured will appear at the callback - */ - ret = process_data_block(dcdtree_handle, - index, - data_buffer, - data_read); - index += data_read; - } - else if(ferror(pf)) - ret = OCSD_ERR_FILE_ERROR; - } - - /* no errors - let the data path know we are at end of trace */ - if(ret == OCSD_OK) - ocsd_dt_process_data(dcdtree_handle, OCSD_OP_EOT, 0,0,NULL,NULL); - - - /* shut down the mem acc CB if in use. */ - if(using_mem_acc_cb) - { - destroy_mem_acc_cb(dcdtree_handle); - } - - /* dispose of the decode tree - which will dispose of any packet processors we created - */ - ocsd_destroy_dcd_tree(dcdtree_handle); - } - else - { - printf("Failed to create trace decode tree\n"); - ret = OCSD_ERR_NOT_INIT; - } - return (int)ret; -} - -int main(int argc, char *argv[]) -{ - FILE *trace_data; - char trace_file_path[512]; - int ret = 0; - char message[512]; - - /* command line params */ - process_cmd_line(argc,argv); - - /* trace data file path */ - strcpy(trace_file_path,default_path_to_snapshot); - strcat(trace_file_path,trace_data_filename); - trace_data = fopen(trace_file_path,"rb"); - - if(trace_data != NULL) - { - /* set up the logging in the library - enable the error logger, with an output printer*/ - ret = ocsd_def_errlog_init(OCSD_ERR_SEV_INFO,1); - - /* set up the output - to file and stdout, set custom logfile name */ - if(ret == 0) - ret = ocsd_def_errlog_config_output(C_API_MSGLOGOUT_FLG_FILE | C_API_MSGLOGOUT_FLG_STDOUT, "c_api_test.log"); - - /* print sign-on message in log */ - sprintf(message, "C-API packet print test\nLibrary Version %s\n\n",ocsd_get_version_str()); - ocsd_def_errlog_msgout(message); - - - /* process the trace data */ - if(ret == 0) - ret = process_trace_data(trace_data); - - /* close the data file */ - fclose(trace_data); - } - else - { - printf("Unable to open file %s to process trace data\n", trace_file_path); - ret = -1; - } - return ret; -} -/* End of File simple_pkt_c_api.c */
From: Mathieu Poirier mathieu.poirier@linaro.org
Replacing all instances of numerical kernel versions with a generic 'master' notation.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org --- HOWTO.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/HOWTO.md b/HOWTO.md index 2a6be3d..596efab 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -7,16 +7,16 @@ This HOWTO explains how to use the perf cmd line tools and the openCSD library to collect and extract program flow traces generated by the CoreSight IP blocks on a Linux system. The examples have been generated using an aarch64 Juno-r0 platform. All information is considered accurate and tested -using library version v0.5 and the latest perf branch `perf-opencsd-4.9` -on the [OpenCSD github repository][1]. +using library version v0.5 and the `perf-opencsd-master` branch on the +[OpenCSD github repository][1].
On Target Trace Acquisition - Perf Record ----------------------------------------- All the enhancement to the Perf tools that support the new `cs_etm` pmu have not been upstreamed yet. To get the required functionality branch -`perf-opencsd-4.9` needs to be downloaded to the target system where -traces are to be collected. This branch is an upstream v4.9 kernel +`perf-opencsd-master` needs to be downloaded to the target system where +traces are to be collected. This branch is a vanilla upstream kernel 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. @@ -277,14 +277,14 @@ the host's (which has nothing to do with the target) architecture: Off Target Perf Tools Compilation --------------------------------- As stated above not all the pieces of the solution have been upstreamed. To -get all the components branch `perf-opencsd-4.9` needs to be +get all the components the latest `perf-opencsd-master` needs to be obtained:
- linaro@t430:~/linaro/coresight$ git clone -b perf-opencsd-4.9 https://github.com/Linaro/OpenCSD.git perf-opencsd-4.9 + linaro@t430:~/linaro/coresight$ git clone -b perf-opencsd-master https://github.com/Linaro/OpenCSD.git perf-opencsd-master ... ...
- linaro@t430:~/linaro/coresight$ ls perf-opencsd-4.9/ + linaro@t430:~/linaro/coresight$ ls perf-opencsd-master/ arch certs CREDITS Documentation firmware include ipc Kconfig lib Makefile net REPORTING-BUGS scripts sound usr block COPYING crypto drivers fs init Kbuild kernel MAINTAINERS mm README samples security tools virt
@@ -295,12 +295,12 @@ successful, but handling of CoreSight trace data won't be supported.
**See perf-test-scripts below for assistance in creating a build and test enviroment.**
- linaro@t430:~/linaro/coresight$ cd perf-opencsd-4.9 + linaro@t430:~/linaro/coresight$ cd perf-opencsd-master linaro@t430:~/linaro/coresight/perf-opencsd-4.9$ export CSTRACE_PATH=~/linaro/coresight/my-opencsd/decoder linaro@t430:~/linaro/coresight/perf-opencsd-4.9$ make -C tools/perf ... ... - linaro@t430:~/linaro/coresight/perf-opencsd-4.9$ ls -l tools/perf/perf + linaro@t430:~/linaro/coresight/perf-opencsd-master ls -l tools/perf/perf -rwxrwxr-x 1 linaro linaro 6276360 Mar 3 10:05 tools/perf/perf
@@ -339,7 +339,7 @@ to be sure everything is clean. linaro@t430:~/linaro/coresight/sept20$ rm -rf ~/.debug linaro@t430:~/linaro/coresight/sept20$ cp -dpR .debug ~/ linaro@t430:~/linaro/coresight/sept20$ export LD_LIBRARY_PATH=~/linaro/coresight/my-opencsd/decoder/lib/linux64/dbg/ - linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.9/tools/perf/perf report --stdio + linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-master/tools/perf/perf report --stdio
# To display the perf.data header info, please use --header/--header-only options. # @@ -383,7 +383,7 @@ to be sure everything is clean.
Additional data can be obtained, which contains a dump of the trace packets received using the command
- mjl@ubuntu-vbox:./perf-opencsd-4.9/coresight/tools/perf/perf report --stdio --dump + mjl@ubuntu-vbox:./perf-opencsd-master/coresight/tools/perf/perf report --stdio --dump
resulting a large amount of data, trace looking like:-
@@ -432,10 +432,10 @@ Trace Decoding with Perf Script Working with perf scripts needs more command line options but yields interesting results.
- linaro@t430:~/linaro/coresight/sept20$ export EXEC_PATH=/home/linaro/coresight/perf-opencsd-4.9/tools/perf/ + linaro@t430:~/linaro/coresight/sept20$ export EXEC_PATH=/home/linaro/coresight/perf-opencsd-master/tools/perf/ linaro@t430:~/linaro/coresight/sept20$ export SCRIPT_PATH=$EXEC_PATH/scripts/python/ linaro@t430:~/linaro/coresight/sept20$ export XTOOL_PATH=/your/aarch64/toolchain/path/bin/ - linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.9/tools/perf/perf --exec-path=${EXEC_PATH} script --script=python:${SCRIPT_PATH}/cs-trace-disasm.py -- -d ${XTOOL_PATH}/aarch64-linux-gnu-objdump + linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-master/tools/perf/perf --exec-path=${EXEC_PATH} script --script=python:${SCRIPT_PATH}/cs-trace-disasm.py -- -d ${XTOOL_PATH}/aarch64-linux-gnu-objdump
7f89f24d80: 910003e0 mov x0, sp 7f89f24d84: 94000d53 bl 7f89f282d0 <free@plt+0x3790> @@ -467,18 +467,18 @@ Kernel Trace Decoding When dealing with kernel space traces the vmlinux file has to be communicated explicitely to perf using the "--vmlinux" command line option:
- linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.9/tools/perf/perf report --stdio --vmlinux=./vmlinux + linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-master/tools/perf/perf report --stdio --vmlinux=./vmlinux ... ... - linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.9/tools/perf/perf script --vmlinux=./vmlinux + linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-master/tools/perf/perf script --vmlinux=./vmlinux
When using scripts things get a little more convoluted. Using the same example an above but for traces but for kernel traces, the command line becomes:
- linaro@t430:~/linaro/coresight/sept20$ export EXEC_PATH=/home/linaro/coresight/perf-opencsd-4.9/tools/perf/ + linaro@t430:~/linaro/coresight/sept20$ export EXEC_PATH=/home/linaro/coresight/perf-opencsd-master/tools/perf/ linaro@t430:~/linaro/coresight/sept20$ export SCRIPT_PATH=$EXEC_PATH/scripts/python/ linaro@t430:~/linaro/coresight/sept20$ export XTOOL_PATH=/your/aarch64/toolchain/path/bin/ - linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.9/tools/perf/perf --exec-path=${EXEC_PATH} script \ + linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-master/tools/perf/perf --exec-path=${EXEC_PATH} script \ --vmlinux=./vmlinux \ --script=python:${SCRIPT_PATH}/cs-trace-disasm.py -- \ -d ${XTOOLS_PATH}/aarch64-linux-gnu-objdump \
When collecting on device trace, allow 4 * FSYNC frames to be used as padding or barrier frames to split data from trace runs.
Allows linux drivers to work correctly with tools such as perf that will grab multiple buffers of data and concatenate them in the output without the ability for the decoder to spot the breaks.
Updates frame indexing to account for skipped FSYNCs on resets. Allows frame index to be forwarded downstream reset operation.
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/include/common/trc_pkt_proc_base.h | 10 ++-- decoder/include/ocsd_if_types.h | 3 +- decoder/source/trc_frame_deformatter.cpp | 82 +++++++++++++++++++++++------ decoder/source/trc_frame_deformatter_impl.h | 3 +- 4 files changed, 74 insertions(+), 24 deletions(-)
diff --git a/decoder/include/common/trc_pkt_proc_base.h b/decoder/include/common/trc_pkt_proc_base.h index f09ad61..3098a3d 100644 --- a/decoder/include/common/trc_pkt_proc_base.h +++ b/decoder/include/common/trc_pkt_proc_base.h @@ -185,7 +185,7 @@ protected:
private: /* decode control */ - ocsd_datapath_resp_t Reset(); + ocsd_datapath_resp_t Reset(const ocsd_trc_index_t index); ocsd_datapath_resp_t Flush(); ocsd_datapath_resp_t EOT();
@@ -247,7 +247,7 @@ template<class P,class Pt, class Pc> ocsd_datapath_resp_t TrcPktProcBase<P, Pt, break;
case OCSD_OP_RESET: - resp = Reset(); + resp = Reset(index); break;
default: @@ -259,13 +259,13 @@ template<class P,class Pt, class Pc> ocsd_datapath_resp_t TrcPktProcBase<P, Pt, }
-template<class P,class Pt, class Pc> ocsd_datapath_resp_t TrcPktProcBase<P, Pt, Pc>::Reset() +template<class P,class Pt, class Pc> ocsd_datapath_resp_t TrcPktProcBase<P, Pt, Pc>::Reset(const ocsd_trc_index_t index) { ocsd_datapath_resp_t resp = OCSD_RESP_CONT;
// reset the trace decoder attachment on main data path. if(m_pkt_out_i.hasAttachedAndEnabled()) - resp = m_pkt_out_i.first()->PacketDataIn(OCSD_OP_RESET,0,0); + resp = m_pkt_out_i.first()->PacketDataIn(OCSD_OP_RESET,index,0);
// reset the packet processor implmentation if(!OCSD_DATA_RESP_IS_FATAL(resp)) @@ -273,7 +273,7 @@ template<class P,class Pt, class Pc> ocsd_datapath_resp_t TrcPktProcBase<P, Pt,
// packet monitor if(m_pkt_raw_mon_i.hasAttachedAndEnabled()) - m_pkt_raw_mon_i.first()->RawPacketDataMon(OCSD_OP_RESET,0,0,0,0); + m_pkt_raw_mon_i.first()->RawPacketDataMon(OCSD_OP_RESET,index,0,0,0);
return resp; } diff --git a/decoder/include/ocsd_if_types.h b/decoder/include/ocsd_if_types.h index 14056e6..43df2ae 100644 --- a/decoder/include/ocsd_if_types.h +++ b/decoder/include/ocsd_if_types.h @@ -242,7 +242,8 @@ typedef enum _ocsd_dcd_tree_src_t { #define OCSD_DFRMTR_FRAME_MEM_ALIGN 0x04 /**< Deformatter Config : formatted frames are memory aligned, no syncs. Input data 16 byte frame aligned. */ #define OCSD_DFRMTR_PACKED_RAW_OUT 0x08 /**< Deformatter Config : output raw packed frame data if raw monitor attached. */ #define OCSD_DFRMTR_UNPACKED_RAW_OUT 0x10 /**< Deformatter Config : output raw unpacked frame data if raw monitor attached. */ -#define OCSD_DFRMTR_VALID_MASK 0x1F /**< Deformatter Config : valid mask for deformatter configuration */ +#define OCSD_DFRMTR_RESET_ON_4X_FSYNC 0x20 /**< Deformatter Config : reset downstream decoders if frame aligned 4x consecutive fsyncs spotted. (perf workaround) */ +#define OCSD_DFRMTR_VALID_MASK 0x3F /**< Deformatter Config : valid mask for deformatter configuration */
#define OCSD_DFRMTR_FRAME_SIZE 0x10 /**< CoreSight frame formatter frame size constant in bytes. */
diff --git a/decoder/source/trc_frame_deformatter.cpp b/decoder/source/trc_frame_deformatter.cpp index 57a7197..769c38c 100644 --- a/decoder/source/trc_frame_deformatter.cpp +++ b/decoder/source/trc_frame_deformatter.cpp @@ -181,7 +181,8 @@ ocsd_datapath_resp_t TraceFmtDcdImpl::Flush() return highestDataPathResp(); }
-ocsd_datapath_resp_t TraceFmtDcdImpl::executeNoneDataOpAllIDs(ocsd_datapath_op_t op) +ocsd_datapath_resp_t TraceFmtDcdImpl::executeNoneDataOpAllIDs(ocsd_datapath_op_t op, + const ocsd_trc_index_t index /* = 0*/) { ITrcDataIn *pTrcComp = 0; for(uint8_t id = 0; id < 128; id++) @@ -191,7 +192,7 @@ ocsd_datapath_resp_t TraceFmtDcdImpl::executeNoneDataOpAllIDs(ocsd_datapath_op_t pTrcComp = m_IDStreams[id].first(); while(pTrcComp) { - CollateDataPathResp(pTrcComp->TraceDataIn(op,0,0,0,0)); + CollateDataPathResp(pTrcComp->TraceDataIn(op,index,0,0,0)); pTrcComp = m_IDStreams[id].next(); } } @@ -402,9 +403,54 @@ void TraceFmtDcdImpl::outputUnsyncedBytes(uint32_t /*num_bytes*/) //**TBD: }
+int TraceFmtDcdImpl::checkForResetFSyncPatterns() +{ + const uint32_t FSYNC_PATTERN = 0x7FFFFFFF; // LE host pattern for FSYNC + bool check_for_fsync = true; + int num_fsyncs = 0; + const uint8_t *dataPtr = m_in_block_base + m_in_block_processed; + + while (check_for_fsync && (m_in_block_processed < m_in_block_size)) + { + // look for consecutive fsyncs as padding or for reset downstream - both cases will reset downstream.... + if (*((uint32_t *)(dataPtr)) == FSYNC_PATTERN) + { + dataPtr += sizeof(uint32_t); + num_fsyncs++; + } + else + check_for_fsync = false; + } + + if (num_fsyncs) + { + printf("Frame deformatter: Found %d FSYNCS\n",num_fsyncs); + if ((num_fsyncs % 4) == 0) + { + // reset the upstream decoders + executeNoneDataOpAllIDs(OCSD_OP_RESET,m_trc_curr_idx); + + // reset the intra frame parameters + m_curr_src_ID = OCSD_BAD_CS_SRC_ID; + m_ex_frm_n_bytes = 0; + m_trc_curr_idx_sof = OCSD_BAD_TRC_INDEX; + } + else + { + // TBD: throw processing error, none frame size block of fsyncs + } + } + return num_fsyncs * 4; +} + + bool TraceFmtDcdImpl::extractFrame() { - bool cont_process = true; // continue processing after extraction. + const uint32_t FSYNC_PATTERN = 0x7FFFFFFF; // LE host pattern for FSYNC + const uint16_t HSYNC_PATTERN = 0x7FFF; // LE host pattern for HSYNC + + + 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 @@ -412,18 +458,23 @@ bool TraceFmtDcdImpl::extractFrame() // memory aligned sources are always multiples of frames, aligned to start. if( m_cfgFlags & OCSD_DFRMTR_FRAME_MEM_ALIGN) { - if(m_in_block_processed == m_in_block_size) + // some linux drivers (e.g. for perf) will insert FSYNCS to pad or differentiate + // between blocks of aligned data, always in frame aligned complete 16 byte frames. + if( m_cfgFlags & OCSD_DFRMTR_RESET_ON_4X_FSYNC) + f_sync_bytes = checkForResetFSyncPatterns(); + + if((m_in_block_processed+f_sync_bytes) == m_in_block_size) { m_ex_frm_n_bytes = 0; cont_process = false; // end of input data. } - else - { - // always a complete frame. - m_ex_frm_n_bytes = OCSD_DFRMTR_FRAME_SIZE; - memcpy(m_ex_frm_data, m_in_block_base+m_in_block_processed,m_ex_frm_n_bytes); - m_trc_curr_idx_sof = m_trc_curr_idx; - ex_bytes = OCSD_DFRMTR_FRAME_SIZE; + else + { + // always a complete frame. + m_ex_frm_n_bytes = OCSD_DFRMTR_FRAME_SIZE; + memcpy(m_ex_frm_data, m_in_block_base + m_in_block_processed + f_sync_bytes, m_ex_frm_n_bytes); + m_trc_curr_idx_sof = m_trc_curr_idx + f_sync_bytes; + ex_bytes = OCSD_DFRMTR_FRAME_SIZE; } } else @@ -431,9 +482,6 @@ bool TraceFmtDcdImpl::extractFrame() // extract data accounting for frame syncs and hsyncs if present. // we know we are aligned at this point - could be FSYNC or HSYNCs here.
- #define FSYNC_PATTERN 0x7FFFFFFF // LE host pattern for FSYNC - #define HSYNC_PATTERN 0x7FFF // LE host pattern for HSYNC - // check what we a looking for bool hasFSyncs = ((m_cfgFlags & OCSD_DFRMTR_HAS_FSYNCS) == OCSD_DFRMTR_HAS_FSYNCS); bool hasHSyncs = ((m_cfgFlags & OCSD_DFRMTR_HAS_HSYNCS) == OCSD_DFRMTR_HAS_HSYNCS); @@ -446,7 +494,7 @@ bool TraceFmtDcdImpl::extractFrame() // can have FSYNCS at start of frame (in middle is an error). if(hasFSyncs && cont_process && (m_ex_frm_n_bytes == 0)) { - while((*((uint32_t *)(dataPtr)) == (uint32_t)FSYNC_PATTERN) && cont_process) + while((*((uint32_t *)(dataPtr)) == FSYNC_PATTERN) && cont_process) { f_sync_bytes += 4; dataPtr += 4; @@ -462,7 +510,7 @@ bool TraceFmtDcdImpl::extractFrame() // check for illegal out of sequence FSYNC if((m_ex_frm_n_bytes % 4) == 0) { - if(*((uint32_t *)(dataPtr)) == (uint32_t)FSYNC_PATTERN) + if(*((uint32_t *)(dataPtr)) == FSYNC_PATTERN) { // throw an illegal FSYNC error } @@ -478,7 +526,7 @@ bool TraceFmtDcdImpl::extractFrame() ex_bytes +=2;
// check pair is not HSYNC - if(*((uint16_t *)(dataPtr)) == (uint16_t)HSYNC_PATTERN) + if(*((uint16_t *)(dataPtr)) == HSYNC_PATTERN) { if(hasHSyncs) { diff --git a/decoder/source/trc_frame_deformatter_impl.h b/decoder/source/trc_frame_deformatter_impl.h index 8e3f1ba..488bfad 100644 --- a/decoder/source/trc_frame_deformatter_impl.h +++ b/decoder/source/trc_frame_deformatter_impl.h @@ -76,7 +76,7 @@ private: ocsd_err_t SetForcedSyncIndex(ocsd_trc_index_t index, bool bSet);
private: - ocsd_datapath_resp_t executeNoneDataOpAllIDs(ocsd_datapath_op_t op); + ocsd_datapath_resp_t executeNoneDataOpAllIDs(ocsd_datapath_op_t op, const ocsd_trc_index_t index = 0); ocsd_datapath_resp_t processTraceData(const ocsd_trc_index_t index, const uint32_t dataBlockSize, const uint8_t *pDataBlock, @@ -113,6 +113,7 @@ private: void setRawChanFilterAll(bool bEnable); const bool rawChanEnabled(const uint8_t id) const;
+ int checkForResetFSyncPatterns();
friend class TraceFormatterFrameDecoder;
Add output mode and flags to standard library message logger to allow attachment of external print string interface. This allows client programs to use built in logger, but supply string printing as part of the app. (e.g. perf may use this to in --dump command).
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/include/common/ocsd_msg_logger.h | 18 ++++++++++++++++-- decoder/source/ocsd_msg_logger.cpp | 19 ++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/decoder/include/common/ocsd_msg_logger.h b/decoder/include/common/ocsd_msg_logger.h index ad73301..c40af91 100644 --- a/decoder/include/common/ocsd_msg_logger.h +++ b/decoder/include/common/ocsd_msg_logger.h @@ -38,6 +38,15 @@ #include <string> #include <fstream>
+class ocsdMsgLogStrOutI +{ +public: + ocsdMsgLogStrOutI() {}; + virtual ~ocsdMsgLogStrOutI() {}; + + virtual void printOutStr(const std::string &outStr) = 0; +}; + class ocsdMsgLogger { public: @@ -48,11 +57,15 @@ public: OUT_NONE = 0, OUT_FILE = 1, OUT_STDERR = 2, - OUT_STDOUT = 4 + OUT_STDOUT = 4, + OUT_STR_CB = 8 /* output to external string callback interface */ } output_dest;
void setLogOpts(int logOpts); - void setLogFileName(const char *fileName); + const int getLogOpts() const { return m_outFlags; }; + + void setLogFileName(const char *fileName); + void setStrOutFn(ocsdMsgLogStrOutI *p_IstrOut);
void LogMsg(const std::string &msg);
@@ -63,6 +76,7 @@ private:
std::string m_logFileName; std::fstream m_out_file; + ocsdMsgLogStrOutI *m_pOutStrI; };
#endif // ARM_OCSD_MSG_LOGGER_H_INCLUDED diff --git a/decoder/source/ocsd_msg_logger.cpp b/decoder/source/ocsd_msg_logger.cpp index 02b3921..2ddf4ee 100644 --- a/decoder/source/ocsd_msg_logger.cpp +++ b/decoder/source/ocsd_msg_logger.cpp @@ -37,9 +37,12 @@ #include <iostream> #include <sstream>
+#define MSGLOG_OUT_MASK (ocsdMsgLogger::OUT_FILE | ocsdMsgLogger::OUT_STDERR | ocsdMsgLogger::OUT_STDOUT | ocsdMsgLogger::OUT_STR_CB) + ocsdMsgLogger::ocsdMsgLogger() : m_outFlags(ocsdMsgLogger::OUT_STDOUT), - m_logFileName("ocsd_trace_decode.log") + m_logFileName("ocsd_trace_decode.log"), + m_pOutStrI(0) { }
@@ -50,7 +53,7 @@ ocsdMsgLogger::~ocsdMsgLogger()
void ocsdMsgLogger::setLogOpts(int logOpts) { - m_outFlags = logOpts & (ocsdMsgLogger::OUT_FILE | ocsdMsgLogger::OUT_STDERR | ocsdMsgLogger::OUT_STDOUT); + m_outFlags = logOpts & (MSGLOG_OUT_MASK); }
void ocsdMsgLogger::setLogFileName(const char *fileName) @@ -60,6 +63,10 @@ void ocsdMsgLogger::setLogFileName(const char *fileName) m_out_file.close(); }
+void ocsdMsgLogger::setStrOutFn(ocsdMsgLogStrOutI *p_IstrOut) +{ + m_pOutStrI = p_IstrOut; +}
void ocsdMsgLogger::LogMsg(const std::string &msg) { @@ -84,11 +91,17 @@ void ocsdMsgLogger::LogMsg(const std::string &msg) m_out_file << msg; m_out_file.flush(); } + + if (m_outFlags & OUT_STR_CB) + { + if (m_pOutStrI) + m_pOutStrI->printOutStr(msg); + } }
const bool ocsdMsgLogger::isLogging() const { - return (bool)((m_outFlags & (ocsdMsgLogger::OUT_FILE | ocsdMsgLogger::OUT_STDERR | ocsdMsgLogger::OUT_STDOUT)) != 0); + return (bool)((m_outFlags & MSGLOG_OUT_MASK) != 0); }
/* End of File ocsd_msg_logger.cpp */
Move packet printing code from the test environment into the main library. Allows for later additions to let external clients use built in print objects to create strings and logs when using the library, avoiding the need for specific callbacks. Applies to raw trace frames, generic output packets and built-in packet protocols.
Creates packet printer factory to generate printer objects. Test programs adjusted to verify new API.
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/build/linux/ref_trace_decode_lib/makefile | 10 +- .../ref_trace_decode_lib.vcxproj | 8 + .../ref_trace_decode_lib.vcxproj.filters | 30 ++++ decoder/include/opencsd.h | 4 + decoder/include/pkt_printers/gen_elem_printer.h | 95 +++++++++++ decoder/include/pkt_printers/item_printer.h | 94 ++++++++++ decoder/include/pkt_printers/pkt_printer_t.h | 189 +++++++++++++++++++++ decoder/include/pkt_printers/raw_frame_printer.h | 69 ++++++++ decoder/include/pkt_printers/trc_pkt_printers.h | 43 +++++ decoder/include/pkt_printers/trc_print_fact.h | 62 +++++++ decoder/source/pkt_printers/raw_frame_printer.cpp | 104 ++++++++++++ decoder/source/pkt_printers/trc_print_fact.cpp | 111 ++++++++++++ decoder/source/trc_frame_deformatter.cpp | 21 ++- decoder/tests/build/linux/trc_pkt_lister/makefile | 3 +- .../trc_pkt_lister/trc_pkt_lister.vcxproj | 6 +- .../trc_pkt_lister/trc_pkt_lister.vcxproj.filters | 14 +- decoder/tests/source/gen_elem_printer.h | 96 ----------- decoder/tests/source/item_printer.h | 94 ---------- decoder/tests/source/pkt_printer_t.h | 188 -------------------- decoder/tests/source/raw_frame_printer.cpp | 96 ----------- decoder/tests/source/raw_frame_printer.h | 71 -------- decoder/tests/source/trc_pkt_lister.cpp | 91 +++++----- 22 files changed, 881 insertions(+), 618 deletions(-) create mode 100644 decoder/include/pkt_printers/gen_elem_printer.h create mode 100644 decoder/include/pkt_printers/item_printer.h create mode 100644 decoder/include/pkt_printers/pkt_printer_t.h create mode 100644 decoder/include/pkt_printers/raw_frame_printer.h create mode 100644 decoder/include/pkt_printers/trc_pkt_printers.h create mode 100644 decoder/include/pkt_printers/trc_print_fact.h create mode 100644 decoder/source/pkt_printers/raw_frame_printer.cpp create mode 100644 decoder/source/pkt_printers/trc_print_fact.cpp delete mode 100644 decoder/tests/source/gen_elem_printer.h delete mode 100644 decoder/tests/source/item_printer.h delete mode 100644 decoder/tests/source/pkt_printer_t.h delete mode 100644 decoder/tests/source/raw_frame_printer.cpp delete mode 100644 decoder/tests/source/raw_frame_printer.h
diff --git a/decoder/build/linux/ref_trace_decode_lib/makefile b/decoder/build/linux/ref_trace_decode_lib/makefile index 5d89999..748bab1 100644 --- a/decoder/build/linux/ref_trace_decode_lib/makefile +++ b/decoder/build/linux/ref_trace_decode_lib/makefile @@ -48,7 +48,8 @@ VPATH= $(OCSD_SOURCE) \ $(OCSD_SOURCE)/ptm \ $(OCSD_SOURCE)/i_dec \ $(OCSD_SOURCE)/mem_acc \ - $(OCSD_SOURCE)/stm + $(OCSD_SOURCE)/stm \ + $(OCSD_SOURCE)/pkt_printers
CPP_INCLUDES= \ @@ -86,6 +87,10 @@ STMOBJ= $(BUILD_DIR)/trc_pkt_elem_stm.o \ $(BUILD_DIR)/trc_pkt_proc_stm.o \ $(BUILD_DIR)/trc_pkt_decode_stm.o
+PKTPRNTOBJ= $(BUILD_DIR)/raw_frame_printer.o \ + $(BUILD_DIR)/trc_print_fact.o + + OBJECTS=$(BUILD_DIR)/ocsd_code_follower.o \ $(BUILD_DIR)/ocsd_dcd_tree.o \ $(BUILD_DIR)/ocsd_error.o \ @@ -104,7 +109,8 @@ OBJECTS=$(BUILD_DIR)/ocsd_code_follower.o \ $(IDECOBJ) \ $(MEMACCOBJ) \ $(STMOBJ) \ - $(PTMOBJ) + $(PTMOBJ) \ + $(PKTPRNTOBJ)
all: build_dir $(OBJECTS) mkdir -p $(LIB_TARGET_DIR) 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 05e5857..709f031 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 @@ -372,6 +372,12 @@ <ClInclude Include="..\..\..\include\ocsd_if_types.h" /> <ClInclude Include="..\..\..\include\ocsd_if_version.h" /> <ClInclude Include="..\..\..\include\opencsd.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" /> + <ClInclude Include="..\..\..\include\pkt_printers\raw_frame_printer.h" /> + <ClInclude Include="..\..\..\include\pkt_printers\trc_pkt_printers.h" /> + <ClInclude Include="..\..\..\include\pkt_printers\trc_print_fact.h" /> <ClInclude Include="..\..\..\include\ptm\ptm_decoder.h" /> <ClInclude Include="..\..\..\include\ptm\trc_cmp_cfg_ptm.h" /> <ClInclude Include="..\..\..\include\ptm\trc_dcd_mngr_ptm.h" /> @@ -421,6 +427,8 @@ <ClCompile Include="..\..\..\source\ocsd_lib_dcd_register.cpp" /> <ClCompile Include="..\..\..\source\ocsd_msg_logger.cpp" /> <ClCompile Include="..\..\..\source\ocsd_version.cpp" /> + <ClCompile Include="..\..\..\source\pkt_printers\raw_frame_printer.cpp" /> + <ClCompile Include="..\..\..\source\pkt_printers\trc_print_fact.cpp" /> <ClCompile Include="..\..\..\source\ptm\trc_cmp_cfg_ptm.cpp" /> <ClCompile Include="..\..\..\source\ptm\trc_pkt_decode_ptm.cpp" /> <ClCompile Include="..\..\..\source\ptm\trc_pkt_elem_ptm.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 87aa847..2ee0f50 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 @@ -58,6 +58,12 @@ <Filter Include="Header Files\common"> <UniqueIdentifier>{58d2398e-efdd-45d9-b7be-fc6096f3bec2}</UniqueIdentifier> </Filter> + <Filter Include="Header Files\pkt_printers"> + <UniqueIdentifier>{0e6e1f5d-465e-4f91-88a3-479952bbd316}</UniqueIdentifier> + </Filter> + <Filter Include="Source Files\pkt_printers"> + <UniqueIdentifier>{baf047d0-0ff7-4502-b42b-4f1fda94d54b}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> <None Include="..\..\..\..\LICENSE"> @@ -329,6 +335,24 @@ <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> + <ClInclude Include="..\..\..\include\pkt_printers\item_printer.h"> + <Filter>Header Files\pkt_printers</Filter> + </ClInclude> + <ClInclude Include="..\..\..\include\pkt_printers\pkt_printer_t.h"> + <Filter>Header Files\pkt_printers</Filter> + </ClInclude> + <ClInclude Include="..\..\..\include\pkt_printers\raw_frame_printer.h"> + <Filter>Header Files\pkt_printers</Filter> + </ClInclude> + <ClInclude Include="..\..\..\include\pkt_printers\trc_pkt_printers.h"> + <Filter>Header Files\pkt_printers</Filter> + </ClInclude> + <ClInclude Include="..\..\..\include\pkt_printers\trc_print_fact.h"> + <Filter>Header Files\pkt_printers</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\..\..\source\trc_component.cpp"> @@ -445,5 +469,11 @@ <ClCompile Include="..\..\..\source\stm\trc_pkt_decode_stm.cpp"> <Filter>Source Files\stm</Filter> </ClCompile> + <ClCompile Include="..\..\..\source\pkt_printers\raw_frame_printer.cpp"> + <Filter>Source Files\pkt_printers</Filter> + </ClCompile> + <ClCompile Include="..\..\..\source\pkt_printers\trc_print_fact.cpp"> + <Filter>Source Files\pkt_printers</Filter> + </ClCompile> </ItemGroup> </Project> \ No newline at end of file diff --git a/decoder/include/opencsd.h b/decoder/include/opencsd.h index ad6e2d2..fa8a45a 100644 --- a/decoder/include/opencsd.h +++ b/decoder/include/opencsd.h @@ -70,6 +70,10 @@ #include "i_dec/trc_i_decode.h" #include "mem_acc/trc_mem_acc.h"
+/* printers for builtin packet elements */ +#include "pkt_printers/trc_pkt_printers.h" +#include "pkt_printers/trc_print_fact.h" + /** The decode tree and decoder register*/ #include "common/ocsd_lib_dcd_register.h" #include "common/ocsd_dcd_tree.h" diff --git a/decoder/include/pkt_printers/gen_elem_printer.h b/decoder/include/pkt_printers/gen_elem_printer.h new file mode 100644 index 0000000..ba3138a --- /dev/null +++ b/decoder/include/pkt_printers/gen_elem_printer.h @@ -0,0 +1,95 @@ +/* + * \file gen_elem_printer.h + * \brief OpenCSD : Generic element printer class. + * + * \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: + * + * 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_GEN_ELEM_PRINTER_H_INCLUDED +#define ARM_GEN_ELEM_PRINTER_H_INCLUDED + +#include "opencsd.h" + +class TrcGenericElementPrinter : public ItemPrinter, public ITrcGenElemIn +{ +public: + TrcGenericElementPrinter(); + virtual ~TrcGenericElementPrinter() {}; + + virtual ocsd_datapath_resp_t TraceElemIn(const ocsd_trc_index_t index_sop, + const uint8_t trc_chan_id, + const OcsdTraceElement &elem); + + // funtionality to test wait / flush mechanism + void ackWait() { m_needWaitAck = false; }; + const bool needAckWait() const { return m_needWaitAck; }; + +protected: + bool m_needWaitAck; +}; + + +inline TrcGenericElementPrinter::TrcGenericElementPrinter() : + m_needWaitAck(false) +{ +} + +inline ocsd_datapath_resp_t TrcGenericElementPrinter::TraceElemIn(const ocsd_trc_index_t index_sop, + const uint8_t trc_chan_id, + const OcsdTraceElement &elem) +{ + ocsd_datapath_resp_t resp = OCSD_RESP_CONT; + 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; + itemPrintLine(oss.str()); + + // funtionality to test wait / flush mechanism + if(m_needWaitAck) + { + oss.str(""); + oss << "WARNING: Generic Element Printer; New element without previous _WAIT acknowledged\n"; + itemPrintLine(oss.str()); + m_needWaitAck = false; + } + + if(getTestWaits()) + { + resp = OCSD_RESP_WAIT; // return _WAIT for the 1st N packets. + decTestWaits(); + m_needWaitAck = true; + } + return resp; +} + +#endif // ARM_GEN_ELEM_PRINTER_H_INCLUDED + +/* End of File gen_elem_printer.h */ diff --git a/decoder/include/pkt_printers/item_printer.h b/decoder/include/pkt_printers/item_printer.h new file mode 100644 index 0000000..cc3ec37 --- /dev/null +++ b/decoder/include/pkt_printers/item_printer.h @@ -0,0 +1,94 @@ +/* + * \file item_printer.h + * \brief OpenCSD : + * + * \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: + * + * 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_ITEM_PRINTER_H_INCLUDED +#define ARM_ITEM_PRINTER_H_INCLUDED + +#include "opencsd.h" +#include <string> + +class ItemPrinter +{ +public: + ItemPrinter(); + virtual ~ItemPrinter(); + + void setMessageLogger(ocsdMsgLogger *pMsgLogger) { m_pMsgLogger = pMsgLogger; }; + void itemPrintLine(const std::string &msg); + + // return wait for the first N packets - test the wait mechanism. + void setTestWaits(const int num_waits); + const int getTestWaits() const; + void decTestWaits(); + +protected: + ocsdMsgLogger *m_pMsgLogger; + int m_test_waits; +}; + +inline ItemPrinter::ItemPrinter() : + m_pMsgLogger(0), + m_test_waits(0) +{ +} + +inline ItemPrinter::~ItemPrinter() +{ + m_pMsgLogger = 0; +} + +inline void ItemPrinter::itemPrintLine(const std::string &msg) +{ + if(m_pMsgLogger) + m_pMsgLogger->LogMsg(msg); +} + +inline void ItemPrinter::setTestWaits(const int num_waits) +{ + m_test_waits = num_waits; +} + +inline const int ItemPrinter::getTestWaits() const +{ + return m_test_waits; +} + +inline void ItemPrinter::decTestWaits() +{ + m_test_waits--; +} + +#endif // ARM_ITEM_PRINTER_H_INCLUDED + +/* End of File item_printer.h */ diff --git a/decoder/include/pkt_printers/pkt_printer_t.h b/decoder/include/pkt_printers/pkt_printer_t.h new file mode 100644 index 0000000..fc3ad2a --- /dev/null +++ b/decoder/include/pkt_printers/pkt_printer_t.h @@ -0,0 +1,189 @@ +/* + * \file pkt_printer_t.h + * \brief OpenCSD : Test packet printer. + * + * \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: + * + * 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_PKT_PRINTER_T_H_INCLUDED +#define ARM_PKT_PRINTER_T_H_INCLUDED + +#include "opencsd.h" + +#include <string> +#include <sstream> +#include <iostream> +#include <iomanip> + +template<class P> +class PacketPrinter : public IPktDataIn<P>, public IPktRawDataMon<P>, public ItemPrinter +{ +public: + PacketPrinter(const uint8_t trcID); + PacketPrinter(const uint8_t trcID, ocsdMsgLogger *pMsgLogger); + virtual ~PacketPrinter(); + + + virtual ocsd_datapath_resp_t PacketDataIn( const ocsd_datapath_op_t op, + const ocsd_trc_index_t index_sop, + const P *p_packet_in); + + 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); + + +private: + void printIdx_ID(const ocsd_trc_index_t index_sop); + + uint8_t m_trcID; + bool m_bRawPrint; + std::ostringstream m_oss; + ocsd_datapath_resp_t m_last_resp; + +}; + +template<class P> PacketPrinter<P>::PacketPrinter(uint8_t trcID) : + m_trcID(trcID), + m_bRawPrint(false), + m_last_resp(OCSD_RESP_CONT) +{ +} + +template<class P> PacketPrinter<P>::PacketPrinter(const uint8_t trcID, ocsdMsgLogger *pMsgLogger) : + m_trcID(trcID), + m_bRawPrint(false), + m_last_resp(OCSD_RESP_CONT) +{ + setMessageLogger(pMsgLogger); +} + +template<class P> PacketPrinter<P>::~PacketPrinter() +{ +} + +template<class P> ocsd_datapath_resp_t PacketPrinter<P>::PacketDataIn( const ocsd_datapath_op_t op, + const ocsd_trc_index_t index_sop, + const P *p_packet_in) +{ + std::string pktstr; + ocsd_datapath_resp_t resp = OCSD_RESP_CONT; + + // wait / flush test verification + if(!m_bRawPrint && (m_last_resp == OCSD_RESP_WAIT)) + { + // expect a flush or a complete reset after a wait. + if((op != OCSD_OP_FLUSH) || (op != OCSD_OP_RESET)) + { + m_oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tERROR: FLUSH operation expected after wait on trace decode path\n"; + itemPrintLine(m_oss.str()); + m_oss.str(""); + return OCSD_RESP_FATAL_INVALID_OP; + } + } + + switch(op) + { + case OCSD_OP_DATA: + p_packet_in->toString(pktstr); + if(!m_bRawPrint) + printIdx_ID(index_sop); + m_oss << ";\t" << pktstr << std::endl; + + // test the wait/flush response mechnism + if(getTestWaits() && !m_bRawPrint) + { + decTestWaits(); + resp = OCSD_RESP_WAIT; + } + break; + + case OCSD_OP_EOT: + m_oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tEND OF TRACE DATA\n"; + break; + + case OCSD_OP_FLUSH: + m_oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tFLUSH operation on trace decode path\n"; + break; + + case OCSD_OP_RESET: + m_oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tRESET operation on trace decode path\n"; + break; + } + + m_last_resp = resp; + itemPrintLine(m_oss.str()); + m_oss.str(""); + return resp; +} + +template<class P> void PacketPrinter<P>::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) +{ + switch(op) + { + case OCSD_OP_DATA: + printIdx_ID(index_sop); + m_oss << "; ["; + if((size > 0) && (p_data != 0)) + { + uint32_t data = 0; + for(uint32_t i = 0; i < size; i++) + { + data = (uint32_t)(p_data[i] & 0xFF); + m_oss << "0x" << std::hex << std::setw(2) << std::setfill('0') << data << " "; + } + } + m_oss << "]"; + m_bRawPrint = true; + PacketDataIn(op,index_sop,pkt); + m_bRawPrint = false; + break; + + default: + PacketDataIn(op,index_sop,pkt); + break; + } + +} + +template<class P> void PacketPrinter<P>::printIdx_ID(const ocsd_trc_index_t index_sop) +{ + m_oss << "Idx:" << std::dec << index_sop << "; ID:"<< std::hex << (uint32_t)m_trcID; +} + +#endif // ARM_PKT_PRINTER_T_H_INCLUDED + +/* End of File pkt_printer_t.h */ diff --git a/decoder/include/pkt_printers/raw_frame_printer.h b/decoder/include/pkt_printers/raw_frame_printer.h new file mode 100644 index 0000000..50caeb8 --- /dev/null +++ b/decoder/include/pkt_printers/raw_frame_printer.h @@ -0,0 +1,69 @@ +/* + * \file raw_frame_printer.h + * \brief OpenCSD : + * + * \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: + * + * 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_RAW_FRAME_PRINTER_H_INCLUDED +#define ARM_RAW_FRAME_PRINTER_H_INCLUDED + +#include "opencsd.h" + +#include <string> +#include <sstream> + +class RawFramePrinter : public ITrcRawFrameIn, public ItemPrinter +{ +public: + RawFramePrinter() {}; + RawFramePrinter(ocsdMsgLogger *pMsgLogger); + virtual ~RawFramePrinter() {}; + + virtual ocsd_err_t TraceRawFrameIn( const ocsd_datapath_op_t op, + const ocsd_trc_index_t index, + const ocsd_rawframe_elem_t frame_element, + const int dataBlockSize, + const uint8_t *pDataBlock, + const uint8_t traceID); + +private: + void createDataString(const int dataSize, const uint8_t *pData, int bytesPerLine, std::string &dataStr); + +}; + +inline RawFramePrinter::RawFramePrinter(ocsdMsgLogger *pMsgLogger) +{ + setMessageLogger(pMsgLogger); +} + +#endif // ARM_RAW_FRAME_PRINTER_H_INCLUDED + +/* End of File raw_frame_printer.h */ diff --git a/decoder/include/pkt_printers/trc_pkt_printers.h b/decoder/include/pkt_printers/trc_pkt_printers.h new file mode 100644 index 0000000..439701a --- /dev/null +++ b/decoder/include/pkt_printers/trc_pkt_printers.h @@ -0,0 +1,43 @@ +/* +* \file trc_pkt_printers.h +* \brief OpenCSD : Known protocol packet printers. +* +* \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: +* +* 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_PKT_PRINTERS_H_INCLUDED +#define ARM_TRC_PKT_PRINTERS_H_INCLUDED + +#include "pkt_printers/item_printer.h" +#include "pkt_printers/pkt_printer_t.h" +#include "pkt_printers/gen_elem_printer.h" +#include "pkt_printers/raw_frame_printer.h" + +#endif // ARM_TRC_PKT_PRINTERS_H_INCLUDED diff --git a/decoder/include/pkt_printers/trc_print_fact.h b/decoder/include/pkt_printers/trc_print_fact.h new file mode 100644 index 0000000..002d74c --- /dev/null +++ b/decoder/include/pkt_printers/trc_print_fact.h @@ -0,0 +1,62 @@ +/* +* \file trc_print_fact.h +* \brief OpenCSD : Factory for protocol packet printers. +* +* \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: +* +* 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_PRINT_FACT_H_INCLUDED +#define ARM_TRC_PRINT_FACT_H_INCLUDED + +#include "opencsd.h" + +class PktPrinterFact +{ +public: + static ItemPrinter *createProtocolPrinter(ocsd_trace_protocol_t protocol, uint8_t elemID, ocsdMsgLogger *pMsgLogger = 0); + static RawFramePrinter *createRawFramePrinter(ocsdMsgLogger *pMsgLogger = 0); + static TrcGenericElementPrinter *createGenElemPrinter(ocsdMsgLogger *pMsgLogger = 0); + + static void destroyAllPrinters(); + static const int numPrinters(); + static std::vector<ItemPrinter *> &getPrinterList(); + +private: + static void SavePrinter(ItemPrinter *pPrinter, ocsdMsgLogger *pMsgLogger); + + PktPrinterFact() {}; + ~PktPrinterFact() {}; + + static std::vector<ItemPrinter *> sm_printers; /* list of printers created. */ +}; + +#endif // ARM_TRC_PRINT_FACT_H_INCLUDED + +/* end of file trc_print_fact.h */ diff --git a/decoder/source/pkt_printers/raw_frame_printer.cpp b/decoder/source/pkt_printers/raw_frame_printer.cpp new file mode 100644 index 0000000..7ac2ddf --- /dev/null +++ b/decoder/source/pkt_printers/raw_frame_printer.cpp @@ -0,0 +1,104 @@ +/* + * \file raw_frame_printer.cpp + * \brief OpenCSD : + * + * \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: + * + * 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 <string> +#include <sstream> +#include <iomanip> + +#include "opencsd.h" + + +ocsd_err_t RawFramePrinter::TraceRawFrameIn( const ocsd_datapath_op_t op, + const ocsd_trc_index_t index, + const ocsd_rawframe_elem_t frame_element, + const int dataBlockSize, + const uint8_t *pDataBlock, + const uint8_t traceID) +{ + + if(op == OCSD_OP_DATA) // only interested in actual frame data. + { + std::string strData; + std::ostringstream oss; + int printDataSize = dataBlockSize; + + oss << "Frame Data; Index" << std::setw(7) << index << "; "; + + switch(frame_element) + { + case OCSD_FRM_PACKED: oss << std::setw(15) << "RAW_PACKED; "; break; + case OCSD_FRM_HSYNC: oss << std::setw(15) << "HSYNC; "; break; + case OCSD_FRM_FSYNC: oss << std::setw(15) << "FSYNC; "; break; + case OCSD_FRM_ID_DATA: + oss << std::setw(10) << "ID_DATA["; + if (traceID == OCSD_BAD_CS_SRC_ID) + oss << "????"; + else + oss << "0x" << std::hex << std::setw(2) << std::setfill('0') << (uint16_t)traceID; + oss << "]; "; + break; + default: oss << std::setw(15) << "UNKNOWN; "; break; + } + + if(printDataSize) + { + createDataString(printDataSize,pDataBlock,16,strData); + oss << strData; + } + oss << std::endl; + itemPrintLine(oss.str()); + } + return OCSD_OK; +} + +void RawFramePrinter::createDataString(const int dataSize, const uint8_t *pData, int bytesPerLine, std::string &dataStr) +{ + int lineBytes = 0; + std::ostringstream oss; + + for(int i = 0; i < dataSize; i++) + { + if(lineBytes == bytesPerLine) + { + oss << std::endl; + lineBytes = 0; + } + oss << std::hex << std::setw(2) << std::setfill('0') << (uint32_t)pData[i] << " "; + lineBytes ++; + } + dataStr = oss.str(); +} + + +/* End of File raw_frame_printer.cpp */ diff --git a/decoder/source/pkt_printers/trc_print_fact.cpp b/decoder/source/pkt_printers/trc_print_fact.cpp new file mode 100644 index 0000000..39d770d --- /dev/null +++ b/decoder/source/pkt_printers/trc_print_fact.cpp @@ -0,0 +1,111 @@ +/* +* \file trc_print_fact.cpp +* \brief OpenCSD : Trace Packet printer factory. +* +* \copyright Copyright (c) 2017, 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 "pkt_printers/trc_print_fact.h" + +std::vector<ItemPrinter *> PktPrinterFact::sm_printers; + +RawFramePrinter * PktPrinterFact::createRawFramePrinter(ocsdMsgLogger *pMsgLogger /*= 0*/) +{ + RawFramePrinter *pPrinter = 0; + pPrinter = new (std::nothrow)RawFramePrinter(); + SavePrinter(pPrinter, pMsgLogger); + return pPrinter; +} + +TrcGenericElementPrinter *PktPrinterFact::createGenElemPrinter(ocsdMsgLogger *pMsgLogger /*= 0*/) +{ + TrcGenericElementPrinter *pPrinter = 0; + pPrinter = new (std::nothrow)TrcGenericElementPrinter(); + SavePrinter(pPrinter, pMsgLogger); + return pPrinter; +} + +ItemPrinter *PktPrinterFact::createProtocolPrinter(ocsd_trace_protocol_t protocol, uint8_t CSID, ocsdMsgLogger *pMsgLogger /*= 0*/) +{ + ItemPrinter *pPrinter = 0; + switch (protocol) + { + case OCSD_PROTOCOL_ETMV4I: + pPrinter = new (std::nothrow) PacketPrinter<EtmV4ITrcPacket>(CSID); + break; + case OCSD_PROTOCOL_ETMV3: + pPrinter = new (std::nothrow) PacketPrinter<EtmV3TrcPacket>(CSID); + break; + case OCSD_PROTOCOL_PTM: + pPrinter = new (std::nothrow) PacketPrinter<PtmTrcPacket>(CSID); + break; + case OCSD_PROTOCOL_STM: + pPrinter = new (std::nothrow) PacketPrinter<StmTrcPacket>(CSID); + break; + default: + break; + } + SavePrinter(pPrinter, pMsgLogger); + return pPrinter; +} + +const int PktPrinterFact::numPrinters() +{ + return sm_printers.size(); +} + +std::vector<ItemPrinter *> &PktPrinterFact::getPrinterList() +{ + return sm_printers; +} + +void PktPrinterFact::SavePrinter(ItemPrinter *pPrinter, ocsdMsgLogger *pMsgLogger) +{ + if (pPrinter) + { + pPrinter->setMessageLogger(pMsgLogger); + sm_printers.push_back((ItemPrinter *)pPrinter); + } +} + +void PktPrinterFact::destroyAllPrinters() +{ + std::vector<ItemPrinter *>::iterator it; + it = sm_printers.begin(); + while (it != sm_printers.end()) + { + delete *it; + it++; + } + sm_printers.clear(); +} + +/* end of file trc_print_fact.cpp */ diff --git a/decoder/source/trc_frame_deformatter.cpp b/decoder/source/trc_frame_deformatter.cpp index 769c38c..dad84e5 100644 --- a/decoder/source/trc_frame_deformatter.cpp +++ b/decoder/source/trc_frame_deformatter.cpp @@ -460,8 +460,21 @@ bool TraceFmtDcdImpl::extractFrame() { // some linux drivers (e.g. for perf) will insert FSYNCS to pad or differentiate // between blocks of aligned data, always in frame aligned complete 16 byte frames. - if( m_cfgFlags & OCSD_DFRMTR_RESET_ON_4X_FSYNC) - f_sync_bytes = checkForResetFSyncPatterns(); + if (m_cfgFlags & OCSD_DFRMTR_RESET_ON_4X_FSYNC) + { + f_sync_bytes = checkForResetFSyncPatterns(); + + /* in this case the FSYNC pattern is output on both packed and unpacked cases */ + if (f_sync_bytes && (m_b_output_packed_raw || m_b_output_unpacked_raw)) + { + outputRawMonBytes(OCSD_OP_DATA, + m_trc_curr_idx, + OCSD_FRM_FSYNC, + f_sync_bytes, + m_in_block_base + m_in_block_processed, + 0); + } + }
if((m_in_block_processed+f_sync_bytes) == m_in_block_size) { @@ -719,8 +732,8 @@ bool TraceFmtDcdImpl::outputFrame() } else { - // optional raw output for debugging / monitor tools - if(m_b_output_unpacked_raw && rawChanEnabled( m_out_data[m_out_processed].id)) + // optional raw output for debugging / monitor tools of unknown src ID data + if(m_b_output_unpacked_raw) { outputRawMonBytes( OCSD_OP_DATA, m_out_data[m_out_processed].index, diff --git a/decoder/tests/build/linux/trc_pkt_lister/makefile b/decoder/tests/build/linux/trc_pkt_lister/makefile index d2975f8..f160b9c 100644 --- a/decoder/tests/build/linux/trc_pkt_lister/makefile +++ b/decoder/tests/build/linux/trc_pkt_lister/makefile @@ -48,8 +48,7 @@ CPP_INCLUDES = \ -I$(OCSD_INCLUDE) \ -I$(OCSD_TESTS)/snapshot_parser_lib/include
-OBJECTS = $(BUILD_DIR)/trc_pkt_lister.o \ - $(BUILD_DIR)/raw_frame_printer.o +OBJECTS = $(BUILD_DIR)/trc_pkt_lister.o
LIBS = -L$(LIB_TEST_TARGET_DIR) -lsnapshot_parser \ -L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME) diff --git a/decoder/tests/build/win-vs2015/trc_pkt_lister/trc_pkt_lister.vcxproj b/decoder/tests/build/win-vs2015/trc_pkt_lister/trc_pkt_lister.vcxproj index a739864..3f90191 100644 --- a/decoder/tests/build/win-vs2015/trc_pkt_lister/trc_pkt_lister.vcxproj +++ b/decoder/tests/build/win-vs2015/trc_pkt_lister/trc_pkt_lister.vcxproj @@ -300,7 +300,6 @@ </Link> </ItemDefinitionGroup> <ItemGroup> - <ClCompile Include="..\..\..\source\raw_frame_printer.cpp" /> <ClCompile Include="..\..\..\source\trc_pkt_lister.cpp" /> </ItemGroup> <ItemGroup> @@ -309,10 +308,7 @@ </ProjectReference> </ItemGroup> <ItemGroup> - <ClInclude Include="..\..\..\source\gen_elem_printer.h" /> - <ClInclude Include="..\..\..\source\item_printer.h" /> - <ClInclude Include="..\..\..\source\pkt_printer_t.h" /> - <ClInclude Include="..\..\..\source\raw_frame_printer.h" /> + <ClInclude Include="..\..\..\..\include\pkt_printers\trc_pkt_printers.h" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/decoder/tests/build/win-vs2015/trc_pkt_lister/trc_pkt_lister.vcxproj.filters b/decoder/tests/build/win-vs2015/trc_pkt_lister/trc_pkt_lister.vcxproj.filters index daab04a..9f44406 100644 --- a/decoder/tests/build/win-vs2015/trc_pkt_lister/trc_pkt_lister.vcxproj.filters +++ b/decoder/tests/build/win-vs2015/trc_pkt_lister/trc_pkt_lister.vcxproj.filters @@ -18,21 +18,9 @@ <ClCompile Include="..\..\..\source\trc_pkt_lister.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="..\..\..\source\raw_frame_printer.cpp"> - <Filter>Source Files</Filter> - </ClCompile> </ItemGroup> <ItemGroup> - <ClInclude Include="..\..\..\source\pkt_printer_t.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\..\..\source\item_printer.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\..\..\source\raw_frame_printer.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\..\..\source\gen_elem_printer.h"> + <ClInclude Include="..\..\..\..\include\pkt_printers\trc_pkt_printers.h"> <Filter>Header Files</Filter> </ClInclude> </ItemGroup> diff --git a/decoder/tests/source/gen_elem_printer.h b/decoder/tests/source/gen_elem_printer.h deleted file mode 100644 index f3e9717..0000000 --- a/decoder/tests/source/gen_elem_printer.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * \file gen_elem_printer.h - * \brief OpenCSD : Generic element printer class. - * - * \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: - * - * 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_GEN_ELEM_PRINTER_H_INCLUDED -#define ARM_GEN_ELEM_PRINTER_H_INCLUDED - -#include "opencsd.h" -#include "item_printer.h" - -class TrcGenericElementPrinter : public ItemPrinter, public ITrcGenElemIn -{ -public: - TrcGenericElementPrinter(); - virtual ~TrcGenericElementPrinter() {}; - - virtual ocsd_datapath_resp_t TraceElemIn(const ocsd_trc_index_t index_sop, - const uint8_t trc_chan_id, - const OcsdTraceElement &elem); - - // funtionality to test wait / flush mechanism - void ackWait() { m_needWaitAck = false; }; - const bool needAckWait() const { return m_needWaitAck; }; - -protected: - bool m_needWaitAck; -}; - - -inline TrcGenericElementPrinter::TrcGenericElementPrinter() : - m_needWaitAck(false) -{ -} - -inline ocsd_datapath_resp_t TrcGenericElementPrinter::TraceElemIn(const ocsd_trc_index_t index_sop, - const uint8_t trc_chan_id, - const OcsdTraceElement &elem) -{ - ocsd_datapath_resp_t resp = OCSD_RESP_CONT; - 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; - itemPrintLine(oss.str()); - - // funtionality to test wait / flush mechanism - if(m_needWaitAck) - { - oss.str(""); - oss << "WARNING: Generic Element Printer; New element without previous _WAIT acknowledged\n"; - itemPrintLine(oss.str()); - m_needWaitAck = false; - } - - if(getTestWaits()) - { - resp = OCSD_RESP_WAIT; // return _WAIT for the 1st N packets. - decTestWaits(); - m_needWaitAck = true; - } - return resp; -} - -#endif // ARM_GEN_ELEM_PRINTER_H_INCLUDED - -/* End of File gen_elem_printer.h */ diff --git a/decoder/tests/source/item_printer.h b/decoder/tests/source/item_printer.h deleted file mode 100644 index cc3ec37..0000000 --- a/decoder/tests/source/item_printer.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * \file item_printer.h - * \brief OpenCSD : - * - * \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: - * - * 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_ITEM_PRINTER_H_INCLUDED -#define ARM_ITEM_PRINTER_H_INCLUDED - -#include "opencsd.h" -#include <string> - -class ItemPrinter -{ -public: - ItemPrinter(); - virtual ~ItemPrinter(); - - void setMessageLogger(ocsdMsgLogger *pMsgLogger) { m_pMsgLogger = pMsgLogger; }; - void itemPrintLine(const std::string &msg); - - // return wait for the first N packets - test the wait mechanism. - void setTestWaits(const int num_waits); - const int getTestWaits() const; - void decTestWaits(); - -protected: - ocsdMsgLogger *m_pMsgLogger; - int m_test_waits; -}; - -inline ItemPrinter::ItemPrinter() : - m_pMsgLogger(0), - m_test_waits(0) -{ -} - -inline ItemPrinter::~ItemPrinter() -{ - m_pMsgLogger = 0; -} - -inline void ItemPrinter::itemPrintLine(const std::string &msg) -{ - if(m_pMsgLogger) - m_pMsgLogger->LogMsg(msg); -} - -inline void ItemPrinter::setTestWaits(const int num_waits) -{ - m_test_waits = num_waits; -} - -inline const int ItemPrinter::getTestWaits() const -{ - return m_test_waits; -} - -inline void ItemPrinter::decTestWaits() -{ - m_test_waits--; -} - -#endif // ARM_ITEM_PRINTER_H_INCLUDED - -/* End of File item_printer.h */ diff --git a/decoder/tests/source/pkt_printer_t.h b/decoder/tests/source/pkt_printer_t.h deleted file mode 100644 index 8876ac6..0000000 --- a/decoder/tests/source/pkt_printer_t.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * \file pkt_printer_t.h - * \brief OpenCSD : Test packet printer. - * - * \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: - * - * 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_PKT_PRINTER_T_H_INCLUDED -#define ARM_PKT_PRINTER_T_H_INCLUDED - -#include "opencsd.h" -#include "item_printer.h" - -#include <string> -#include <sstream> - -template<class P> -class PacketPrinter : public IPktDataIn<P>, public IPktRawDataMon<P>, public ItemPrinter -{ -public: - PacketPrinter(const uint8_t trcID); - PacketPrinter(const uint8_t trcID, ocsdMsgLogger *pMsgLogger); - virtual ~PacketPrinter(); - - - virtual ocsd_datapath_resp_t PacketDataIn( const ocsd_datapath_op_t op, - const ocsd_trc_index_t index_sop, - const P *p_packet_in); - - 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); - - -private: - void printIdx_ID(const ocsd_trc_index_t index_sop); - - uint8_t m_trcID; - bool m_bRawPrint; - std::ostringstream m_oss; - ocsd_datapath_resp_t m_last_resp; - -}; - -template<class P> PacketPrinter<P>::PacketPrinter(uint8_t trcID) : - m_trcID(trcID), - m_bRawPrint(false), - m_last_resp(OCSD_RESP_CONT) -{ -} - -template<class P> PacketPrinter<P>::PacketPrinter(const uint8_t trcID, ocsdMsgLogger *pMsgLogger) : - m_trcID(trcID), - m_bRawPrint(false), - m_last_resp(OCSD_RESP_CONT) -{ - setMessageLogger(pMsgLogger); -} - -template<class P> PacketPrinter<P>::~PacketPrinter() -{ -} - -template<class P> ocsd_datapath_resp_t PacketPrinter<P>::PacketDataIn( const ocsd_datapath_op_t op, - const ocsd_trc_index_t index_sop, - const P *p_packet_in) -{ - std::string pktstr; - ocsd_datapath_resp_t resp = OCSD_RESP_CONT; - - // wait / flush test verification - if(!m_bRawPrint && (m_last_resp == OCSD_RESP_WAIT)) - { - // expect a flush or a complete reset after a wait. - if((op != OCSD_OP_FLUSH) || (op != OCSD_OP_RESET)) - { - m_oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tERROR: FLUSH operation expected after wait on trace decode path\n"; - itemPrintLine(m_oss.str()); - m_oss.str(""); - return OCSD_RESP_FATAL_INVALID_OP; - } - } - - switch(op) - { - case OCSD_OP_DATA: - p_packet_in->toString(pktstr); - if(!m_bRawPrint) - printIdx_ID(index_sop); - m_oss << ";\t" << pktstr << std::endl; - - // test the wait/flush response mechnism - if(getTestWaits() && !m_bRawPrint) - { - decTestWaits(); - resp = OCSD_RESP_WAIT; - } - break; - - case OCSD_OP_EOT: - m_oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tEND OF TRACE DATA\n"; - break; - - case OCSD_OP_FLUSH: - m_oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tFLUSH operation on trace decode path\n"; - break; - - case OCSD_OP_RESET: - m_oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tRESET operation on trace decode path\n"; - break; - } - - m_last_resp = resp; - itemPrintLine(m_oss.str()); - m_oss.str(""); - return resp; -} - -template<class P> void PacketPrinter<P>::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) -{ - switch(op) - { - case OCSD_OP_DATA: - printIdx_ID(index_sop); - m_oss << "; ["; - if((size > 0) && (p_data != 0)) - { - uint32_t data = 0; - for(uint32_t i = 0; i < size; i++) - { - data = (uint32_t)(p_data[i] & 0xFF); - m_oss << "0x" << std::hex << std::setw(2) << std::setfill('0') << data << " "; - } - } - m_oss << "]"; - m_bRawPrint = true; - PacketDataIn(op,index_sop,pkt); - m_bRawPrint = false; - break; - - default: - PacketDataIn(op,index_sop,pkt); - break; - } - -} - -template<class P> void PacketPrinter<P>::printIdx_ID(const ocsd_trc_index_t index_sop) -{ - m_oss << "Idx:" << std::dec << index_sop << "; ID:"<< std::hex << (uint32_t)m_trcID; -} - -#endif // ARM_PKT_PRINTER_T_H_INCLUDED - -/* End of File pkt_printer_t.h */ diff --git a/decoder/tests/source/raw_frame_printer.cpp b/decoder/tests/source/raw_frame_printer.cpp deleted file mode 100644 index f16c906..0000000 --- a/decoder/tests/source/raw_frame_printer.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * \file raw_frame_printer.cpp - * \brief OpenCSD : - * - * \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: - * - * 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 <string> -#include <sstream> -#include <iomanip> - -#include "raw_frame_printer.h" - - -ocsd_err_t RawFramePrinter::TraceRawFrameIn( const ocsd_datapath_op_t op, - const ocsd_trc_index_t index, - const ocsd_rawframe_elem_t frame_element, - const int dataBlockSize, - const uint8_t *pDataBlock, - const uint8_t traceID) -{ - - if(op == OCSD_OP_DATA) // only interested in actual frame data. - { - std::string strData; - std::ostringstream oss; - int printDataSize = dataBlockSize; - - oss << "Frame Data; Index" << std::setw(7) << index << "; "; - switch(frame_element) - { - case OCSD_FRM_PACKED: oss << std::setw(15) << "RAW_PACKED; "; break; - case OCSD_FRM_HSYNC: oss << std::setw(15) << "HSYNC; "; break; - case OCSD_FRM_FSYNC: oss << std::setw(15) << "FSYNC; "; break; - case OCSD_FRM_ID_DATA: oss << std::setw(10) << "ID_DATA[0x" << std::hex << std::setw(2) << std::setfill('0') << (uint16_t)traceID << "]; "; break; - default: oss << std::setw(15) << "UNKNOWN; "; break; - } - - if(printDataSize) - { - createDataString(printDataSize,pDataBlock,16,strData); - oss << strData; - } - oss << std::endl; - itemPrintLine(oss.str()); - } - return OCSD_OK; -} - -void RawFramePrinter::createDataString(const int dataSize, const uint8_t *pData, int bytesPerLine, std::string &dataStr) -{ - int lineBytes = 0; - std::ostringstream oss; - - for(int i = 0; i < dataSize; i++) - { - if(lineBytes == bytesPerLine) - { - oss << std::endl; - lineBytes = 0; - } - oss << std::hex << std::setw(2) << std::setfill('0') << (uint32_t)pData[i] << " "; - lineBytes ++; - } - dataStr = oss.str(); -} - - -/* End of File raw_frame_printer.cpp */ diff --git a/decoder/tests/source/raw_frame_printer.h b/decoder/tests/source/raw_frame_printer.h deleted file mode 100644 index 8fb41c2..0000000 --- a/decoder/tests/source/raw_frame_printer.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * \file raw_frame_printer.h - * \brief OpenCSD : - * - * \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: - * - * 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_RAW_FRAME_PRINTER_H_INCLUDED -#define ARM_RAW_FRAME_PRINTER_H_INCLUDED - -#include "opencsd.h" -#include "item_printer.h" - -#include <string> -#include <sstream> - -class RawFramePrinter : public ITrcRawFrameIn, public ItemPrinter -{ -public: - RawFramePrinter() {}; - RawFramePrinter(ocsdMsgLogger *pMsgLogger); - virtual ~RawFramePrinter() {}; - - virtual ocsd_err_t TraceRawFrameIn( const ocsd_datapath_op_t op, - const ocsd_trc_index_t index, - const ocsd_rawframe_elem_t frame_element, - const int dataBlockSize, - const uint8_t *pDataBlock, - const uint8_t traceID); - -private: - void createDataString(const int dataSize, const uint8_t *pData, int bytesPerLine, std::string &dataStr); - -}; - -inline RawFramePrinter::RawFramePrinter(ocsdMsgLogger *pMsgLogger) -{ - setMessageLogger(pMsgLogger); -} - - -#endif // ARM_RAW_FRAME_PRINTER_H_INCLUDED - -/* End of File raw_frame_printer.h */ diff --git a/decoder/tests/source/trc_pkt_lister.cpp b/decoder/tests/source/trc_pkt_lister.cpp index 1839bc2..47a887e 100644 --- a/decoder/tests/source/trc_pkt_lister.cpp +++ b/decoder/tests/source/trc_pkt_lister.cpp @@ -44,11 +44,6 @@ #include "opencsd.h" // the library #include "trace_snapshots.h" // the snapshot reading test library
-// include some printers for packet elements -#include "pkt_printer_t.h" -#include "raw_frame_printer.h" -#include "gen_elem_printer.h" - static bool process_cmd_line_opts( int argc, char* argv[]); static void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader, const std::string &trace_buffer_name); static bool process_cmd_line_logger_opts(int argc, char* argv[]); @@ -170,7 +165,7 @@ int main(int argc, char* argv[]) else { std::ostringstream oss; - oss << "Trace Packet Lister : Snapshot path" << ss_path << "not found\n"; + oss << "Trace Packet Lister : Snapshot path" << ss_path << " not found\n"; logger.LogMsg(oss.str()); }
@@ -425,9 +420,10 @@ bool process_cmd_line_opts(int argc, char* argv[]) // if packet processing only, then waits will be coming from there until the count is extinguished // wait testing with packet processor only really works correctly if we are doing a single source as there is no way at this // point to know which source has sent the _WAIT. with multi packet processor waiting may get false warnings once the _WAITs run out. -bool ExpectingPPrintWaitResp(std::vector<ItemPrinter *> &printers, TrcGenericElementPrinter &genElemPrinter) +bool ExpectingPPrintWaitResp(TrcGenericElementPrinter &genElemPrinter) { bool ExpectingWaits = false; + std::vector<ItemPrinter *> &printers = PktPrinterFact::getPrinterList(); if(test_waits > 0) { // see if last response was from the Gen elem printer expecting a wait @@ -452,21 +448,26 @@ bool ExpectingPPrintWaitResp(std::vector<ItemPrinter *> &printers, TrcGenericEle return ExpectingWaits; }
-void AttachPacketPrinters( DecodeTree *dcd_tree, std::vector<ItemPrinter *> &printers) +void AttachPacketPrinters( DecodeTree *dcd_tree) { uint8_t elemID; + ocsd_trace_protocol_t protocol; + std::ostringstream oss; + // attach packet printers to each trace source in the tree DecodeTreeElement *pElement = dcd_tree->getFirstElement(elemID); while(pElement && !no_undecoded_packets) { if(!element_filtered(elemID)) { - switch(pElement->getProtocol()) + oss.str(""); + protocol = pElement->getProtocol(); + switch(protocol) { case OCSD_PROTOCOL_ETMV4I: { - std::ostringstream oss; - PacketPrinter<EtmV4ITrcPacket> *pPrinter = new (std::nothrow) PacketPrinter<EtmV4ITrcPacket>(elemID,&logger); + + PacketPrinter<EtmV4ITrcPacket> *pPrinter = dynamic_cast<PacketPrinter<EtmV4ITrcPacket> *>(PktPrinterFact::createProtocolPrinter(protocol,elemID,&logger)); if(pPrinter) { // if we are decoding then the decoder is attached to the packet output - attach the printer to the monitor point. @@ -478,18 +479,17 @@ void AttachPacketPrinters( DecodeTree *dcd_tree, std::vector<ItemPrinter *> &pri if(test_waits) pPrinter->setTestWaits(test_waits); } - printers.push_back(pPrinter); // save printer to destroy it later + oss << "Trace Packet Lister : ETMv4 Instuction trace Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; } - - oss << "Trace Packet Lister : ETMv4 Instuction trace Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; + else + oss << "Trace Packet Lister : Failed to set printer for ETMv4 Instuction trace Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; logger.LogMsg(oss.str()); } break;
case OCSD_PROTOCOL_ETMV3: { - std::ostringstream oss; - PacketPrinter<EtmV3TrcPacket> *pPrinter = new (std::nothrow) PacketPrinter<EtmV3TrcPacket>(elemID,&logger); + PacketPrinter<EtmV3TrcPacket> *pPrinter = dynamic_cast<PacketPrinter<EtmV3TrcPacket> *>(PktPrinterFact::createProtocolPrinter(protocol, elemID, &logger)); if(pPrinter) { // if we are decoding then the decoder is attached to the packet output - attach the printer to the monitor point. @@ -501,16 +501,16 @@ void AttachPacketPrinters( DecodeTree *dcd_tree, std::vector<ItemPrinter *> &pri if(test_waits) pPrinter->setTestWaits(test_waits); } - printers.push_back(pPrinter); // save printer to destroy it later - } - oss << "Trace Packet Lister : ETMv3 Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; + oss << "Trace Packet Lister : ETMv3 Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; + } + else + oss << "Trace Packet Lister : Failed to set printer for ETMv3 Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; logger.LogMsg(oss.str()); } break;
case OCSD_PROTOCOL_PTM: { - std::ostringstream oss; PacketPrinter<PtmTrcPacket> *pPrinter = new (std::nothrow) PacketPrinter<PtmTrcPacket>(elemID,&logger); if(pPrinter) { @@ -523,7 +523,6 @@ void AttachPacketPrinters( DecodeTree *dcd_tree, std::vector<ItemPrinter *> &pri if(test_waits) pPrinter->setTestWaits(test_waits); } - printers.push_back(pPrinter); // save printer to destroy it later } oss << "Trace Packet Lister : PTM Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; logger.LogMsg(oss.str()); @@ -533,7 +532,6 @@ void AttachPacketPrinters( DecodeTree *dcd_tree, std::vector<ItemPrinter *> &pri
case OCSD_PROTOCOL_STM: { - std::ostringstream oss; PacketPrinter<StmTrcPacket> *pPrinter = new (std::nothrow) PacketPrinter<StmTrcPacket>(elemID,&logger); if(pPrinter) { @@ -547,7 +545,6 @@ void AttachPacketPrinters( DecodeTree *dcd_tree, std::vector<ItemPrinter *> &pri pPrinter->setTestWaits(test_waits); }
- printers.push_back(pPrinter); // save printer to destroy it later } oss << "Trace Packet Lister : STM Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; logger.LogMsg(oss.str()); @@ -556,7 +553,6 @@ void AttachPacketPrinters( DecodeTree *dcd_tree, std::vector<ItemPrinter *> &pri
default: { - std::ostringstream oss; oss << "Trace Packet Lister : Unsupported Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; logger.LogMsg(oss.str()); } @@ -593,39 +589,46 @@ void ConfigureFrameDeMux(DecodeTree *dcd_tree, RawFramePrinter &framePrinter) void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader, const std::string &trace_buffer_name) { CreateDcdTreeFromSnapShot tree_creator; - RawFramePrinter framePrinter; - TrcGenericElementPrinter genElemPrinter; + RawFramePrinter *framePrinter = 0; + TrcGenericElementPrinter *genElemPrinter = 0; + + framePrinter = PktPrinterFact::createRawFramePrinter(&logger); + if (decode) + genElemPrinter = PktPrinterFact::createGenElemPrinter(&logger); + + if ((framePrinter == 0) || (decode && (genElemPrinter == 0))) + { + std::ostringstream oss; + oss << "Trace Packet Lister : failed to create printer objects\n"; + logger.LogMsg(oss.str()); + return; + }
- framePrinter.setMessageLogger(&logger); - tree_creator.initialise(&reader,&err_logger); - if(decode) - genElemPrinter.setMessageLogger(&logger); + tree_creator.initialise(&reader, &err_logger);
if(tree_creator.createDecodeTree(trace_buffer_name, (decode == false))) { - std::vector<ItemPrinter *> printers; DecodeTree *dcd_tree = tree_creator.getDecodeTree();
- AttachPacketPrinters(dcd_tree, printers); + AttachPacketPrinters(dcd_tree);
- ConfigureFrameDeMux(dcd_tree, framePrinter); + ConfigureFrameDeMux(dcd_tree, *framePrinter);
// if decoding set the generic element printer to the output interface on the tree. if(decode) { std::ostringstream oss; - dcd_tree->setGenTraceElemOutI(&genElemPrinter); + dcd_tree->setGenTraceElemOutI(genElemPrinter); oss << "Trace Packet Lister : Set trace element decode printer\n"; logger.LogMsg(oss.str()); - genElemPrinter.setTestWaits(test_waits); + genElemPrinter->setTestWaits(test_waits); }
- if(decode) dcd_tree->logMappedRanges(); // print out the mapped ranges
// check if we have attached at least one printer - if(decode || (printers.size() > 0)) + if(decode || (PktPrinterFact::numPrinters() > 0)) { // set up the filtering at the tree level (avoid pushing to processors with no attached printers) if(!all_source_ids) @@ -668,7 +671,7 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader trace_index += nUsedThisTime;
// test printers can inject _WAIT responses - see if we are expecting one... - if(ExpectingPPrintWaitResp(printers,genElemPrinter)) + if(ExpectingPPrintWaitResp(*genElemPrinter)) { if(OCSD_DATA_RESP_IS_CONT(dataPathResp)) { @@ -682,8 +685,8 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader else // last response was _WAIT { // may need to acknowledge a wait from the gen elem printer - if(genElemPrinter.needAckWait()) - genElemPrinter.ackWait(); + 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); @@ -737,13 +740,7 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader tree_creator.destroyDecodeTree();
// get rid of all the printers. - std::vector<ItemPrinter *>::iterator it; - it = printers.begin(); - while(it != printers.end()) - { - delete *it; - it++; - } + PktPrinterFact::destroyAllPrinters(); } }
Updates to allow registration of a string print callback for the client to log data as part of the application.
Updates to allow client to specify raw trace printing using built in library printer.
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/include/c_api/ocsd_c_api_types.h | 2 + decoder/include/c_api/opencsd_c_api.h | 23 +++++++++++ decoder/include/common/trc_frame_deformatter.h | 1 + decoder/source/c_api/ocsd_c_api.cpp | 42 ++++++++++++++++++++ decoder/source/c_api/ocsd_c_api_obj.h | 35 +++++++++++++++- decoder/source/ocsd_msg_logger.cpp | 15 ++++++- decoder/source/trc_frame_deformatter.cpp | 9 +++++ decoder/tests/source/c_api_pkt_print_test.c | 55 +++++++++++++++++++++++++- 8 files changed, 179 insertions(+), 3 deletions(-)
diff --git a/decoder/include/c_api/ocsd_c_api_types.h b/decoder/include/c_api/ocsd_c_api_types.h index be7316f..8354d00 100644 --- a/decoder/include/c_api/ocsd_c_api_types.h +++ b/decoder/include/c_api/ocsd_c_api_types.h @@ -89,6 +89,8 @@ typedef void (* FnDefPktDataMon)(const void *p_context, const uint32_t size, const uint8_t *p_data);
+/** function pointer tyee for library default logger output to allow client to print zero terminated output string */ +typedef void (* FnDefLoggerPrintStrCB)(const void *p_context, const char *psz_msg_str, const int str_len);
/** Callback interface type when attaching monitor/sink to packet processor */ typedef enum _ocsd_c_api_cb_types { diff --git a/decoder/include/c_api/opencsd_c_api.h b/decoder/include/c_api/opencsd_c_api.h index 2795955..4fc8379 100644 --- a/decoder/include/c_api/opencsd_c_api.h +++ b/decoder/include/c_api/opencsd_c_api.h @@ -339,6 +339,16 @@ OCSD_C_API ocsd_err_t ocsd_def_errlog_init(const ocsd_err_severity_t verbosity, OCSD_C_API ocsd_err_t ocsd_def_errlog_config_output(const int output_flags, const char *log_file_name);
/*! + * Configure the library default error logger to send all strings it is outputting back to the client + * to allow printing within the client application. This is in additional to any other log destinations + * set in ocsd_def_errlog_init(). + * + * @param *p_context : opaque context pointer + * @param p_str_print_cb : client callback function to "print" logstring. + */ +OCSD_C_API ocsd_err_t ocsd_def_errlog_set_strprint_cb(const dcd_tree_handle_t handle, void *p_context, FnDefLoggerPrintStrCB p_str_print_cb); + +/*! * Print a message via the library output printer - if enabled. * * @param *msg : Message to output. @@ -386,6 +396,19 @@ OCSD_C_API void ocsd_gen_elem_init(ocsd_generic_trace_elem *p_pkt, const ocsd_ge
/** @}*/
+/** @name Library packet and data printer control API + @brief Allows client to use libraries packet and data printers to log packets etc rather than attach callbacks. +@{*/ + +/*! + * Set a raw frame printer on the trace frame demuxer. Allows inspection of raw trace data frames for debug. + * Prints via the default error logging mechanisms. + */ +OCSD_C_API ocsd_err_t ocsd_set_raw_frame_printer(const dcd_tree_handle_t handle, int flags); + +/** @}*/ + + /** @name Custom Decoder API functions
@{*/ diff --git a/decoder/include/common/trc_frame_deformatter.h b/decoder/include/common/trc_frame_deformatter.h index 90057ba..c874c82 100644 --- a/decoder/include/common/trc_frame_deformatter.h +++ b/decoder/include/common/trc_frame_deformatter.h @@ -75,6 +75,7 @@ public:
/* configuration - set operational mode for incoming stream (has FSYNCS etc) */ ocsd_err_t Configure(uint32_t cfg_flags); + const uint32_t getConfigFlags() const;
/* enable / disable ID streams - default as all enabled */ ocsd_err_t OutputFilterIDs(std::vector<uint8_t> &id_list, bool bEnable); diff --git a/decoder/source/c_api/ocsd_c_api.cpp b/decoder/source/c_api/ocsd_c_api.cpp index 5738798..9794ffc 100644 --- a/decoder/source/c_api/ocsd_c_api.cpp +++ b/decoder/source/c_api/ocsd_c_api.cpp @@ -64,6 +64,7 @@ static ocsd_err_t ocsd_check_and_add_mem_acc_mapper(const dcd_tree_handle_t hand /* keep a list of interface objects for a decode tree for later disposal */ typedef struct _lib_dt_data_list { std::vector<ITrcTypedBase *> cb_objs; + DefLogStrCBObj s_def_log_str_cb; } lib_dt_data_list;
/* map lists to handles */ @@ -272,6 +273,28 @@ OCSD_C_API ocsd_err_t ocsd_def_errlog_config_output(const int output_flags, cons return OCSD_ERR_NOT_INIT; }
+ +OCSD_C_API ocsd_err_t ocsd_def_errlog_set_strprint_cb(const dcd_tree_handle_t handle, void *p_context, FnDefLoggerPrintStrCB p_str_print_cb) +{ + ocsdMsgLogger *pLogger = DecodeTree::getDefaultErrorLogger()->getOutputLogger(); + if (pLogger) + { + std::map<dcd_tree_handle_t, lib_dt_data_list *>::iterator it; + it = s_data_map.find(handle); + if (it != s_data_map.end()) + { + DefLogStrCBObj *pCBObj = &(it->second->s_def_log_str_cb); + pCBObj->setCBFn(p_context, p_str_print_cb); + pLogger->setStrOutFn(pCBObj); + int logOpts = pLogger->getLogOpts(); + logOpts |= (int)(ocsdMsgLogger::OUT_STR_CB); + pLogger->setLogOpts(logOpts); + return OCSD_OK; + } + } + return OCSD_ERR_NOT_INIT; +} + OCSD_C_API void ocsd_def_errlog_msgout(const char *msg) { ocsdMsgLogger *pLogger = DecodeTree::getDefaultErrorLogger()->getOutputLogger(); @@ -411,6 +434,25 @@ OCSD_C_API void ocsd_gen_elem_init(ocsd_generic_trace_elem *p_pkt, const ocsd_ge p_pkt->ptr_extended_data = 0; }
+OCSD_C_API ocsd_err_t ocsd_set_raw_frame_printer(const dcd_tree_handle_t handle, int flags) +{ + if (handle != C_API_INVALID_TREE_HANDLE) + { + RawFramePrinter *pPrinter = PktPrinterFact::createRawFramePrinter(); + if (pPrinter) + { + pPrinter->setMessageLogger((DecodeTree::getDefaultErrorLogger()->getOutputLogger())); + TraceFormatterFrameDecoder *pFrameDecoder = ((DecodeTree *)handle)->getFrameDeformatter(); + int cfgFlags = pFrameDecoder->getConfigFlags(); + cfgFlags |= ((uint32_t)flags & (OCSD_DFRMTR_PACKED_RAW_OUT | OCSD_DFRMTR_UNPACKED_RAW_OUT)); + pFrameDecoder->Configure(cfgFlags); + return pFrameDecoder->getTrcRawFrameAttachPt()->attach(pPrinter); + } + return OCSD_ERR_MEM; + } + return OCSD_ERR_NOT_INIT; +} + /*******************************************************************************/ /* C API local fns */ /*******************************************************************************/ diff --git a/decoder/source/c_api/ocsd_c_api_obj.h b/decoder/source/c_api/ocsd_c_api_obj.h index 617aa5c..42e8a7d 100644 --- a/decoder/source/c_api/ocsd_c_api_obj.h +++ b/decoder/source/c_api/ocsd_c_api_obj.h @@ -10,7 +10,7 @@
#include "c_api/ocsd_c_api_types.h" #include "interfaces/trc_gen_elem_in_i.h" - +#include "common/ocsd_msg_logger.h"
class TraceElemCBBase { @@ -144,6 +144,39 @@ private: const void *m_p_context; };
+/* handler for default string print CB object */ +class DefLogStrCBObj : public ocsdMsgLogStrOutI +{ +public: + DefLogStrCBObj() + { + m_c_api_cb_fn = 0; + m_p_context = 0; + }; + + virtual ~DefLogStrCBObj() + { + m_c_api_cb_fn = 0; + m_p_context = 0; + }; + + void setCBFn(const void *p_context, FnDefLoggerPrintStrCB pCBFn) + { + m_c_api_cb_fn = pCBFn; + m_p_context = p_context; + }; + + virtual void printOutStr(const std::string &outStr) + { + if(m_c_api_cb_fn) + m_c_api_cb_fn(m_p_context, outStr.c_str(), outStr.length()); + } + +private: + FnDefLoggerPrintStrCB m_c_api_cb_fn; + const void *m_p_context; +}; + #endif // ARM_OCSD_C_API_OBJ_H_INCLUDED
/* End of File ocsd_c_api_obj.h */ diff --git a/decoder/source/ocsd_msg_logger.cpp b/decoder/source/ocsd_msg_logger.cpp index 2ddf4ee..287edfa 100644 --- a/decoder/source/ocsd_msg_logger.cpp +++ b/decoder/source/ocsd_msg_logger.cpp @@ -58,14 +58,27 @@ void ocsdMsgLogger::setLogOpts(int logOpts)
void ocsdMsgLogger::setLogFileName(const char *fileName) { - m_logFileName = fileName; + if (fileName == 0) + m_logFileName = ""; + else + m_logFileName = fileName; + if(m_out_file.is_open()) m_out_file.close(); + + if (m_logFileName.length()) + m_outFlags |= (int)ocsdMsgLogger::OUT_FILE; + else + m_outFlags &= ~((int)ocsdMsgLogger::OUT_FILE); }
void ocsdMsgLogger::setStrOutFn(ocsdMsgLogStrOutI *p_IstrOut) { m_pOutStrI = p_IstrOut; + if (p_IstrOut) + m_outFlags |= (int)ocsdMsgLogger::OUT_STR_CB; + else + m_outFlags &= ~((int)ocsdMsgLogger::OUT_STR_CB); }
void ocsdMsgLogger::LogMsg(const std::string &msg) diff --git a/decoder/source/trc_frame_deformatter.cpp b/decoder/source/trc_frame_deformatter.cpp index dad84e5..b4f40a2 100644 --- a/decoder/source/trc_frame_deformatter.cpp +++ b/decoder/source/trc_frame_deformatter.cpp @@ -821,6 +821,15 @@ ocsd_err_t TraceFormatterFrameDecoder::Configure(uint32_t cfg_flags) return OCSD_OK; }
+const uint32_t TraceFormatterFrameDecoder::getConfigFlags() const +{ + uint32_t flags = 0; + if(m_pDecoder) + flags = m_pDecoder->m_cfgFlags; + return flags; +} + + /* enable / disable ID streams - default as all enabled */ ocsd_err_t TraceFormatterFrameDecoder::OutputFilterIDs(std::vector<uint8_t> &id_list, bool bEnable) { diff --git a/decoder/tests/source/c_api_pkt_print_test.c b/decoder/tests/source/c_api_pkt_print_test.c index ad84bdf..bc64d4c 100644 --- a/decoder/tests/source/c_api_pkt_print_test.c +++ b/decoder/tests/source/c_api_pkt_print_test.c @@ -102,6 +102,11 @@ static int test_extern_decoder = 0; /* test the external decoder infrastructure. static ocsd_extern_dcd_fact_t *p_ext_fact; /* external decoder factory */ #define EXT_DCD_NAME "ext_echo"
+/* raw packet printing test */ +static int frame_raw_unpacked = 0; +static int frame_raw_packed = 0; +static int test_printstr = 0; + /* Process command line options - choose the operation to use for the test. */ static int process_cmd_line(int argc, char *argv[]) { @@ -157,6 +162,18 @@ static int process_cmd_line(int argc, char *argv[]) { test_extern_decoder = 1; } + else if (strcmp(argv[idx], "-raw") == 0) + { + frame_raw_unpacked = 1; + } + else if (strcmp(argv[idx], "-raw_packed") == 0) + { + frame_raw_packed = 1; + } + else if (strcmp(argv[idx], "-test_printstr") == 0) + { + test_printstr = 1; + } else if(strcmp(argv[idx],"-help") == 0) { return -1; @@ -173,6 +190,7 @@ static void print_cmd_line_help() printf("Usage:\n-etmv3|-stm|-ptm|-extern : choose protocol (one only, default etmv4)\n"); printf("-id <ID> : decode source for id <ID> (default 0x10)\n"); 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_region_file | -test_cb : mem accessor - test multi region file API | test callback API (default single memory file)\n\n"); }
@@ -662,6 +680,33 @@ static ocsd_err_t create_decoder_extern(dcd_tree_handle_t dcd_tree_h) return create_generic_decoder(dcd_tree_h, EXT_DCD_NAME, (void *)&trace_cfg_ext, 0); }
+static ocsd_err_t attach_raw_printers(dcd_tree_handle_t dcd_tree_h) +{ + ocsd_err_t err = OCSD_OK; + int flags = 0; + if (frame_raw_unpacked) + flags |= OCSD_DFRMTR_UNPACKED_RAW_OUT; + if (frame_raw_packed) + flags |= OCSD_DFRMTR_PACKED_RAW_OUT; + if (flags) + { + err = ocsd_set_raw_frame_printer(dcd_tree_h, flags); + } + return err; +} + +static void print_output_str(const void *p_context, const char *psz_msg_str, const int str_len) +{ + printf("** CUST_PRNTSTR: %s", psz_msg_str); +} + +static ocsd_err_t test_printstr_cb(dcd_tree_handle_t dcd_tree_h) +{ + ocsd_err_t err = OCSD_OK; + if (test_printstr) + err = ocsd_def_errlog_set_strprint_cb(dcd_tree_h, 0, print_output_str); + return err; +} /************************************************************************/
ocsd_err_t register_extern_decoder() @@ -781,6 +826,15 @@ int process_trace_data(FILE *pf) /* attach the generic trace element output callback */ ret = ocsd_dt_set_gen_elem_outfn(dcdtree_handle,gen_trace_elem_print,0);
+ + /* raw print and str print cb options tested in their init functions */ + if (ret == OCSD_OK) + ret = test_printstr_cb(dcdtree_handle); + + if (ret == OCSD_OK) + ret = attach_raw_printers(dcdtree_handle); + + /* now push the trace data through the packet processor */ while(!feof(pf) && (ret == OCSD_OK)) { @@ -855,7 +909,6 @@ int main(int argc, char *argv[]) /* print sign-on message in log */ sprintf(message, "C-API packet print test\nLibrary Version %s\n\n",ocsd_get_version_str()); ocsd_def_errlog_msgout(message); -
/* process the trace data */ if(ret == 0)
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/tests/source/c_api_pkt_print_test.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/decoder/tests/source/c_api_pkt_print_test.c b/decoder/tests/source/c_api_pkt_print_test.c index bc64d4c..7ae09f6 100644 --- a/decoder/tests/source/c_api_pkt_print_test.c +++ b/decoder/tests/source/c_api_pkt_print_test.c @@ -882,7 +882,7 @@ int main(int argc, char *argv[]) { FILE *trace_data; char trace_file_path[512]; - int ret = 0; + int ret = 0, i, len; char message[512];
/* command line params */ @@ -910,6 +910,22 @@ int main(int argc, char *argv[]) sprintf(message, "C-API packet print test\nLibrary Version %s\n\n",ocsd_get_version_str()); ocsd_def_errlog_msgout(message);
+ /* print command line used */ + message[0] = 0; + len = 0; + for (i = 0; i < argc; i++) + { + len += strlen(argv[i]) + 1; + if (len < 512) + { + strcat(message, argv[i]); + strcat(message, " "); + } + } + if((len + 2) < 512) + strcat(message, "\n\n"); + ocsd_def_errlog_msgout(message); + /* process the trace data */ if(ret == 0) ret = process_trace_data(trace_data);
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp b/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp index c0e6d7b..082198e 100644 --- a/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp +++ b/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp @@ -157,7 +157,7 @@ void EtmV4ITrcPacket::toString(std::string &str) const case ETM4_PKT_I_TRACE_INFO: { std::ostringstream oss; - oss << "; PCTL=" << std::hex << "0x" << trace_info.val; + oss << "; INFO=" << std::hex << "0x" << trace_info.val; if (trace_info.bits.cc_enabled) oss << "; CC_THRESHOLD=" << std::hex << "0x" << cc_threshold; str += oss.str();
Add API calls to allow set / get of output logger via interface.
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/include/common/ocsd_error_logger.h | 4 ++-- decoder/include/interfaces/trc_error_log_i.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/decoder/include/common/ocsd_error_logger.h b/decoder/include/common/ocsd_error_logger.h index 8505a27..d601397 100644 --- a/decoder/include/common/ocsd_error_logger.h +++ b/decoder/include/common/ocsd_error_logger.h @@ -51,8 +51,8 @@ public:
bool initErrorLogger(const ocsd_err_severity_t verbosity, bool bCreateOutputLogger = false);
- ocsdMsgLogger *getOutputLogger() { return m_output_logger; }; - void setOutputLogger(ocsdMsgLogger *pLogger); + virtual ocsdMsgLogger *getOutputLogger() { return m_output_logger; }; + virtual void setOutputLogger(ocsdMsgLogger *pLogger);
virtual const ocsd_hndl_err_log_t RegisterErrorSource(const std::string &component_name);
diff --git a/decoder/include/interfaces/trc_error_log_i.h b/decoder/include/interfaces/trc_error_log_i.h index c9e9381..2e64ac2 100644 --- a/decoder/include/interfaces/trc_error_log_i.h +++ b/decoder/include/interfaces/trc_error_log_i.h @@ -40,6 +40,7 @@ #include <string>
class ocsdError; +class ocsdMsgLogger;
/*! * @class ITraceErrorLog @@ -116,6 +117,8 @@ public: */ virtual ocsdError *GetLastIDError(const uint8_t chan_id) = 0;
+ virtual ocsdMsgLogger *getOutputLogger() = 0; + virtual void setOutputLogger(ocsdMsgLogger *pLogger) = 0;
enum generic_handles { HANDLE_GEN_ERR = 0,
Adds packet printer create / attch interface to decode tree. Adds C-API functions to access new packet printer API. Updates tests to use new API.
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/include/c_api/opencsd_c_api.h | 37 +++++- decoder/include/common/ocsd_dcd_tree.h | 18 ++- decoder/include/pkt_printers/trc_print_fact.h | 16 ++- decoder/source/c_api/ocsd_c_api.cpp | 32 ++--- decoder/source/ocsd_dcd_tree.cpp | 111 +++++++++++++++++- decoder/source/pkt_printers/trc_print_fact.cpp | 54 +++++---- decoder/tests/source/c_api_pkt_print_test.c | 29 ++++- decoder/tests/source/trc_pkt_lister.cpp | 156 +++++-------------------- 8 files changed, 273 insertions(+), 180 deletions(-)
diff --git a/decoder/include/c_api/opencsd_c_api.h b/decoder/include/c_api/opencsd_c_api.h index 4fc8379..f9f4ed4 100644 --- a/decoder/include/c_api/opencsd_c_api.h +++ b/decoder/include/c_api/opencsd_c_api.h @@ -397,14 +397,45 @@ OCSD_C_API void ocsd_gen_elem_init(ocsd_generic_trace_elem *p_pkt, const ocsd_ge /** @}*/
/** @name Library packet and data printer control API - @brief Allows client to use libraries packet and data printers to log packets etc rather than attach callbacks. + @brief Allows client to use libraries packet and data printers to log packets etc rather than attach callbacks + to packet output and use packet to string calls. @{*/
/*! * Set a raw frame printer on the trace frame demuxer. Allows inspection of raw trace data frames for debug. - * Prints via the default error logging mechanisms. + * Prints via the library default error logging mechanisms. + * + * The flags input determines the data printed. OR combination of one or both of: + * OCSD_DFRMTR_PACKED_RAW_OUT : Output the undemuxed raw data frames. + * OCSD_DFRMTR_UNPACKED_RAW_OUT : Output the raw data by trace ID after unpacking the frame. + * + * @param handle : Handle to decode tree. + * @param flags : indicates type of raw frames to print. + * + * @return ocsd_err_t : Library error code - RCDTL_OK if successful. + */ +OCSD_C_API ocsd_err_t ocsd_dt_set_raw_frame_printer(const dcd_tree_handle_t handle, int flags); + +/*! + * Set a library printer on the generic element output of a full decoder. + * + * @param handle : Handle to decode tree. + * + * @return ocsd_err_t : Library error code - RCDTL_OK if successful. + */ +OCSD_C_API ocsd_err_t ocsd_dt_set_gen_elem_printer(const dcd_tree_handle_t handle); + +/*! + * Attach a library printer to the packet processor. May be attached to the main packet output, or the monitor + * output if the main packet output is to be attached to a packet decoder in the datapath. + * + * @param handle : Handle to decode tree. + * @param cs_id : Coresight trace ID for stream to print. + * @param monitor: 0 to attach printer directly to datapath packet output, 1 to attach to packet monitor output + * + * @return ocsd_err_t : Library error code - RCDTL_OK if successful. */ -OCSD_C_API ocsd_err_t ocsd_set_raw_frame_printer(const dcd_tree_handle_t handle, int flags); +OCSD_C_API ocsd_err_t ocsd_dt_set_pkt_protocol_printer(const dcd_tree_handle_t handle, uint8_t cs_id, int monitor);
/** @}*/
diff --git a/decoder/include/common/ocsd_dcd_tree.h b/decoder/include/common/ocsd_dcd_tree.h index 1ab5fbc..496f8e5 100644 --- a/decoder/include/common/ocsd_dcd_tree.h +++ b/decoder/include/common/ocsd_dcd_tree.h @@ -83,7 +83,7 @@ public: /** @}*/
-/** @name Error Logging +/** @name Error and element Logging @{*/ /** @brief The library default error logger */ static ocsdDefaultErrorLogger* getDefaultErrorLogger() { return &s_error_logger; }; @@ -94,6 +94,20 @@ public: /** set an alternate error logging interface. */ static void setAlternateErrorLogger(ITraceErrorLog *p_error_logger);
+ /** get the list of packet printers for this decode tree */ + std::vector<ItemPrinter *> &getPrinterList() { return m_printer_list; }; + + /** add a protocol packet printer */ + ocsd_err_t addPacketPrinter(uint8_t CSID, bool bMonitor, ItemPrinter **ppPrinter); + + /** add a raw frame printer */ + ocsd_err_t addRawFramePrinter(RawFramePrinter **ppPrinter, uint32_t flags); + + /** add a generic element output printer */ + ocsd_err_t addGenElemPrinter(TrcGenericElementPrinter **ppPrinter); + + + /** @}*/
@@ -372,6 +386,8 @@ private: TrcMemAccMapper *m_default_mapper; //!< the mem acc mapper to use bool m_created_mapper; //!< true if created by decode tree object
+ std::vector<ItemPrinter *> m_printer_list; //!< list of packet printers. + /* global error logger - all sources */ static ITraceErrorLog *s_i_error_logger; static std::list<DecodeTree *> s_trace_dcd_trees; diff --git a/decoder/include/pkt_printers/trc_print_fact.h b/decoder/include/pkt_printers/trc_print_fact.h index 002d74c..73dd9dc 100644 --- a/decoder/include/pkt_printers/trc_print_fact.h +++ b/decoder/include/pkt_printers/trc_print_fact.h @@ -40,21 +40,19 @@ class PktPrinterFact { public: - static ItemPrinter *createProtocolPrinter(ocsd_trace_protocol_t protocol, uint8_t elemID, ocsdMsgLogger *pMsgLogger = 0); - static RawFramePrinter *createRawFramePrinter(ocsdMsgLogger *pMsgLogger = 0); - static TrcGenericElementPrinter *createGenElemPrinter(ocsdMsgLogger *pMsgLogger = 0); + static ItemPrinter *createProtocolPrinter(std::vector<ItemPrinter *> &printer_list, ocsd_trace_protocol_t protocol, uint8_t elemID, ocsdMsgLogger *pMsgLogger = 0); + static RawFramePrinter *createRawFramePrinter(std::vector<ItemPrinter *> &printer_list, ocsdMsgLogger *pMsgLogger = 0); + static TrcGenericElementPrinter *createGenElemPrinter(std::vector<ItemPrinter *> &printer_list, ocsdMsgLogger *pMsgLogger = 0);
- static void destroyAllPrinters(); - static const int numPrinters(); - static std::vector<ItemPrinter *> &getPrinterList(); + static void destroyPrinter(std::vector<ItemPrinter *> &printer_list, ItemPrinter *pPrinter); + static void destroyAllPrinters(std::vector<ItemPrinter *> &printer_list); + static const int numPrinters(std::vector<ItemPrinter *> &printer_list);
private: - static void SavePrinter(ItemPrinter *pPrinter, ocsdMsgLogger *pMsgLogger); + static void SavePrinter(std::vector<ItemPrinter *> &printer_list, ItemPrinter *pPrinter, ocsdMsgLogger *pMsgLogger);
PktPrinterFact() {}; ~PktPrinterFact() {}; - - static std::vector<ItemPrinter *> sm_printers; /* list of printers created. */ };
#endif // ARM_TRC_PRINT_FACT_H_INCLUDED diff --git a/decoder/source/c_api/ocsd_c_api.cpp b/decoder/source/c_api/ocsd_c_api.cpp index 9794ffc..b866db8 100644 --- a/decoder/source/c_api/ocsd_c_api.cpp +++ b/decoder/source/c_api/ocsd_c_api.cpp @@ -434,23 +434,29 @@ OCSD_C_API void ocsd_gen_elem_init(ocsd_generic_trace_elem *p_pkt, const ocsd_ge p_pkt->ptr_extended_data = 0; }
-OCSD_C_API ocsd_err_t ocsd_set_raw_frame_printer(const dcd_tree_handle_t handle, int flags) +OCSD_C_API ocsd_err_t ocsd_dt_set_raw_frame_printer(const dcd_tree_handle_t handle, int flags) { if (handle != C_API_INVALID_TREE_HANDLE) + return ((DecodeTree *)handle)->addRawFramePrinter(0, (uint32_t)flags); + return OCSD_ERR_NOT_INIT; +} + +OCSD_C_API ocsd_err_t ocsd_dt_set_gen_elem_printer(const dcd_tree_handle_t handle) +{ + if (handle != C_API_INVALID_TREE_HANDLE) + return ((DecodeTree *)handle)->addGenElemPrinter(0); + return OCSD_ERR_NOT_INIT; +} + +OCSD_C_API ocsd_err_t ocsd_dt_set_pkt_protocol_printer(const dcd_tree_handle_t handle, uint8_t cs_id, int monitor) +{ + ocsd_err_t err = OCSD_ERR_NOT_INIT; + if (handle != C_API_INVALID_TREE_HANDLE) { - RawFramePrinter *pPrinter = PktPrinterFact::createRawFramePrinter(); - if (pPrinter) - { - pPrinter->setMessageLogger((DecodeTree::getDefaultErrorLogger()->getOutputLogger())); - TraceFormatterFrameDecoder *pFrameDecoder = ((DecodeTree *)handle)->getFrameDeformatter(); - int cfgFlags = pFrameDecoder->getConfigFlags(); - cfgFlags |= ((uint32_t)flags & (OCSD_DFRMTR_PACKED_RAW_OUT | OCSD_DFRMTR_UNPACKED_RAW_OUT)); - pFrameDecoder->Configure(cfgFlags); - return pFrameDecoder->getTrcRawFrameAttachPt()->attach(pPrinter); - } - return OCSD_ERR_MEM; + DecodeTree *p_tree = (DecodeTree *)handle; + err = p_tree->addPacketPrinter(cs_id, (bool)(monitor != 0), 0); } - return OCSD_ERR_NOT_INIT; + return err; }
/*******************************************************************************/ diff --git a/decoder/source/ocsd_dcd_tree.cpp b/decoder/source/ocsd_dcd_tree.cpp index b6451d0..0cce134 100644 --- a/decoder/source/ocsd_dcd_tree.cpp +++ b/decoder/source/ocsd_dcd_tree.cpp @@ -109,7 +109,7 @@ DecodeTree::~DecodeTree() { destroyDecodeElement(i); } - + PktPrinterFact::destroyAllPrinters(m_printer_list); }
@@ -559,4 +559,113 @@ ocsd_err_t DecodeTree::clearIDFilter() return err; }
+/** add a protocol packet printer */ +ocsd_err_t DecodeTree::addPacketPrinter(uint8_t CSID, bool bMonitor, ItemPrinter **ppPrinter) +{ + ocsd_err_t err = OCSD_ERR_INVALID_PARAM_VAL; + DecodeTreeElement *pElement = getDecoderElement(CSID); + if (pElement) + { + ocsd_trace_protocol_t protocol = pElement->getProtocol(); + ItemPrinter *pPrinter; + + pPrinter = PktPrinterFact::createProtocolPrinter(getPrinterList(), protocol, CSID); + if (pPrinter) + { + pPrinter->setMessageLogger(getCurrentErrorLogI()->getOutputLogger()); + switch (protocol) + { + case OCSD_PROTOCOL_ETMV4I: + { + PacketPrinter<EtmV4ITrcPacket> *pTPrinter = dynamic_cast<PacketPrinter<EtmV4ITrcPacket> *>(pPrinter); + if (bMonitor) + err = pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(), (IPktRawDataMon<EtmV4ITrcPacket> *)pTPrinter); + else + err = pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(), (IPktDataIn<EtmV4ITrcPacket> *)pTPrinter); + } + break; + + case OCSD_PROTOCOL_ETMV3: + { + PacketPrinter<EtmV3TrcPacket> *pTPrinter = dynamic_cast<PacketPrinter<EtmV3TrcPacket> *>(pPrinter); + if (bMonitor) + err = pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(), (IPktRawDataMon<EtmV3TrcPacket> *)pTPrinter); + else + err = pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(), (IPktDataIn<EtmV3TrcPacket> *)pTPrinter); + } + break; + + case OCSD_PROTOCOL_PTM: + { + PacketPrinter<PtmTrcPacket> *pTPrinter = dynamic_cast<PacketPrinter<PtmTrcPacket> *>(pPrinter); + if (bMonitor) + err = pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(), (IPktRawDataMon<PtmTrcPacket> *)pTPrinter); + else + err = pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(), (IPktDataIn<PtmTrcPacket> *)pTPrinter); + } + break; + + case OCSD_PROTOCOL_STM: + { + PacketPrinter<StmTrcPacket> *pTPrinter = dynamic_cast<PacketPrinter<StmTrcPacket> *>(pPrinter); + if (bMonitor) + err = pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(), (IPktRawDataMon<StmTrcPacket> *)pTPrinter); + else + err = pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(), (IPktDataIn<StmTrcPacket> *)pTPrinter); + } + break; + + default: + err = OCSD_ERR_NO_PROTOCOL; + break; + } + + if (err == OCSD_OK) + { + if (ppPrinter) + *ppPrinter = pPrinter; + } + else + PktPrinterFact::destroyPrinter(getPrinterList(), pPrinter); + } + } + return err; +} + +/** add a raw frame printer */ +ocsd_err_t DecodeTree::addRawFramePrinter(RawFramePrinter **ppPrinter, uint32_t flags) +{ + ocsd_err_t err = OCSD_ERR_MEM; + RawFramePrinter *pPrinter = PktPrinterFact::createRawFramePrinter(getPrinterList()); + if (pPrinter) + { + pPrinter->setMessageLogger((DecodeTree::getCurrentErrorLogI()->getOutputLogger())); + TraceFormatterFrameDecoder *pFrameDecoder = getFrameDeformatter(); + uint32_t cfgFlags = pFrameDecoder->getConfigFlags(); + cfgFlags |= ((uint32_t)flags & (OCSD_DFRMTR_PACKED_RAW_OUT | OCSD_DFRMTR_UNPACKED_RAW_OUT)); + pFrameDecoder->Configure(cfgFlags); + err = pFrameDecoder->getTrcRawFrameAttachPt()->attach(pPrinter); + if (ppPrinter && (err==OCSD_OK)) + *ppPrinter = pPrinter; + } + return err; +} + +/** add a generic element output printer */ +ocsd_err_t DecodeTree::addGenElemPrinter(TrcGenericElementPrinter **ppPrinter) +{ + ocsd_err_t err = OCSD_ERR_MEM; + TrcGenericElementPrinter *pPrinter = PktPrinterFact::createGenElemPrinter(getPrinterList()); + if (pPrinter) + { + pPrinter->setMessageLogger((DecodeTree::getCurrentErrorLogI()->getOutputLogger())); + setGenTraceElemOutI(pPrinter); + err = OCSD_OK; + if (ppPrinter) + *ppPrinter = pPrinter; + } + return err; + +} + /* End of File ocsd_dcd_tree.cpp */ diff --git a/decoder/source/pkt_printers/trc_print_fact.cpp b/decoder/source/pkt_printers/trc_print_fact.cpp index 39d770d..52dcb6b 100644 --- a/decoder/source/pkt_printers/trc_print_fact.cpp +++ b/decoder/source/pkt_printers/trc_print_fact.cpp @@ -35,25 +35,23 @@
#include "pkt_printers/trc_print_fact.h"
-std::vector<ItemPrinter *> PktPrinterFact::sm_printers; - -RawFramePrinter * PktPrinterFact::createRawFramePrinter(ocsdMsgLogger *pMsgLogger /*= 0*/) +RawFramePrinter * PktPrinterFact::createRawFramePrinter(std::vector<ItemPrinter *> &printer_list, ocsdMsgLogger *pMsgLogger /*= 0*/) { RawFramePrinter *pPrinter = 0; pPrinter = new (std::nothrow)RawFramePrinter(); - SavePrinter(pPrinter, pMsgLogger); + SavePrinter(printer_list, pPrinter, pMsgLogger); return pPrinter; }
-TrcGenericElementPrinter *PktPrinterFact::createGenElemPrinter(ocsdMsgLogger *pMsgLogger /*= 0*/) +TrcGenericElementPrinter *PktPrinterFact::createGenElemPrinter(std::vector<ItemPrinter *> &printer_list, ocsdMsgLogger *pMsgLogger /*= 0*/) { TrcGenericElementPrinter *pPrinter = 0; pPrinter = new (std::nothrow)TrcGenericElementPrinter(); - SavePrinter(pPrinter, pMsgLogger); + SavePrinter(printer_list, pPrinter, pMsgLogger); return pPrinter; }
-ItemPrinter *PktPrinterFact::createProtocolPrinter(ocsd_trace_protocol_t protocol, uint8_t CSID, ocsdMsgLogger *pMsgLogger /*= 0*/) +ItemPrinter *PktPrinterFact::createProtocolPrinter(std::vector<ItemPrinter *> &printer_list, ocsd_trace_protocol_t protocol, uint8_t CSID, ocsdMsgLogger *pMsgLogger /*= 0*/) { ItemPrinter *pPrinter = 0; switch (protocol) @@ -73,39 +71,53 @@ ItemPrinter *PktPrinterFact::createProtocolPrinter(ocsd_trace_protocol_t protoco default: break; } - SavePrinter(pPrinter, pMsgLogger); + SavePrinter(printer_list, pPrinter, pMsgLogger); return pPrinter; }
-const int PktPrinterFact::numPrinters() -{ - return sm_printers.size(); -} - -std::vector<ItemPrinter *> &PktPrinterFact::getPrinterList() +const int PktPrinterFact::numPrinters(std::vector<ItemPrinter *> &printer_list) { - return sm_printers; + return printer_list.size(); }
-void PktPrinterFact::SavePrinter(ItemPrinter *pPrinter, ocsdMsgLogger *pMsgLogger) +void PktPrinterFact::SavePrinter(std::vector<ItemPrinter *> &printer_list, ItemPrinter *pPrinter, ocsdMsgLogger *pMsgLogger) { if (pPrinter) { pPrinter->setMessageLogger(pMsgLogger); - sm_printers.push_back((ItemPrinter *)pPrinter); + printer_list.push_back((ItemPrinter *)pPrinter); } }
-void PktPrinterFact::destroyAllPrinters() +void PktPrinterFact::destroyAllPrinters(std::vector<ItemPrinter *> &printer_list) { std::vector<ItemPrinter *>::iterator it; - it = sm_printers.begin(); - while (it != sm_printers.end()) + it = printer_list.begin(); + while (it != printer_list.end()) { delete *it; it++; } - sm_printers.clear(); + printer_list.clear(); }
+void PktPrinterFact::destroyPrinter(std::vector<ItemPrinter *> &printer_list, ItemPrinter *pPrinter) +{ + std::vector<ItemPrinter *>::iterator it; + it = printer_list.begin(); + while (it != printer_list.end()) + { + if (*it == pPrinter) + { + printer_list.erase(it); + delete pPrinter; + return; + } + else + it++; + } +} + + + /* end of file trc_print_fact.cpp */ diff --git a/decoder/tests/source/c_api_pkt_print_test.c b/decoder/tests/source/c_api_pkt_print_test.c index 7ae09f6..1390b62 100644 --- a/decoder/tests/source/c_api_pkt_print_test.c +++ b/decoder/tests/source/c_api_pkt_print_test.c @@ -107,6 +107,9 @@ static int frame_raw_unpacked = 0; static int frame_raw_packed = 0; static int test_printstr = 0;
+/* test the library printer API */ +static int test_lib_printers = 0; + /* Process command line options - choose the operation to use for the test. */ static int process_cmd_line(int argc, char *argv[]) { @@ -174,6 +177,10 @@ static int process_cmd_line(int argc, char *argv[]) { test_printstr = 1; } + else if (strcmp(argv[idx], "-test_libprint") == 0) + { + test_lib_printers = 1; + } else if(strcmp(argv[idx],"-help") == 0) { return -1; @@ -191,6 +198,7 @@ static void print_cmd_line_help() printf("-id <ID> : decode source for id <ID> (default 0x10)\n"); 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"); }
@@ -514,7 +522,10 @@ static ocsd_err_t create_generic_decoder(dcd_tree_handle_t handle, const char *p if(ret == OCSD_OK) { /* Attach the packet handler to the output of the packet processor - referenced by CSID */ - ret = ocsd_dt_attach_packet_callback(handle,CSID, OCSD_C_API_CB_PKT_SINK,&packet_handler,p_context); + if (test_lib_printers) + ret = ocsd_dt_set_pkt_protocol_printer(handle, CSID, 0); + else + ret = ocsd_dt_attach_packet_callback(handle,CSID, OCSD_C_API_CB_PKT_SINK,&packet_handler,p_context); if(ret != OCSD_OK) ocsd_dt_remove_decoder(handle,CSID); /* if the attach failed then destroy the decoder. */ } @@ -533,7 +544,10 @@ static ocsd_err_t create_generic_decoder(dcd_tree_handle_t handle, const char *p * print the packets as well as the decode - use the packet processors monitor * output this time, as the main output is attached to the packet decoder. */ - ret = ocsd_dt_attach_packet_callback(handle,CSID,OCSD_C_API_CB_PKT_MON,packet_monitor,p_context); + if (test_lib_printers) + ret = ocsd_dt_set_pkt_protocol_printer(handle, CSID, 1); + else + ret = ocsd_dt_attach_packet_callback(handle,CSID,OCSD_C_API_CB_PKT_MON,packet_monitor,p_context); }
/* attach a memory accessor */ @@ -690,7 +704,7 @@ static ocsd_err_t attach_raw_printers(dcd_tree_handle_t dcd_tree_h) flags |= OCSD_DFRMTR_PACKED_RAW_OUT; if (flags) { - err = ocsd_set_raw_frame_printer(dcd_tree_h, flags); + err = ocsd_dt_set_raw_frame_printer(dcd_tree_h, flags); } return err; } @@ -822,9 +836,14 @@ int process_trace_data(FILE *pf) ret = create_decoder(dcdtree_handle); ocsd_tl_log_mapped_mem_ranges(dcdtree_handle);
- if(ret == OCSD_OK) + if (ret == OCSD_OK) + { /* attach the generic trace element output callback */ - ret = ocsd_dt_set_gen_elem_outfn(dcdtree_handle,gen_trace_elem_print,0); + if (test_lib_printers) + ret = ocsd_dt_set_gen_elem_printer(dcdtree_handle); + else + ret = ocsd_dt_set_gen_elem_outfn(dcdtree_handle, gen_trace_elem_print, 0); + }
/* raw print and str print cb options tested in their init functions */ diff --git a/decoder/tests/source/trc_pkt_lister.cpp b/decoder/tests/source/trc_pkt_lister.cpp index 47a887e..854f158 100644 --- a/decoder/tests/source/trc_pkt_lister.cpp +++ b/decoder/tests/source/trc_pkt_lister.cpp @@ -420,10 +420,10 @@ bool process_cmd_line_opts(int argc, char* argv[]) // if packet processing only, then waits will be coming from there until the count is extinguished // wait testing with packet processor only really works correctly if we are doing a single source as there is no way at this // point to know which source has sent the _WAIT. with multi packet processor waiting may get false warnings once the _WAITs run out. -bool ExpectingPPrintWaitResp(TrcGenericElementPrinter &genElemPrinter) +bool ExpectingPPrintWaitResp(DecodeTree *dcd_tree, TrcGenericElementPrinter &genElemPrinter) { bool ExpectingWaits = false; - std::vector<ItemPrinter *> &printers = PktPrinterFact::getPrinterList(); + std::vector<ItemPrinter *> &printers = dcd_tree->getPrinterList(); if(test_waits > 0) { // see if last response was from the Gen elem printer expecting a wait @@ -451,7 +451,6 @@ bool ExpectingPPrintWaitResp(TrcGenericElementPrinter &genElemPrinter) void AttachPacketPrinters( DecodeTree *dcd_tree) { uint8_t elemID; - ocsd_trace_protocol_t protocol; std::ostringstream oss;
// attach packet printers to each trace source in the tree @@ -461,112 +460,28 @@ void AttachPacketPrinters( DecodeTree *dcd_tree) if(!element_filtered(elemID)) { oss.str(""); - protocol = pElement->getProtocol(); - switch(protocol) - { - case OCSD_PROTOCOL_ETMV4I: - { - - PacketPrinter<EtmV4ITrcPacket> *pPrinter = dynamic_cast<PacketPrinter<EtmV4ITrcPacket> *>(PktPrinterFact::createProtocolPrinter(protocol,elemID,&logger)); - if(pPrinter) - { - // if we are decoding then the decoder is attached to the packet output - attach the printer to the monitor point. - if(decode || pkt_mon) - pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(),(IPktRawDataMon<EtmV4ITrcPacket> *)pPrinter); - else - { - pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(),(IPktDataIn<EtmV4ITrcPacket> *)pPrinter); - if(test_waits) - pPrinter->setTestWaits(test_waits); - } - oss << "Trace Packet Lister : ETMv4 Instuction trace Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; - } - else - oss << "Trace Packet Lister : Failed to set printer for ETMv4 Instuction trace Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; - logger.LogMsg(oss.str()); - } - break; - - case OCSD_PROTOCOL_ETMV3: - { - PacketPrinter<EtmV3TrcPacket> *pPrinter = dynamic_cast<PacketPrinter<EtmV3TrcPacket> *>(PktPrinterFact::createProtocolPrinter(protocol, elemID, &logger)); - if(pPrinter) - { - // if we are decoding then the decoder is attached to the packet output - attach the printer to the monitor point. - if(decode || pkt_mon) - pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(),(IPktRawDataMon<EtmV3TrcPacket> *)pPrinter); - else - { - pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(),(IPktDataIn<EtmV3TrcPacket> *)pPrinter); - if(test_waits) - pPrinter->setTestWaits(test_waits); - } - oss << "Trace Packet Lister : ETMv3 Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; - } - else - oss << "Trace Packet Lister : Failed to set printer for ETMv3 Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; - logger.LogMsg(oss.str()); - } - break; - - case OCSD_PROTOCOL_PTM: - { - PacketPrinter<PtmTrcPacket> *pPrinter = new (std::nothrow) PacketPrinter<PtmTrcPacket>(elemID,&logger); - if(pPrinter) - { - // if we are decoding then the decoder is attached to the packet output - attach the printer to the monitor point. - if(decode || pkt_mon) - pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(),(IPktRawDataMon<PtmTrcPacket> *)pPrinter); - else - { - pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(),(IPktDataIn<PtmTrcPacket> *)pPrinter); - if(test_waits) - pPrinter->setTestWaits(test_waits); - } - } - oss << "Trace Packet Lister : PTM Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; - logger.LogMsg(oss.str()); - } - break;
+ ItemPrinter *pPrinter; + ocsd_err_t err = dcd_tree->addPacketPrinter(elemID, (bool)(decode || pkt_mon),&pPrinter); + if (err == OCSD_OK) + { + // if not decoding or monitor only + if((!(decode || pkt_mon)) && test_waits) + pPrinter->setTestWaits(test_waits);
- case OCSD_PROTOCOL_STM: - { - PacketPrinter<StmTrcPacket> *pPrinter = new (std::nothrow) PacketPrinter<StmTrcPacket>(elemID,&logger); - if(pPrinter) - { - // if we are decoding then the decoder is attached to the packet output - attach the printer to the monitor point. - if(decode || pkt_mon) - pElement->getDecoderMngr()->attachPktMonitor(pElement->getDecoderHandle(),(IPktRawDataMon<StmTrcPacket> *)pPrinter); - else - { - pElement->getDecoderMngr()->attachPktSink(pElement->getDecoderHandle(),(IPktDataIn<StmTrcPacket> *)pPrinter); - if(test_waits) - pPrinter->setTestWaits(test_waits); - } - - } - oss << "Trace Packet Lister : STM Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; - logger.LogMsg(oss.str()); - } - break; - - default: - { - oss << "Trace Packet Lister : Unsupported Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; - logger.LogMsg(oss.str()); - } - break; + oss << "Trace Packet Lister : Protocol printer " << pElement->getDecoderTypeName() << " on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; + } + else + oss << "Trace Packet Lister : Failed to Protocol printer " << pElement->getDecoderTypeName() << " on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; + logger.LogMsg(oss.str());
- // TBD : handle other protocol types. - } } pElement = dcd_tree->getNextElement(elemID); }
}
-void ConfigureFrameDeMux(DecodeTree *dcd_tree, RawFramePrinter &framePrinter) +void ConfigureFrameDeMux(DecodeTree *dcd_tree, RawFramePrinter **framePrinter) { // configure the frame deformatter, and attach a frame printer to the frame deformatter if needed TraceFormatterFrameDecoder *pDeformatter = dcd_tree->getFrameDeformatter(); @@ -575,50 +490,40 @@ void ConfigureFrameDeMux(DecodeTree *dcd_tree, RawFramePrinter &framePrinter) // configuration - memory alinged buffer uint32_t configFlags = OCSD_DFRMTR_FRAME_MEM_ALIGN;
- // if we want the raw frames output - if(outRawPacked || outRawUnpacked) + pDeformatter->Configure(configFlags); + if (outRawPacked || outRawUnpacked) { - pDeformatter->getTrcRawFrameAttachPt()->attach(&framePrinter); - if(outRawPacked) configFlags |= OCSD_DFRMTR_PACKED_RAW_OUT; - if(outRawUnpacked) configFlags |= OCSD_DFRMTR_UNPACKED_RAW_OUT; + if (outRawPacked) configFlags |= OCSD_DFRMTR_PACKED_RAW_OUT; + if (outRawUnpacked) configFlags |= OCSD_DFRMTR_UNPACKED_RAW_OUT; + dcd_tree->addRawFramePrinter(framePrinter, configFlags); } - pDeformatter->Configure(configFlags); } }
void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader, const std::string &trace_buffer_name) { CreateDcdTreeFromSnapShot tree_creator; - RawFramePrinter *framePrinter = 0; - TrcGenericElementPrinter *genElemPrinter = 0; - - framePrinter = PktPrinterFact::createRawFramePrinter(&logger); - if (decode) - genElemPrinter = PktPrinterFact::createGenElemPrinter(&logger); - - if ((framePrinter == 0) || (decode && (genElemPrinter == 0))) - { - std::ostringstream oss; - oss << "Trace Packet Lister : failed to create printer objects\n"; - logger.LogMsg(oss.str()); - return; - }
tree_creator.initialise(&reader, &err_logger);
if(tree_creator.createDecodeTree(trace_buffer_name, (decode == false))) { DecodeTree *dcd_tree = tree_creator.getDecodeTree(); + dcd_tree->setAlternateErrorLogger(&err_logger); + + RawFramePrinter *framePrinter = 0; + TrcGenericElementPrinter *genElemPrinter = 0;
AttachPacketPrinters(dcd_tree);
- ConfigureFrameDeMux(dcd_tree, *framePrinter); + ConfigureFrameDeMux(dcd_tree, &framePrinter);
// if decoding set the generic element printer to the output interface on the tree. if(decode) { std::ostringstream oss; - dcd_tree->setGenTraceElemOutI(genElemPrinter); + //dcd_tree->setGenTraceElemOutI(genElemPrinter); + dcd_tree->addGenElemPrinter(&genElemPrinter); oss << "Trace Packet Lister : Set trace element decode printer\n"; logger.LogMsg(oss.str()); genElemPrinter->setTestWaits(test_waits); @@ -628,7 +533,7 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader dcd_tree->logMappedRanges(); // print out the mapped ranges
// check if we have attached at least one printer - if(decode || (PktPrinterFact::numPrinters() > 0)) + if(decode || (PktPrinterFact::numPrinters(dcd_tree->getPrinterList()) > 0)) { // set up the filtering at the tree level (avoid pushing to processors with no attached printers) if(!all_source_ids) @@ -671,7 +576,7 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader trace_index += nUsedThisTime;
// test printers can inject _WAIT responses - see if we are expecting one... - if(ExpectingPPrintWaitResp(*genElemPrinter)) + if(ExpectingPPrintWaitResp(dcd_tree, *genElemPrinter)) { if(OCSD_DATA_RESP_IS_CONT(dataPathResp)) { @@ -738,9 +643,6 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader
// get rid of the decode tree. tree_creator.destroyDecodeTree(); - - // get rid of all the printers. - PktPrinterFact::destroyAllPrinters(); } }
Update version information files. Update README.md to describe new version updates. Update HOWTO.md for additional perf build option.
Signed-off-by: Mike Leach mike.leach@linaro.org --- HOWTO.md | 11 ++++++++++- README.md | 4 +++- TODO | 16 ++-------------- decoder/include/ocsd_if_version.h | 6 +++--- 4 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/HOWTO.md b/HOWTO.md index 596efab..835def5 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -7,7 +7,7 @@ This HOWTO explains how to use the perf cmd line tools and the openCSD library to collect and extract program flow traces generated by the CoreSight IP blocks on a Linux system. The examples have been generated using an aarch64 Juno-r0 platform. All information is considered accurate and tested -using library version v0.5 and the `perf-opencsd-master` branch on the +using library version v0.6 and the `perf-opencsd-master` branch on the [OpenCSD github repository][1].
@@ -308,6 +308,15 @@ When compiling Perf, some perl libraries may not be present on the host system. Adding the "NO_LIBPERL=1" option will prevent the build script from complaining too much.
+Additional debug output from the decoder can be compiled in by setting the +`CSTRACE_RAW` environment variable. Setting this to `packed` gets trace frame +output as follows:- + + Frame Data; Index 576; RAW_PACKED; d6 d6 d6 d6 d6 d6 d6 d6 fc fb d6 d6 d6 d6 e0 7f + Frame Data; Index 576; ID_DATA[0x14]; d7 d6 d7 d6 d7 d6 d7 d6 fd fb d7 d6 d7 d6 e0 + +Set to any other value will remove the RAW_PACKED lines. + At the end of the compilation a new perf binary is available in `tools/perf/`
diff --git a/README.md b/README.md index f7c2e26..464f070 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Releases will appear on the master branch in the git repository with an appropri CoreSight Trace Component Support. ----------------------------------
-_Current Version 0.5.4_ +_Current Version 0.6.0_
### Current support:
@@ -107,6 +107,8 @@ Version and Modification Information - _Version 0.5.2_: Minor Update & Bugfixes - Update trace info packet string o/p + Cycle count packet bugfixes. - _Version 0.5.3_: Doc update for using AutoFDO with ETM and additional timestamp and cycle count options. - _Version 0.5.4_: Updates: X-compile for arm/arm64. Remove deprecated VS2010 builds. Bugfix: GCC inline semantics in debug build. +- _Version 0.6.0_: Packet printers moved from tests into the main library. C++ and C APIs updated to allow clients to use them. + Update to allow perf to insert barrier packets (4xFSYNC) which the decoder can be made to use to reset the decode state.
Licence Information =================== diff --git a/TODO b/TODO index e705a82..1dbb6dd 100644 --- a/TODO +++ b/TODO @@ -1,15 +1,3 @@ -* Decode Tree API updates. --> Re-factor the decode tree API to: - 1) Use new structure to enable custom decoders - may be proprietary / binaries to - be used in the decoder structure. - 2) Make it easier to add a new decoder to the library source, without the overhead of - doing all the creation fns. - -* STM "full decode". --> This is simply to come up with a generic packet format that will consist of - Master+Channel+<payload>, where <payload> is [data]+[TS]+[marker/flag]. This - combines a number of packets from the raw STPv2 format. - * ETMv4/PTM - decoder updates to handle advanced configuration. -> Certain (currently unused by perf / current hardware) configuration settings can alter the format of the trace output. One example is Return Stack - @@ -26,6 +14,6 @@ the instruction trace.
Cortex-A cores do not support this architecturally. On R and M profile cores it -is an option. There are scenrios in future that could see linux on R cores, plus +is an option. There are scenarios in future that could see linux on R cores, plus on something like Juno it is possible to switch on trace for the SCP -(M class processor). So at some point data trace +(M class processor). So at some point data trace may be required. diff --git a/decoder/include/ocsd_if_version.h b/decoder/include/ocsd_if_version.h index 0fd0a2a..1d58607 100644 --- a/decoder/include/ocsd_if_version.h +++ b/decoder/include/ocsd_if_version.h @@ -43,8 +43,8 @@ /** @name Library Versioning @{*/ #define OCSD_VER_MAJOR 0x0 /**< Library Major Version */ -#define OCSD_VER_MINOR 0x5 /**< Library Minor Version */ -#define OCSD_VER_PATCH 0x4 /**< Library Patch Version */ +#define OCSD_VER_MINOR 0x6 /**< Library Minor Version */ +#define OCSD_VER_PATCH 0x0 /**< Library Patch Version */
/** Library version number - MMMMnnpp format. MMMM = major version, @@ -53,7 +53,7 @@ */ #define OCSD_VER_NUM (((uint32_t)OCSD_VER_MAJOR << 16) | ((uint32_t)OCSD_VER_MINOR << 8) | ((uint32_t)OCSD_VER_PATCH))
-#define OCSD_VER_STRING "0.5.4" /**< Library Version string */ +#define OCSD_VER_STRING "0.6.0" /**< Library Version string */ #define OCSD_LIB_NAME "OpenCSD Library" /**< Library name string */ #define OCSD_LIB_SHORT_NAME "OCSD" /**< Library Short name string */ /** @}*/