ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
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 
67 namespace etiss
68 {
69 
70 namespace plugin
71 {
72 
73 namespace gdb
74 {
75 
80 {
81  public:
82  enum BPType
83  {
88  };
89  public:
90  BreakpointDB();
91  inline bool isEmpty() { return instrbrkpt_ == 0; }
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 
146  void preDReadCallback(etiss::uint64 addr);
147  void preDWriteCallback(etiss::uint64 addr);
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_;
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_int32 int32
Definition: 386-GCC.h:81
etiss_uint32 uint32
Definition: 386-GCC.h:80
etiss_uint64 uint64
Definition: 386-GCC.h:82
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.
Definition: Instruction.h:562
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
Definition: GDBConnection.h:76
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.
Definition: GDBServer.cpp:826
etiss::int32 postMemAccessCallback(etiss::int32 exception)
Definition: GDBServer.cpp:775
std::string _getPluginName() const override
Definition: GDBServer.cpp:809
void * getPluginHandle() override
called to get the handle that is available in translated code via getPoinerCode()....
Definition: GDBServer.cpp:814
etiss::int32 execute() override
called before a block and may act in the same way as a block
Definition: GDBServer.cpp:225
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)...
Definition: GDBServer.cpp:819
ETISS_System * wrap(ETISS_CPU *cpu, ETISS_System *system) override
SystemWrapper,.
BreakpointDB watchpoints_
Definition: GDBServer.h:170
ETISS_System * system_
Definition: GDBServer.h:161
Server(etiss::plugin::gdb::PacketProtocol &pp)
Definition: GDBServer.cpp:157
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
Definition: GDBServer.cpp:269
void finalizeCodeBlock(etiss::CodeBlock &) const override
called after all instructions have been translated for the code block
Definition: GDBServer.cpp:277
ETISS_System * unwrappedSys_
Definition: GDBServer.h:162
BreakpointDB breakpoints_
Definition: GDBServer.h:169
void preDWriteCallback(etiss::uint64 addr)
Definition: GDBServer.cpp:764
void handlePacket(bool block)
Definition: GDBServer.cpp:284
static Server * createTCPServer(std::map< std::string, std::string > options)
Definition: GDBServer.cpp:833
etiss::uint64 status_jumpaddr_
Definition: GDBServer.h:168
void preDReadCallback(etiss::uint64 addr)
Definition: GDBServer.cpp:754
etiss::int32 preInstructionCallback()
Definition: GDBServer.cpp:173
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