Author Topic: Debugging multithreaded applications  (Read 5116 times)

BigJim

  • Guest
Debugging multithreaded applications
« on: March 17, 2007, 11:07:01 pm »
Hi! For the last 10 years or so I've been using Borland's 5.1 C++ compiler, but under XP it's starting to behave a little oddly, so, after doing a lot of research, I've started using C::B (with gcc & gdb) and really like it.

However, when debugging, if I hit F4 to run the program to the cursor, sometimes it doesn't - it just runs the program beyond the desired point. I'm working on a multithreaded application - is there some switch or something I should be using to tell C::B/gcc/gdb it's multithreaded?

TIA

DonSixto

  • Guest
Re: Debugging multithreaded applications
« Reply #1 on: March 22, 2007, 04:50:01 pm »
Hi!
I tested it under linux (fc6 c::b svn 3592, gcc, gdb 6.5-15.fc6rh) and win xp (c::b svn 3737, mingw32-gcc 3.4.4, gdb 6.3) and it works right in both platforms. I used pthread in linux, pthread.2 in winxp.
You can press F4 when gdb is waiting for an action from you. Otherwise, it will not catch it.
The same hapens with breakpoints, you can set them when gdb is waiting for an action from you, otherwise it does not set it (in borland debugger, you can set breakpoints even if the program is running).
The default C::B Debug configuration is good enough for debugging.
In particular, for debugging you must have -g option set (project | build options | compiler settings | compiler flags | produce debugging symbols), remove all optimization options in the same screen, and unset the option 'strip all symbols from binary' ('linker | general | include debug info' equivalent in borland).

Hope this helps.