[Haifux] Multi-thread debugging for C++ on Linux

Ohad Lutzky ohad at lutzky.net
Fri Nov 28 21:29:30 MSK 2008

Hello all,

Allow me to add a certain point which wasn't clear in my question:
This is NOT for me. Myself, I use vim and gdb, and rarely ever write
software with more than one thread (per process, that is ;) ). This is
intended for other users, which are not necessarily highly familiar
with Linux programming, and the ideal solution for my problem would be
an all-in-one GUI debugger (such as DDD). I am, however, open to any
neat tricks you might have in mind, which are not in
silver-platter-GUI form.

Hai: Thanks, I'll take a look at Insight. (Doesn't seem as nice as ddd
though, not even a builtin gdb console... what features should I look
Yotam: We're a VIM shop ;) (and still, would this be beneficial? I'm
pretty sure that it's a rather thin frontend)
Gabi: Debugging is rarely intended to verify code correctness, nay? :)
But gdb is indeed capable of those features, they just seemed pretty
basic to me.
Guy: The solution to the single-stepping problem would essentially be
"suspend all threads but this one", which indeed gdb can't seem to do.
I'm not sure why.

At any rate, thanks for the input, guys. I guess the answer I got is
that gdb is still the best thread-debugging solution in Linux.

On Fri, Nov 28, 2008 at 6:40 PM, guy keren <choo at actcom.co.il> wrote:
> i did not understand what feature you want.
> gdb supports suspending all the threads together (which is what you normally want), continuing all of them together, and doing a single-step in one thread (which has the annoying side-effect of allowing other threads to also continue executing at the same time - this is the one feature of gdb which i find annoying).
> generally, i don't debug multi-threaded programs using a debugger. i use logs, a single log file, where each line contains the thread-id (so you'll be able to filter out messages belonging to a single thread of execution). i use the debugger for two major activities:
> 1. debugging a crashed process (i.e. analysis of a code file) - gdb supports this and shows you the stacks and variables of all the threads.
> 2. break-pointing a program at a given command (or when a given memory address is being altered or accessed) - and studing the state of the program without single-stepping.
> if you find the solution to single-stepping a single thread - let me know. this will be a nice feature. i once thought i saw a way to do it, but when i searched for this again - i didn't find it.
> --guy
> Ohad Lutzky wrote:
>> Hello all,
>> I am examining the issue of debugging multi-threaded (specifically using pthreads, and written in C or C++) applications in Linux. The basic tools, as far as I can tell, are somewhat lacking; while the DDD documentation does have a screenshot showing a "suspend" button in Status->Threads, this does not show up in my version of ddd (3.3.11), and I can't really figure out how to do this from within gdb. Is it even possible? As far as I know, this is possible with Java, and I'm guessing that it has to do with additional JRE instrumentation (the debugger tells JRE to suspend the thread, and while the Linux thread is running, the JRE code therein does a sched_yield).
>> So my question are:
>> 1. Am I missing something, and this is in fact possible with GDB? If so, is there a graphical interface (my coworkers are fond of those...) which supports this?
>> 2. Is there a different Linux (on x86) debugger which does support this?
>> 3. What is the situation of this problem on other OSes?
>> 4. What other neat thread-related debugging tools (other than suspending individual threads, that is) are there, and which debuggers support them?
>> I've been trying to google the answers to these questions, but so far I've come up short. Any wise keywords would be appreciated :)
>> --
>> Man is the only animal that laughs and weeps, for he is the only animal that is struck with the difference between what things are and what they ought to be.
>> - William Hazlitt
>> Ohad Lutzky
>> ------------------------------------------------------------------------
>> _______________________________________________
>> Haifux mailing list
>> Haifux at haifux.org
>> http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux

Man is the only animal that laughs and weeps, for he is the only
animal that is struck with the difference between what things are and
what they ought to be.
- William Hazlitt

Ohad Lutzky

More information about the Haifux mailing list