Author Topic: How to debug a WinApi App with Threads  (Read 6099 times)

flammi

  • Guest
How to debug a WinApi App with Threads
« 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.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: How to debug a WinApi App with Threads
« Reply #1 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.
Be patient!
This bug will be fixed soon...

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2808
Re: How to debug a WinApi App with Threads
« Reply #2 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
« Last Edit: October 26, 2006, 04:18:50 pm by Pecan »

Offline kkez

  • Almost regular
  • **
  • Posts: 153
    • WinapiZone
Re: How to debug a WinApi App with Threads
« Reply #3 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   :)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9693
Re: How to debug a WinApi App with Threads
« Reply #4 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...?! ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

flammi

  • Guest
Re: How to debug a WinApi App with Threads
« Reply #5 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9693
Re: How to debug a WinApi App with Threads
« Reply #6 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