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
GDBServer.h
Go to the documentation of this file.
1
55#ifndef ETISS_INCLUDE_GDB_GDBSERVER_H_
56#define ETISS_INCLUDE_GDB_GDBSERVER_H_
57
58#include "etiss/CPUArch.h"
60#include "etiss/jit/CPU.h"
61#include "etiss/jit/System.h"
62
63#include "etiss/Plugin.h"
64
65#include <memory>
66
67namespace etiss
68{
69
70namespace plugin
71{
72
73namespace gdb
74{
75
80{
81 public:
89 public:
91 inline bool isEmpty() { return instrbrkpt_ == 0; }
92 inline etiss::uint32 get(etiss::uint64 addr)
93 {
94 if (unlikely(instrbrkpt_ == 0))
95 return 0;
96 unsigned a1 = (addr)&0xFFFF;
97 if (unlikely(instrbrkpt_[a1] != 0))
98 {
99 unsigned a2 = (addr >> 16) & 0xFFFF;
100 if (unlikely(instrbrkpt_[a1][a2] != 0))
101 {
102 unsigned a3 = (addr >> 32) & 0xFFFF;
103 if (unlikely(instrbrkpt_[a1][a2][a3] != 0))
104 {
105 unsigned a4 = (addr >> 48) & 0xFFFF;
106 std::cout << "Breakpoint hit: " << std::hex << (addr << 2) << std::dec << std::endl;
107 return instrbrkpt_[a1][a2][a3][a4];
108 }
109 }
110 }
111 return 0;
112 }
113 void set(etiss::uint64 addr, etiss::uint32 val);
114
115 private:
116 etiss::uint32 ***
119};
120
125{
126 public:
128
129 // Plugin
130 void init(ETISS_CPU *cpu, ETISS_System *system, CPUArch *arch) override;
131 void cleanup() override;
132
133 // Coroutine
134 etiss::int32 execute() override; // called before block execution, check for BREAK command
135
136 // Translation
138 void finalizeCodeBlock(etiss::CodeBlock &) const override;
139 void *getPluginHandle() override; // handle is pointer to this object
140
142 ETISS_System *wrap(ETISS_CPU *cpu, ETISS_System *system) override; // wrap for memory breakpoints
143 ETISS_System *unwrap(ETISS_CPU *cpu, ETISS_System *system) override; // undo wrapping
144
145 etiss::int32 preInstructionCallback();
146 void preDReadCallback(etiss::uint64 addr);
147 void preDWriteCallback(etiss::uint64 addr);
148 etiss::int32 postMemAccessCallback(etiss::int32 exception);
149
150
151 protected:
152 // Plugin
153 std::string _getPluginName() const override;
154
155 void handlePacket(bool block);
156
157 protected:
165 unsigned status_step_;
168 etiss::uint64 status_jumpaddr_;
174
175 private:
176 std::shared_ptr<Connection> cinst_;
177
178 public:
179 static Server *createTCPServer(std::map<std::string, std::string> options);
180 static Server *createTCPServer(int port);
181};
182} // namespace gdb
183
184} // namespace plugin
185
186} // namespace etiss
187
188#endif
ETISS_PLUGIN_EXPORT etiss::CPUArch std::map< std::string, std::string > options
create new instance of the CPUArch type at index
contains neccesary interfaces for instruction translation.
plugins for extensions to code translation and instruction execution
#define unlikely(x)
Definition types.h:74
the interface to translate instructions of and processor architecture
Definition CPUArch.h:162
A list of CodeSets.
Definition CodePart.h:570
this plugin will be called before a block is executed.
Definition Plugin.h:299
this plugin allows to wrap the ETISS_System interface
Definition Plugin.h:326
allows to add code to the translation of instructions
Definition Plugin.h:262
holds etiss::instr::VariableInstructionSet instances for different modes.
structure to store breakpoints
Definition GDBServer.h:80
etiss::uint32 **** instrbrkpt_
important: index maps are reversed to instruction pointer e.g pointer(0x0102030405060708) [POINTER !...
Definition GDBServer.h:117
void set(etiss::uint64 addr, etiss::uint32 val)
Definition GDBServer.cpp:68
etiss::uint32 get(etiss::uint64 addr)
Definition GDBServer.h:92
implements gdb's packet protocol
gdb server implementation that is used as a plugin in etiss
Definition GDBServer.h:125
void cleanup() override
this function is called after cpu execution loop (etiss::CPUCore::execute) finished.
etiss::int32 postMemAccessCallback(etiss::int32 exception)
std::string _getPluginName() const override
void * getPluginHandle() override
called to get the handle that is available in translated code via getPoinerCode()....
etiss::int32 execute() override
called before a block and may act in the same way as a block
etiss::plugin::gdb::PacketProtocol & con_
Definition GDBServer.h:158
ETISS_System * unwrap(ETISS_CPU *cpu, ETISS_System *system) override
undo wrap function call this function will be called AFTER etiss::Plugin::cleanup
void init(ETISS_CPU *cpu, ETISS_System *system, CPUArch *arch) override
this function is called before the plugin is used in the cpu execution loop (etiss::CPUCore::execute)...
ETISS_System * wrap(ETISS_CPU *cpu, ETISS_System *system) override
SystemWrapper,.
std::shared_ptr< Connection > cinst_
Definition GDBServer.h:176
void finalizeInstrSet(etiss::instr::ModedInstructionSet &) const override
called after all instructions have been added to allow last changes
void finalizeCodeBlock(etiss::CodeBlock &) const override
called after all instructions have been translated for the code block
ETISS_System * unwrappedSys_
Definition GDBServer.h:162
void preDWriteCallback(etiss::uint64 addr)
void handlePacket(bool block)
static Server * createTCPServer(std::map< std::string, std::string > options)
etiss::uint64 status_jumpaddr_
Definition GDBServer.h:168
void preDReadCallback(etiss::uint64 addr)
etiss::int32 preInstructionCallback()
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition Benchmark.h:53
basic cpu state structure needed for execution of any cpu architecture.
Definition CPU.h:89
memory access and time synchronization functions.
Definition System.h:78