ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
GDBServer.h
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.
17#ifndef ETISS_INCLUDE_GDB_GDBSERVER_H_
18#define ETISS_INCLUDE_GDB_GDBSERVER_H_
19
20#include "etiss/Misc.h"
21
22#include "etiss/Plugin.h"
23
24#include <memory>
25
26namespace etiss
27{
28
29namespace plugin
30{
31
32namespace gdb
33{
34
39{
40 public:
48
49 public:
51 inline bool isEmpty() { return instrbrkpt_ == 0; }
52 inline etiss::uint32 get(etiss::uint64 addr)
53 {
54 if (unlikely(instrbrkpt_ == 0))
55 return 0;
56 unsigned a1 = (addr) & 0xFFFF;
57 if (unlikely(instrbrkpt_[a1] != 0))
58 {
59 unsigned a2 = (addr >> 16) & 0xFFFF;
60 if (unlikely(instrbrkpt_[a1][a2] != 0))
61 {
62 unsigned a3 = (addr >> 32) & 0xFFFF;
63 if (unlikely(instrbrkpt_[a1][a2][a3] != 0))
64 {
65 unsigned a4 = (addr >> 48) & 0xFFFF;
66 std::cout << "Breakpoint hit: " << std::hex << (addr << 2) << std::dec << std::endl;
67 return instrbrkpt_[a1][a2][a3][a4];
68 }
69 }
70 }
71 return 0;
72 }
73 void set(etiss::uint64 addr, etiss::uint32 val);
74
75 private:
76 etiss::uint32 ***
79};
80
85{
86 public:
88
89 // Plugin
90 void init(ETISS_CPU *cpu, ETISS_System *system, CPUArch *arch) override;
91 void cleanup() override;
92
93 // Coroutine
94 etiss::int32 execute() override; // called before block execution, check for BREAK command
95
96 // Translation
98 void finalizeCodeBlock(etiss::CodeBlock &) const override;
99 void *getPluginHandle() override; // handle is pointer to this object
100
102 ETISS_System *wrap(ETISS_CPU *cpu, ETISS_System *system) override; // wrap for memory breakpoints
103 ETISS_System *unwrap(ETISS_CPU *cpu, ETISS_System *system) override; // undo wrapping
104
105 etiss::int32 preInstructionCallback();
106 void preDReadCallback(etiss::uint64 addr);
107 void preDWriteCallback(etiss::uint64 addr);
108 etiss::int32 postMemAccessCallback(etiss::int32 exception);
109
110 protected:
111 // Plugin
112 std::string _getPluginName() const override;
113
114 void handlePacket(bool block);
115
116 protected:
124 unsigned status_step_;
127 etiss::uint64 status_jumpaddr_;
133
134 private:
135 std::shared_ptr<Connection> cinst_;
136
137 public:
138 static Server *createTCPServer(std::map<std::string, std::string> options);
139 static Server *createTCPServer(int port);
140};
141} // namespace gdb
142
143} // namespace plugin
144
145} // namespace etiss
146
147#endif
ETISS_PLUGIN_EXPORT etiss::CPUArch std::map< std::string, std::string > options
create new instance of the CPUArch type at index
general configuration and logging
plugins for extensions to code translation and instruction execution
#define unlikely(x)
Definition types.h:36
the interface to translate instructions of and processor architecture
Definition CPUArch.h:116
A list of CodeSets.
Definition CodePart.h:532
this plugin will be called before a block is executed.
Definition Plugin.h:259
this plugin allows to wrap the ETISS_System interface
Definition Plugin.h:286
allows to add code to the translation of instructions
Definition Plugin.h:222
holds etiss::instr::VariableInstructionSet instances for different modes.
structure to store breakpoints
Definition GDBServer.h:39
etiss::uint32 **** instrbrkpt_
important: index maps are reversed to instruction pointer e.g pointer(0x0102030405060708) [POINTER !...
Definition GDBServer.h:77
void set(etiss::uint64 addr, etiss::uint32 val)
Definition GDBServer.cpp:34
etiss::uint32 get(etiss::uint64 addr)
Definition GDBServer.h:52
implements gdb's packet protocol
gdb server implementation that is used as a plugin in etiss
Definition GDBServer.h:85
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:117
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:135
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:121
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:127
void preDReadCallback(etiss::uint64 addr)
etiss::int32 preInstructionCallback()
forwards: include/jit/*
Definition Benchmark.h:17
basic cpu state structure needed for execution of any cpu architecture.
Definition CPU.h:51
memory access and time synchronization functions.
Definition System.h:40