122#define NUMREGBYTES (NUMREGS * 4)
136#define STACKSIZE 10000
150asm(
".globl _return_to_prog");
151asm(
"_return_to_prog:");
152asm(
" movw _registers+44, %ss");
153asm(
" movl _registers+16, %esp");
154asm(
" movl _registers+4, %ecx");
155asm(
" movl _registers+8, %edx");
156asm(
" movl _registers+12, %ebx");
157asm(
" movl _registers+20, %ebp");
158asm(
" movl _registers+24, %esi");
159asm(
" movl _registers+28, %edi");
160asm(
" movw _registers+48, %ds");
161asm(
" movw _registers+52, %es");
162asm(
" movw _registers+56, %fs");
163asm(
" movw _registers+60, %gs");
164asm(
" movl _registers+36, %eax");
166asm(
" movl _registers+40, %eax");
168asm(
" movl _registers+32, %eax");
170asm(
" movl _registers, %eax");
191#define SAVE_REGISTERS1() \
192 asm ("movl %eax, _registers"); \
193 asm ("movl %ecx, _registers+4"); \
194 asm ("movl %edx, _registers+8"); \
195 asm ("movl %ebx, _registers+12"); \
196 asm ("movl %ebp, _registers+20"); \
197 asm ("movl %esi, _registers+24"); \
198 asm ("movl %edi, _registers+28"); \
199 asm ("movw $0, %ax"); \
200 asm ("movw %ds, _registers+48"); \
201 asm ("movw %ax, _registers+50"); \
202 asm ("movw %es, _registers+52"); \
203 asm ("movw %ax, _registers+54"); \
204 asm ("movw %fs, _registers+56"); \
205 asm ("movw %ax, _registers+58"); \
206 asm ("movw %gs, _registers+60"); \
207 asm ("movw %ax, _registers+62");
208#define SAVE_ERRCODE() \
210 asm ("movl %ebx, _gdb_i386errcode");
211#define SAVE_REGISTERS2() \
213 asm ("movl %ebx, _registers+32"); \
215 asm ("movl %ebx, _registers+40"); \
216 asm ("movw %ax, _registers+42"); \
218 asm ("movl %ebx, _registers+36"); \
220 asm ("movw %ss, _registers+44"); \
221 asm ("movw %ax, _registers+46"); \
222 asm ("movl %esp, _registers+16");
225#define CHECK_FAULT() \
226 asm ("cmpl $0, _mem_fault_routine"); \
227 asm ("jne mem_fault");
234asm (
" movl %eax, _gdb_i386errcode");
239asm (
" movl _mem_fault_routine, %eax");
254asm (
" movl $0, %eax");
255asm (
" movl %eax, _mem_fault_routine");
260#define CALL_HOOK() asm("call _remcomHandler");
274asm(
".globl __catchException3");
275asm(
"__catchException3:");
284asm(
".globl __catchException1");
285asm(
"__catchException1:");
294asm(
".globl __catchException0");
295asm(
"__catchException0:");
304asm(
".globl __catchException4");
305asm(
"__catchException4:");
314asm(
".globl __catchException5");
315asm(
"__catchException5:");
324asm(
".globl __catchException6");
325asm(
"__catchException6:");
334asm(
".globl __catchException7");
335asm(
"__catchException7:");
344asm(
".globl __catchException8");
345asm(
"__catchException8:");
355asm(
".globl __catchException9");
356asm(
"__catchException9:");
365asm(
".globl __catchException10");
366asm(
"__catchException10:");
376asm(
".globl __catchException12");
377asm(
"__catchException12:");
387asm(
".globl __catchException16");
388asm(
"__catchException16:");
399asm (
".globl __catchException13");
400asm (
"__catchException13:");
411asm (
".globl __catchException11");
412asm (
"__catchException11:");
423asm (
".globl __catchException14");
424asm (
"__catchException14:");
436asm(
"_remcomHandler:");
439asm(
" movl _stackPtr, %esp");
441asm(
" call _handle_exception");
454#define BREAKPOINT() __asm int 3;
456#define BREAKPOINT() asm(" int $3");
462#define WIN32_LEAN_AND_MEAN
515 if ((ch >=
'a') && (ch <=
'f'))
516 return (ch -
'a' + 10);
517 if ((ch >=
'0') && (ch <=
'9'))
519 if ((ch >=
'A') && (ch <=
'F'))
520 return (ch -
'A' + 10);
534 unsigned char xmitcsum;
566 xmitcsum =
hex (ch) << 4;
568 xmitcsum +=
hex (ch);
575 "bad checksum. My count = 0x%x, sent=0x%x. buf=%s\n",
748 switch (exceptionVector)
818 *intValue = (*intValue << 4) | hexValue;
836 int sigval, stepping;
846 printf (
"vector=%d, sr=0x%x, pc=0x%x\n",
908 if (regno >= 0 && regno <
NUMREGS)
1064int s_initial_breakpoint = 0;
1071int init_gdb_connect()
1075 ser_port =
fopen(
"COM1:",
"rwb");
1082 return fgetc(ser_port);
1097#define I386_EXCEPTION_CNT 17
1103 if (exc_nr < I386_EXCEPTION_CNT) {
1106 if (exc_nr==11 || exc_nr==13 || exc_nr==14) {
1121 if (exc_nr < I386_EXCEPTION_CNT) {
1126 if (s_initial_breakpoint) {
1127 s_initial_breakpoint = 0;
1133 win32_exception_handler(exc_info);
1152void disable_debugging()
1154 if (s_prev_exc_handler) {
1156 s_prev_exc_handler = 0;
1163#pragma comment(lib, "wsock32")
1166static int s_rem_fd = -1;
1168int init_gdb_connect()
1173 int srv_socket, rem_len;
1187 if (srv_socket == -1) {
1192 if (
bind(srv_socket, (
struct sockaddr*) &srv_addr,
sizeof(srv_addr)) == -1) {
1197 if (
listen(srv_socket, 4) == -1) {
1202 rem_len =
sizeof(rem_addr);
1205 s_rem_fd =
accept(srv_socket, (
struct sockaddr*)&rem_addr, &rem_len);
1235 LOG(
TEXT(
"debugger connection broken"));
1248 if (s_rem_fd != -1) {
1253 LOG(
TEXT(
"debugger connection broken"));
1264 if (!init_gdb_connect())
1269 s_initial_breakpoint = 1;
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI DECLSPEC_HOTPATCH SetUnhandledExceptionFilter(IN LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
GLuint GLuint GLsizei count
GLdouble GLdouble GLdouble r
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLenum const GLvoid * addr
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static const char hexchars[]
void putpacket(char *buffer)
char * hex2mem(char *buf, char *mem, int count, int may_fault)
void handle_exception(int exceptionVector)
static volatile int mem_err
static char remcomOutBuffer[BUFMAX]
#define SAVE_REGISTERS1()
#define SAVE_REGISTERS2()
int computeSignal(int exceptionVector)
int hexToInt(char **ptr, int *intValue)
static void(*volatile mem_fault_routine)()
static char remcomInBuffer[BUFMAX]
void debug_error(char *format)
void _returnFromException()
char * mem2hex(char *mem, char *buf, int count, int may_fault)
void set_char(char *addr, int val)
void set_debug_traps(void)
int remcomStack[STACKSIZE/sizeof(int)]
#define EXCEPTION_CONTINUE_SEARCH
#define EXCEPTION_CONTINUE_EXECUTION
_Check_return_opt_ _CRTIMP int __cdecl fgetc(_Inout_ FILE *_File)
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
int initialize_gdb_stub()
#define strcpy_s(d, l, s)
#define PAGE_EXECUTE_READWRITE
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
PEXCEPTION_RECORD ExceptionRecord
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER