Updated test program to configure frame deformatter to output raw frames
diff --git a/.gitignore b/.gitignore
index ce8e18d..14b8c04 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,3 +49,4 @@
# ignore bin test directory
bin/
+*.log
diff --git a/ref_trace_decoder/tests/build/win/trc_pkt_lister/trc_pkt_lister.vcxproj b/ref_trace_decoder/tests/build/win/trc_pkt_lister/trc_pkt_lister.vcxproj
index 7706649..5b459ba 100644
--- a/ref_trace_decoder/tests/build/win/trc_pkt_lister/trc_pkt_lister.vcxproj
+++ b/ref_trace_decoder/tests/build/win/trc_pkt_lister/trc_pkt_lister.vcxproj
@@ -143,6 +143,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="..\..\..\source\raw_frame_printer.cpp" />
<ClCompile Include="..\..\..\source\trc_pkt_lister.cpp" />
</ItemGroup>
<ItemGroup>
@@ -156,6 +157,7 @@
<ItemGroup>
<ClInclude Include="..\..\..\source\item_printer.h" />
<ClInclude Include="..\..\..\source\pkt_printer_t.h" />
+ <ClInclude Include="..\..\..\source\raw_frame_printer.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/ref_trace_decoder/tests/build/win/trc_pkt_lister/trc_pkt_lister.vcxproj.filters b/ref_trace_decoder/tests/build/win/trc_pkt_lister/trc_pkt_lister.vcxproj.filters
index c676afe..286a51b 100644
--- a/ref_trace_decoder/tests/build/win/trc_pkt_lister/trc_pkt_lister.vcxproj.filters
+++ b/ref_trace_decoder/tests/build/win/trc_pkt_lister/trc_pkt_lister.vcxproj.filters
@@ -18,6 +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">
@@ -26,5 +29,8 @@
<ClInclude Include="..\..\..\source\item_printer.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\source\raw_frame_printer.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
diff --git a/ref_trace_decoder/tests/source/item_printer.h b/ref_trace_decoder/tests/source/item_printer.h
index 57b8e82..4708cbf 100644
--- a/ref_trace_decoder/tests/source/item_printer.h
+++ b/ref_trace_decoder/tests/source/item_printer.h
@@ -51,17 +51,17 @@
rctdlMsgLogger *m_pMsgLogger;
};
-ItemPrinter::ItemPrinter() :
+inline ItemPrinter::ItemPrinter() :
m_pMsgLogger(0)
{
}
-ItemPrinter::~ItemPrinter()
+inline ItemPrinter::~ItemPrinter()
{
m_pMsgLogger = 0;
}
-void ItemPrinter::itemPrintLine(const std::string &msg)
+inline void ItemPrinter::itemPrintLine(const std::string &msg)
{
if(m_pMsgLogger)
m_pMsgLogger->LogMsg(msg);
diff --git a/ref_trace_decoder/tests/source/pkt_printer_t.h b/ref_trace_decoder/tests/source/pkt_printer_t.h
index e9d1539..3ffacc8 100644
--- a/ref_trace_decoder/tests/source/pkt_printer_t.h
+++ b/ref_trace_decoder/tests/source/pkt_printer_t.h
@@ -84,20 +84,20 @@
{
case RCTDL_OP_DATA:
p_packet_in->toString(pktstr);
- oss << "Idx:" << index_sop << "; ID:"<< m_trcID << "\t" << pktstr << std::endl;
+ oss << "Idx:" << index_sop << "; ID:"<< std::hex << (uint32_t)m_trcID << "\t" << pktstr << std::endl;
itemPrintLine(oss.str());
break;
case RCTDL_OP_EOT:
- oss <<"ID:"<< m_trcID << "\tEND OF TRACE DATA\n";
+ oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tEND OF TRACE DATA\n";
break;
case RCTDL_OP_FLUSH:
- oss <<"ID:"<< m_trcID << "\tFLUSH operation on trace decode path\n";
+ oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tFLUSH operation on trace decode path\n";
break;
case RCTDL_OP_RESET:
- oss <<"ID:"<< m_trcID << "\tRESET operation on trace decode path\n";
+ oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tRESET operation on trace decode path\n";
break;
}
diff --git a/ref_trace_decoder/tests/source/raw_frame_printer.cpp b/ref_trace_decoder/tests/source/raw_frame_printer.cpp
new file mode 100644
index 0000000..e366bfa
--- /dev/null
+++ b/ref_trace_decoder/tests/source/raw_frame_printer.cpp
@@ -0,0 +1,101 @@
+/*
+ * \file raw_frame_printer.cpp
+ * \brief Reference CoreSight Trace Decoder :
+ *
+ * \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"
+
+
+rctdl_err_t RawFramePrinter::TraceRawFrameIn( const rctdl_datapath_op_t op,
+ const rctdl_trc_index_t index,
+ const rctdl_rawframe_elem_t frame_element,
+ const int dataBlockSize,
+ const uint8_t *pDataBlock)
+{
+
+ if(op == RCTDL_OP_DATA) // only interested in actual frame data.
+ {
+ std::string strData;
+ std::ostringstream oss;
+ int printDataSize = dataBlockSize;
+ int printOffset = 0;
+
+ oss << "Frame Data; Index" << std::setw(7) << index << "; ";
+ oss << std::setw(12);
+ switch(frame_element)
+ {
+ case RCTDL_FRM_PACKED: oss << "RAW_PACKED; "; break;
+ case RCTDL_FRM_HSYNC: oss << "HSYNC; "; break;
+ case RCTDL_FRM_FSYNC: oss << "FSYNC; "; break;
+ case RCTDL_FRM_ID_DATA: oss << "ID_DATA; "; break;
+ case RCTDL_FRM_ID_CHANGE: oss << "ID UPDATE; "; break;
+ default: oss << "UNKNOWN; "; break;
+ }
+
+ if((frame_element == RCTDL_FRM_ID_CHANGE) && (printDataSize > 0))
+ {
+ oss << "ID:0x" << std::hex << std::setw(2) << (uint32_t)pDataBlock[0] << "; ";
+ printDataSize--;
+ printOffset++;
+ }
+
+ if(printDataSize)
+ {
+ createDataString(printDataSize,pDataBlock+printOffset,16,strData);
+ oss << strData;
+ }
+ itemPrintLine(oss.str());
+ }
+ return RCTDL_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++)
+ {
+ oss << std::hex << std::setw(2) <<std::setfill('0') << (uint32_t)pData[i] << " ";
+ lineBytes ++;
+ if(lineBytes == bytesPerLine)
+ oss << std::endl;
+ }
+ dataStr = oss.str();
+}
+
+
+/* End of File raw_frame_printer.cpp */
diff --git a/ref_trace_decoder/tests/source/raw_frame_printer.h b/ref_trace_decoder/tests/source/raw_frame_printer.h
new file mode 100644
index 0000000..11018dc
--- /dev/null
+++ b/ref_trace_decoder/tests/source/raw_frame_printer.h
@@ -0,0 +1,70 @@
+/*
+ * \file raw_frame_printer.h
+ * \brief Reference CoreSight Trace Decoder :
+ *
+ * \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 "rctdl.h"
+#include "item_printer.h"
+
+#include <string>
+#include <sstream>
+
+class RawFramePrinter : public ITrcRawFrameIn, public ItemPrinter
+{
+public:
+ RawFramePrinter() {};
+ RawFramePrinter(rctdlMsgLogger *pMsgLogger);
+ virtual ~RawFramePrinter() {};
+
+ virtual rctdl_err_t TraceRawFrameIn( const rctdl_datapath_op_t op,
+ const rctdl_trc_index_t index,
+ const rctdl_rawframe_elem_t frame_element,
+ const int dataBlockSize,
+ const uint8_t *pDataBlock);
+
+private:
+ void createDataString(const int dataSize, const uint8_t *pData, int bytesPerLine, std::string &dataStr);
+
+};
+
+inline RawFramePrinter::RawFramePrinter(rctdlMsgLogger *pMsgLogger)
+{
+ setMessageLogger(pMsgLogger);
+}
+
+
+#endif // ARM_RAW_FRAME_PRINTER_H_INCLUDED
+
+/* End of File raw_frame_printer.h */
diff --git a/ref_trace_decoder/tests/source/trc_pkt_lister.cpp b/ref_trace_decoder/tests/source/trc_pkt_lister.cpp
index d1969c3..e686bb7 100644
--- a/ref_trace_decoder/tests/source/trc_pkt_lister.cpp
+++ b/ref_trace_decoder/tests/source/trc_pkt_lister.cpp
@@ -44,9 +44,10 @@
#include "rctdl.h"
#include "trace_snapshots.h"
#include "pkt_printer_t.h"
+#include "raw_frame_printer.h"
-static bool process_cmd_line_opts(rctdlMsgLogger &logger, int argc, char* argv[]);
-static void ListTracePackets(rctdlMsgLogger &logger, rctdlDefaultErrorLogger &err_logger, SnapShotReader &reader, const std::string &trace_buffer_name);
+static bool process_cmd_line_opts( int argc, char* argv[]);
+static void ListTracePackets(rctdlDefaultErrorLogger &err_logger, SnapShotReader &reader, const std::string &trace_buffer_name);
// default path
#ifdef WIN32
@@ -59,6 +60,7 @@
static bool all_source_ids = true; // output all IDs in source.
static std::vector<uint8_t> id_list; // output specific IDs in source
+static rctdlMsgLogger logger;
static int logOpts = rctdlMsgLogger::OUT_STDOUT | rctdlMsgLogger::OUT_FILE;
static std::string logfileName = "trc_pkt_lister.log";
@@ -66,14 +68,13 @@
{
// TBD: get the logger cmd line options here.
- rctdlMsgLogger logger;
logger.setLogOpts(logOpts);
logger.setLogFileName(logfileName.c_str());
rctdlDefaultErrorLogger err_log;
err_log.initErrorLogger(RCTDL_ERR_SEV_INFO,&logger);
- if(!process_cmd_line_opts(logger, argc, argv))
+ if(!process_cmd_line_opts(argc, argv))
return -1;
SnapShotReader ss_reader;
@@ -103,7 +104,7 @@
std::ostringstream oss;
oss << "Using " << source_buffer_name << " as trace source\n";
logger.LogMsg(oss.str());
- ListTracePackets(logger, err_log,ss_reader,source_buffer_name);
+ ListTracePackets(err_log,ss_reader,source_buffer_name);
}
else
@@ -124,7 +125,7 @@
}
-bool process_cmd_line_opts(rctdlMsgLogger &logger, int argc, char* argv[])
+bool process_cmd_line_opts(int argc, char* argv[])
{
bool bOptsOK = true;
if(argc > 1)
@@ -141,7 +142,7 @@
ss_path = argv[optIdx];
else
{
- logger.LogMsg("Error: Missing directory string on -ss_dir option\n");
+ logger.LogMsg("Trace Packet Lister : Error: Missing directory string on -ss_dir option\n");
bOptsOK = false;
}
}
@@ -155,7 +156,7 @@
if((Id == 0) || (Id >=70))
{
std::ostringstream iderrstr;
- iderrstr << "Error: invalid ID number " << Id << " on -id option" << std::endl;
+ iderrstr << "Trace Packet Lister : Error: invalid ID number " << Id << " on -id option" << std::endl;
logger.LogMsg(iderrstr.str());
bOptsOK = false;
}
@@ -167,7 +168,7 @@
}
else
{
- logger.LogMsg("Error: No ID number on -id option\n");
+ logger.LogMsg("Trace Packet Lister : Error: No ID number on -id option\n");
bOptsOK = false;
}
}
@@ -179,14 +180,14 @@
source_buffer_name = argv[optIdx];
else
{
- logger.LogMsg("Error: Missing source name string on -src_name option\n");
+ logger.LogMsg("Trace Packet Lister : Error: Missing source name string on -src_name option\n");
bOptsOK = false;
}
}
else
{
std::ostringstream errstr;
- errstr << "Warning: Ignored unknown option " << argv[optIdx] << "." << std::endl;
+ errstr << "Trace Packet Lister : Warning: Ignored unknown option " << argv[optIdx] << "." << std::endl;
logger.LogMsg(errstr.str());
}
options_to_process--;
@@ -197,10 +198,14 @@
return bOptsOK;
}
-void ListTracePackets(rctdlMsgLogger &logger, rctdlDefaultErrorLogger &err_logger, SnapShotReader &reader, const std::string &trace_buffer_name)
+void ListTracePackets(rctdlDefaultErrorLogger &err_logger, SnapShotReader &reader, const std::string &trace_buffer_name)
{
CreateDcdTreeFromSnapShot tree_creator;
+ RawFramePrinter framePrinter;
+
+ framePrinter.setMessageLogger(&logger);
tree_creator.initialise(&reader,&err_logger);
+
if(tree_creator.createDecodeTree(trace_buffer_name, true))
{
std::vector<ItemPrinter *> printers;
@@ -215,11 +220,25 @@
switch(pElement->getProtocol())
{
case RCTDL_PROTOCOL_ETMV4I:
- PacketPrinter<EtmV4ITrcPacket> *pPrinter = new (std::nothrow) PacketPrinter<EtmV4ITrcPacket>(elemID,&logger);
- if(pPrinter)
{
- pElement->getEtmV4IPktProc()->getPacketOutAttachPt()->attach(pPrinter);
- printers.push_back(pPrinter); // save printer to destroy it later
+ std::ostringstream oss;
+ PacketPrinter<EtmV4ITrcPacket> *pPrinter = new (std::nothrow) PacketPrinter<EtmV4ITrcPacket>(elemID,&logger);
+ if(pPrinter)
+ {
+ pElement->getEtmV4IPktProc()->getPacketOutAttachPt()->attach(pPrinter);
+ printers.push_back(pPrinter); // save printer to destroy it later
+ }
+
+ oss << "Trace Packet Lister : ETMv4 Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n";
+ logger.LogMsg(oss.str());
+ }
+ break;
+
+ default:
+ {
+ std::ostringstream oss;
+ oss << "Trace Packet Lister : Unsupported Protocol on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n";
+ logger.LogMsg(oss.str());
}
break;
@@ -228,6 +247,16 @@
pElement = dcd_tree->getNextElement(elemID);
}
+ // attached a frame printer to the frame deformatter
+ TraceFormatterFrameDecoder *pDeformatter = dcd_tree->getFrameDeformatter();
+ if(pDeformatter != 0)
+ {
+ // wwe want the raw frames.
+ pDeformatter->getTrcRawFrameAttachPt()->attach(&framePrinter);
+ pDeformatter->Configure(RCTDL_DFRMTR_FRAME_MEM_ALIGN | RCTDL_DFRMTR_UNPACKED_RAW_OUT | RCTDL_DFRMTR_PACKED_RAW_OUT);
+ }
+
+
// check if we have attached at least one printer
if(printers.size() > 0)
{
@@ -271,16 +300,46 @@
}
}
}
- // mark end of trace into the data path
- dcd_tree->TraceDataIn(RCTDL_OP_EOT,0,0,0,0);
+
+ // fatal error - no futher processing
+ if(RCTDL_DATA_RESP_IS_FATAL(dataPathResp))
+ {
+ std::ostringstream oss;
+ oss << "Trace Packet Lister : Data Path fatal error\n";
+ logger.LogMsg(oss.str());
+ rctdlError *perr = err_logger.GetLastError();
+ if(perr != 0)
+ logger.LogMsg(rctdlError::getErrorString(perr));
+
+ }
+ else
+ {
+ // mark end of trace into the data path
+ dcd_tree->TraceDataIn(RCTDL_OP_EOT,0,0,0,0);
+ }
+
// close the input file.
in.close();
+
+ std::ostringstream oss;
+ oss << "Trace Packet Lister : Trace buffer done, processed " << trace_index << "bytes.\n";
+ logger.LogMsg(oss.str());
+
}
else
{
+ std::ostringstream oss;
+ oss << "Trace Packet Lister : Error : Unable to open trace buffer.\n";
+ logger.LogMsg(oss.str());
}
}
+ else
+ {
+ std::ostringstream oss;
+ oss << "Trace Packet Lister : No supported protocols found.\n";
+ logger.LogMsg(oss.str());
+ }
// clean up