56 #include "etiss/jit/types.h"
77 unsigned a1 = (addr)&0xFFFF;
85 unsigned a2 = (addr >> 16) & 0xFFFF;
93 unsigned a3 = (addr >> 32) & 0xFFFF;
101 unsigned a4 = (addr >> 48) & 0xFFFF;
106 for (
unsigned i = 0; i < (1 << 16); i++)
118 for (
unsigned i = 0; i < (1 << 16); i++)
130 for (
unsigned i = 0; i < (1 << 16); i++)
142 for (
unsigned i = 0; i < (1 << 16); i++)
195 return RETURNCODE::CPUTERMINATED;
212 return RETURNCODE::CPUTERMINATED;
230 return RETURNCODE::CPUTERMINATED;
242 return RETURNCODE::CPUTERMINATED;
256 cp.
code() = std::string(
"{\n"
257 "\tetiss_int32 _gdb_exception = gdb_pre_instruction(cpu,system,") +
260 "\tif (_gdb_exception != 0)\n\t return _gdb_exception==-16?0:_gdb_exception;\n"
280 cb.
fileglobalCode().insert(
"extern etiss_int32 gdb_pre_instruction(ETISS_CPU * ,ETISS_System * ,void * );extern "
281 "void gdb_pre_instruction_noreturn(ETISS_CPU * ,ETISS_System * ,void * );");
290 std::string command =
con_.
rcv(isnotification);
291 if (command.length() > 0)
303 bool nodbgaction =
false;
305 bool answerisnotification =
false;
310 for (
unsigned i = 0; i <
arch_->
getGDBCore().mappedRegisterCount(); i++)
345 for (
unsigned i = 0; i <
arch_->
getGDBCore().mappedRegisterCount(); i++)
355 treglen += f->width_;
357 if (command.length() == (treglen * 2) + 1)
361 for (
unsigned i = 0; i <
arch_->
getGDBCore().mappedRegisterCount(); i++)
390 off += f->width_ * 2;
402 unsigned regIndex = 0;
403 std::string valToWrite;
404 if (command.length() > 1)
406 for (
size_t i = 1; i < command.length(); ++i)
408 if (command[i] ==
'=' && command.length() > i + 1)
410 valToWrite = command.substr(i + 1);
443 off += f->width_ * 2;
448 unsigned regIndex = 0;
449 if (command.length() > 1)
451 for (
size_t i = 1; i < command.length(); ++i)
487 etiss::uint64 addr = hex::tryInt<etiss::uint64>(command, pos);
506 etiss::uint64 addr = hex::tryInt<etiss::uint64>(command, pos);
510 std::vector<etiss::uint8> buf(
length);
513 buf[i] = hex::tryInt<etiss::uint8>(command, pos);
528 if (command.length() > 1)
531 for (
size_t i = 1; i < command.length(); i += 2)
533 addr = (addr << 8) |
hex::toByte(command[i], command[i + 1]);
547 if (command.length() > 1)
550 for (
size_t i = 1; i < command.length(); i += 2)
552 addr = (addr << 8) |
hex::toByte(command[i], command[i + 1]);
580 if (command.length() > 2 && command[2] ==
',')
610 etiss::uint64 addr = hex::tryInt<etiss::uint64>(command, pos);
618 if ((existingFlags & requestedFlags) != requestedFlags)
620 bpDB->
set(addr, existingFlags | requestedFlags);
634 if (command.length() > 2 && command[2] ==
',')
665 etiss::uint64 addr = hex::tryInt<etiss::uint64>(command, pos);
670 if ((existingFlags & flagsToDelete) != 0)
672 bpDB->
set(addr, existingFlags & ~flagsToDelete);
686 if (command.substr(1, 9) ==
"Supported")
690 else if (command.substr(1, 8) ==
"Attached")
694 else if (command.substr(1, 8) ==
"Symbol::")
698 else if (command.substr(1, 1) ==
"C")
702 else if (command.substr(1, 7) ==
"TStatus")
704 answer =
"T0;tnotrun:0";
706 else if (command.substr(1, 11) ==
"fThreadInfo")
710 else if (command.substr(1, 11) ==
"sThreadInfo")
723 if (command.length() > 1)
732 std::cout <<
"GDB: unknown command: " << command << std::endl;
741 std::cout <<
"GDB: unknown command: " << command << std::endl;
749 con_.
snd(answer, answerisnotification);
795 return RETURNCODE::CPUTERMINATED;
838 auto f =
options.find(
"plugin.gdbserver.port");
841 int tmp = atoi(f->second.c_str());
846 std::string(
"etiss::plugin::gdb::Server: failed to parse port value for tcp socket: ") +
854 auto f =
options.find(
"skipcount");
857 int tmp = atoi(f->second.c_str());
859 s->execute_skip_count = tmp;
865 auto f =
options.find(
"minPcAlign");
868 int tmp = atoi(f->second.c_str());
870 s->minimal_pc_alignment = tmp;
878 #if ETISS_USE_POSIX_SOCKET
880 std::string(
"etiss::plugin::gdb::Server: starting tcp server on port ") +
etiss::toString(port));
882 std::shared_ptr<Connection> cs(
new etiss::plugin::gdb::UnixTCPGDBConnection(port));
ETISS_PLUGIN_EXPORT etiss::CPUArch std::map< std::string, std::string > options
create new instance of the CPUArch type at index
defines main cpu core interface
etiss_int32 gdb_pre_instruction(ETISS_CPU *cpu, ETISS_System *system, void *gdbserver)
static void Server_finalizeInstrSet(etiss::instr::InstructionSet *set, std::string pcode)
void gdb_pre_instruction_noreturn(ETISS_CPU *, ETISS_System *, void *gdbserver)
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
__device__ __2f16 float bool s
static __inline__ uint32_t
static __inline__ uint64_t
static __inline__ uint8_t
static __inline__ uint16_t
the interface to translate instructions of and processor architecture
virtual etiss::plugin::gdb::GDBCore & getGDBCore()
returns arch dependent gdb functions.
virtual std::shared_ptr< VirtualStruct > getStruct()
Get the virtual structure of this CPUCore instance.
std::set< std::string > & fileglobalCode()
Contains a small code snipped.
@ PREINITIALDEBUGRETURNING
CodePart & prepend(CodePart::TYPE type)
CPUCore * plugin_core_
holds a pointer to the associated CPUCore instance.
std::string getPointerCode() const
returns a C code expression that allows to get or assign a pointer to the variable assigned to this t...
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)
structure to store breakpoints
etiss::uint32 **** instrbrkpt_
important: index maps are reversed to instruction pointer e.g pointer(0x0102030405060708) [POINTER !...
void set(etiss::uint64 addr, etiss::uint32 val)
etiss::uint32 get(etiss::uint64 addr)
virtual etiss::uint64 getInstructionPointer(ETISS_CPU *cpu)
allows to calculate the index of the instruction to be executed for breakpoint checks.
virtual std::string mapRegister(unsigned index)
the returned string identifies the register at the given index as defined by gdb.
virtual bool isLittleEndian()
returns true if the values are expected to be little endian
implements gdb's packet protocol
virtual bool snd(std::string answer, bool isnotification)
virtual std::string rcv(bool &isnotification)
virtual bool available(bool block=false)
gdb server implementation that is used as a plugin in etiss
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_
bool status_pending_jump_
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)...
unsigned execute_skip_count
BreakpointDB watchpoints_
unsigned execute_skip_index
Server(etiss::plugin::gdb::PacketProtocol &pp)
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
bool status_pending_kill_
BreakpointDB breakpoints_
void preDWriteCallback(etiss::uint64 addr)
void handlePacket(bool block)
unsigned minimal_pc_alignment
static Server * createTCPServer(std::map< std::string, std::string > options)
etiss::uint64 status_jumpaddr_
void preDReadCallback(etiss::uint64 addr)
etiss::int32 preInstructionCallback()
MM_EXPORT const int32_t NOERROR
uint8_t toByte(char h, char l)
converts 2 hex characters to a byte
std::string fromByte(uint8_t byte)
converts a byte to a hex string (without "0x" prefix);
std::string fromBytes(uint8_t *buf, size_t length)
converts a sequence of bytes to a representing hex string (without "0x" prefix)
uint8_t fromHex(char c)
convert a character to the hex value it represents(0-15)
void fromInt(std::string &string, INT val, bool isLittleEndian)
converts an integer type variable to a hexadecimal representation with the given endianness
std::string toString(const T &val)
conversion of type T to std::string.
void log(Verbosity level, std::string msg)
write log message at the given level.
float __ovld __cnfn length(float p)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
basic cpu state structure needed for execution of any cpu architecture.
etiss_uint64 instructionPointer
pointer to next instruction.
memory access and time synchronization functions.
void * handle
custom handle that will be passed to the functions of this structure
etiss_int32(* dbg_write)(void *handle, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
direct debug write
etiss_int32(* dbg_read)(void *handle, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
direct debug read