diff -ruN kozos18/i386-stub.c kozos19/i386-stub.c --- kozos18/i386-stub.c Mon Nov 19 18:42:25 2007 +++ kozos19/i386-stub.c Mon Nov 19 21:53:46 2007 @@ -752,6 +752,41 @@ return (numChars); } +int +hexToIntN (char **ptr, int num) +{ + int i; + int intValue = 0, hexValue; + + for (i = 0; i < num * 2; i++) + { + hexValue = hex (**ptr); + if (hexValue >= 0) + intValue = (intValue << 4) | hexValue; + else + break; + + (*ptr)++; + } + + return (intValue); +} + +char * +intNToHex (char *ptr, int intValue, int num) +{ + int hexValue; + + for (; num; num--) + { + hexValue = (intValue >> ((num - 1) * 8)) & 0xff; + *ptr++ = hexchars[hexValue >> 4]; + *ptr++ = hexchars[hexValue & 0xf]; + } + *ptr = '\0'; + return (ptr); +} + /* * This function does all command procesing for interfacing to gdb. */ @@ -939,7 +974,8 @@ countmax = hex(*ptr++) << 4; countmax += hex(*ptr++); - hex2mem(ptr, threadid, 8, 0); + threadid[0] = hexToIntN(&ptr, 4); + threadid[1] = hexToIntN(&ptr, 4); doneflag = 1; for (i = 0; i < THREAD_NUM; i++) { @@ -958,12 +994,14 @@ *ptr++ = hexchars[count >> 4]; *ptr++ = hexchars[count & 0xf]; *ptr++ = doneflag ? '1' : '0'; - ptr = mem2hex(threadid, ptr, 8, 0); + ptr = intNToHex(ptr, threadid[0], 4); + ptr = intNToHex(ptr, threadid[1], 4); if (!doneflag) { threadid[0] = 0; threadid[1] = (int)thp->id; - ptr = mem2hex(threadid, ptr, 8, 0); + ptr = intNToHex(ptr, threadid[0], 4); + ptr = intNToHex(ptr, threadid[1], 4); } *ptr++ = '\0'; }