Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Debugging programs with multiple threads

Name: Anonymous 2010-02-02 19:19

How does /prog/ do it?

I set up a separate thread that can be sent messages,and puts them into a FIFO to ensure its printed in the correct order, but is there a better way? I want to just drop in print statements ;_;

Name: Anonymous 2010-02-02 19:41

you must _feel_ the code

Name: Anonymous 2010-02-02 19:52

I don't play around with multithreaded programs often but an obvious suggestion is to have each thread be debugged individually outwards (as in, any threads initialized from within or depending on other threads.  Also, set any required variable that thread needs to "working" limits (even testing those working limits to make sure).

Seriously, that's just a shot in the dark.

Name: Anonymous 2010-02-02 20:43

It's not really difficult. You think about the execution of threads and where they may possibly overlap. Ask yourself what happens if the threads execute in a certain order - and if you have no answer or your answer is "I don't know," you probably have a threading bug.

Name: Anonymous 2010-02-02 20:48

>>4
This. If you're having difficulty, you're doing something horribly wrong. Remember, threads are evil.

That being said, printf is thread-safe in glibc, and on BSD afaik.

Name: Anonymous 2010-02-02 21:35

also, gdb can handle threads sanely.

Try, for example:
thread apply all backtrace

Name: Anonymous 2010-02-02 22:37

>>6
Unfortunately, it can't handle any other debugging sanely. You need interactivity for maximum effectiveness on debugging.

Name: Anonymous 2010-02-03 0:31

>>7
What the fuck? In what way is gdb not interactive?

Name: Anonymous 2010-02-03 2:03

>>8
In the way that it just lays there like a dead fish while you're banging away at it.

Name: Anonymous 2010-02-03 2:08

>>8
Ignore the troll.

Name: Anonymous 2010-02-03 2:50

>>9
Yeah, banging away at it will do that to a fish.

Name: Anonymous 2010-02-03 5:27

WHAT LANGUAGE OP FAGGOT?

Name: Anonymous 2010-02-03 6:15

>>12
Why would that matter? Threading is a problem in lots of languages.
>>4
Yes, I know. I had various synchronisation points, and I was mostly using this information to ensure that execution was correct up to the bug.

Name: Anonymous 2010-02-03 9:13

Use erlang, problem solved.

Name: Anonymous 2010-02-03 16:10

>>14
message passing now you have n problems
use superior DISCRETE SYNCHRONOUS CONCURRENCY paradigm

------
http://www-sop.inria.fr/meije/esterel/esterel-eng.html

Name: Anonymous 2011-02-03 1:08


Don't change these.
Name: Email:
Entire Thread Thread List