From bf0a5a80dea775492d01c8e251ca1dbc2cfa5109 Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Wed, 16 Feb 2022 10:12:45 +0100 Subject: [PATCH 1/3] adds functionality to reduce the output --- incl/iss/plugin/pctrace.h | 1 + 1 file changed, 1 insertion(+) diff --git a/incl/iss/plugin/pctrace.h b/incl/iss/plugin/pctrace.h index 0cad8b0..d227666 100644 --- a/incl/iss/plugin/pctrace.h +++ b/incl/iss/plugin/pctrace.h @@ -90,6 +90,7 @@ private: std::ofstream output; std::string filename; std::vector delays; + bool jumped, first; }; } From 2bba5645c33713703cb48038f1fa56d776586b5f Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Wed, 16 Feb 2022 10:12:45 +0100 Subject: [PATCH 2/3] adds functionality to reduce the output --- incl/iss/plugin/pctrace.h | 1 + src/plugin/pctrace.cpp | 52 +++++++++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/incl/iss/plugin/pctrace.h b/incl/iss/plugin/pctrace.h index 0cad8b0..d227666 100644 --- a/incl/iss/plugin/pctrace.h +++ b/incl/iss/plugin/pctrace.h @@ -90,6 +90,7 @@ private: std::ofstream output; std::string filename; std::vector delays; + bool jumped, first; }; } diff --git a/src/plugin/pctrace.cpp b/src/plugin/pctrace.cpp index 1a92dd4..97ca4fc 100644 --- a/src/plugin/pctrace.cpp +++ b/src/plugin/pctrace.cpp @@ -20,6 +20,8 @@ iss::plugin::cov::cov(std::string const &filename) , filename(filename) { output.open("output.trc"); + jumped = false; + first = true; } iss::plugin::cov::~cov() { @@ -79,19 +81,53 @@ bool iss::plugin::cov::registration(const char *const version, vm_if& vm) { } + +inline string formatPC(uint64_t pc) { + stringstream stream; + stream << "0x" << std::hex << pc; + return stream.str(); +} + void iss::plugin::cov::callback(instr_info_t iinfo, const exec_info& einfo) { -// if((instr_if->get_next_pc() - instr_if->get_pc() != 4) ||( instr_if->get_next_pc() - instr_if->get_pc() != 2)){ -// std::cout << "jump from " << std::hex << instr_if->get_pc() << " to " << instr_if->get_next_pc()<< " after " << std::dec << counter <<" linear instructions" <get_pc() <<"," << delay << "\n"; + delay = entry.not_taken; + + if (first){ + output << formatPC(instr_if->get_pc()) << "," << delay; + first = false; + } + if(instr_if->get_next_pc()-instr_if->get_pc() != delays[iinfo.instr_id].size/8){ + //The goal is to keep the output in start-target pairs, so after a jump the target address needs to get written + //to the output. If the target happens to also be a start, we keep the pairing by adding a 0-delay entry. + if (jumped) + output <<"\n" <get_pc()) << "," << 0; + output <<"\n" << formatPC(instr_if->get_pc()) << "," << delay; + jumped = true; + } + else{ + if (jumped){ + output <<"\n" << formatPC(instr_if->get_pc()) << "," << delay; + jumped = false; + } + else if(delay!=1){ + output <<"\n" << formatPC(instr_if->get_pc()) << "," << delay; + output <<"\n" << formatPC(instr_if->get_pc()) << "," << 0; + } + + } + +//source code for the full output +// auto delay = 0; +// auto entry = delays[iinfo.instr_id]; +// bool taken = einfo.branch_taken; +// if (einfo.branch_taken) +// delay = entry.taken; +// else +// delay = entry.not_taken; +// output<get_pc() <<"," << delay << "\n"; } From 58311b37dbec793328f4d03f3ec5742cafc99ef3 Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Mon, 28 Mar 2022 11:16:09 +0200 Subject: [PATCH 3/3] Merge branch 'feature/reduced_output' of https://git.minres.com/DBT-RISE/DBT-RISE-TGC.git into feature/reduced_output --- src/plugin/pctrace.cpp | 70 +++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/plugin/pctrace.cpp b/src/plugin/pctrace.cpp index 97ca4fc..e178072 100644 --- a/src/plugin/pctrace.cpp +++ b/src/plugin/pctrace.cpp @@ -89,45 +89,45 @@ inline string formatPC(uint64_t pc) { } void iss::plugin::cov::callback(instr_info_t iinfo, const exec_info& einfo) { - auto delay = 0; - auto entry = delays[iinfo.instr_id]; - bool taken = einfo.branch_taken; - if (einfo.branch_taken) - delay = entry.taken; - else - delay = entry.not_taken; - - if (first){ - output << formatPC(instr_if->get_pc()) << "," << delay; - first = false; - } - if(instr_if->get_next_pc()-instr_if->get_pc() != delays[iinfo.instr_id].size/8){ - //The goal is to keep the output in start-target pairs, so after a jump the target address needs to get written - //to the output. If the target happens to also be a start, we keep the pairing by adding a 0-delay entry. - if (jumped) - output <<"\n" <get_pc()) << "," << 0; - output <<"\n" << formatPC(instr_if->get_pc()) << "," << delay; - jumped = true; - } - else{ - if (jumped){ - output <<"\n" << formatPC(instr_if->get_pc()) << "," << delay; - jumped = false; - } - else if(delay!=1){ - output <<"\n" << formatPC(instr_if->get_pc()) << "," << delay; - output <<"\n" << formatPC(instr_if->get_pc()) << "," << 0; - } - - } - -//source code for the full output // auto delay = 0; // auto entry = delays[iinfo.instr_id]; // bool taken = einfo.branch_taken; // if (einfo.branch_taken) // delay = entry.taken; // else -// delay = entry.not_taken; -// output<get_pc() <<"," << delay << "\n"; +// delay = entry.not_taken; +// +// if (first){ +// output << formatPC(instr_if->get_pc()) << "," << delay; +// first = false; +// } +// if(instr_if->get_next_pc()-instr_if->get_pc() != delays[iinfo.instr_id].size/8){ +// //The goal is to keep the output in start-target pairs, so after a jump the target address needs to get written +// //to the output. If the target happens to also be a start, we keep the pairing by adding a 0-delay entry. +// if (jumped) +// output <<"\n" <get_pc()) << "," << 0; +// output <<"\n" << formatPC(instr_if->get_pc()) << "," << delay; +// jumped = true; +// } +// else{ +// if (jumped){ +// output <<"\n" << formatPC(instr_if->get_pc()) << "," << delay; +// jumped = false; +// } +// else if(delay!=1){ +// output <<"\n" << formatPC(instr_if->get_pc()) << "," << delay; +// output <<"\n" << formatPC(instr_if->get_pc()) << "," << 0; +// } +// +// } + +//source code for the full output + auto delay = 0; + auto entry = delays[iinfo.instr_id]; + bool taken = einfo.branch_taken; + if (einfo.branch_taken) + delay = entry.taken; + else + delay = entry.not_taken; + output<get_pc() <<"," << delay << "\n"; }