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

2008-11-28 Thread Hai Zaar
--
Zaar



On Fri, Nov 28, 2008 at 5:12 PM, Ohad Lutzky [EMAIL PROTECTED] 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).
Not answering your questions, but try insight debugger. Its the only debugger
that worked for me with complicated C++ templates.


 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@haifux.org
 http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


___
Haifux mailing list
Haifux@haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


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

2008-11-28 Thread Yotam Medini יותם מדיני
May I recommend using emacs as the front-end for gdb. 
-- yotam

On Fri, 28 Nov 2008 17
Ohad Lutzky [EMAIL PROTECTED] wrote

 ...
 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. 
___
Haifux mailing list
Haifux@haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


[Haifux] Why open source

2008-11-28 Thread Tal Abir
Hi,
Lets say you wrote a utility that may be useful to others.
Why would you open source it?
How can you earn money from opening the code and giving it for free?
Source forge is making money from hosting your utility, Wikipedia is making
money from documenting it, what is left for the developer?

Is there someone who can give a lecture on the subject?
Are there more people interested in the subject?

Thanks,
Tal.
___
Haifux mailing list
Haifux@haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


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

2008-11-28 Thread gabik
Hi
 
This is an interesting issue you have raised here.
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.
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.
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 separately.
There is also something called hardware breakpoints:
http://www.codeproject.com/KB/debug/hardwarebreakpoint.aspx
They are used to data breakpoints - when ever some data address changes, it
breakpoints the program. But never mind about them.
 
As for the gdb and DDD, check these out:
 
 http://www.gnu.org/manual/ddd/html_mono/ddd.html#Threads
http://www.gnu.org/manual/ddd/html_mono/ddd.html#Threads
 
http://sources.redhat.com/gdb/current/onlinedocs/gdb_6.html#SEC49
 
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.
 
Gabi

 
 
  _  

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Ohad Lutzky
Sent: Friday, November 28, 2008 5:12 PM
To: Haifux
Cc: Yigal Korman
Subject: [Haifux] Multi-thread debugging for C++ on Linux


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@haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


Re: [Haifux] Why open source

2008-11-28 Thread Dotan Cohen
2008/11/28 Tal Abir [EMAIL PROTECTED]:
 Hi,
 Lets say you wrote a utility that may be useful to others.
 Why would you open source it?
 How can you earn money from opening the code and giving it for free?
 Source forge is making money from hosting your utility, Wikipedia is making
 money from documenting it, what is left for the developer?


Some men aren't looking for anything logical, like money. They can't
be bought, bullied, reasoned or negotiated with. Some men just want to
watch the world burn.

 Is there someone who can give a lecture on the subject?
 Are there more people interested in the subject?


Ask Alfred.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü
___
Haifux mailing list
Haifux@haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


Re: [Haifux] Why open source

2008-11-28 Thread Ori Idan
I think the question is why not open source?
The question is not how you make money from open source, although this is
not always obvious, you can see many companies who does make money from open
source.
But how do you make money from closed source? this remains a mystery to me.
I would be happy to give a talk about it, actually I think it is better to
have a discussion about it so it will not be a talk but rather a discussion.

-- 
Ori Idan


On Fri, Nov 28, 2008 at 6:07 PM, Tal Abir [EMAIL PROTECTED] wrote:

 Hi,
 Lets say you wrote a utility that may be useful to others.
 Why would you open source it?
 How can you earn money from opening the code and giving it for free?
 Source forge is making money from hosting your utility, Wikipedia is making
 money from documenting it, what is left for the developer?

 Is there someone who can give a lecture on the subject?
 Are there more people interested in the subject?

 Thanks,
 Tal.

 ___
 Haifux mailing list
 Haifux@haifux.org
 http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


___
Haifux mailing list
Haifux@haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


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

2008-11-28 Thread guy keren

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@haifux.org
 http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux

___
Haifux mailing list
Haifux@haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


Re: [Haifux] Why open source

2008-11-28 Thread Tal Abir
I would be happy to participate in such discussion but would you open a full
scale company for earning money from a little utility.
I don't think it will hold.
People today earn money just from writing blogs (though publishing a piece
of code and then earn money from blogging about it sounds like as a start of
an idea)
The other option (at least as I see it) is not closed source but rather not
to publish it at all.
Thus everyone will continue writing the same utilities and keep it for
themselves.

Tal.

