diff options
Diffstat (limited to 'decoder/tests/source/trc_pkt_lister.cpp')
-rw-r--r-- | decoder/tests/source/trc_pkt_lister.cpp | 80 |
1 files changed, 74 insertions, 6 deletions
diff --git a/decoder/tests/source/trc_pkt_lister.cpp b/decoder/tests/source/trc_pkt_lister.cpp index 50260a5f8b9b..9760351c9c7b 100644 --- a/decoder/tests/source/trc_pkt_lister.cpp +++ b/decoder/tests/source/trc_pkt_lister.cpp @@ -73,6 +73,8 @@ static int test_waits = 0; static bool dstream_format = false; static bool tpiu_format = false; static bool has_hsync = false; +static bool src_addr_n = false; +static bool stats = false; int main(int argc, char* argv[]) { @@ -185,14 +187,16 @@ void print_help() oss << "\nDecode:\n\n"; oss << "-id <n> Set an ID to list (may be used multiple times) - default if no id set is for all IDs to be printed\n"; oss << "-src_name <name> List packets from a given snapshot source name (defaults to first source found)\n"; - oss << "-dstream_format Input is DSTREAM framed."; - oss << "-tpiu Input from TPIU - sync by FSYNC."; - oss << "-tpiu_hsync Input from TPIU - sync by FSYNC and HSYNC."; + oss << "-dstream_format Input is DSTREAM framed.\n"; + oss << "-tpiu Input from TPIU - sync by FSYNC.\n"; + oss << "-tpiu_hsync Input from TPIU - sync by FSYNC and HSYNC.\n"; oss << "-decode Full decode of the packets from the trace snapshot (default is to list undecoded packets only\n"; oss << "-decode_only Does not list the undecoded packets, just the trace decode.\n"; oss << "-o_raw_packed Output raw packed trace frames\n"; oss << "-o_raw_unpacked Output raw unpacked trace data per ID\n"; 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 << "\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"; @@ -390,6 +394,14 @@ bool process_cmd_line_opts(int argc, char* argv[]) no_undecoded_packets = true; decode = true; } + else if (strcmp(argv[optIdx], "-src_addr_n") == 0) + { + src_addr_n = true; + } + else if (strcmp(argv[optIdx], "-stats") == 0) + { + stats = true; + } else if((strcmp(argv[optIdx], "-help") == 0) || (strcmp(argv[optIdx], "--help") == 0) || (strcmp(argv[optIdx], "-h") == 0)) { print_help(); @@ -518,8 +530,9 @@ void ConfigureFrameDeMux(DecodeTree *dcd_tree, RawFramePrinter **framePrinter) if (!configFlags) { configFlags = OCSD_DFRMTR_FRAME_MEM_ALIGN; - pDeformatter->Configure(configFlags); } + pDeformatter->Configure(configFlags); + if (outRawPacked || outRawUnpacked) { if (outRawPacked) configFlags |= OCSD_DFRMTR_PACKED_RAW_OUT; @@ -529,13 +542,67 @@ void ConfigureFrameDeMux(DecodeTree *dcd_tree, RawFramePrinter **framePrinter) } } +void PrintDecodeStats(DecodeTree *dcd_tree) +{ + uint8_t elemID; + std::ostringstream oss; + ocsd_decode_stats_t *pStats = 0; + ocsd_err_t err; + bool gotDemuxStats = false; + ocsd_demux_stats_t demux_stats; + + oss << "\nReading packet decoder statistics....\n\n"; + logger.LogMsg(oss.str()); + + DecodeTreeElement *pElement = dcd_tree->getFirstElement(elemID); + while (pElement) + { + oss.str(""); + err = dcd_tree->getDecoderStats(elemID, &pStats); + if (!err && pStats) + { + oss << "Decode stats ID 0x" << std::hex << (uint32_t)elemID << "\n"; + oss << "Total Bytes: " << std::dec << pStats->channel_total << "; Unsynced Bytes: " << std::dec << pStats->channel_unsynced << "\n"; + oss << "Bad Header Errors: " << std::dec << pStats->bad_header_errs << "; Bad Sequence Errors: " << std::dec << pStats->bad_sequence_errs << "\n"; + + // demux stats same for all IDs - grab them at the first opportunity.. + if (!gotDemuxStats) { + memcpy(&demux_stats, &pStats->demux, sizeof(ocsd_demux_stats_t)); + gotDemuxStats = true; + } + + } + else + oss << "Decode stats unavailable on Trace ID 0x" << std::hex << (uint32_t)elemID << "\n"; + + + logger.LogMsg(oss.str()); + pElement = dcd_tree->getNextElement(elemID); + } + + // if we have copied over the stats and there is at least 1 frame byte (impossible for there to be 0 if demuxing) + if (gotDemuxStats && demux_stats.frame_bytes) { + uint64_t total = demux_stats.valid_id_bytes + demux_stats.no_id_bytes + demux_stats.unknown_id_bytes + + demux_stats.reserved_id_bytes + demux_stats.frame_bytes; + oss.str(""); + oss << "\nFrame Demux Stats\n"; + oss << "Trace data bytes sent to registered ID decoders: " << std::dec << demux_stats.valid_id_bytes << "\n"; + oss << "Trace data bytes without registered ID decoders: " << std::dec << demux_stats.no_id_bytes << "\n"; + oss << "Trace data bytes with unknown ID: " << std::dec << demux_stats.unknown_id_bytes << "\n"; + oss << "Trace data bytes with reserved ID: " << std::dec << demux_stats.reserved_id_bytes << "\n"; + oss << "Frame demux bytes, ID bytes and sync bytes: " << std::dec << demux_stats.frame_bytes << "\n"; + oss << "Total bytes processed by frame demux: " << std::dec << total << "\n\n"; + logger.LogMsg(oss.str()); + } +} + void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader, const std::string &trace_buffer_name) { CreateDcdTreeFromSnapShot tree_creator; tree_creator.initialise(&reader, &err_logger); - if(tree_creator.createDecodeTree(trace_buffer_name, (decode == false))) + if(tree_creator.createDecodeTree(trace_buffer_name, (decode == false), src_addr_n ? ETE_OPFLG_PKTDEC_SRCADDR_N_ATOMS : 0)) { DecodeTree *dcd_tree = tree_creator.getDecodeTree(); dcd_tree->setAlternateErrorLogger(&err_logger); @@ -672,7 +739,8 @@ void ListTracePackets(ocsdDefaultErrorLogger &err_logger, SnapShotReader &reader std::ostringstream oss; oss << "Trace Packet Lister : Trace buffer done, processed " << trace_index << " bytes.\n"; logger.LogMsg(oss.str()); - + if (stats) + PrintDecodeStats(dcd_tree); } else { |