ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
PrintInstruction.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2//
3// This file is part of ETISS. It is licensed under the BSD 3-Clause License; you may not use this file except in
4// compliance with the License. You should have received a copy of the license along with this project. If not, see the
5// LICENSE file.
15extern "C"
16{
17 int pi_6cac = 0;
18}
19
21#include "etiss/CPUArch.h"
22#include "etiss/Instruction.h"
23
24using namespace etiss::plugin;
25
27{
28 block.fileglobalCode().insert("extern void PrintInstruction_print(const char *,uint64_t);"); // add print function
29}
30
32{
33
34 mis.foreach (
36 {
37 vis.foreach (
39 {
40 set.foreach (
42 {
43 instr.addCallback(
44 [&instr](etiss::instr::BitArray &ba, etiss::CodeSet &cs,
46 {
47 std::stringstream ss;
48
49 ss << "PrintInstruction_print(\"";
50
51 ss << "0x" << std::hex << std::setfill('0') << std::setw(16) << ic.current_address_
52 << ": ";
53
54 ss << instr.printASM(ba);
55
56 ss << "\\n";
57
58 ss << "\",cpu->instructionPointer);\n";
59
60 cs.append(CodePart::PREINITIALDEBUGRETURNING).code() = ss.str();
61
62 return true;
63 },
64 0);
65 });
66 });
67 });
68}
69
71{
72 return "PrintInstruction";
73}
74
76{
77 return nullptr;
78}
79
80extern "C"
81{
82 void PrintInstruction_print(const char *c, uint64_t addr)
83 {
84 std::cout << c;
85 std::cout.flush();
86 if (addr == 0x6cac)
87 {
88 // std::cout << "TCOUNT: " << std::dec << ++pi_6cac << "\n";
89 }
90 }
91}
contains neccesary interfaces for instruction translation.
contains container classes to store instruction definitions + translation functions and build a trans...
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:532
std::set< std::string > & fileglobalCode()
Definition CodePart.h:566
@ PREINITIALDEBUGRETURNING
Definition CodePart.h:359
A set of CodeParts.
Definition CodePart.h:399
void append(const CodePart &part, CodePart::TYPE type)
Definition CodePart.h:412
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