<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16705" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=883445315-28112008><FONT face=Arial color=#0000ff
size=2>Hi</FONT></SPAN></DIV>
<DIV><SPAN class=883445315-28112008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=883445315-28112008><FONT face=Arial color=#0000ff size=2>This
is an interesting issue you have raised here.</FONT></SPAN></DIV>
<DIV><SPAN class=883445315-28112008><FONT face=Arial color=#0000ff
size=2>Indeed, in JVM it seems to be more easy to breakpoint a thread, but
actually there is nothing too special that Java does that other native debugger
can't do.</FONT></SPAN></DIV>
<DIV><SPAN class=883445315-28112008><FONT face=Arial color=#0000ff size=2>One
type of breakpoints is called software breakpoints and are based on int3 Intel
instruction (special type of software trap/exception, like int0x80 sys call). It
should be inserted at the code level.</FONT></SPAN></DIV>
<DIV><SPAN class=883445315-28112008><FONT face=Arial color=#0000ff size=2>So as
long as the threads are kernel threads and have different pids (which is what
happens in latest fixed versions of POSIX Linux threads), it should be possible
to breakpoint each thread <FONT face=Arial color=#0000ff
size=2></FONT>separately.</FONT></SPAN></DIV>
<DIV><SPAN class=883445315-28112008><FONT face=Arial color=#0000ff size=2>There
is also something called hardware breakpoints: <A
href="http://www.codeproject.com/KB/debug/hardwarebreakpoint.aspx">http://www.codeproject.com/KB/debug/hardwarebreakpoint.aspx</A></FONT></SPAN></DIV>
<DIV><SPAN class=883445315-28112008><FONT face=Arial color=#0000ff size=2>They
are used to data breakpoints - when ever some data address changes, it
breakpoints the program. But never mind about them.</FONT></SPAN></DIV>
<DIV><SPAN class=883445315-28112008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=883445315-28112008><FONT face=Arial color=#0000ff size=2>As for
the gdb and DDD, check these out:</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><A href="http://www.gnu.org/manual/ddd/html_mono/ddd.html#Threads"><FONT
face=Arial
size=2>http://www.gnu.org/manual/ddd/html_mono/ddd.html#Threads</FONT></A></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><A
href="http://sources.redhat.com/gdb/current/onlinedocs/gdb_6.html#SEC49">http://sources.redhat.com/gdb/current/onlinedocs/gdb_6.html#SEC49</A></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=883445315-28112008>I
would also add that being able to stop a specific thread may indeed be
useful, but you should not rely on such a kind of debugging to ensure
correctness of your multithreaded program. You should do a much more thorough
different-concurrent-scenarios debugging and than printfing and asserts might be
more useful.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=883445315-28112008></SPAN></FONT> </DIV>
<DIV><SPAN class=883445315-28112008></SPAN><FONT face=Arial><FONT
color=#0000ff><FONT size=2><SPAN
class=883445315-28112008>G</SPAN>abi</FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=883445315-28112008></SPAN></FONT></FONT></FONT><FONT face=Arial
color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff
size=2></FONT><BR> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> haifux-bounces@haifux.org
[mailto:haifux-bounces@haifux.org] <B>On Behalf Of </B>Ohad
Lutzky<BR><B>Sent:</B> Friday, November 28, 2008 5:12 PM<BR><B>To:</B>
Haifux<BR><B>Cc:</B> Yigal Korman<BR><B>Subject:</B> [Haifux] Multi-thread
debugging for C++ on Linux<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr>Hello all,<BR><BR>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).<BR><BR>So my question are:<BR>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?<BR>2. Is there a different
Linux (on x86) debugger which does support this?<BR>3. What is the situation of
this problem on other OSes?<BR>4. What other neat thread-related debugging tools
(other than suspending individual threads, that is) are there, and which
debuggers support them?<BR><BR>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
:)<BR clear=all><BR>-- <BR>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.<BR>- William Hazlitt<BR><BR>Ohad
Lutzky<BR></DIV></BODY></HTML>