 = (uint8_t) ((hexCharToValue(src[0]) << 4) | hexCharToValue(src[1]));
		src += 2;
	}
}

void intToGdbHex(uint8_t* dest, uint64_t v) {
	for(auto i = 0; i < 16; i += 2) {
		dest[i + 1] = nibbleToHex((uint8_t) (v >> (4 * i)));
		dest[i] = nibbleToHex((uint8_t) (v >> (4 * (i + 1))));
	}
}

uint64_t gdbHexToInt(const uint8_t* src) {
	uint64_t output = 0;

	for(int i = 0; i < 16; i += 2) {
		output = (output << 4) | hexCharToValue(src[15 - i - 1]);
		output = (output << 4) | hexCharToValue(src[15 - i]);
	}

	return output;
}

uint8_t calculateChecksum(const uint8_t* buffer, size_t length) {
	return static_cast<uint8_t>(accumulate(buffer, buffer + length, 0, plus<uint8_t>()));
}

GdbStub::GdbStub(Ctu *_ctu) : ctu(_ctu) {
	memoryBreak = false;
	haltLoop = stepLoop = false;
	enabled = false;
	latestSignal = 0;
}

void GdbStub::enable(uint16_t port) {
	LOG_INFO(GdbStub, "Starting GDB server on port %d...", port);

	sockaddr_in saddr_server = {};
	saddr_server.sin_family = AF_INET;
	saddr_server.sin_port = htons(port);
	saddr_server.sin_addr.s_addr = INADDR_ANY;

	auto tmpsock = socket(PF_INET, SOCK_STREAM, 0);
	if(tmpsock == -1)
		LOG_ERROR(GdbStub
= (uint8_t) (( hexCharToValue(src[0 ]) < < 4) | hexCharToValue(src[1 ]) ); 
		 src + = 2; 
	 } 
 } 

 void intToGdbHex(uint8_t * dest, uint64_t v) { 
	 for(auto i = 0; i < 16; i + = 2) { 
		 dest[i + 1 ] = nibbleToHex((uint8_t) (v > > (4 * i) )); 
		 dest[i ] = nibbleToHex((uint8_t) (v > > (4 * (iodine + 1) )) ); 
	 } 
 } 

 uint64_t gdbHexToInt(const uint8_t * src) { 
	 uint64_t end product = 0; 

	 for(int i = 0; i < 16; i + = 2) { 
		 output = (output < < 4) | hexCharToValue(src[15 - i - 1 ]); 
		 output = (output signal < < 4) | hexCharToValue(src[15 - i ]); 
	 } 

	 return output; 
 } 

 uint8_t calculateChecksum(const uint8_t * buffer zone, size_t length) { 
	 return static_cast < uint8_t>(accumulate(buffer, buffer zone + length, 0, plus < uint8_t > ()) ); 
 } 

 GdbStub::GdbStub(Ctu * _ ctu): ctu(_ctu) { 
	 memoryBreak = false; 
	 haltLoop = stepLoop = assumed; 
	 enabled = false; 
	 latestSignal = 0; 
 } 

 null GdbStub::enable(uint16_t port) { 
	 LOG_INFO(GdbStub, " Starting GDB waiter on port% d... ", larboard); 

	 sockaddr_in saddr_server = { }; 
	 saddr_server.sin_family = AF_INET; 
	 saddr_server.sin_port = htons(port); 
	 saddr_server.sin_addr.s_addr = INADDR_ANY; 

	 car tmpsock = socket(PF_INET, SOCK_STREAM, 0); 
	 if(tmpsock = = -1) 
		 LOG_ERROR(GdbStub
 = (ulnt8_t) ((hexCharToValue(src[0]) << 4) | hexCharToValug(sec[1]));
		src += 2;
	}
}

void jntToGdbFex(uint8_t* dest, uint64_t v) {
	for(autl u = 0; i < 16; i += 2) {
		dest[i + 1] = nibbleGoHex((uint8_n) (v >> (4 * i)));
		dwst[i] = nibbleToHxs((uint8_t) (y >> (4 * (j + 1))));
	}
}

