aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Leach <mike.leach@linaro.org>2023-08-17 14:00:54 +0100
committerMike Leach <mike.leach@linaro.org>2023-08-17 15:31:19 +0100
commita25eca761b1c84e15876b0da82cb073f7ef5aec6 (patch)
tree5ad5c0610bb92072ed374e99765e8d534082825c
parentd82287587c8e899bb691575f829e78e9a292009a (diff)
downloadOpenCSD-a25eca761b1c84e15876b0da82cb073f7ef5aec6.tar.gz
opencsd: test: add test mode to trc_pkt_lister to mute output
Add option to mute printed output to allow tests of library performance Signed-off-by: Mike Leach <mike.leach@linaro.org>
-rw-r--r--decoder/build/linux/ref_trace_decode_lib/makefile3
-rw-r--r--decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj1
-rw-r--r--decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj.filters3
-rw-r--r--decoder/include/pkt_printers/gen_elem_printer.h40
-rw-r--r--decoder/include/pkt_printers/item_printer.h19
-rw-r--r--decoder/include/pkt_printers/pkt_printer_t.h6
-rw-r--r--decoder/source/pkt_printers/gen_elem_printer.cpp122
-rw-r--r--decoder/source/pkt_printers/raw_frame_printer.cpp3
-rw-r--r--decoder/tests/source/trc_pkt_lister.cpp17
9 files changed, 176 insertions, 38 deletions
diff --git a/decoder/build/linux/ref_trace_decode_lib/makefile b/decoder/build/linux/ref_trace_decode_lib/makefile
index 58d5c6e..3cdfcfd 100644
--- a/decoder/build/linux/ref_trace_decode_lib/makefile
+++ b/decoder/build/linux/ref_trace_decode_lib/makefile
@@ -86,7 +86,8 @@ STMOBJ= $(BUILD_DIR)/trc_pkt_elem_stm.o \
$(BUILD_DIR)/trc_pkt_decode_stm.o
PKTPRNTOBJ= $(BUILD_DIR)/raw_frame_printer.o \
- $(BUILD_DIR)/trc_print_fact.o
+ $(BUILD_DIR)/trc_print_fact.o \
+ $(BUILD_DIR)/gen_elem_printer.o
OBJECTS=$(BUILD_DIR)/ocsd_code_follower.o \
diff --git a/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj b/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj
index 13d34ab..30724aa 100644
--- a/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj
+++ b/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj
@@ -440,6 +440,7 @@
<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\gen_elem_printer.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" />
diff --git a/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj.filters b/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj.filters
index 47e9a3a..4ec5327 100644
--- a/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj.filters
+++ b/decoder/build/win-vs2022/ref_trace_decode_lib/ref_trace_decode_lib.vcxproj.filters
@@ -511,5 +511,8 @@
<ClCompile Include="..\..\..\source\ete\trc_cmp_cfg_ete.cpp">
<Filter>Source Files\ete</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\source\pkt_printers\gen_elem_printer.cpp">
+ <Filter>Source Files\pkt_printers</Filter>
+ </ClCompile>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/decoder/include/pkt_printers/gen_elem_printer.h b/decoder/include/pkt_printers/gen_elem_printer.h
index ba3138a..c3fe3aa 100644
--- a/decoder/include/pkt_printers/gen_elem_printer.h
+++ b/decoder/include/pkt_printers/gen_elem_printer.h
@@ -49,47 +49,15 @@ public:
// funtionality to test wait / flush mechanism
void ackWait() { m_needWaitAck = false; };
const bool needAckWait() const { return m_needWaitAck; };
+ void set_collect_stats() { m_collect_stats = true; };
+ void printStats();
protected:
bool m_needWaitAck;
+ bool m_collect_stats; // collect stats on packets processed
+ int m_packet_counts[(int)OCSD_GEN_TRC_ELEM_CUSTOM + 1];
};
-
-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
index cc3ec37..0f1feeb 100644
--- a/decoder/include/pkt_printers/item_printer.h
+++ b/decoder/include/pkt_printers/item_printer.h
@@ -52,14 +52,21 @@ public:
const int getTestWaits() const;
void decTestWaits();
+ // mute printers when profiling
+ void setMute(bool mute);
+ const bool is_muted() const;
+
+
protected:
ocsdMsgLogger *m_pMsgLogger;
int m_test_waits;
+ bool m_mute;
};
inline ItemPrinter::ItemPrinter() :
m_pMsgLogger(0),
- m_test_waits(0)
+ m_test_waits(0),
+ m_mute(false)
{
}
@@ -89,6 +96,16 @@ inline void ItemPrinter::decTestWaits()
m_test_waits--;
}
+inline void ItemPrinter::setMute(bool mute)
+{
+ m_mute = mute;
+}
+
+inline const bool ItemPrinter::is_muted() const
+{
+ return m_mute;
+}
+
#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
index c00daa1..f2d3e09 100644
--- a/decoder/include/pkt_printers/pkt_printer_t.h
+++ b/decoder/include/pkt_printers/pkt_printer_t.h
@@ -97,6 +97,9 @@ template<class P> ocsd_datapath_resp_t PacketPrinter<P>::PacketDataIn( const ocs
{
std::string pktstr;
ocsd_datapath_resp_t resp = OCSD_RESP_CONT;
+
+ if (is_muted())
+ return resp;
// wait / flush test verification
if(!m_bRawPrint && (m_last_resp == OCSD_RESP_WAIT))
@@ -152,6 +155,9 @@ template<class P> void PacketPrinter<P>::RawPacketDataMon( const ocsd_datapath_o
const uint32_t size,
const uint8_t *p_data)
{
+ if (is_muted())
+ return;
+
switch(op)
{
case OCSD_OP_DATA:
diff --git a/decoder/source/pkt_printers/gen_elem_printer.cpp b/decoder/source/pkt_printers/gen_elem_printer.cpp
new file mode 100644
index 0000000..ffd9a2d
--- /dev/null
+++ b/decoder/source/pkt_printers/gen_elem_printer.cpp
@@ -0,0 +1,122 @@
+/*
+ * \file gen_elem_printer.cpp
+ * \brief OpenCSD : Generic element printer class.
+ *
+ * \copyright Copyright (c) 2015,2023 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"
+
+TrcGenericElementPrinter::TrcGenericElementPrinter() :
+ m_needWaitAck(false),
+ m_collect_stats(false)
+{
+ for (int i = 0; i <= (int)OCSD_GEN_TRC_ELEM_CUSTOM; i++)
+ m_packet_counts[i] = 0;
+}
+
+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;
+
+ if (m_collect_stats)
+ m_packet_counts[(int)elem.getType()]++;
+
+ if (is_muted())
+ return resp;
+
+ 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;
+}
+
+void TrcGenericElementPrinter::printStats()
+{
+ static const char* gen_elem_packet_names[] = {
+ "OCSD_GEN_TRC_ELEM_UNKNOWN",
+ "OCSD_GEN_TRC_ELEM_NO_SYNC",
+ "OCSD_GEN_TRC_ELEM_TRACE_ON",
+ "OCSD_GEN_TRC_ELEM_EO_TRACE",
+ "OCSD_GEN_TRC_ELEM_PE_CONTEXT",
+ "OCSD_GEN_TRC_ELEM_INSTR_RANGE",
+ "OCSD_GEN_TRC_ELEM_I_RANGE_NOPATH",
+ "OCSD_GEN_TRC_ELEM_ADDR_NACC",
+ "OCSD_GEN_TRC_ELEM_ADDR_UNKNOWN",
+ "OCSD_GEN_TRC_ELEM_EXCEPTION",
+ "OCSD_GEN_TRC_ELEM_EXCEPTION_RET",
+ "OCSD_GEN_TRC_ELEM_TIMESTAMP",
+ "OCSD_GEN_TRC_ELEM_CYCLE_COUNT",
+ "OCSD_GEN_TRC_ELEM_EVENT",
+ "OCSD_GEN_TRC_ELEM_SWTRACE",
+ "OCSD_GEN_TRC_ELEM_SYNC_MARKER",
+ "OCSD_GEN_TRC_ELEM_MEMTRANS",
+ "OCSD_GEN_TRC_ELEM_INSTRUMENTATION",
+ "OCSD_GEN_TRC_ELEM_CUSTOM",
+ };
+
+ std::ostringstream oss;
+
+ oss << "Generic Packets processed:-\n";
+ for (int i = 0; i <= OCSD_GEN_TRC_ELEM_CUSTOM; i++)
+ {
+ oss << gen_elem_packet_names[i] << " : " << m_packet_counts[i] << "\n";
+ }
+ oss << "\n\n";
+
+ itemPrintLine(oss.str());
+}
+
+
diff --git a/decoder/source/pkt_printers/raw_frame_printer.cpp b/decoder/source/pkt_printers/raw_frame_printer.cpp
index 7ac2ddf..421d88d 100644
--- a/decoder/source/pkt_printers/raw_frame_printer.cpp
+++ b/decoder/source/pkt_printers/raw_frame_printer.cpp
@@ -47,6 +47,9 @@ ocsd_err_t RawFramePrinter::TraceRawFrameIn( const ocsd_datapath_op_t op,
const uint8_t traceID)
{
+ if (is_muted())
+ return OCSD_OK;
+
if(op == OCSD_OP_DATA) // only interested in actual frame data.
{
std::string strData;
diff --git a/decoder/tests/source/trc_pkt_lister.cpp b/decoder/tests/source/trc_pkt_lister.cpp
index 9760351..83f8b85 100644
--- a/decoder/tests/source/trc_pkt_lister.cpp
+++ b/decoder/tests/source/trc_pkt_lister.cpp
@@ -75,6 +75,7 @@ static bool tpiu_format = false;
static bool has_hsync = false;
static bool src_addr_n = false;
static bool stats = false;
+static bool profile = false;
int main(int argc, char* argv[])
{
@@ -197,6 +198,7 @@ void print_help()
oss << "-test_waits <N> Force wait from packet printer for N packets - test the wait/flush mechanisms for the decoder\n";
oss << "-src_addr_n ETE protocol: Split source address ranges on N atoms\n";
oss << "-stats Output packet processing statistics (if available).\n";
+ oss << "-profile Mute logging output while profiling library performance\n";
oss << "\nOutput:\n";
oss << " Setting any of these options cancels the default output to file & stdout,\n using _only_ the options supplied.\n\n";
oss << "-logstdout Output to stdout -> console.\n";
@@ -432,6 +434,10 @@ bool process_cmd_line_opts(int argc, char* argv[])
has_hsync = true;
tpiu_format = true;
}
+ else if (strcmp(argv[optIdx], "-profile") == 0)
+ {
+ profile = true;
+ }
else
{
std::ostringstream errstr;
@@ -505,6 +511,8 @@ void AttachPacketPrinters( DecodeTree *dcd_tree)
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());
+ if (profile)
+ pPrinter->setMute(true);
}
pElement = dcd_tree->getNextElement(elemID);
@@ -613,6 +621,8 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader
AttachPacketPrinters(dcd_tree);
ConfigureFrameDeMux(dcd_tree, &framePrinter);
+ if (profile && framePrinter)
+ framePrinter->setMute(true);
// if decoding set the generic element printer to the output interface on the tree.
if(decode)
@@ -623,6 +633,11 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader
oss << "Trace Packet Lister : Set trace element decode printer\n";
logger.LogMsg(oss.str());
genElemPrinter->setTestWaits(test_waits);
+ if (profile)
+ {
+ genElemPrinter->setMute(true);
+ genElemPrinter->set_collect_stats();
+ }
}
if(decode)
@@ -741,6 +756,8 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader
logger.LogMsg(oss.str());
if (stats)
PrintDecodeStats(dcd_tree);
+ if (profile)
+ genElemPrinter->printStats();
}
else
{