applied Fix GDB support patch, needs testing, but patch provider verified it to work.

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@881 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
squall-leonhart 2009-08-08 15:28:56 +00:00
parent 9d9005542c
commit 6cb59fe795
2 changed files with 150 additions and 114 deletions

View File

@ -127,12 +127,12 @@ bool remoteTcpInit()
int error = WSAGetLastError(); int error = WSAGetLastError();
#endif // _WIN32 #endif // _WIN32
} }
char dummy; //char dummy;
recv(s2, &dummy, 1, 0); //recv(s2, &dummy, 1, 0);
if(dummy != '+') { //if(dummy != '+') {
fprintf(stderr, "ACK not received\n"); // fprintf(stderr, "ACK not received\n");
exit(-1); // exit(-1);
} //}
remoteSocket = s2; remoteSocket = s2;
// close(s); // close(s);
} }
@ -167,14 +167,14 @@ int remotePipeRecv(char *data, int len)
bool remotePipeInit() bool remotePipeInit()
{ {
char dummy; // char dummy;
if (read(0, &dummy, 1) == 1) // if (read(0, &dummy, 1) == 1)
{ // {
if(dummy != '+') { // if(dummy != '+') {
fprintf(stderr, "ACK not received\n"); // fprintf(stderr, "ACK not received\n");
exit(-1); // exit(-1);
} // }
} // }
return true; return true;
} }
@ -230,16 +230,13 @@ void remotePutPacket(const char *packet)
*p++ = hex[csum & 15]; *p++ = hex[csum & 15];
*p++ = 0; *p++ = 0;
// printf("Sending %s\n", buffer); // printf("Sending %s\n", buffer);
remoteSendFnc(buffer, (int)count + 4);
char c = 0; char c = 0;
while(c != '+'){
remoteSendFnc(buffer, (int)count + 4);
remoteRecvFnc(&c, 1); remoteRecvFnc(&c, 1);
/* // fprintf(stderr,"sent:%s recieved:%c\n",buffer,c);
if(c == '+') }
printf("ACK\n");
else if(c=='-')
printf("NACK\n");
*/
} }
#define debuggerReadMemory(addr) \ #define debuggerReadMemory(addr) \
@ -560,7 +557,9 @@ void remoteStubMain()
remoteResumed = false; remoteResumed = false;
} }
const char *hex = "0123456789abcdef";
while(1) { while(1) {
char ack;
char buffer[1024]; char buffer[1024];
int res = remoteRecvFnc(buffer, 1024); int res = remoteRecvFnc(buffer, 1024);
@ -573,16 +572,35 @@ void remoteStubMain()
debugger = false; debugger = false;
break; break;
} }
if(res < 1024){
buffer[res] = 0;
}else{
fprintf(stderr, "res=%d\n",res);
}
// fprintf(stderr, "Received %s\n", buffer); // fprintf(stderr, "res=%d Received %s\n",res, buffer);
char *p = buffer; char c = buffer[0];
char c = *p++; char *p = &buffer[0];
char pp = '+'; int i = 0;
remoteSendFnc(&pp, 1); unsigned char csum = 0;
while(i < res){
if(c != '$') if(buffer[i] == '$'){
continue; i++;
c= *p++; csum = 0;
c = buffer[i];
p = &buffer[i+1];
while((i<res) && (buffer[i] !='#')){
csum += buffer[i];
i++;
}
}else if(buffer[i] == '#'){
buffer[i] = 0;
if((i+2)<res){
if((buffer[i+1] == hex[csum>>4]) && (buffer[i+2] == hex[csum & 0xf])){
ack = '+';
remoteSendFnc(&ack, 1);
//fprintf(stderr, "SentACK c=%c\n",c);
//process message...
switch(c) { switch(c) {
case '?': case '?':
remoteSendSignal(); remoteSendSignal();
@ -660,12 +678,29 @@ void remoteStubMain()
break; break;
default: default:
{ {
*(strchr(p, '#') + 3) = 0;
fprintf(stderr, "Unknown packet %s\n", --p); fprintf(stderr, "Unknown packet %s\n", --p);
remotePutPacket(""); remotePutPacket("");
} }
break; break;
} }
}else{
fprintf(stderr, "bad chksum csum=%x msg=%c%c\n",csum,buffer[i+1],buffer[i+2]);
ack = '-';
remoteSendFnc(&ack, 1);
fprintf(stderr, "SentNACK\n");
}//if
i+=3;
}else{
fprintf(stderr, "didn't receive chksum i=%d res=%d\n",i,res);
i++;
}//if
}else{
if(buffer[i] != '+'){ //ingnore ACKs
fprintf(stderr, "not sure what to do with:%c i=%d res=%d\n",buffer[i],i,res);
}
i++;
}//if
}//while
} }
} }

View File

@ -2190,6 +2190,7 @@ int main(int argc, char **argv)
exit(-1); exit(-1);
} }
} else { } else {
soundInit();
cartridgeType = 0; cartridgeType = 0;
strcpy(filename, "gnu_stub"); strcpy(filename, "gnu_stub");
rom = (u8 *)malloc(0x2000000); rom = (u8 *)malloc(0x2000000);