Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: flammi on October 26, 2006, 02:22:27 pm

Title: How to debug a WinApi App with Threads
Post by: flammi on October 26, 2006, 02:22:27 pm
Hello,

I want to debug a Win32 Gui Project.
The only problem is, that this App uses Threads ( CreateThread(...) ). ( debugging of Apps without Threads works fine! )
The debugger didn't stop at breakpoints in the Thread i created, only breakpoints in the WinMain Thread were recognized.

How can i debug the Thread i created with CreateThread()???

Produce debugging Symbols is enabled.
I am using Code::Blocks 1.0 revision 3140 (a Nightly Build) with MingW.
Title: Re: How to debug a WinApi App with Threads
Post by: mandrav on October 26, 2006, 02:49:17 pm
Nothing special to do. Set a breakpoint inside the thread's code and it will break. If it doesn't (and breakpoint filename error is not printed in the log), it means the code was never run.
Title: Re: How to debug a WinApi App with Threads
Post by: Pecan on October 26, 2006, 03:02:41 pm
See the warnings about breakpoints in ctor/dtors.
http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks
Title: Re: How to debug a WinApi App with Threads
Post by: kkez on October 26, 2006, 03:26:42 pm
I just tested a breakpoint inside a thread proc in a winapi app, and gdb stops where it is. So that means your code wasn't run :)

Ps: Pecan, you forgot an s: http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks   :)
Title: Re: How to debug a WinApi App with Threads
Post by: MortenMacFly on October 26, 2006, 03:36:18 pm
See the warnings about breakpoints in ctor/dtors.
http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks
See: This page is useful from the first second... why didn't we do this in the first place...?! ;-)
Title: Re: How to debug a WinApi App with Threads
Post by: flammi on October 26, 2006, 04:27:42 pm
Hmm, i created a new Build Target and now the debugger is working fine. I don't changed anything in the code and at the position of the breakpoints.  :D

Thank you for your help.
Title: Re: How to debug a WinApi App with Threads
Post by: MortenMacFly on October 26, 2006, 06:10:56 pm
Hmm, i created a new Build Target and now the debugger is working fine. I don't changed anything in the code and at the position of the breakpoints.  :D
You may haver simply missed to *re*-build your sources after enabling the debugger switch. Thus the compiler still uses the old object files since they are up-to-date, but they don't inlcude debug symbols.
With regards, Morten.