ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PrintInstruction.cpp
Go to the documentation of this file.
1
53extern "C"
54{
55 int pi_6cac = 0;
56}
57
59#include "etiss/CPUArch.h"
60
61using namespace etiss::plugin;
62
64{
65 block.fileglobalCode().insert("extern void PrintInstruction_print(const char *,uint64_t);"); // add print function
66}
67
69{
70
73 set.foreach ([](etiss::instr::Instruction &instr) {
74 instr.addCallback(
76 std::stringstream ss;
77
78 ss << "PrintInstruction_print(\"";
79
80 ss << "0x" << std::hex << std::setfill('0') << std::setw(16) << ic.current_address_ << ": ";
81
82 ss << instr.printASM(ba);
83
84 ss << "\\n";
85
86 ss << "\",cpu->instructionPointer);\n";
87
88 cs.append(CodePart::PREINITIALDEBUGRETURNING).code() = ss.str();
89
90 return true;
91 },
92 0);
93 });
94 });
95 });
96}
97
99{
100 return "PrintInstruction";
101}
102
104{
105 return nullptr;
106}
107
108extern "C"
109{
110 void PrintInstruction_print(const char *c, uint64_t addr)
111 {
112 std::cout << c;
113 std::cout.flush();
114 if (addr == 0x6cac)
115 {
116 // std::cout << "TCOUNT: " << std::dec << ++pi_6cac << "\n";
117 }
118 }
119}
contains neccesary interfaces for instruction translation.
int pi_6cac
void PrintInstruction_print(const char *c, uint64_t addr)
contains a simple plugin to print instructions
__device__ __2f16 float c
A list of CodeSets.
Definition CodePart.h:570
std::set< std::string > & fileglobalCode()
Definition CodePart.h:604
@ PREINITIALDEBUGRETURNING
Definition CodePart.h:397
A set of CodeParts.
Definition CodePart.h:437
void append(const CodePart &part, CodePart::TYPE type)
Definition CodePart.h:450
stores a bit vector
this class contains parameters that persist in between instruction lookpus/translation within a trans...
uint64_t current_address_
start address of current instruction
holds etiss::instr::Instruction instances and handles automatic instruction tree creation.
void foreach(std::function< void(Instruction &)> func)
holds information and translation callbacks for an instruction.
bool addCallback(std::function< bool(BitArray &, etiss::CodeSet &, InstructionContext &)> callback, uint32_t builtinGroups, const std::set< uint32_t > &groups=std::set< uint32_t >())
std::string printASM(BitArray &)
holds etiss::instr::VariableInstructionSet instances for different modes.
void foreach(std::function< void(VariableInstructionSet &)> call)
holds etiss::instr::InstructionSet instances with different bit widths.
void foreach(std::function< void(InstructionSet &)> func)
virtual void * getPluginHandle()
called to get the handle that is available in translated code via getPoinerCode()....
virtual void finalizeInstrSet(etiss::instr::ModedInstructionSet &) const
called after all instructions have been added to allow last changes
virtual void initCodeBlock(etiss::CodeBlock &block) const
called before instructions are translated for the code block
virtual std::string _getPluginName() const