56 #include "etiss/jit/types.h"
79 size_t cur = buffer.find(
c);
82 while (cur != std::string::npos)
84 if (buffer[cur - 1] !=
'}' && (cur <= 1 || buffer[cur - 2] !=
'}'))
88 cur = buffer.find(
c, cur);
95 while (buffer.length() > pos)
97 if (buffer[pos] ==
'+' || buffer[pos] ==
'-')
99 int ret = (
int)buffer[pos];
103 else if (buffer[pos] ==
'%' || buffer[pos] ==
'$')
105 std::string substr = buffer.substr(pos);
107 if (cpos == std::string::npos)
109 pos = pos + cpos + 3;
111 else if (buffer[pos] !=
' ')
117 std::cout <<
"ERROR: gdb transmission corrupted; aborting" <<
stream_code_info << std::endl;
127 if (dol == std::string::npos && per == std::string::npos)
129 return std::string::npos;
131 else if (dol == std::string::npos)
135 else if (per == std::string::npos)
141 return dol < per ? dol : per;
146 if (prefix.length() >
str.length())
148 return str.substr(0, prefix.length()) == prefix;
154 if (
command ==
"QStartNoAckMode")
209 if (diamond == std::string::npos)
212 if (
buffer.length() < diamond + 1 + 2)
217 std::string tmp =
buffer.substr(1, diamond - 1);
219 for (
unsigned i = 0; i < tmp.length(); i++)
221 chksm = chksm + (
uint8_t)tmp[i];
240 if (tmp.find(
'}') == std::string::npos && tmp.find(
'*') == std::string::npos)
249 for (
unsigned i = 0; i <
command.length(); i++)
255 for (
int j = 0; j < (
int)
command[i + 1] - 29; j++)
273 for (
unsigned i = 0; i < tmp.length(); i++)
277 if (i + 1 < tmp.length())
279 command.push_back(tmp[++i] ^ 0x20);
283 std::cout <<
"ERROR: PacketProtocol::available() or its parser functions contain an error"
308 std::string pack = isnotification ?
"%" :
"$";
309 for (
unsigned i = 0; i < answer.length(); i++)
311 if (answer[i] ==
'}' || answer[i] ==
'#' || answer[i] ==
'$' || answer[i] ==
'%' || answer[i] ==
'*')
314 pack.push_back(answer[i] ^ 0x20);
318 pack.push_back(answer[i]);
323 for (
unsigned i = 1; i < pack.length() - 1; i++)
325 chksm = chksm + (
uint8_t)pack[i];
349 std::cout <<
"ERROR: gdp protocol implementation contains an error" <<
stream_code_info << std::endl;
352 std::this_thread::sleep_for(std::chrono::milliseconds(1));
size_t PacketProtocol_getPacketStart(std::string &buffer)
size_t PacketProtocol_findUE(std::string &buffer, char c)
bool PacketProtocol_startsWith(const std::string &str, const std::string &prefix)
int PacketProtocol_findResponse(std::string &buffer)
__device__ __2f16 float c
static __inline__ uint8_t
interface for gdb connections.
virtual bool isRelyable()
virtual void clearBREAK()
virtual bool pendingBREAK()
virtual std::string rcv()=0
virtual bool available()=0
virtual bool snd(std::string answer)=0
virtual PacketProtocol & getPacketProtocol()
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)
bool command_isnotification
virtual void tryReadPacket()
virtual bool _available(bool block)
PacketProtocol(Connection &connection)
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);