122 #define NUMREGBYTES (NUMREGS * 4) 136 #define STACKSIZE 10000 150 asm(
".globl _return_to_prog");
151 asm(
"_return_to_prog:");
152 asm(
" movw _registers+44, %ss");
153 asm(
" movl _registers+16, %esp");
154 asm(
" movl _registers+4, %ecx");
155 asm(
" movl _registers+8, %edx");
156 asm(
" movl _registers+12, %ebx");
157 asm(
" movl _registers+20, %ebp");
158 asm(
" movl _registers+24, %esi");
159 asm(
" movl _registers+28, %edi");
160 asm(
" movw _registers+48, %ds");
161 asm(
" movw _registers+52, %es");
162 asm(
" movw _registers+56, %fs");
163 asm(
" movw _registers+60, %gs");
164 asm(
" movl _registers+36, %eax");
166 asm(
" movl _registers+40, %eax");
168 asm(
" movl _registers+32, %eax");
170 asm(
" 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"); 234 asm (
" movl %eax, _gdb_i386errcode");
239 asm (
" movl _mem_fault_routine, %eax");
254 asm (
" movl $0, %eax");
255 asm (
" movl %eax, _mem_fault_routine");
260 #define CALL_HOOK() asm("call _remcomHandler"); 274 asm(
".globl __catchException3");
275 asm(
"__catchException3:");
284 asm(
".globl __catchException1");
285 asm(
"__catchException1:");
294 asm(
".globl __catchException0");
295 asm(
"__catchException0:");
304 asm(
".globl __catchException4");
305 asm(
"__catchException4:");
314 asm(
".globl __catchException5");
315 asm(
"__catchException5:");
324 asm(
".globl __catchException6");
325 asm(
"__catchException6:");
334 asm(
".globl __catchException7");
335 asm(
"__catchException7:");
344 asm(
".globl __catchException8");
345 asm(
"__catchException8:");
355 asm(
".globl __catchException9");
356 asm(
"__catchException9:");
365 asm(
".globl __catchException10");
366 asm(
"__catchException10:");
376 asm(
".globl __catchException12");
377 asm(
"__catchException12:");
387 asm(
".globl __catchException16");
388 asm(
"__catchException16:");
399 asm (
".globl __catchException13");
400 asm (
"__catchException13:");
411 asm (
".globl __catchException11");
412 asm (
"__catchException11:");
423 asm (
".globl __catchException14");
424 asm (
"__catchException14:");
436 asm(
"_remcomHandler:");
439 asm(
" movl _stackPtr, %esp");
441 asm(
" 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)
1064 int s_initial_breakpoint = 0;
1071 int init_gdb_connect()
1075 ser_port =
fopen(
"COM1:",
"rwb");
1082 return fgetc(ser_port);
1091 #else // DEBUG_SERIAL 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);
1152 void disable_debugging()
1154 if (s_prev_exc_handler) {
1156 s_prev_exc_handler = 0;
1160 #define _INC_WINDOWS 1163 #pragma comment(lib, "wsock32") 1166 static int s_rem_fd = -1;
1168 int 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);
1221 #endif // DEBUG_SERIAL 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;
int remcomStack[STACKSIZE/sizeof(int)]
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
#define SAVE_REGISTERS2()
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
static void(*volatile mem_fault_routine)()
char * hex2mem(char *buf, char *mem, int count, int may_fault)
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
GLdouble GLdouble GLdouble r
int hexToInt(char **ptr, int *intValue)
GLuint GLuint GLsizei count
static const char hexchars[]
void _returnFromException()
int initialize_gdb_stub()
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
void set_char(char *addr, int val)
#define EXCEPTION_CONTINUE_EXECUTION
GLenum GLuint GLenum GLsizei const GLchar * buf
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI DECLSPEC_HOTPATCH SetUnhandledExceptionFilter(IN LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
GLenum GLuint GLenum GLsizei length
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
void debug_error(char *format)
#define SAVE_REGISTERS1()
void putpacket(char *buffer)
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
static volatile int mem_err
GLenum const GLvoid * addr
static char remcomOutBuffer[BUFMAX]
#define strcpy_s(d, l, s)
PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
void set_debug_traps(void)
char * mem2hex(char *mem, char *buf, int count, int may_fault)
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
#define EXCEPTION_CONTINUE_SEARCH
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
static char remcomInBuffer[BUFMAX]
PEXCEPTION_RECORD ExceptionRecord
#define PAGE_EXECUTE_READWRITE
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
void handle_exception(int exceptionVector)
int computeSignal(int exceptionVector)
_Check_return_opt_ _CRTIMP int __cdecl fgetc(_Inout_ FILE *_File)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *