Changeset 4648 for trunk/src/kernel32/oslibdebug.cpp
- Timestamp:
- Nov 20, 2000, 10:52:37 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/oslibdebug.cpp
r4387 r4648 1 /* $Id: oslibdebug.cpp,v 1. 4 2000-10-02 18:39:35sandervl Exp $ */1 /* $Id: oslibdebug.cpp,v 1.5 2000-11-20 09:52:37 sandervl Exp $ */ 2 2 3 3 /* 4 4 * OS/2 debug apis 5 5 * 6 * Copyright 1999 Edgar Buerkle 6 * Copyright 2000 Sander van Leeuwen 7 * Copyright 2000 Edgar Buerkle 8 * Copyright 2000 Michal Necasek 7 9 * 8 10 * Project Odin Software License can be found in LICENSE.TXT … … 36 38 VOID _Optlink DebugThread(VOID *argpid) 37 39 { 38 CHAR QueueName[30]=DEBUG_QUEUENAME; 39 CHAR SemName[30]=DEBUG_SEMNAME; 40 CHAR QSemName[30]=DEBUG_QSEMNAME; 41 HQUEUE QueueHandle=0; 42 HEV hevSem=0, hevQSem=0; 40 BOOL fTerminate = FALSE; 41 CHAR QueueName[30] = DEBUG_QUEUENAME; 42 CHAR SemName[30] = DEBUG_SEMNAME; 43 CHAR QSemName[30] = DEBUG_QSEMNAME; 44 HQUEUE QueueHandle = 0; 45 HEV hevSem = 0, 46 hevQSem = 0; 47 uDB_t DbgBuf = {0}; 43 48 int rc; 44 uDB_t DbgBuf={0};45 49 char path[CCHMAXPATH]; 46 50 Win32DllBase *winmod; 47 51 LPDEBUG_EVENT lpde; 48 52 ULONG *pid = (ULONG*)argpid; 53 ULONG staticPid = *pid; 49 54 char tmp[12]; 50 55 … … 91 96 } 92 97 93 while (rc == 0)98 while (rc == 0) 94 99 { 95 100 DosWaitEventSem(hevSem, SEM_INDEFINITE_WAIT); … … 104 109 dprintf(("DosDebug error: rc = %d", rc)); 105 110 111 if (fTerminate) // break out of the while loop 112 break; 113 106 114 switch (DbgBuf.Cmd) 107 115 { … … 109 117 dprintf(("DosDebug: GO ok")); 110 118 goto DosDebug_GO; 119 111 120 case DBG_N_Error: 112 121 dprintf(("DosDebug: Error %d", DbgBuf.Value)); … … 118 127 } 119 128 break; // end thread !!! 129 120 130 case DBG_N_ProcTerm: 121 dprintf(("DosDebug: Process terminated with rc %d\n", DbgBuf.Value));131 dprintf(("DosDebug: Process terminated with rc %d\n", DbgBuf.Value)); 122 132 lpde = (LPDEBUG_EVENT) malloc(sizeof(DEBUG_EVENT)); 123 133 lpde->dwDebugEventCode = EXIT_PROCESS_DEBUG_EVENT_W; … … 126 136 lpde->u.ExitThread.dwExitCode = DbgBuf.Value; 127 137 DosWriteQueue(QueueHandle, 0, sizeof(DEBUG_EVENT), lpde, 0); 128 break; 138 // We should now fire final DBG_C_Go and end processing. We shouldn't 139 // get any more debug events. 140 fTerminate = TRUE; 141 // goto DosDebug_GO; *pid is invalid?!? 142 DbgBuf.Cmd = DBG_C_Go; 143 DbgBuf.Pid = staticPid; 144 goto DebugApi; 145 break; 146 129 147 case DBG_N_Exception: 130 148 dprintf(("DosDebug: Exception")); … … 136 154 DbgBuf.Value = XCPT_CONTINUE_SEARCH; 137 155 goto DebugApi; 156 138 157 case DBG_N_ModuleLoad: 139 158 DosQueryModuleName(DbgBuf.Value, CCHMAXPATH, path); … … 161 180 DosWriteQueue(QueueHandle, 0, sizeof(DEBUG_EVENT), lpde, 0); 162 181 break; 182 163 183 case DBG_N_CoError: 164 184 dprintf(("DosDebug: Coprocessor Error")); … … 166 186 goto DosDebug_GO; 167 187 break; 188 168 189 case DBG_N_ThreadTerm: 169 190 dprintf(("DosDebug: Thread %d terminated with rc %d", DbgBuf.Tid,DbgBuf.Value)); … … 175 196 DosWriteQueue(QueueHandle, 0, sizeof(DEBUG_EVENT), lpde, 0); 176 197 break; 198 177 199 case DBG_N_AsyncStop: 178 200 dprintf(("DosDebug: Async stop")); 179 201 goto DosDebug_GO; 180 202 break; 203 181 204 case DBG_N_NewProc: 182 205 dprintf(("DosDebug: Debuggee started new Pid %d",DbgBuf.Value)); … … 198 221 DosWriteQueue(QueueHandle, 0, sizeof(DEBUG_EVENT), lpde, 0); 199 222 break; 223 200 224 case DBG_N_AliasFree: 201 225 dprintf(("DosDebug: AliasFree")); 202 226 goto DosDebug_GO; 203 227 break; 228 204 229 case DBG_N_Watchpoint: 205 230 dprintf(("DosDebug: WatchPoint")); 206 231 goto DosDebug_GO; 207 232 break; 233 208 234 case DBG_N_ThreadCreate: 235 // Note: Win32 debuggers expect a process creation event first! 209 236 dprintf(("DosDebug: Thread %d created",DbgBuf.Tid)); 237 238 if (DbgBuf.Tid == 1) { // Is this the first thread of a process? 239 // If so, fake a process creation event 240 dprintf(("DosDebug: Faking process creation event")); 241 lpde = (LPDEBUG_EVENT) malloc(sizeof(DEBUG_EVENT)); 242 lpde->dwDebugEventCode = CREATE_PROCESS_DEBUG_EVENT_W; 243 lpde->dwProcessId = *pid; 244 lpde->dwThreadId = 0; 245 //TODO: fill union 246 lpde->u.CreateProcessInfo.hFile = 0; 247 lpde->u.CreateProcessInfo.hProcess = 0; 248 lpde->u.CreateProcessInfo.hThread = 0; 249 lpde->u.CreateProcessInfo.lpBaseOfImage = NULL; 250 lpde->u.CreateProcessInfo.dwDebugInfoFileOffset = 0; 251 lpde->u.CreateProcessInfo.nDebugInfoSize = 0; 252 lpde->u.CreateProcessInfo.lpThreadLocalBase = NULL; 253 lpde->u.CreateProcessInfo.lpStartAddress = NULL; 254 lpde->u.CreateProcessInfo.lpImageName = NULL; 255 lpde->u.CreateProcessInfo.fUnicode = FALSE; 256 DosWriteQueue(QueueHandle, 0, sizeof(DEBUG_EVENT), lpde, 0); 257 } 210 258 lpde = (LPDEBUG_EVENT) malloc(sizeof(DEBUG_EVENT)); 211 259 lpde->dwDebugEventCode = CREATE_THREAD_DEBUG_EVENT_W; … … 218 266 DosWriteQueue(QueueHandle, 0, sizeof(DEBUG_EVENT), lpde, 0); 219 267 break; 268 220 269 case DBG_N_ModuleFree: 221 270 DosQueryModuleName(DbgBuf.Value, CCHMAXPATH, path); … … 235 284 DosWriteQueue(QueueHandle, 0, sizeof(DEBUG_EVENT), lpde, 0); 236 285 break; 286 237 287 case DBG_N_RangeStep: 238 288 dprintf(("DosDebug: RangeStep")); 239 289 goto DosDebug_GO; 240 290 break; 291 241 292 default: 242 293 dprintf(("DosDebug: Unkown Notify %d", DbgBuf.Cmd)); … … 246 297 } 247 298 299 dprintf(("DosDebug - ending the service thread")); 248 300 DosCloseQueue(QueueHandle); 249 301 DosCloseEventSem(hevSem); 250 302 DosCloseEventSem(hevQSem); 251 *pid = 0; 252 303 // *pid = 0; No can do - for some reason *pid is invalid by now 253 304 } 305 254 306 //****************************************************************************** 255 307 //****************************************************************************** … … 389 441 390 442 tid = _beginthread(DebugThread, NULL, 1024, (PVOID) pid); 391 if (tid == 0)443 if (tid == 0) 392 444 { 393 dprintf(("OSLibStartDebugger: Could create debug thread"));445 dprintf(("OSLibStartDebugger: Could not create debug thread!")); 394 446 SetFS(sel); 395 447 return;
Note:
See TracChangeset
for help on using the changeset viewer.