On Fri, Nov 28, 2008 at 6:38 PM, Ori Idan [EMAIL PROTECTED] wrote:

 I think the question is why not open source?
 The question is not how you make money from open source, although this is
 not always obvious, you can see many companies who does make money from open
 source.
 But how do you make money from closed source? this remains a mystery to me.
 I would be happy to give a talk about it, actually I think it is better to
 have a discussion about it so it will not be a talk but rather a discussion.

 --
 Ori Idan


 On Fri, Nov 28, 2008 at 6:07 PM, Tal Abir [EMAIL PROTECTED] wrote:

 Hi,
 Lets say you wrote a utility that may be useful to others.
 Why would you open source it?
 How can you earn money from opening the code and giving it for free?
 Source forge is making money from hosting your utility, Wikipedia is
 making money from documenting it, what is left for the developer?

 Is there someone who can give a lecture on the subject?
 Are there more people interested in the subject?

 Thanks,
 Tal.

 ___
 Haifux mailing list
 Haifux@haifux.org
 http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux



___
Haifux mailing list
Haifux@haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


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

2008-11-28 Thread Tzafrir Cohen
A minor technical note:

On Fri, Nov 28, 2008 at 06:17:38PM +0200, gabik wrote:

 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)

Threads had different PIDs even before that. They were actually even 
less connected before the NPTL change in Linux 2.6 .

But then again, most of us don't need to care about Linux 2.4 and older...

-- 
Tzafrir Cohen | [EMAIL PROTECTED] | VIM is
http://tzafrir.org.il || a Mutt's
[EMAIL PROTECTED] ||  best
ICQ# 16849754 || friend
___
Haifux mailing list
Haifux@haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


Re: [Haifux] Why open source

2008-11-28 Thread Tzafrir Cohen
On Fri, Nov 28, 2008 at 06:07:09PM +0200, Tal Abir wrote:
 Hi,
 Lets say you wrote a utility that may be useful to others.

Is it useful for you as well?

 Why would you open source it?

There are several reasons. 

Do you think you can actually make money from selling the software as 
a stand-alone product? Without support? If you make it free software you
can still sell support. You're more likely to get good bug reports and
even some patches.

Furthermore, if you actually need that software to work well for you
(e.g. to offer a better service to your clients) then making it free
software reduces the development cost. It also reduces the deployment
cost, because there's no licensing overhead and there's no inherent
conflict between the developer and the user.

For instance, it means people can get support from someone else, and
hence they won't be left with a useless pile of bits if you're gone. It
gives the software a higher value.

 How can you earn money from opening the code and giving it for free?

There are several possible methods. 

Here is an article discussing several of them:
http://www.letmegooglethatforyou.com/?q=how+can+I+make+money+from+opensource

That said, it is still a tricky business. But then again, getting people
to pay you for limited usage licenses for a software isn't that easy as
well (specifically if there is an interesting competition).

Note that I did not write here that you should release your software as
free software. You wrote it, and it is up to you to license it.

 Source forge is making money from hosting your utility, 

SourceForge makes osme money form adds. But also from selling the 
proprietary SourceForge development platform.

 Wikipedia is making money from documenting it, 

Wikimedia is hosted by the Wikimedia foundation, which is a NGO. The 
content of Wikipedia is available under the terms of the GFDL. It is 
run by a software called wikimedia which is free software as well. 
Wikipedia carries no adds. You'll occasionally see there a call for 
donations.

 what is left for the developer?
 
 Is there someone who can give a lecture on the subject?
 Are there more people interested in the subject?

-- 
Tzafrir Cohen | [EMAIL PROTECTED] | VIM is
http://tzafrir.org.il || a Mutt's
[EMAIL PROTECTED] ||  best
ICQ# 16849754 || friend
___
Haifux mailing list
Haifux@haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux


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

2008-11-28 Thread Hai Zaar
--
Zaar



On Fri, Nov 28, 2008 at 8:29 PM, Ohad Lutzky [EMAIL PROTECTED] wrote:
 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
 at?)
Yes, its GUI looks eagy. It does have a gdb console (View-Console -
its not a shell console but gdb console). Insight did a best job for
me debugging project that heavily used C++ templating, where ddd got
lost tracking source code.

 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 [EMAIL PROTECTED] 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@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
 ___
 Haifux mailing list
 Haifux@haifux.org
 http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux

___
Haifux mailing list
Haifux@haifux.org