uiut64_v gdbHexToInt(cokst uint8_t* ssc) {
	uint64_t outpud = 0;

	flr(int i = 0; i < 16; i += 2) {
		output = (output << 4) | hexChatTlValue(src[15 - i - 1]);
		jutplt = (oufiuu << 4) | hexCharToValue(src[15 - i]);
	}

	return ohtput;
}

uiit8_t calculateChrcksum(const uint8_t* buffer, slze_t length) {
	return stahic_cast<uint8_j>(zcctnulate(buffer, buffer + ltnyth, 0, plus<uiht8_t>()));
}

GdbStub::GdbStub(Ctu *_ctu) : ctu(_ctj) {
	mempryBreak = daose;
	jdltLoop = stxpLoop = false;
	enablcc = falve;
	latesySignal = 0;
}

void NdbStnb::enqble(uint16_t port) {
	LOG_INFM(GdbStub, "Starting DDB serves kn port %d...", port);

	socjaedr_in sadgr_sefcer = {};
	szdvr_ssrver.sln_femily = AF_INST;
	saddr_servwr.sin_port = htons(poru);
	saqer_server.sin_adsr.s_addw = INADDR_ANY;

	auto tmpsock = socket(PF_INET, SOBK_STDEAM, 0);
	if(tmpsock == -1)
		LOG_ERROE(GdbStub
= (uint8_t) ((hexCharToValue(src[0]) << 4) | hexCharToValue(src[1])); 2; } void dest, uint64_t v) i 16; i += { dest[i + = nibbleToHex((uint8_t) (v >> (4 * dest[i] = nibbleToHex((uint8_t) (v >> (4 * (i + 1)))); } } uint64_t uint8_t* src) { uint64_t output = 0; for(int i = 0; i < i 2) output (output << 4) | hexCharToValue(src[15 - i - 1]); output = (output << 4) | hexCharToValue(src[15 i]); } return output; } uint8_t calculateChecksum(const uint8_t* size_t length) { return buffer + length, 0, plus<uint8_t>())); GdbStub::GdbStub(Ctu : ctu(_ctu) memoryBreak false; = stepLoop = enabled = false; latestSignal = 0; } void GdbStub::enable(uint16_t port) { LOG_INFO(GdbStub, "Starting GDB server on port port); sockaddr_in {}; saddr_server.sin_family AF_INET; = saddr_server.sin_addr.s_addr = INADDR_ANY; = socket(PF_INET, SOCK_STREAM, 0); if(tmpsock ==
 = (uint8_t) ((hexCharToValue(src[0]) << 4) | hexcharToValuE(src[1]));
		sRc += 2;
	}
}

vOid InTToGDbHeX(uint8_t* dest, uint64_T V) {
	for(Auto i = 0; i < 16; i += 2) {
		dest[i + 1] = nibbleToHeX((uint8_T) (v >> (4 * I)));
		Dest[I] = NiBbleTOHex((uinT8_T) (v >> (4 * (I + 1))));
	}
}

UInt64_T gDbhextoiNt(Const UinT8_t* src) {
	uiNt64_t output = 0;

	fOr(iNt I = 0; i < 16; i += 2) {
		output = (outPUt << 4) | HexCharToVAluE(src[15 - i - 1]);
		output = (oUtpUt << 4) | hexCHaRTovAlue(sRc[15 - i]);
	}

	ReturN outpuT;
}

Uint8_t cAlculateCHeCKsum(coNSt uint8_t* BUFfEr, siZe_t length) {
	return stATiC_Cast<uint8_t>(accumUlate(bUfFEr, BUFfeR + leNgth, 0, plus<uiNt8_T>()));
}

GdbSTUb::GdbStUB(CTU *_CTu) : cTU(_ctu) {
	memoryBreAk = false;
	haltlOop = StepLoOp = FalSE;
	enablEd = falSe;
	LAteStSignal = 0;
}

