From b01590fdf4cb18198e3d677e07c5929694630601 Mon Sep 17 00:00:00 2001 From: Yan Lee Date: Tue, 15 Aug 2023 00:40:29 -0700 Subject: [PATCH] mem: port: add getTraceInString() method Return the whole port trace of the packet as a string. Change-Id: I7b1b1fef628a47a6ce147cb5fb75af81948c1d89 --- src/mem/port.hh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/mem/port.hh b/src/mem/port.hh index da4addf375..5f977aaab8 100644 --- a/src/mem/port.hh +++ b/src/mem/port.hh @@ -47,6 +47,7 @@ #define __MEM_PORT_HH__ #include +#include #include #include @@ -100,6 +101,21 @@ class TracingExtension : public gem5::Extension bool empty() { return trace_.empty(); } std::stack& getTrace() { return trace_; } + std::string getTraceInString() + { + std::stringstream port_trace; + std::stack copy_stack = trace_; + port_trace << "Port trace of the Packet (" << std::endl + << "[Destination] "; + while (!copy_stack.empty()) { + if (copy_stack.size() == 1) + port_trace << "[Source] "; + port_trace << copy_stack.top() << std::endl; + copy_stack.pop(); + } + port_trace << ")"; + return port_trace.str(); + } private: std::stack trace_;