Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
Qt Creator 2.2.1, Qt Creator 2.3.1, Qt Creator 2.4.0
-
None
-
Windows XP, 2003 server;
qtcreator 2.4.1 and older.
-
I611ef0244cb7ceca9e86ed35220ab3200cc55c45
Description
Hello
I have read a lot of articles about problems with debug console application under windows
(breakpoints are ignored, etc...)
Looks like relative bugs:
https://bugreports.qt-project.org/browse/QTCREATORBUG-4997
https://bugreports.qt-project.org/browse/QTCREATORBUG-6141
This bugs are in resolved status now.
Sorry but I have a doubts about resolving.
I have spend couple hours for research/experiments and find out the following:
Problem is in the file process_stub_win.c
There is part of code from original process_stub_win.c (Please look at the comment)
do { if (!WaitForDebugEvent (&dbev, INFINITE)){ systemError("Cannot fetch debug event, error %d\n"); } if (dbev.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT){ image = dbev.u.CreateProcessInfo.hFile; } if (dbev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT) { /* There is too late to attach dgb. gdb should be attached before this event. */ if (SuspendThread(pi.hThread) == (DWORD)-1) systemError("Cannot suspend debugee, error %d\n"); } if (!ContinueDebugEvent(dbev.dwProcessId, dbev.dwThreadId, DBG_CONTINUE)) systemError("Cannot continue debug event, error %d\n"); } while (dbev.dwDebugEventCode != EXCEPTION_DEBUG_EVENT);
GDB should be attached When all DLL`s has ben loaded.
So please replace this code by the following:
int suspended = 0; int dll_count = 0; do { WaitForDebugEvent (&dbev, INFINITE); SuspendThread(pi.hThread); if (dbev.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT){ image = dbev.u.CreateProcessInfo.hFile; } if (dbev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT){ dll_count++; if (dll_count>=4) { SuspendThread(pi.hThread); suspended = 1; } } ContinueDebugEvent(dbev.dwProcessId, dbev.dwThreadId, DBG_CONTINUE); ResumeThread(pi.hThread); } while (suspended==0);
By default, MinGW links four DLL`s nt.dll, kernel32.dll and two mingw dll`s,
so if it successfuly loaded then we should attach the gdb to process.