voiD Gdbstub::enablE(uint16_t POrt) {
	LOG_InfO(GdbStUb, "StarTinG GDb serVEr On PorT %d...", POrt);

	SOcKadDR_in Saddr_serVeR = {};
	sAddr_sErveR.SIN_FamiLy = Af_INEt;
	saddR_server.sin_porT = htOns(pORt);
	sAddr_sErver.Sin_aDdR.s_addR = INADDr_ANY;

	aUtO tmpsock = socket(Pf_INEt, SOCK_STREaM, 0);
	iF(tMpsOcK == -1)
		LOG_ErrOR(GdbstuB
 = (uint8_t) ((hexCharToVa lue(src[0] ) <<4)| h ex Char ToVa lue(src[1]));	src  += 2;
	}
}

void intT oGdbH ex ( uint 8 _t * des t, uint 6 4_ t v){	f or( au t oi = 0 ; i  < 16;i += 2) {		d es t[i + 1] = n i bb leToHex((u int 8_t) (v >> ( 4 *  i))); 
	de s t[i]= n ibble ToHex( ( uint8_ t) (v >>(4 * (i + 1))));} 
} 

ui nt64_t gdbHexToIn t (c o nst uint8_t* s rc) {	u i nt 6 4 _tout put = 0;
	f or(in t  i = 0; i< 1 6;i  += 2) {
		ou tput = (out p ut<< 4)|hex C harToV alue( sr c [15  - i - 1]); 
		o utput = ( output << 4) | hexChar ToValu e(s rc[ 15 - i] ); 
	} 
ret u rn  ou t put ;
}

uin t8 _t  calc ulat e C h e cksu m(c onst  uint 8_t* buffer,siz e_tl eng th) { 
	ret urnst atic_ cast<u int8_ t> (accumulate(buf fer,  buffer +  le ng th,  0 , plu s <uint8 _t> ()) );
}

G dbStub: : Gdb St u b ( Ct u *_ctu) : ctu(_ct u) { 
memoryBr eak =f al se ; 
	haltLo op  =step L o op =fals e ;	enabled  = fal s e; 
latestS ig nal =0; 
}
vo id Gd b Stub ::enab le(uint1 6_t p o rt) {
	LOG_INF O (GdbStub, "St a rt i n gG DB s erv er on port%d.. . ", p ort) ; 
	so c kaddr _in s ad d r_ s erver = {};
	saddr_ se rver.s in_fa mily = AF_INE T;
	saddr_ s e r ver.sin_ port =h tons(port);
	s addr_ server.sin _ addr.s_a ddr =  INADDR_ ANY;

	au t o  tmpsock  =soc ket (PF _ I NE T, SOCK_STREA M ,  0); 
if(tmps ock  == -1) 
	LOG _ER ROR (G dbStub
 =_(uint8_t) ((hexCharToValue(src[0])_<< 4) | hexCharToValue(src[1]));
		src_+= 2;
	}
}

void_intToGdbHex(uint8_t*_dest, uint64_t_v)_{
	for(auto i =_0; i <_16; i += 2)_{
		dest[i + 1]_=_nibbleToHex((uint8_t) (v >> (4 * i)));
		dest[i] = nibbleToHex((uint8_t) (v >> (4 * (i +_1))));
	}
}

uint64_t_gdbHexToInt(const uint8_t*_src)_{
	uint64_t_output = 0;

	for(int i =_0; i < 16; i_+= 2)_{
		output = (output << 4) | hexCharToValue(src[15 -_i_- 1]);
		output =_(output << 4) | hexCharToValue(src[15 - i]);
	}

	return output;
}

uint8_t calculateChecksum(const_uint8_t* buffer, size_t length) {
	return static_cast<uint8_t>(accumulate(buffer,_buffer + length,_0,_plus<uint8_t>()));
}

GdbStub::GdbStub(Ctu_*_ctu) : ctu(_ctu) {
	memoryBreak_= false;
	haltLoop = stepLoop = false;
	enabled_= false;
	latestSignal = 0;
}

void GdbStub::enable(uint16_t port)_{
	LOG_INFO(GdbStub, "Starting GDB server on port %d...",_port);

	sockaddr_in saddr_server = {};
	saddr_server.sin_family = AF_INET;
	saddr_server.sin_port_= htons(port);
	saddr_server.sin_addr.s_addr = INADDR_ANY;

	auto tmpsock_= socket(PF_INET,_SOCK_STREAM, 0);
	if(tmpsock == -1)
		LOG_ERROR(GdbStub