ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
VariableValueLogger.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.
6
8#include "etiss/CPUCore.h"
9#include "etiss/Instruction.h"
10
11#include <iostream>
12
13extern "C"
14{
20}
21
22namespace etiss
23{
24
25namespace plugin
26{
27
29 const std::string &field, const std::string &file,
30 std::function<void(std::ostream &out, const std::string &field, uint64_t value)> writer)
31 : field_(field)
32{
33 if (!writer)
34 writer = [](std::ostream &out, const std::string &field, uint64_t value)
35 { out << field << "," << value << "\n"; };
36 out_.open(file.c_str(), std::ios::binary);
37 writer_ = writer;
38}
39
41{
42 block.fileglobalCode().insert("extern void etiss_plugin_VariableValueLogger(void *); ");
43}
44
46{
47 auto f = plugin_core_->getStruct()->findName(field_);
48 unsigned width = f ? static_cast<unsigned>(f->width_) : 64;
49 mis.foreach (
50 [this, width](etiss::instr::VariableInstructionSet &vis)
51 {
52 vis.foreach (
53 [this, width](etiss::instr::InstructionSet &is)
54 {
55 is.foreach (
56 [this, width](etiss::instr::Instruction &i)
57 {
59 [this, width](etiss::instr::BitArray &, etiss::CodeSet &cs,
61 {
63 p.getRegisterDependencies().add(field_, width);
64 p.code() =
65 std::string("etiss_plugin_VariableValueLogger(") + getPointerCode() + ");";
66 return true;
67 },
68 0);
69 });
70 });
71 });
72}
73
75{
76 if (field_ == "instructionPointer")
77 {
79 }
80 else
81 {
82 writer_(out_, field_, plugin_core_->getStruct()->findName(field_)->read());
83 }
84 out_.flush();
85}
86
88{
89 return std::string("VariableValueLogger for ") + field_;
90}
91
92} // namespace plugin
93
94} // namespace etiss
defines main cpu core interface
contains container classes to store instruction definitions + translation functions and build a trans...
void etiss_plugin_VariableValueLogger(void *ptr)
static __inline__ uint64_t
Definition arm_cde.h:31
virtual std::shared_ptr< VirtualStruct > getStruct()
Get the virtual structure of this CPUCore instance.
Definition CPUCore.h:122
A list of CodeSets.
Definition CodePart.h:532
std::set< std::string > & fileglobalCode()
Definition CodePart.h:566
Contains a small code snipped.
Definition CodePart.h:348
std::string & code()
Definition CodePart.h:378
RegisterSet & getRegisterDependencies()
Definition CodePart.h:375
A set of CodeParts.
Definition CodePart.h:399
void append(const CodePart &part, CodePart::TYPE type)
Definition CodePart.h:412
CPUCore * plugin_core_
holds a pointer to the associated CPUCore instance.
Definition Plugin.h:160
ETISS_CPU * plugin_cpu_
holds a pointer to the cpu structure. will be set before init call and after cleanup call
Definition Plugin.h:155
std::string getPointerCode() const
returns a C code expression that allows to get or assign a pointer to the variable assigned to this t...
Definition Plugin.cpp:63
stores a bit vector
this class contains parameters that persist in between instruction lookpus/translation within a trans...
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 >())
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)
writes the value of a field before each instruction
std::ofstream out_
file stream for logger.
VariableValueLogger(const std::string &field, const std::string &file, std::function< void(std::ostream &out, const std::string &field, uint64_t value)> writer)
virtual std::string _getPluginName() const
returns the name of the Plugin.
virtual void initCodeBlock(etiss::CodeBlock &block) const
called before instructions are translated for the code block
void writeValue()
Calls the function specified with writer_ to log the variable.
std::function< void(std::ostream &out, const std::string &field, uint64_t value)> writer_
Function which specifies the outout format.
virtual void finalizeInstrSet(etiss::instr::ModedInstructionSet &) const
called after all instructions have been added to allow last changes
std::string field_
Name of the field to log.
forwards: include/jit/*
Definition Benchmark.h:17
etiss_uint64 instructionPointer
pointer to next instruction.
Definition CPU.h:54