Slashdot Mirror


What Debugger Is Best For Multithreaded Apps?

pollyp asks: "I'm on a team that's working on a multi-threaded (pthreads) C++ application running on GNU/Debian 2.2. One of the challenges of this project is trying to debug the app, or making sense of core files; the feeling is that gdb is just too difficult to work with in a heavily threaded app. We're looking for better tools, and if that means changing languages or going to another UN*X, we're ready to do it. So what is the best, most mature OS/language/tool UN*X environment for doing multi-threaded application development on Intel?"

"One part of the team wants to stay on GNU/Linux but use Java. Java's performance is becoming less and less of an issue, and the GNU/Linux development tools are reasonably attractive (e.g., Visual Age's debugger). The other part of the team wants to stick with C++, but move over to Solaris. But none of us have any practical experience with Solaris, nor do any of us have a sense of how fully baked their Intel development environment is."

257 comments

  1. We use the Paradigm C++ Debugger by Anonymous Coward · · Score: 1

    Why change views when you change from editor to debugger and back like older tool chains force you to do? In Paradigm C++, the editor and the debugger are the same view. A click lets you edit code, another click lets you rebuild your application and you have never left the position of your code to make the change and confirmed the correction. This is the most time-efficient method of debugging.

    You can start a debugging session by double clicking the .AXE node in the Project window. Once in a debugging session, the Edit window local menu (right-click in window) and Speedbuttons under the Menu bar display debugging commands. The Load command under the Debug menu will load a .AXE file on the target and start a debugging session if you don't have a project file.

    You can build your application in real or protected mode. Choosing a Target platform is as easy as right-clicking the .AXE node in the Project window, selecting TargetExpert and choosing a target type. You can even run a protected mode application without a remote target system and test your code right on the PC. This can be done by choosing Win32 emulation as your Target Model in TargetExpert. Memory models can also be changed in this dialog.

    Paradigm C++ even has the smarts to inspect an object by simply passing the mouse cursor over it in the Edit Window. Since it also knows the debug symbols in the current scope, you always have access to the most frequently used debug information without any additional effort.

    During debugging, the editor view includes local menus containing debugging options such as Inspect or Watch. Source lines with debugging information are marked with red dots and the current execution point and enabled/disabled breakpoints are all marked.

    You can open a CPU view to see the actual code created by the compiler or assembler or see register contents. This window handles viewing of memory, registers, processor flags, and stack and includes options to help you checkout low-level code. You can bring up the CPU view at the current CS:IP by using the View menu command. Or to bring up the CPU view corresponding to any source line, use theView CPU command from the Edit view local menu.

    1. Re:We use the Paradigm C++ Debugger by Anonymous Coward · · Score: 2

      Why do I have the feeling that the article and this comment were posted by the same person plugging their software?

      I mean 10 minutes after the article was posted we get this 6 paragraph commercial posted by an AC. Don't mean to sound bitchy, Paradigm C++ could be good and I might give it a try when/if I develop in C++ again, but at least you should try being more honest about what you are doing...

    2. Re:We use the Paradigm C++ Debugger by marcovje · · Score: 1


      I think that too. The company would have actually answered the question (and said something about threading, which is totally absent in the Paradigm post)

      The few lowlevel workarounds that are included (single handedly setting cs:ip), can be done in GDB too afaik.

    3. Re:We use the Paradigm C++ Debugger by X.25 · · Score: 1

      I mean 10 minutes after the article was posted we get this 6 paragraph commercial posted by an AC

      I'm not sure if you realize that it's not AC that approves the topic/question on /. but the /. team? So, you suggest that guy who asked the question was reloading the main page for XY hours and when he caught his question posted he immediately added this comment?

      Get real...

  2. Gnu Visual Debugger by Anonymous Coward · · Score: 2

    The gnu visual debugger is based on gdb, and claims to have much-improved support for multithreaded code. I haven't used it myself, though.

    If you're considering a different language, Ada is worth a look. Gnat is a complete and stable compiler in a way that g++ is not, and the language was designed for multithreading from the start.

    1. Re:Gnu Visual Debugger by bugger · · Score: 1

      I cannot download this tool - all I find is: "If you would like to have more information on GtkAda or GVD feel free to drop us a note at sales@gnat.com or sales@act-europe.fr, we will be happy to call you at your convenience."

    2. Re:Gnu Visual Debugger by sansa · · Score: 2

      Not sure why that is. You can get it for now at www.gnuada.org, though you might have to make do with a (source) rpm.

    3. Re:Gnu Visual Debugger by Black+Parrot · · Score: 2

      Notice that GVD currently supports only C and Ada.

      It is supposedly designed where support for other languages can be added, so if you use C++ you may want to ask around and find out what the current status/prospect for C++ support is.

      --

      --
      Sheesh, evil *and* a jerk. -- Jade
    4. Re:Gnu Visual Debugger by segoave · · Score: 4

      Or you could try ddd
      If you need a visual dbugger. It acts like gdb, which I already love, but adds a visual edge that gdb alone doesn't have. When I am really stumped with gdb, I go to ddd.

    5. Re:Gnu Visual Debugger by orange7 · · Score: 1
      ddd is a front-end to gdb. It does all its debugging work by calling through to gdb. So, unfortunately it's not going to solve this guy's problem with gdb's notoriously poor multithreading support.

      Andrew

    6. Re:Gnu Visual Debugger by breadmaker · · Score: 1

      Holy ADA!!! I love you ada, will you marry me? ada.text_io.computer.put(item=>"I barely know you, can we just date");

    7. Re:Gnu Visual Debugger by Tet · · Score: 2
      The gnu visual debugger is based on gdb, and claims to have much-improved support for multithreaded code.

      Similarly, smartgdb has long claimed to have improved thread support, although I don't know if it's been kept up to date. The web site doesn't appear to have been updated in a while.

      --
      "The invisible and the non-existent look very much alike." -- Delos B. McKown
  3. Avoid Solaris/86 like the plague it is.... by SuiteSisterMary · · Score: 2

    ...and be aware that there are many, many bugs in Solaris' threading libraries.

    --
    Vintage computer games and RPG books available. Email me if you're interested.
    1. Re:Avoid Solaris/86 like the plague it is.... by trkball · · Score: 1

      Not at all. It is actually a very good platform to work with, and I feel comfortable saying that after using it for the last two years. It's a lot more like Linux than it is like Windows, folks ;-)

      My two cents: use Forte for Java on Solaris x86, and solve both your problems!

  4. The best tool by Bongo · · Score: 3

    So what is the best ... tool ... for doing ... application development?

    16 cups of this.

  5. If you can afford it, move to Java by Kieckerjan · · Score: 4
    Given the fact that 90% of all C / C++ bugs are caused by memory related issues (buffer overruns and memleaks being the most notorious ones) it would probably be a wise choice to move to Java, if you don't mind the (minor) performance hit. My own experience is that when writing Java code you spend a lot less time in the debugger, because (a) the garbage collector prevents memleaks (b) buffer overflows generate very clear error messages instead of a stupid core dump. So the choice of debugger automatically becomes much less of a issue.

    As to performance: if you're not writing a nuclear explosion simulator, Java's performance is probably adequate. (Think StarOffice here.)
    --

    --
    Being well balanced is overrated. -- John Carmack
    1. Re:If you can afford it, move to Java by marcovje · · Score: 1


      I think that is a pretty severe performance hit.

      I would rather use the Ada as suggested before.

    2. Re:If you can afford it, move to Java by svanderw · · Score: 1

      If you're trying to track down memory leaks/overruns/general corruption in C or C++, even in multi-threaded apps, I've found Insure++ from Parasoft extremely helpful. It even tracks corruption on your stack (something I couldn't find in any other piece of software for x86/Linux)

    3. Re:If you can afford it, move to Java by japer · · Score: 5

      Actually, it is a misconception that java doesn't suffer from memory leaks. Just because it is garbage collected doesn't mean that you don't have huge trees of objects that will never get gc'd. If you don't explicitly design in creation/destruction of your objects you will leak memory. For the average sized application it propably isn't noticeable, but if your app needs to run for a long time, you will eventually run out of heap.

    4. Re:If you can afford it, move to Java by Anonymous Coward · · Score: 1

      Don't blame Java for this!

      It's your idiot management team and the developers who were put in a bad situation.

      Java is a great tool when used appropriately and you can develop enterprise-class applications and services using it. The myth that it's easier to develop in is one of it's achilles heels, because people tend to throw inexperienced developers at a job that requires advanced engineers.

      You are correct that many of C/C++'s "evils" are solved by third party tools, but they are third party tools that cost money and increase the complexity of the development. You get a lot of stuff under one nice simple development paradigm with Java.

      Take your best C++ developer and give them a couple years with Java and you will have a developer cranking out Java code that is more solid than the best C++ code they ever wrote.

    5. Re:If you can afford it, move to Java by Kieckerjan · · Score: 1
      Hmm, I suppose there are occassions in which the system cannot decide if a object is definitely dead and hence to be garbage collected, but the question is: do these occassions arise in each and every program of reasonable size? If so, then the concept of a garbage collector itself is fatally flawed. I find that hard to believe.

      Frank
      --

      --
      Being well balanced is overrated. -- John Carmack
    6. Re:If you can afford it, move to Java by dubl-u · · Score: 3

      Yes and no.

      Actually, it is a misconception that java doesn't suffer from memory leaks.

      A classic memory leak is one where you have memory allocated but no longer have any way to make use of it. These kinds of errors aren't possible in a garbage collected language. Once you let go of your last pointer to something in Java (or, say, Perl) then the GC takes care of everything automatically.

      When debugging other people's C code, the most common memory leak I see is the temporary allocation of scratch space in some low-level routine without a corresponding release of the memory. This does not happen in Java.

      If you don't explicitly design in creation/destruction of your objects you will leak memory.

      Agreed. This is especially a problem with people new to OO design, where they haven't yet developed a good understanding of modular integrity. In practice, though, I find these kinds of errors much less frequent and much easier to find than classic memory leaks.

    7. Re:If you can afford it, move to Java by japer · · Score: 3
      Actualy, I don't mean that the VM can't figure out if an object is dead or not. The problem arises as designers make design decisions without understnding the consequences.

      The problem arises when, from the designers point of view, the object will no longer be used, but from the VMs point of view, the object is still alive. An object that has a root parent in the reference hierarchy will not be garbage collected.

      Things I have seen that hold onto large object trees are things like, anonymous innner classes (implcit "this" reference), listeners on gui components not being removed, and static class variables holding onto objects.

      Java is a great programming language because it is easy to use thanks to all the built in stuff, but nothing is free. You generally pay for it with performance and memory usage.

      Here's an article discussing "memory leaks" in java

      http://www.devx.com/upload/free/features/javapro/1 999/06jun99/tl0699/tl0699.asp

    8. Re:If you can afford it, move to Java by Edward+Teach · · Score: 1
      Agreed. This is especially a problem with people new to OO design, where they haven't yet developed a good understanding of modular integrity. In practice, though, I find these kinds of errors much less frequent and much easier to find than classic memory leaks.



      I know what you mean. As a Java instructor, getting people to understand that the scope of variables is very important, is a task in and of itself.

      --- This is my sig. There are many like it, but this one is mine. ---

      --

      Setting his threshold to 5, Sparky eliminated most of the trolls on /.

    9. Re:If you can afford it, move to Java by japer · · Score: 1
      I've found this to be quite the oposite actually. I've found it very difficult/ tedious to fix the memory leaks in java. The only way I know of to find the leaks is through 3rd party tools like JProbe. Once you find them, you have to cleanup all the references to the Object to make it available for gc.

      The tediousness comes when you have to store all your listeners in member variables and explicitly remove them when you want your gui objects to go away. (or something equally annoying)

      Again though unless you have a very large or very long running app you would be unlikely to ever notice this. I believe the default max java heap size is 16M.

    10. Re:If you can afford it, move to Java by Anm · · Score: 2
      Things I have seen that hold onto large object trees are things like, anonymous innner classes (implcit "this" reference), listeners on gui components not being removed, and static class variables holding onto objects.
      While you are correct about many designers making poor design designs that affect garbage collection, anonymous inner classes are not an example. The implicit this reference you refer to is from the inner class, not to the inner class. Better examples are one-shot listeners that are never removed, and never nulling out unused private variables. The other issue with Java is that is does not know when to deallocate memory from it's heap. This can be a serious problem if you expect to hit memory load ever, even if it is a small percentage of the time the process is left running. Anm
    11. Re:If you can afford it, move to Java by BdosError · · Score: 2
      http://www.devx.com/upload/free/features/javapro/1 999/06jun99/tl0699/tl0699.asp
      That link didn't work for me, but here's another article on the same topic, at Java Report magazine's site: here

      BdosError

      --
      Complexity is Easy. Simplicity is Hard.
    12. Re:If you can afford it, move to Java by dubl-u · · Score: 2

      The problem with going to Java from C++, is that when you dumb down the language, you also dumb down the programmers.

      As we covered elsewhere in this thread, it's true that Java tends to penalize developers (and users) for programmer error a little less than C/C++. That's not intrinsically good or bad; that's just how it is. It's practical goodness/badness depends on circumstance.

      If you're using the language mainly as a training tool, then this insulation is bad. It allows developers to become sloppy, and keeps them from learning why sloppy is bad. A more raw language is a steeper learning curve, but that just means that you get to the high ground more quickly.

      But if you're using the language to deliver a real-world product, then this insulation is good. Your goal is to deliver a useful thing quickly. SEGVs are certainly helpful to the developer, but the user of a piece of crashing software generally doesn't share that opinion.

      And really, the goals of developer improvement and user satisfaction aren't mutually exclusive; you just have to use different tools than crashing code. Instead, you use things like walk-throughs, design review, code review, and pair programming. All of these techniques results in better people, better code, and happier users. And this is true regardless of how forgiving your language of choice is.

      Note also that your argument applies even better to, say, assembler. The closer you are to the hardware, the better your code is likely to be, because there's less to take up your slack. But I take it you don't do most of your work in assembler, right?

      [...]chasing marketing-driven rainbows.

      The silver-bullet syndrome has been around much longer than Java. Indeed, many people had exactly the same gripes about OO programming or, for that matter, C.

      The so called "evils" of C/C++ [...] Are solved quite well with tools [... and] good disciplined techniques.

      Instead of C/C++, you can insert any language in that statement. A skilled developer with the right tools and a sense of discipline can do good work in almost any language. Comparing the work of experts in one language with the work of fools in another is not a very useful thing to do.

    13. Re:If you can afford it, move to Java by AlphaHelix · · Score: 1

      Instrumenting code debuggers suck for tracking down memory leaks. They're slow, and innacurate. Try Great Circle from Geodesic Systems instead. It's a full featured debugging and deployment garbage collector for C/C++ based on the Boehm collector, that can be integrated with only a relink. It's pretty nifty. DISCLAIMER: I used to work for Geodesic Systems, but I no longer do, nor do I have any stake in the company, except some friends.
      * mild mannered physics grad student by day *

      --
      * mild mannered physics grad student by day *
      * daring code hacker by night *
      http://www.silent-tristero.com
    14. Re:If you can afford it, move to Java by Alex+Belits · · Score: 2

      Java merely conceals memory leaks by converting them to almost undetectable reference leaks -- different ways, same result, as after few hours or days of running program runs out of memory and crashes (usually crashing a bunch of other stuff in the process). I'll rather have an immediately detectable dangling pointer or traceable leak in C or C++.

      --
      Contrary to the popular belief, there indeed is no God.
    15. Re:If you can afford it, move to Java by breadmaker · · Score: 1

      I would definitly move to Ada, there is no other option. try pasting the proc in your code, I think it will help tremendously.

      --pre:x,y are defined x is of type bile, y is of type cleetus
      --post: Program is debugged, Bile is spewed, Cleetus is a slack jawed yokle, is O(nlogn)
      procedure Make_insects (X : out Bile; y: in out Cleetus ) is

      temp : bug := "fly"/x;
      Begin --make bugs

      Spew(x);
      Slack_jawed_yokle(y)
      Make_insects(temp);
      ada.text_io.program.fix(item=>curr_program);
      end make_insects;

    16. Re:If you can afford it, move to Java by asherlangton · · Score: 1

      it would probably be a wise choice to move to Java, if you don't mind the (minor) performance hit.

      I was recently writing some short programs to generate Farey Fractions and noticed the Java program took about 10 time as long to execute (on a Sun Ultra 5) as a nearly identical C++ program. Of course, this is highly unscientific, and Java may be much closer to C++ for some applications. Java does handle threads very nicely, in my opinion.

      I'm planning to do some experimenting with writing code for a Beowulf cluster this winter, and would like to use Java for the ease of use of its threads, but I just can't stomach the performance hit. I keep seeing references to native compilers , but haven't had luck finding anything. I've been thinking about playing with one of the open source just-in-time compilers to see if it could be hacked to generate native code of some sort (though perhaps not the most optimized). Does anybody have any words of wisdom about this?

    17. Re:If you can afford it, move to Java by noc · · Score: 1
      Wow, I'd heard bad things about Java's GC, but that's amazing. Coming from a Common Lisp perspective, I'm appalled that the Java GC doesn't actually collect garbage, but just runs destructors!

      This is a problem with the language, not with programmers' understanding of OO design. Finalization on objects can be a good way to prevent a programmer from accidentally forgetting to free a resource, but the garbage collector should certainly collect all the garbage!

    18. Re:If you can afford it, move to Java by elflord · · Score: 2
      You're missing the point. Java does indeed collect garbage. It doesn't just "run destructors", it doesn't even use a simple "reference count", which still requires a fair bit of baby sitting (eg linked lists).

      Java has proper garbage collection. That is, any object that is no longer accessible gets collected (so isolated cycles of objects get collected for example).

      The issues they are discussing are problems with garbage collection in general, they are not unique to java. You are likely to find yourself facing the same issues if you write nontrivial programs.

    19. Re:If you can afford it, move to Java by pod · · Score: 1

      Put another way, the parent post is saying there are still memory leaks in Java, they're just not the same leaks as you find in C. While in C you have to worry about not losing the address, in Java you have to look at your object lifetime and when you no longer need them and all their references, etc. In a nutshell, it's a memory leak, but a higher-level memory leak, if you will; just as Java does more low level stuff for you and you don't have to worry about misplaced pointers, you now have more abstract memory leaks. And, yes, just like C memory leaks, the Java ones come about from sloppy/careless programming, inadequate debugging or bad design.

      --
      "Hot lesbian witches! It's fucking genius!"
  6. Don't change horses in the middle of the stream by SLOGEN · · Score: 5

    Are you really changing Language and OS for better multi-thread debug?

    This is one of the symptomathics of IT today. You start out analyzing the problem, then you choose an aproprite tool. Some month's later you hit trouble and you consider moving to new language, OS, architecture, whatever, totally discarding the initial analysis that led to the choises you made!

    On topic: You should not expect multi-threaded code to be easily debugged, afterall it is hard to write!

    You should instead put effort into the really core components that are multi-threading sensitive (synchronization when referencing datastructures and stuff like that, btw. C++ is excellent for that, using Monitors), and make all other code REQUIRE to use the methodology you develop in these components.

    Try to collect the multi-thread sensitivity in small, well-defined areas of your program, and try to prove, or at least reason, about the correctness of the code there. One thing you may wan't to do is define (in C++) Locking Iterators, which Lock datastructures they work on, and (using reference counts) automatically unlocks the structure when Iterators fall out of scope.

    You may also have some luck in using some of the design patterns that deal with multi-threading.

    Morale:You cannot debug away every race-condition, that's bad practice you HAVE to think.

    --
    SLOGEN [ http://ungdomshus.nu : Sebastian cover music]
    1. Re:Don't change horses in the middle of the stream by marcovje · · Score: 2


      In the true open source mind, it would be better to say:

      You are changing a debugger because it misses a feature? THEN IMPLEMENT IT

      I'm sure the GDB team is curiously awaiting your patches.

      You can CVS the GDB source up to date every day.
      (I use a gdb from the devel branch, because it compiles easier on FreeBSD)

    2. Re:Don't change horses in the middle of the stream by Minix · · Score: 1

      Good on you, SLOGEN. The most sensible technical response-post I've seen on /. in an age.

      --
      "There are four boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order." Ed Howdershelt
    3. Re:Don't change horses in the middle of the stream by SlaterSan · · Score: 1

      I think more often than not it's the first step that's skipped. So many company do so little pre-planing. If more people took the time to analyze their problem and choose the correct arch/language there would be far fewer switches occuring. Choose the right tool for the job BEFORE you start, don't lock yourself into somehting just because it's there.

    4. Re:Don't change horses in the middle of the stream by the_quark · · Score: 3
      What you say is true, but it's not the issue. You can design the multi-threaded sensitivity properly, you can implement to the best of your ability, but, eventually, someone IS going to do the equivilant of *0 = 1, and your program is going to dump core. Even if it's just a typo. Believe me, I know, I founded the Freeamp project, and it is multithreaded to hell and back, and it has been a nightmare to get all the crash bugs out of it.

      The problem is, that, under Linux, if you load the resultant core file (from any multithreaded program) into GDB, it often dumps core. Which isn't very useful.

      The end result of this is that you can have a dual PIII-800 workstation, running the very latest in tools, with a highly trained developer, doing a friggin' binary search through the code with printfs trying to figure out where the stomped pointer is coming from.

      Believe me, you do this a few time and you're gonna start thinking that a language that does memory management for you probably wouldn't be such a bad idea, either.

      My OT rant - RedHat/Cygnus (leader of the gdb effort) needs to get this fixed. Quite frankly, it's hard to take Linux as a serious development platform when multithreaded debugging is twenty years back. Support the developers, first, and everything else will follow.

    5. Re:Don't change horses in the middle of the stream by DocTee · · Score: 1

      "So you're saying that I can debug multi-threaded applications?"
      "No. I'm saying that when you're ready.. you won't have to."

      --
      - doctea
    6. Re:Don't change horses in the middle of the stream by haystor · · Score: 1
      This is one of the symptomathics of IT today. You start out analyzing the problem, then you choose an aproprite tool. Some month's later you hit trouble and you consider moving to new language, OS, architecture, whatever, totally discarding the initial analysis that led to the choises you made!

      This is one of the symptomatics of /. readers today. You start out answering someone's question. Some time later you have trouble answering them, then change the question you choose to answer, totally discarding the initial question made.

      This was a simple question of what's the best debugger. The fact that its been posted on /. means that this question might pertain not just to this guy, but other people as well. Telling them that multi-threaded programming should be difficult and implying their problems stem from them not thinking is just plain rude.

      --
      t
    7. Re:Don't change horses in the middle of the stream by marcovje · · Score: 1
      Then why do you expect to get a free ride from the open-source community if you have nothing to add?

      Simply pay up for commercial tools, and shut up. You do

      • yourself (get it instantly with support),
      • the open-source community (one whiner with nothing to add less). Open source is a give and take thing
      • And the people writing commercial developper software get food on the table too (they have actual jobs and develop for a living), that way, a decent developper firm (like Borland) doesn't have to be supported by Microsoft.
      a favour.

      (P.s. what is that VB people keep trying to tell me about?

      P.p.s. I do write a lot of code. But I keep hobby and profession strictly separated, and for professional work, I pay my dues for professional software, and for my non-commercial stuff I do actual work myself, and contribute back to the community, instead of doubling the workload of hard working core-teams with my whining)

  7. Fun programming by Far� · · Score: 3
    Functional programming languages will provide you with great tools that will avoid most sources of core-dumping:
    • OCaml is multithreaded (linuxthreads was born as a way to get it to work on linux), although a single program won't take advantage of a multiprocessor. Core dump is impossible using its static strong typing, and the optimizing native-code compiler provides with great performance.
    • JOCaml is an extension of OCaml based on the Join-Calculus, the latest and greatest paradigm for distributed programming (can be seen as actor-based programming done right, as based on a well-understood algebra). Can take advantage not only of multiprocessors, but of processor farms, or any distributed architecture, even heterogeneous architectures. Only bytecode can migrate, native code modules and primitives must be compiled into the servers.
    • Erlang is based on a paradigm quite similar to jocaml, but is designed for industrial applicability rather than hacker coolness; it has dynamic typing, a pure functional core (despite the logic programming syntax, it only has matching, not unification), enriched with explicit asynchronous communication primitives, and an implementation that every phone call you make depends on, if you use British Telecom. If you need tens of thousands of threads and/or lots of nodes, this is what you need.
    • There is also Mozart, an distributed implementation of Oz, a real logic programming language (has unification).
    • Haskell and Mercury also have extensions for concurrent and distributed programming in the works, but I admit I don't know how usable they are for real programming.
    Use real languages with a nicely designed concurrent programming algebra, not fake languages that were never designed to begin with, and had a kluge of concurrent primitives added by drunk people without a clue. Forget core dumps. Catch exceptions and receive exit messages instead.

    -- Faré @ TUNES.org

    --

    -- Faré @ TUNES.org
    Reflection & Cybernet

    1. Re:Fun programming by harmonica · · Score: 2

      Someone is asking how to debug multithreaded C++ code and gets as an answer to use functional programming languages. Sorry, but how is this insightful? I've had to use functional programming languages (Scheme, Haskell) and like a lot of what I've seen, so this is no flamebait. It's good to know all kinds of programming languages and paradigms (bad word ;-)). But once a decision has been made for a certain language, it's no longer an issue to change the language. Nice list, though, I didn't know them all!

    2. Re:Fun programming by Fourthstring · · Score: 1

      You misread the article. The person mentioned that the team was willing to change languages. Taken from this standpoint, the poster's comment was very informative.

    3. Re:Fun programming by extrasolar · · Score: 2

      Fare also wrote the vast majority of one of the vastest programming language comparisons I have seem. See The Language Review Subproject at Tunes.org.

      And Tunes *has* produced at least one line of code...I think it was a prototype implementation of their programming language---Slate, I beleive.

  8. Ada 95 by Anonymous Coward · · Score: 1
    I would strongly suggest you consider Ada 95. From a concurrency perspective it is extremely good. You'll probably find that you introduce fewer bugs in the first place because the syntax for tasks is nice and clear.

    As for debuggers, I've used DDD (a gdb frontend) but never with threads. I tend to just use the old trick of sticking a few printf statements in key places.

    1. Re:Ada 95 by Black+Parrot · · Score: 2
      > I would strongly suggest you consider Ada 95.

      Be forewarned that when you first start using Ada you will find it very annoying that it actually expects you to say what you mean with respect to types. People who say they like C++ because "it has a stronger type system than C" don't know what "type system" actually means. (No famebait intended; just a warning to brace yourself for the shock if you do decide to give Ada a try.)

      However, in my experience, once you get into the habit of thinking out what you are trying to do, you will find that most of your bugs are discovered at compile time, and your ratio of Coding_Time:Debugging_Time will go way up.

      Notice this quote from the GVD home page:
      Why we chose GtkAda instead of Gtk+... Another reason was to reduce the time we spent developing GVD. Using GtkAda and GNAT, we can decrease time to market by a factor of two to four over any other language/compiler.
      Raymond and Hoare notwithstanding (yes, I saw that /. fortune cookie yesterday), Ada is a very useful language.

      Also, another party has mentioned that Ada is designed for multithreading; I would just like to add that MT support is in the syntax of the language itself, and has been since 1983.

      --
      --
      Sheesh, evil *and* a jerk. -- Jade
    2. Re:Ada 95 by plague3106 · · Score: 1

      I tend to just use the old trick of sticking a few printf statements in key places.

      Heh...even with all the cool new tech, that still seems the most advanced way to find out exactly whats going on.

    3. Re:Ada 95 by Black+Parrot · · Score: 2

      > In particular, does you IDE trigger of a cascade of unnecessary compiles when you make a change, or is it sophisticated enough to figure out which ones are really needed?

      I never use IDEs -- just naked code and a compiler. However, for the two Ada compilers I have used, you get minimal component recompilations based on the timestamp of the source file vs. the timestamp of an information file that was automatically built last time you compiled.

      I'm not sure, but I think this is a requirement in the language spec. Forcing certain dependency recompilations is a safety issue, but forcing global recompilation merely be a waste.

      It certainly motivates modularity, since you can change a line of code in a single module, and then recompile a huge project in half a second.

      --

      --
      Sheesh, evil *and* a jerk. -- Jade
  9. debugger and threads by Anonymous Coward · · Score: 3

    As far as debugging is considered I would recommend DDD. It is a visual frontend to various language debuggers including C++. And it does provide access to threads of a process. So although it does not replace gdb, it may make using it easier for you.

    I would also suggest using a thread class that encapsulates the pthreads interface. I have a system in production that uses the omniThreads thread library. omniThreads is part of the omniORB library, but it compiles stand alone without any ORB related stuff. (FYI: I compiled it as a shared library ) It is very portable across machines (may help when switching to another machine)

    Writing threaded programs is very easy in Java. However, my apps have been simple enough that I have not had to debug the threaded application. If your application is a server app, with not so realtime requirements, you may want to try java. If it is a GUI app, you probably should not !!

    1. Re:debugger and threads by MichaelJ · · Score: 1
      Another multithreaded class library is Rogue Wave's Threads.h++, which I believe since I last saw it has been encapsulated into another of their products. As it is, Sun's Workshop environment, (well, actually the SunPro C++ compiler, which works in that environment) comes with RW's Tools.h++ class libraries, which are pretty darn good, with the exception of RWCString, which is wicked slow in a multithreaded environment. There are many fine treatises out there about why lazy-write, reference counted classes are inefficient in a multithreaded environment, and this is one of those classes.

      Also, as several people mentioned and I want to here second, Purify from Rational is an amazing debugging tool. I have used many different tools for watching memory allocations/accesses/leaks, and Purify, while seemingly simple, is actually elegant and extremely thorough and only continues to get "smarter" about what it does.

      Michael J.

      --

      Michael J.
      Root, God, what is difference?
  10. Totalview by gormanly · · Score: 3

    Well, I do parallel F90 development, and the only debugger worth the name that I've come across is Totalview from Etnus. Supports C++ on Linux and the tech support's pretty good. Free trial version too.

    1. Re:Totalview by shocking · · Score: 1

      I can only agree with this. I've been using Totalview on a number of platforms, Linux, AIX, Solaris & SGI boxes. It's quite decent, and understands MPI & PVM as well, which is highly useful for the sorts of stuff I'm doing. Get hold of it - its user interface isn't too bad either.

    2. Re:TotalView by Trepalium · · Score: 1

      Well, if they're developing it everyday, it's entirely possible. I would assume they're tring to reassure customers by indicating that it's powerful enough to work on itself.

      --
      I used up all my sick days, so I'm calling in dead.
    3. Re:TotalView by Sax+Maniac · · Score: 1
      The released version doesn't get debugged every day!

      Our internal development version is still under active development. We're adding new features and more scalablity every day. Those feaures are debugged before release.

      --
      I can explanate how to administrate your network. You must configurate and segmentate it, so it can computate.
    4. Re:Totalview by jcownie · · Score: 1

      > We tried the trial version of Totalview on both > Alpha and x86 linux, and it too was broken. I am one of the TotalView developers, and we'd love to fix these problems. So, if you have reproducers we can look at, please let us have them and we'll try to get the problems in TV fixed... Since you're posting anonymously I can't send this directly :-(

  11. Solaris by MichaelJ · · Score: 5
    I used Solaris (on Sparc, though) quite extensively for multithreaded development using their SunPro Workshop (4.x) environment. A very well-done IDE that integrates directly with Emacs, your own Makefiles, and overall can be as much or as little visual vs. command-line as you'd like.

    The debugger is dbx, fully supporting multithreaded debugging, and has a full GUI on top of it, as well as full visual integration into Emacs (better than you've ever seen gdb do).

    Some people think that Solaris' thread libraries are less than adequate. Personally, I've never used a better multithreading system. The entire "kernel-scheduled LWP managing user-scheduled threads" many-many concept is more efficient and works far better than Linux's one-one kernel-scheduled threads. And all your threads run with the same PID - what a concept!

    The obvious disclaimers are that I haven't used the newest Solaris tools, nor was this done on x86, but definitely consider not only the tool quality but also the OS' attitude towards threads. Solaris is better than Linux in that regard, IMO.

    Michael J.

    --

    Michael J.
    Root, God, what is difference?
    1. Re:Solaris by Serveert · · Score: 1

      Solaris has very evolved tools. My company does development on Solaris then ports to other platforms. Solaris's dbx is _rock solid_ for mthread apps. Also you have pstack and truss (ie strace for linux). Purify runs on Solaris too. Also you can get vsar, the most amazing tool ever invented. It enapsulates everything in sar but in a vt100 interface so you can monitor _everything_ realtime. I don't know if Solaris x86 is as nice as Solaric Sparc.

      --
      2 years and no mod points. Join reddit. Because openness is good.
    2. Re:Solaris by RelliK · · Score: 1
      Developing on Solaris pretty much requires you to buy a SPARC box from Sun, which are quite pricey. It would be too expensive for you to buy say a Ultra 5 for every developer. However, a good compromise is to buy *one* Sun box, and run Sun Workshop over remote X session. I did that last year when I was doing C++ development on Solaris. That was out of necessity though -- my Sun box was so damn slow (SPARC 20), while all the other developers had Ultra 10's. Anyway, this is a good way to get all the mature development tools that are available for Solaris (like Sun Workshop, purify, etc.) while at the same time avoiding high cost of Sun boxes. Oh, and you can still use your favorite OS on your workstation :-)

      P.S. If anybody tries to reply that running GUI apps remotely over X is slow, this is BS. I have first-hand experience that points to the contrary. My university has 6 labs of diskless X terminals (20-30 terminals each), and that's just in the MC building. There's more of them elsewhere. Long live X :-)
      ___

      --
      ___
      If you think big enough, you'll never have to do it.
    3. Re:Solaris by RelliK · · Score: 1
      Actually, the prices for the lower-end PCI machines are not that far from PC prices, especially considering that every developer that I've ever met seems to need a dual PIII with half a Gig of PC133. Not to mention a 20-inch flatscreen.

      Uhhm, sure. A *single* CPU Ultra 10 (440MHz) with 512 MB RAM and 20Gb IDE HD costs $4225 (see here), and that's not including the monitor. For that much money you can get dual P3 (or better yet, Athlon) with GeForce 2 and 21" monitor included.
      ___

      --
      ___
      If you think big enough, you'll never have to do it.
    4. Re:Solaris by Serveert · · Score: 1

      Hrmm I seem to remember trying to use dbx to do this and it was even slower than Purify. I could be wrong though.

      --
      2 years and no mod points. Join reddit. Because openness is good.
    5. Re:Solaris by nbvb · · Score: 1

      Sure. But it doesn't _SUCK_, like the Wintel crap does. The Ultra 5 and Ultra 10 are more PC-like than the rest of the Sun line, but you get what you pay for. My company insists on buying REAL workstations for its Sys Admins. I've got an Ultra 60 on my desktop; my manager has an Ultra 2 (and loves it!). Our 2 new Sys Admins are getting SunBlade 1000's. Sun makes some KICK ASS hardware. You get what you pay for, though. An Ultra 60 is worth $15K easy.

    6. Re:Solaris by RelliK · · Score: 1
      You get what you pay for, though. An Ultra 60 is worth $15K easy.

      Please elaborate on this one. I have a really hard time believing a single Ultra 60 is worth the price of 5 high-end Linux boxes.


      ___

      --
      ___
      If you think big enough, you'll never have to do it.
    7. Re:Solaris by Argon · · Score: 1
      The whole idea of "kernel-scheduled LWP managing user-scheduled threads" sucks. Even Sun seems to agree, set LD_LIBRARY_PATH=/usr/lib/lwp in Solaris 8 and have a one-one model. For best MT performance work with a minimum number of threads and use a one-one model.

      In fact for our applications we by default use "bound threads" on Solaris. The two level threading model introduces too many problems. For example, our application was supposed to start threads dynamically on demand and I spent 2 weeks debugging a problem with the pthreads library (it wasn't spawning enough LWPs). We switched to bound threads at that time and never looked back. Ganesan

    8. Re:Solaris by Bigboote66 · · Score: 1

      Why the big religious war? Why not just use Solaris X86:

      http://www.sun.com/software/solaris/ds/ds-intel/

      -BbT

  12. Try GVD and FSU Threads by Florian+Weimer · · Score: 1
    GVD, the GNU Visual Debugger, is a graphical frontend for your favorite debugger (it comes with GDB support, but you can add other debuggers pretty easily, too). Written in Ada to debug Ada programs (where multitasking support have been part of the programming language for ages), GVD presents multiple threads of control in a usable manner. However, GVD is still quite young, so there might be some rough edges.

    On the other hand, I've experienced that LinuxThreads (the thread implementation provided by GNU libc) and GDB don't mix too well. Maybe you can try another pthreads implementation, for example the one from Florida State University (FSU Threads).

  13. Thread problems by lkaos · · Score: 1

    Threads are notariously hard to debug. Linux threads have been in my experience especially hard. Make sure your using the latest kernel as there are some problems with the If you think about it, how would one debug a highly threaded application? What would you do with something that had 20+ threads? I can just imagine a programmer sitting there switching between terminal...

    --
    int func(int a);
    func((b += 3, b));
  14. GNU Visual Debugger by Ipsilon · · Score: 2

    I've been usign GVD for a couple of weeks and works well with multithreaded programs:

    http://www.act-europe.fr/gvd"

    And it also supports native and cross debuggers (VxWorks, LynxOS, JVM, ...), remote launching of debuggers, different languages, etc.

    --
    To visit or not to visit: findusclub.com

    --

    The opinions in this comment are subject to GPL, you can copy, modify and redistribute freely (as in speech).

  15. "Best" debugger is no debugger by Scorcher · · Score: 1

    The best debugger is your brain analyzing the observable behaviour of the code. Read it, study it. Fix the bugs based on that. With a debugger, you tend to fix symptoms, not the disease. Anything else is second best at best.

    Almost all of the Linux kernel was debugged that way.

    1. Re:"Best" debugger is no debugger by robwells · · Score: 2
      The is what Kernighan & Pike say in their excellent book "The Practice of Programming." (And I agree..)

      As they say, "...we tend not to use debuggers beyond getting a stack trace or the value of a variable or two. One reason is that it is easy to get lost in the details of complicated data structures and control flow; .... It is more helpful to use the debugger to discover the state of the program when it fails, then think about how the failure could have happened. ..."

      Just my 0.02...

      R.

    2. Re:"Best" debugger is no debugger by eric17 · · Score: 1

      Actually doing things this way, one often finds other bugs in the code. It's kind of a forced code review. Other things that tend to come out of not using a debugger: more use of assertions to catch bad conditions, better unit testing, development of better tracing and logging mechanisms, and generally a habit of reflecting on new code after it is typed in.

      The things I learned from programming a system without a debugger are priceless. Now, even with a debugger available, I still make use of most of these practices to develop, and it's been a blessing.

    3. Re:"Best" debugger is no debugger by _N0EL · · Score: 1
      Reminds me of the old restroom joke... Dude finishes at the urinal and heads for the door. Guy sees this, says "Shouldn't you wash your hands?" Dude says "I've learned to not piss on my hands."

      While I agree with studying code and testing small parts of it in isolation, a debugger can be a useful tool to use along with this... maybe the problem is not debuggers, but people wanting to totally rely on them for insight. The complexity of an application (esp. a multithreaded one) seems to imply that there is a limit to how much can be found by just studying code. There are limits to human processing at work, eg., short-term memory limits such as the "seven +/- two pieces of information" rule of Miller (Psychology Review vol. 63(2)) that we run across in software design books. If you've got five threads, each with multiple issues to keep track of, you are going to lose track of what is going on. A debugger could be useful in this situation.

      --

      "My mother works for Microsoft now. A whole other cult."

  16. How much have you done... by Faizdog · · Score: 1

    That you feel it's ok to change the language, or even the OS? I mean if you are at the debugging stage, then unless you have a really simple application (which wouldn't be heavily threaded then), you have all the original conceptual coding done. I agree with the other posters that there's something fishy about this article.

    Anyway, I've done some concurrent programming, and in my experience Java is a great language for concurrency. The fact that threads are a built in feature of Java (unlike C++ which has add-ons i.e. p-threads) provides a very powerful tool for concurrent programming.

    Java Threads are easy to use, and to learn. I'm assuming you already know Java, but if you don't, you know C++, and if you can afford to rewrite your whole application you can spend the half a day it'll take you to learn Java.

    If you are in unix you can look at m_fork from SGI's libraries, but I still say to stick with Java.

    --
    -"Those who fought today will die tommorow."-
  17. I don't know about debuggers for Linux... by fnordboy · · Score: 2

    but Irix has a couple of really handy debugging utilities, Purify and TotalView Debugger. I haven't used Purify much, but TotalView is incredibly handy.
    -fnord

    1. Re:I don't know about debuggers for Linux... by musicmaker · · Score: 1

      I beleive that Purify is available for Linux

      --
      Everyone is living in a personal delusion, just some are more delusional than others.
  18. Re:Well Done by I'm+Not+a+New+User! · · Score: 1

    Go on, mod me down. There aren't enough trolls on this discussion.

    Personally I don't debug code. If it's borken I just give out the source to someone esle to fix. I only gpl buggy stuff, then I ungpl it when it works and claim all the credir. Now I'm not offtopic.

    --
    Hope you all get first posts and trolls for Christmas
  19. Don't change by heikkile · · Score: 5
    Firstly, multithreaded stuff is hard to write, and harder to debug. No fancy tool will get you around that. Changing to new languages, tool, and environments usually screws up the first project or two, and it sounds like your project does not need another reason for things to go wrong.

    I can not know much of your situation, but on the surface it looks like a perfect example of the need of a clean rewrite. Scrap all the code you have, and the whole design, and consider all of it at most a preliminary study. But for crying alound, keep the same people and the same tools, unless it is blindingly obvious you are trying to use a totally wrong tool for the job - and C++ for multithreaded programming is not such a bad choice. If need be you may have to add one or two good, experienced people in your team.

    Then, start from the beginning. Design the system all again. You know you have problems with thread, so do not overuse them. Consider each thread a black box, and specify its interfaces, just like you are supposed to do with single-threaded systems. Specify the lockings and controls you need for things to work. Then implement bottom up, and test everything as you go.

    Spend more time in designing end implementing test suites than on the project itself - this will cost more at the onset, but increases your chances of getting the job done, probably faster than without the investment.Build a good debugging log that can be written from any thread, and where you control bufering. Build test routines to delay things, and pepper your code with them. Routines to exercise each module independently, and various combinations. And what ever else you can think of, that might come in handy. Make most tests automatic, so you can leave them running every night if need be. But most of all, make a clean and understandable design, and do not introduce new languages, tools, methods, or any other reasons for confusion!

    --

    In Murphy We Turst

    1. Re:Don't change by hwaara · · Score: 1
      I can not know much of your situation, but on the surface it looks like a perfect example of the need of a clean rewrite.

      Just a tip: don't rewrite!

      Check out this story about rewriting software.

      --
      -Håkan
    2. Re:Don't change by soup · · Score: 1
      Actually, step back from the problem a bit.

      Some items to think about:

      • Why do you need multithreading?
        IMHO, multithreading is most consistent when used to provide asynchronous I/O w/o any of that tedious mucking about w/ the AsyncIO libraries...
      • What does each thread REALLY do for you?
        Each thread needs to keep track of it's own environment and must avoid stepping on resources belonging to someone else.
        Writing device drivers teaches you a lot about what functions you place where.
      • How do your threads interact?
        Hopefully you're not creating memory objects and passing them back-and-forth, are you?

      When dealing with threads you need to think about them in a "transactional" way- yes, they can work as a team, but if you have multiple threads doing the same kind of work, well, you'll need a safe means of processing the queue for these.

      I've dealt with some pretty odd multi-threaded systems WAY BACK WHEN and they were NEVER pretty.

      If you're only doing this to be able to take advantage of an SMP, well, more power to you, but you'll still have to aggressively limit their scope- only the smallest amount of data should be common- and under exclusive accessing control.

      Don't forget that a Multithreaded application usually qualifies as an Algowrithmic procedure...

      --
      -soup (GNUrd, Speaker to Machines) "Laugh at yourself- Why should everyone else have all the fun?" -Romanchek's 6th Ru
    3. Re:Don't change by madhakr · · Score: 1

      The story you reference speaks only about rewriting existing apps. The whole basis of the author's argument is that all your code has already been debugged and used, and throwing it away reintroduces most of the bugs that you spent all that time fixing. If you're writing software for the first time, you don't have that tested codebase to begin with. Scrapping all the code for version 0.001 and rewriting from scratch for 0.002 makes sense if that will make debugging easier. That's completely different from writing a major upgrade for an existing piece of software.

      --
      To go outside the mythos is to become insane...

    4. Re:Don't change by Kevinb · · Score: 1
      The suggestions about building in debug code and test routines and coming up with automated tests are good ones, but I really think they should be built into the existing codebase rather than starting completely from scratch. I don't know how much time you've invested in your original codebase, but from your question I'd suppose that you've already invested a lot of people-hours into it. By starting over, you throw away that investment, especially if you're just going to rebuild it in the same language anyway.

      Look at the Mozilla project and how much starting over from scratch has cost them in terms of time. I'm not saying Mozilla hasn't come a long way, but rather, it's taken them a tremendously long time to do so. This is because a complete rewrite inevitably introduces new bugs and reintroduces old ones, and in the end it's usually faster and easier to work from an existing codebase.

      Several good debugging tools have already been suggested by other posters, so I won't repeat them here. But if you are considering throwing out your existing code, rather than using these tools with your what you have, think long and hard before you do so and justify to yourself that it's really worth it.

  20. DDD + GDB 5.0 by bugger · · Score: 2

    Your options (?) essentially consist of two tools: DDD (http://www.gnu.org/software/ddd/) and GDB 5.0 (http://sources.redhat.com/gdb/)

    I wouldn't go with the latest beta version of DDD, but use the latest release version. You *must* use GBD 5.0 in order to get a hope to work with threads.

    1. Re:DDD + GDB 5.0 by jkujawa · · Score: 1

      I second the recommendation for DDD. It makes working with threads quite nice.

      Core dumps don't work well with threaded apps under linux right now. (There is work being done to fix this, but I can't say anything more about it right now.)
      Your best bet is to catch SIGSEGV, and set up your own error handler to dump the stack. There are libraries to do this on Freshmeat, but I don't recall any names off the top of my head.

    2. Re:DDD + GDB 5.0 by jkujawa · · Score: 1

      *grovels through Freshmeat*
      It's called pstack. http://www.whatsis.com/pstack/

    3. Re:DDD + GDB 5.0 by bugger · · Score: 1

      Oh, I have been using Borland C++Builder and Borland Delphi for quite a while - on Win32.

      I just happen to be burnt often enough on Linux to know the least painful means...

  21. My favorites by Anonymous Coward · · Score: 1
    • printf
    • more
    • reboot

    -- Anne Marie

  22. Re:Still no trolls by I'm+Not+a+New+User! · · Score: 1

    Do i have the reocrd for most stupid posys without being modded down beyond the first?

    --
    Hope you all get first posts and trolls for Christmas
  23. GNU is behind others in C++ development by Anonymous Coward · · Score: 1

    Don't get me wrong. I love Debian/GNU. But let's face it, it is more difficult for them. In this particular case Sun has significant advantages to deliver products adapted to their stuff. A debugger is tighted to the OS and the compiler. Sun has put features in its debugger (thread support) before it appeared in gdb. Concerning C++, gcc is behind others (see advogado for a recent discussion), it is hoped that this will change with gcc 3.0, but it is still not there. It would not be surprising that some of your problems come from here (and gdb 5). You may want to consider to make your development on a platform (Sun sparc, Solaris, Forte ex WorkShop, ex SunPro) with portability in mind and then make the port to Intel. This particular combination is good, but other should be as well. You may also consider to compare differences between a sun sparc platform and a sun X86 platform to see if they are of the same quality. Understandably, quality should be lower for X86, but how much? Now or afterwards, you may want to explain your difficulties with GNU development tools and to pinpoint where they are behind of others for C++ multithread development as objectively and precisely as possible to avoid flaming. Regards, --

  24. I was expecting someone by joss · · Score: 2

    to make this stupid suggestion..

    1. What the hell has this got to do with his suggestion - he's asking about debugging threads. It would have made some sense if you had talked about threads in Java and the tools provided to debug them (for instance JbuilderX allows thread debugging, but it's far from ideal). Java threads are notoriously error prone same as threads everywhere.

    2. "Given the fact that 90% of all C / C++ bugs.."
    This is a fact that you pulled out of your ass. It may be roughly true for novices or students, but is nonsense for experienced developers. With tools like purify, these problems are very easy to track down in C/C++, and 2nd nature to avoid.
    Java encourages people to forget about these problems and rely on gc, then they leave dangling references dotted around and wonder why their disk is grinding.

    3. The performance hit is not minor. Sometimes, in simple cases, Java works great, but it depends what you're doing. An uncontrived comparison is at http://sprout.stanford.edu/uli/java_cpp.html
    In summary, with HotSpot 1.3 beta, (a JIT that Sun touted as being faster than C++ !!) Java was roughly 5 times slower than C++.

    4. Is StarOffice supposed to be an example of a good Java application with acceptable performance ? Heaven help us, it makes Word2000 seem slick and efficient.
    Are there *any* examples of serious Java applications with acceptable performance ?

    --
    http://rareformnewmedia.com/
    1. Re:I was expecting someone by Anonymous Coward · · Score: 1
      You obviously didn't get what he said, dumbass. Of course Java is slow for graphics, but it can be awesome in enterprise software developpement, because of all the nice api you get and because of the inherently clean language that Java is.

      "Games are the best benchmark", duh. Stupid declaration. Best benchmark for graphics, but if you were doing anything else than playing videogames you'd realize there are so much more other types of apps than games. Oh whatever, I don't know why I'm replying to you, you're just a troll anyway.

    2. Re:I was expecting someone by dubl-u · · Score: 5
      Wow! Who peed in your cheerios this morning?

      I was expecting someone to make this stupid suggestion. [...] What the hell has this got to do with his suggestion - he's asking about debugging threads. [...] This is a fact that you pulled out of your ass.

      When a developer (or team of developers) is spending a lot of time debugging and still not solving the problems, I ususally take this as a sign that there are more fundamental problems than the quality of the debugger. I've been developing serious software for 15 years in Pascal, C, Perl, C++, Objective-C, and Java, and I rarely need to us anything more than the occasional printf.

      Admittedly, developing threaded code is hard stuff, and I don't know enough about the original poster's problems to say what is going on. But it is possible that they are in over their heads, in which case it may behoove them to a) admit that they don't know enough and start again from basics, and b) they may wish to choose a language that is more forgiving of inexperienced developers.

      In that case, suggesting Java is a good idea. That's not to say that C is bad; if I am doing something speed-critical and am working with a team of crackerjack developers, then C would be my first choice.

      But if I'm doing something where maximizing CPU efficiency isn't our #1 issue, or if I'm working with developers who are less than stellar, then I lean towards Java. Why?
      • No pointer errors - Experts may not make pointer errors, but average developers sure do. With Java, there are no buffer overruns, no broken pointer arithmetic, no SEGVs. And even better nobody else making some stupid pointer error that hoses one of your data structures, making you spend days looking for a bug that isn't there.
      • No malloc errors - Java allows you to pay less attention to memory allocation. This makes classic memory leaks impossible, and subtle leaks harder. You're right that novice Java developers take longer to learn the value of reference handling than C developers, but this is mainly because Java extracts a much smaller penalty for those errors. By your logic, presumably, C++ would be even better if each time the developer left a dangling reference they received a high-voltage shock to the nipples.
      • Exception handling - It's been several years since I've used C++, so maybe the exception handling there has improved. But Java's exception handling is a good thing, making it much easier to track down errors when they do happen.
      • Multiple VMs - When I am getting some weird-ass error, it's wonderful to be able to try several different VMs on different hardware platforms. That removes all question of OS issues, endian problems, or bugs in the run-time.
      So the "maybe you should use Java" is a reasonable answer to the question, especially since the original poster specifically mentioned that they were looking at using java.

      Ergo, there was no need for you to be an asshole about it.
    3. Re:I was expecting someone by Werail · · Score: 1

      3. The performance hit is not minor.

      Maybe, but consider that the java compilers barely do any kind of optimizing has quite a bit to do with that. C/C++ compilers OTOH are extremely optimized, squeezing every bit of speed from the CPU. In a few years, when java compilers has matured, we'll be able to see if it really is a viable language.

    4. Re:I was expecting someone by Heretic2 · · Score: 1

      C++ has good exception handling, it's just not as idiot proof as Java exceptions. There are a few caveats in C++ you have to worry about that you don't in Java. Generally, if you adhere to the "Resource Allocation is Initialization" methodology of Stroustrup where all memory allocation is done in constructors and deallocation done in destructors, you'll avoid the memory leaks of aborted code in try blocks. Smart pointers really help here. In general though, you should use that in C++. Then there is the additional caveat, don't throw or let exeptions escape from constructors and destructors unless a catestrophic failure happens!

      That said, Java has a sweet syncronization model based on the Hoare Monitor model. The whole "every reference isa monitor" is so useful. I love the way sycronize blocks work. The model has some performance impacts over other syncronization methods, like perhaps having to wake all threads up trying to wake one specific thread, but more or less you can do whatever you need to and it's simpler.

      And, Solaris is probably the best multi-threaded OS out there. Definitely the best *nix. Sun spent TREMENDOUS amounts of effort to fully multi-thread the Solaris Kernel. In addition, they multi-threaded the standard C libary. You know, certain C calls, like strtok, have explicitly defined behavior that prevents concurrent use. So what did Sun do? They went and added a new version of every non thread-reentrant C call with a "_r" suffix that allows it to be used concurrently. The Linux kernel is great for small working sets on machine with one maybe two processors, but for large working sets on platforms with many processors, it's very limiting since the Kernel is almost entirely single-threaded. I believe the network stack might have been multi-threaded recently, but for everything else only one processor can work in Kernel space at a time.

      So it shouldn't really come as a surprise that Java on Solaris is the best multi-threading environment out there. Multi-threading was a priority for Sun and they dumped many millions of dollars into the research. The Solaris Kernel has really good thread context-switching heuristics to optimize multiprocessor thread performane. Additionally, with Java they had the luxury to build multi-threading into the language from the start in a clean and elegant manner that makes it easy to use and easier to debug.

      That said, I do a lot of multi-threaded work in C++. I sorta ganked the Java notion of "implements Runnable" and "extends Thread" for like named C++ classes I use. It just makes things simpler to abstact thread handling like that. I also ended up making my own syncronization objects/classes to encapsilate pthreads or whatever thread libary the platform I use runs on since often a platform will implement pthreads as user level threads with their own thread library as kernel level threads. And finally, I make the ADTs I use thread safe. That takes most of the hassle away.

      Ryan Earl
      Student of Computer Science
      University of Texas

    5. Re:I was expecting someone by Heretic2 · · Score: 1

      Maybe, but consider that the java compilers barely do any kind of optimizing has quite a bit to do with that. C/C++ compilers OTOH are extremely optimized, squeezing every bit of speed from the CPU. In a few years, when java compilers has matured, we'll be able to see if it really is a viable language. It's not the compiler that needs to do the optimizing, it's the Virtual Machine. And nowadays, some VMs do optimizing and Just-in-Time compiling. In fact, it's been shown that an IBM VM that does JIT ends up being faster than compiling the Java to machine dependent code to behing with!

      Ryan Earl
      Student of Computer Science
      University of Texas

    6. Re:I was expecting someone by BdosError · · Score: 1

      At this point, I would like to point you all back to an earlier article here on /. about 'advocacy'. Very apros pos, I'd have to say.

      Just something to keep in mind while you all exchange pleasantries about whether C++ or Java is the appropriate choice for the problem at hand. Notice that the language was a secondary concern to the original post, as they were really looking for a debugger with good multi-threading support.

      Full Disclosure:
      I have spent the last couple of years programming in Java, but previously did C++ for about 7 years.


      BdosError

      --
      Complexity is Easy. Simplicity is Hard.
    7. Re:I was expecting someone by dubl-u · · Score: 2
      3. The performance hit is not minor.

      Although this can be true, for most people it just doesn't matter. Why? A few reasons:
      • Speed is rarely the primary issue - For most projects, things like reliability, speed of development, features, and cost of development are more important than execution speed.
      • Profilers are rarely used - Spending a couple of days profiling and tuning your code will make much, much, much more difference than using C++ over Java. Despite that, there are a lot of developers who never touch profilers.
      • Computers get faster; people don't - Thanks to Moore's Law, 18 months from now you code will be twice as fast. It will not be twice as usable, twice as robust, or have twice as many features, and programmers will not be twice as productive. Generally, if I can trade CPU time for programmer time without harming project goals, I'm glad to do it.


      That said, I should mention that I've only done server-side Java stuff. I have no idea how GUI Java programs could still be so damned slow after years of effort, but at least under Linux, they really suck. But this is some sort of GUI library issue, as my console and HTML has all come out surprisingly zippy.
    8. Re:I was expecting someone by Mr+Z · · Score: 1
    9. Re:I was expecting someone by elflord · · Score: 2
      No pointer errors

      In C++, you can avoid pointer errors if you don't care about performance. Use vector instead of array. Use string. Only use pointers to get polymorphic behaviour. (these pointers are less likely to cause grief than array-style pointers where arithmatic is performed) This use of pointers is not as problematic (for example, in Qt one uses new to create all widgets, but parent widgets always delete their children, so one only needs delete the top level widget.)

      In conclusion, most of the error-prone pointer code is there for performance reasons. And most of the complaints about C++ are pre-STL.

      Exception handling

      Exception handling is part of the standard. Exceptions are first class objects, and can be caught polymorphically. AFAIK, they're not much different to javas.

    10. Re:I was expecting someone by fgodfrey · · Score: 2
      Ok, I don't know much about Java so I won't comment on that part of your statement, but I take exception to the comment about Solaris being the best multi-threaded OS out there. (Disclaimer: I work for SGI) The largest system Sun has is the UE10000 and it has at most 64 processors. SGI has built and sold 512 processor systems. Cray has sold 1500 processor systems (though Unicos/mk isn't really multithreaded in the classical sense). So, it seems to me that that title should go to either Irix or Unicos/mk. The Irix kernel is *very* well threaded.

      Lastly, to get back to the topic at hand, the SGI compiler comes with a fairly nice multi-threaded debugger, though I haven't used it very much (I work in the kernel where you basically don't get a debugger other than "printf").

      --
      Go Badgers! -- #include "std/disclaimer.h"
  25. Better link for GVD by sansa · · Score: 1

    Here's a better place: www.adapower.com/gvd

  26. SunWorkshop C++/Solaris on SPARC by one_who_uses_unix · · Score: 2

    I have authored some pretty intense multi-threaded network servers and find that the tools and environment offered by Sun are far and above the best. The Sun Workshop 5.0 C++ compiler and debuggers are amazing. The OS is rock solid, and the envionment is a genuine joy to work in. You can outfit your developers with Ultra-5 workstations including the compiler all for just $3000 through the end of December too. Solaris 2.6, 7, or 8 are all a good choice.

    --
    KK4SFV
    1. Re:SunWorkshop C++/Solaris on SPARC by Felix+le+Chat · · Score: 1

      This is definetly the best environment to work with. If you are serious about programming in *nix you have to use workshop. This is what we use here at Computer Associates.

  27. Bullshit by multipartmixed · · Score: 2
    The best debugger is not your brain alone. Your brain, in conjunction with a multitude of tools (such as gdb, truss, gprof, assert, and debug-output) gives much better results.

    With a debugger, you tend to fix symptoms, not the disease.

    A doctor "fixes" patients by examining their symptoms, determining what their disease is, and then curing it.

    Programmers do the same thing. Merely thinking about a problem and mentally stepping through code is a piss-poor way to figure out what's going wrong. Stepping through code with a debugger is a hundred times more effective, especially in a team environment where you are debugging code you didn't write, or when a junior programmer is misusing a library routine he thinks he understands.

    While it is true that some programmers take stupid actions based on what they see from the debugger, that is because their brains are stupid -- not because they are using a debugger. The debugger is merely another tool for diagnosing a problem, and provides food for thought. Nobody has ever claimed that is a replacement for a good brain. Yeesh.

    --
    --

    Do daemons dream of electric sleep()?
    1. Re:Bullshit by Muzzarelli · · Score: 1
      Is some situations (real time) it is the only option though.

      I spent about 5 years writing a highly multithreaded application on OS/2. Debuggers were great for finding issues in user interface or database oriented code, but absolutely useless when it came to the core of the application, which was a realtime multimedia, audio decompression/mixing type thing with up to about 24 threads executing.

      Ultimately for me the best tool was a performance analyzer, which I coersed into being a post mortem debugger. Because it had the least timing related impact. (Hardware timing not race condition).

    2. Re:Bullshit by MaximusTheGreat · · Score: 1

      In my experience, just looking at the code and understanding how your program works is the fastest way to debug. I have seen too many people spending hours on a piece of code stepping through a debugger. Don't get me wrong, I don't hate debuggers. But, most of the time I find that a simple "close your eyes and think under what situations your program would behave the way it is behaving" gives me an insight so that I only have to look at a few lines and viola I have my solution. I have worked on really Large projects, and I have found this to be true always. Another thing is that most people don't read there code after they have written and compiled it. They just run it and expect to use the debugger to take care of their problems. I have found it much more useful to give a quick walkthrough of teh code to myself before running it for the first time.

  28. The GNU Visual Debugger by guerby · · Score: 1
    has support for threads, see the GVD home page.

    Note that might want to have a look at the Ada 95 language, it has pretty good support for portable multi-threading (aka tasking, builtin into the language) and a very good compiler: GNAT.

    Laurent

  29. Thinking and discipline by wocky · · Score: 3

    In my experience using various debuggers over a number of different projects, none of them are particularly useful with multithreaded programs. Almost any of them are good enough to get stack dumps of the various threads and to print data values when an assertion fails, but they don't help much beyond that.

    The best way to get a parallel program working is discipline and understanding. Think about how the threads will interface with each other. Design those interfaces using appropriate known and proven synchronization methodologies. Adhere rigorously to those designs. If you're tempted to leave out a lock in some place, you'd better be able to prove that it can be done safely.

    If necessary, write wrappers around your synchronization primitives for better observability and controllability. For example, when the program crashes, you want to be able to see which threads are holding which locks, which are waiting for what conditions, etc. Being able to log the sequence of synchronization actions to a file and to force a replay of those actions in the same order will help in reproducing bugs that otherwise would manifest themselves only once every hundred runs.

    Have manual inspections of the code with a coworker. Play a game where either of you can propose a failing scenario and the other must explain using the code why that can't happen. If neither of you can explain why it can't happen, it probably can.

    Your basic philosophy should be that it's impossible to convince yourself of the correctness of the synchronization through testing. If you can't prove that your synchronization is right, it's most likely wrong. And if it's not wrong, it's so complicated that you'll break it later because you don't understand it.

    --
    David
    1. Re:Thinking and discipline by invalid+email · · Score: 1
      Your basic philosophy should be that it's impossible to convince yourself of the correctness of the synchronization through testing. If you can't prove that your synchronization is right, it's most likely wrong. And if it's not wrong, it's so complicated that you'll break it later because you don't understand it.

      These are the words that should be written above the gates to the hell of multithreaded programming. Do not pass beyond these walls without understanding what they mean.

      Simplicity is paramount to this. If there is only one place that requires a lock, and everything is firewalled behind it, then you only need to ensure that single place works for all threads. The nastiness comes when threading is pervasive throughout the system, where there is no clear concept of object ownership between threads.

  30. How about for C on Linux? by Jay+Maynard · · Score: 2

    There's been a lot of discussion so far about moving to Ada and other languages, and other OSes. I have a similar, but not identical problem: a program written in pure C on Linux (and Win32, via cygwin) that uses threads extensively. So far, I haven't found a debugger that'll do worth a darn at following threads. Rewriting is not an option. Got any suggestions here?
    --

    --
    Disinfect the GNU General Public Virus!
  31. Go to Solaris by smackdaddy · · Score: 1

    We have a heavily threaded C++ program that we develop at my company. It compiles under Sun Workshop 5.0, and Visual Studio. I would recommend getting workshop or the new Forte 6.0 C++ tools for Solaris on Sparc. They are great tools. The Front End for DBX makes debugging multiple threads very easy and when you dump a core, you get a call stack for all of your threads. That is much more easier in my opinion then when I was doing pthreads under xxgdb.

    Another nice part about doing it on Solaris is that after you get all the bugs worked out of it, you can bring it back to a linux platform and run it there. Our Application compiles and runs under Solaris Sparc, Solaris x86, Linux x86, and Windows, so if you design it well you can get the portability with C++.

  32. damn, hate to be the troll here, but... by Anonymous Coward · · Score: 1

    maybe you should consider moving to NT? MSVC has the coolest debugger in the biz imho...

  33. you're right about soffice, but by joss · · Score: 2

    I bet I've written more java than you.
    I spent about two years doing full time java
    development (full fledged scientific java application for Alcan). I first learned java five years ago, and have tried it on and off since then. I recommended using it in that project because the superficial impression it gives is pretty positive, and *anything* is better than using MFC. (I wish I had known about FLTK back then)

    I would not recommend Java for client side application development. If you really care I could drone on for days about why it's a bad idea. Personally I wouldn't use it on server side either, but I agree that it is pretty good for that. Sun has spent many millions of dollars putting together suitable libraries and tools to make it a good tool for server development.

    Actually, I had thought soffice was largely java because it's a misconception that's quite common and also because soffice is slow and bloated, but not as bad as I expected for a java application. I think it's largely C++ though. Please give me an example of a good, substantial Java client-side application if you believe I'm just spreading FUD.

    --
    http://rareformnewmedia.com/
    1. Re:you're right about soffice, but by jkujawa · · Score: 2

      JBuilder?

    2. Re:you're right about soffice, but by joss · · Score: 2

      OK, I've used this quite a lot..
      It's unuseable with less than 128M or RAM. It's almost tolerable with 256M. It suffers from random freezes and needs to be restarted from time to time, otherwise memory consumption rises mysteriously. If you build a sizeable jar file from within Jbuilder it takes about 10 minutes - create the same jar from command line (jar -cvf) will take 20 seconds. It randomly caches class files, so you can never quite tell whether a source change has really taken effect - you can manually delete all the class files, do a full rebuild, and it will still use some cached class file from memory somewhere - misleading you into thinking that your code change didn't fix the bug. In the end we abandoned it and reverted to using jdk1.1.8 command line tools together with gnu make.

      Does anything else sping to mind ?

      --
      http://rareformnewmedia.com/
    3. Re:you're right about soffice, but by Saucepan · · Score: 1
      Lucent PMVision comes to mind. It's been a couple of years since I last ran it, but it's performance was quite adequate even on the wimpy pentium box I was using at the time.

      And then there's always the Oracle admin tools, which are written in Java and-- um, Ok, let's forget about them for now. :)

    4. Re:you're right about soffice, but by Edward+Teach · · Score: 1
      Togethersoft's Together Control Center. http://www.togethersoft.com.

      --- This is my sig. There are many like it, but this one is mine. ---

      --

      Setting his threshold to 5, Sparky eliminated most of the trolls on /.

  34. Check out spin by stripes · · Score: 2
    I donno about switching OSes, but whatever OS you use you should definitly look at SPIN, a tool for modeling locking behaviour (and other things). It has found a large number of problems in real systems that "normal" debuggin had a hard time finding. Race conditions are hard to remove by inspection!

    As for Java vs. C++, well Java isn't a bad language, and having threading built in rather then slapped on as a bag on the side makes it nicer (pop quiz: what C++ facet operations are thread safe?). On the other hand I feel a bit limited in Java, and I miss the STL. As far as I know SPIN will help Java coders as well.

    I don't think Solaris x86 is a good idea. If you want Solaris, get a SPARC. Otherwise you are always behind the support curve, and the hardware support is far more limited then Linuxes. Besides the SPARC hardware is extreamly reliable (if not all that fast), and works great for lights-out operations.

    1. Re:Check out spin by dieman · · Score: 2

      You *miss* the STL? Which part of java.util and other nifty 1.3 classes have you not looked at yet?

      --
      -- dieman - Scott Dier
    2. Re:Check out spin by Fnkmaster · · Score: 2

      Templates, my friend. I work in Java all the time and I still find it frustrating as hell that there are no templates.

    3. Re:Check out spin by LukeyBoy · · Score: 1

      When I'm using Java, I find that every class having the Object as it's highest super-parent makes templates really unneccessary. The Collections framework is extremely well-designed and based on this fact. Linked lists, queues, stacks and so on contain Object references which can be used to hold pointers to any type of data due to the common inheritance.

      I also find that templates add a hell of a lot of overhead in compiled code and source code since a lot of compilers have minor differences in implementation of them (g++, Intel, MSVC) leading to rewriting code when switching development platforms. A lot of complex C++ template classes and functions I've written (that adhere to the C++ specs) work on one compiler and cause unknown errors on another.

  35. debuggers by boedicker · · Score: 1

    In "The Practice of Programming", Kerighan and Pike specifically say that other approaches besides debuggers are necessary for multi-threaded programs. Debuggers encourage laziness anyways. The less you rely on them, the better code you will produce, in my opinion. Code reviews, debugging print statements inside the code, etc. will make you look at the code more, think about it more, and be more defensive in your style. This will always produce more robust code.

  36. SGI Jessie? by Hack-n-slash · · Score: 1

    I'm not a programmer and I have never seen it in action, but SGI has an OSS product named Jessie that's written in Java. I don't know what the performance is like.

    1. Re:SGI Jessie? by duffbeer703 · · Score: 1

      I cannot fly, and I have never been on an airplane, but some guy in Nebraska built a plane out of chopsticks using glue.

      I don't know whether it's safe or not.

      --
      Conformity is the jailer of freedom and enemy of growth. -JFK
  37. The best debugger is 'printf' by Reality+Master+101 · · Score: 3

    Personally, I despise IDEs because they always slow me down. I've noticed that the best programmers never seem to use them. I think putting well-chosen printf's in the code forces you to think about what you're actually writing, rather than writing a bunch of garbage and then using the debugger to bail you out.

    A lot of people think I'm crazy when I say this, but both Linus Torvalds and Gostling have said similar things.

    I've developed both ways, and there is no doubt in my mind that it takes me less time to develop when I just use printf's. But -- it does take more discipline, and that's probably why you see so many mediocre programmers slaves to the debugger and IDE.

    vi, make and printf (with the occasional grep and find) -- that's my debugging environment, and I'm known for my development speed and code quality.


    --

    --
    Sometimes it's best to just let stupid people be stupid.
    1. Re:The best debugger is 'printf' by johnlcallaway · · Score: 2

      YES!!! There are other programmers like me...

      I remember a C++ programmer asking me what debuggers were loaded on our HP system. I turned to him and said 'printf ... just like on all systems' and he looked at me like I had three heads. Ah ... kids these days have it soooo easy!

      Debugging code is very easy ... finding out where the problem is is very difficult. I include in all my programs, under IFDEF control of course, trace statements in each paragraphs that also include timestamps. It is amazing how using standard UNIX tool sets (grep, sort, etc) you can get tons of information from just this. In a multi-threaded program, I also dump out a thread-id I assign to each thread so individual threads can be analyzed.

      To be fair, I do use debuggers from time to time, but usually only has a last resort. I find it is much easier to add extra printfs than it is to set up conditional breakpoints and then step through code for hours.

      Using the above information, it is usually possible to narrow the issue down to a few lines of code. Time then to add some more printf's to dump values.

      One very large advantage of using vi (or emacs) and printfs is they are available on all UNIX systems and all compilers. When changing jobs, the last thing I want to do is be neck deep in a bug while trying to learn a new debugger

      I only use the 6 editor....

      --
      I rarely read replies, it's my opinion and if you thought about your opinion a little more, I'm OK with that.
    2. Re:The best debugger is 'printf' by geisler · · Score: 2

      I use printf(), also, but it isn't sufficient for multi-threaded programs because of race and deadlock conditions. The printf() can change the timing enough to alter remove the race or deadlock. A nice debugger would help in those cases to tell where each thread is. Unfortunately, I haven't used one. In fact, I was in this situation earlier this week on a machine without any working debuggers. Reading through the code reasoning what was happening was the only method open to me. I love gdb and use printf() all the time, but in the end, understanding your code thoroughly is the only way you will be able to find and fix errors.

    3. Re:The best debugger is 'printf' by Ristretto · · Score: 2

      This makes a nice segue back to multithreaded debugging. Printf is a prime source of "Heisenbugs" in multithreaded code, because it causes code to be serialized behind the big printf lock. Programs with race conditions frequently work fine when printf is used for debugging. There are non-IDE, non-debugger based workarounds, of course. One I've found to work well is maintaining a per-thread debug log -- this avoids global synchronization and so tends to leave timing more or less intact. Incidentally, I couldn't agree less with your judgement on debugging tools, etc. The foregoing suggests that you have limited exposure to multithreaded code, where tools make a big difference.

    4. Re:The best debugger is 'printf' by kaisyain · · Score: 2

      How does an IDE slow you down? I've never understood that. What is it that is taking you so long to do? If you want to use the IDE the same way you use vi, make, and printf you can. The only difference is you press F6 instead of typing :make. And you press F7 instead of typing "ctrl-z; cd ../../../object/directory; ./a.out" or moving the mouse to a free xterm and typing "./a.out" there.

      I fail to see how your way is faster.

      In my experience, people who are slower with IDEs just haven't bothered to learn how to use them. They are the people who spend a few days playing around with VisualStudio and then give up saying "it is too complicated, it slows me down" all the while forgetting that it took them WEEKS or MONTHS to get to the level of profiency they currently have with vi and make.

    5. Re:The best debugger is 'printf' by borgboy · · Score: 1

      AMEN ...although, VisualStudio sucks...

      --
      meh.
    6. Re:The best debugger is 'printf' by Peaker · · Score: 1

      printf debugging is possible. But debugging with debuggers IS productive, and unlike many people think, it DOES take skill and practice.
      You have to know to ask the right questions, and place the breakpoints in the right locations.
      If you are stepping through code for hours, you are doing something wrong.
      Generally, you should always have a strongly-defined input->output for each piece of code, and debugging your code should consist of finding the exact point where the code generates unexpected output from your input (or state or condition). Step in the code to find the exact point it breaks more specifically.
      This, ofcourse, is for the case when your output (meaning not only actual output, but getting wrong things done) is simply wrong for some reason. For the case of crashes/etc, integrated debuggers usually make seg. faults trivial to understand via the immediate stack trace, local-scope watches, etc. that jump up automatically, and allow you to even change a bit of code, set the program counter to another location, compile, and continue the program's run from where you wish (no need to restart it). This, however, is a specific VC++ trait, and I wish I could find it in more environments..

      I use both methods to debug, but I find debuggers simply more productive.

    7. Re:The best debugger is 'printf' by QuoteMstr · · Score: 1

      printf can be useful sometimes, yes, especially when you want a log of something's operation that you can mull over later. The problem is that there are certain classes of errors that printf cannot catch, e.g., smashing the stack and corrupting the heap. For these, tools like electric fence are invaluable.

      Debugggers also allow you to dynamically insepct and *MODIFY* the values of variables, unlike printf. To look at a new variable with printf, you'd need to recompile the source file!

      As for Linux --- it does have a kernel debugger.

    8. Re:The best debugger is 'printf' by johnlcallaway · · Score: 1

      Tim said ---
      I'm confused - are IDE debuggers good or bad? You seem to say that they are bad, and all you need is printf...but then hint that they are good by saying that people who use them have it easy?

      There is a good reason for the confusion ... the post didn't say if debuggers were either good or bad. Instead, I attempted to convey that printf can be a really good tool on UNIX systems, and to present a simple, non-intrusive concept (printf statements w/timestamps in each function that actually mean something) that can be easily turned off or on for debugging and other code analysis purposes, such as benchmarking.

      Let me return the favor of quoting other people's ideas ... here is a quote that might bring my feelings on this topic into perspective
      When the only tool you know how to use is a hammer, everything starts to look like a nail. - (Author unknown to me ... I usually don't quote other people)

      Is there really one perfect debugging tool? Debuggers are really great when you don't have a clue why a daemon is just dropping of the face of the Earth without a coredump or a message after running for a few hours. Set a few watch parameters and go home for the evening. (Just an example ... don't everyone get all hot and bothered and supply a gazillion other good examples.)

      Maybe the best debugging tool to use is your own brain and an open mind. How many times of each of us spent hours (days??) tracking down a bug only to realize that the clue to the problem was in front of us all the time, but we were so sure it was something else that the blinders never came off.

      My preference will almost always be printf first, debuggers later. But, there is one really bad thing about printf I would like to mention ... many programmers forget to take them out aftwards or don't but them in an IFDEF block. That makes for really messy log files.

      Thar be bugs hear

      --
      I rarely read replies, it's my opinion and if you thought about your opinion a little more, I'm OK with that.
    9. Re:The best debugger is 'printf' by Dwonis · · Score: 1

      Your point is undoubtedly true for half of the programmers that hade IDEs, but there's another side to it: Not every programmer has dual infMHz system with infMB of RAM.

      I find that using IDEs would be easier if they weren't so slow and bloated. It's much quicker to use vi in textmode than to start X and some GNOME/KDE debugger, and then wait for the GUI each time you want to do something.

      I usually have 2 terminals open: one for editing with vi, and the other for running the program. I also tend to set up my makefile so I can issue a "make run" to recompile and execute my code.
      --------

    10. Re:The best debugger is 'printf' by kirkb · · Score: 1
      Personally, I despise IDEs because they always slow me down. I've noticed that the best programmers never seem to use them.

      Two words: John Carmack

      --
      Slashdot: come for the pedantry, stay for the condescension.
    11. Re:The best debugger is 'printf' by Switchback · · Score: 3
      This is the type of comment I hear from novice and inexperienced developers. Most new hires right out of college seem to have this fear of debuggers and their debugging skills consist of printf's everywhere. Now don't get me wrong, printf's or some other diagnostic output (such as logging) is very handy to hopefully gain a handle on what is going on, but it's not the solution you want to use if after looking at the output you still have no clue what's happening.

      Debuggers (both command line and GUI) are all essentially the same. Learning one isn't doesn't take very long (on the order of a few minutes) to do the basic things like set breakpoints, step, and watch variables.

      Here are the problems with printf (and other diagnostic output):
      • They don't give you the whole picture and very rarely point you to the exact location of your problem.
      • They have to be maintained. I don't know how many times people have cut & pasted a printf but failed to change its output causing utter confusion. Or the code changes and the printf didn't. They can become a maintenance headache which can actually hinder the troubleshooting process. The should be controlled somehow (preprocessor..some logging level varible etc.) but getting everyone to do that everywhere consistently is also a problem.
      • They can be misleading especially if the output has not been flushed yet.
      • They can get in the way of the actual running of the program and mask bugs (especially race conditions).
      • They can't tell you when a pointer or variable gets stomped on.
      Debuggers on the other hand let you see your entire application state and you can see in an instant if everything is right.
      • If the program crashes you immediately see what went wrong and you can view the call stack to see how it got there.
      • You can easily debug multi-threaded programs because you can force potential race conditions and see if your code works properly or not.
      • You can dynamically alter the flow of your program yourself and force potential problems to check your code behaves properly. Using a debugger is a great way of testing all conditions a piece of code might face: valid input, edge conditions, and invalid input.
      'Debugging' with printf is an iterative and lengthy process of looking at the output, adding more printf's (adding to the maintenance problem), compiling, and looking at the output again. With a debugger, I almost always find the problem on the first or second pass through. You also invariably find other potential problems lurking in the code that just haven't shown up yet. Tracking down a problem with a debugger usually takes me just a few minutes, but going through the printf process takes much longer and may never show you the real problem.

      Think of it this way: You go to a doctor saying you dont' feel well. The printf doctor pokes and prods you until you yell 'ow!'. The debugging doctor uses the intelligent approach where he looks at your symptoms, runs some tests and makes a much more accurate diagnosis of your problem.

      - Rick Alther
    12. Re:The best debugger is 'printf' by rkent · · Score: 1
      Printf is a prime source of "Heisenbugs" in multithreaded code, because it causes code to be serialized behind the big printf lock. Programs with race conditions frequently work fine when printf is used for debugging.

      Well, then just put in "printf("");" everywhere and your program should work perfectly! What's the problem?!

      ; )

    13. Re:The best debugger is 'printf' by CubeRoot · · Score: 1

      Personally, I despise IDEs because they always slow me down. I've noticed that the best programmers never seem to use them. A quality that I have noticed in the programmers that I admire is that they remain open minded about their techniques and tools. Periodically surveying what is available to see if they can improve upon what they have. IDE's have come along way in the last few years. You might be suprised. Using an integrated debugger will not erode one's ability to write and understand good code. If you haven't already thought carefully about the code before it comes time to debug it, then doing so while adding print statements won't help you. My background is primarly UNIX (but with emacs:-) Recently I have found an excellent IDE. The debugger is well written and poses very little impact on the application. So, I always run the app via the debugger. Any time I need to know what is happening I can drop into and immediately get any information you could get from a print statement. Should I need to make a code change, the IDE supports incremental linking and can rebuild in short order. It's a very efficient workflow. That being said, another sign of a good programmer is not jumping on every band wagon. If you have found an effective workflow, then stick with it. Just don't fall into the trap of writing off a whole class of tools forever, and then call it strength of character.

    14. Re:The best debugger is 'printf' by Trepalium · · Score: 1

      Debuggers can be great for locating crash bugs, however they're of far less use when your program is generating incorrect output based on the input you give it. For those, it's usually easier to input a batch of printf's into the code printing out intermediate information to give you a chance to find out where your logic goes horribly wrong. Although every so often you end up with a bug that stops acting up when loaded into a debugger or with added printf's, forcing you to use the other method. Compiler/optimization bugs can be a real pain to sort out and can sap up loads of time no matter what method of debugging you prefer.

      --
      I used up all my sick days, so I'm calling in dead.
    15. Re:The best debugger is 'printf' by Trepalium · · Score: 1

      The problem being is that debuggers themselves can interfere with program/thread scheduling enough to change the behaviour of bugs significantly when dealing with race conditions. Personally, I've found that conventional debuggers are practically worthless when you have a program that's generating improper output -- those are usually better suited to printf/debug fprintf logging, since they generate a history of what the program is doing rather than a snapshot of the app at the given point. Honestly, the only thing I use gdb for these days is for the stack trace so I know where to start looking, although often I already have some idea. The worst bugs, IMO, are when the compiler generates improper code, however. Even the most advanced debugger usually won't help you much there unless you're intimately familiar with disassembling compiled code. Of course, that's part of the fun, right... Along with seeing gcc generate code like 'movl %eax, %eax'

      --
      I used up all my sick days, so I'm calling in dead.
  38. best way to debug programs is to not ENBUG them by bobalu · · Score: 1

    Yes, the best way to debug programs is to not ENBUG them. Lo-tech: Read the code. Have each thread print trace info to a log so you can see the interaction and interleaving of the execution. And if you really want a great system for doing multithreading and are willing to change your entire universe to get there just use OS/2. :-)

    --
    The revolution will NOT be televised.
  39. Reference please by Convergence · · Score: 2

    Please give a reference for where 'toy' languages have been used and have failed.

    1. Re:Reference please by Fourthstring · · Score: 1

      Unfortunately you're wrong. Emacs is all about functional languages. The main Gnu extension languge is a functional language. (Emacs-Lisp & Scheme, respectively.) And neither of these are toys: You can't configure Emacs without using the functional language, unless you really want to rip through the sourcecode to "configure" something.

    2. Re:Reference please by Shelrem · · Score: 1

      Uhh, Quake3 is written in C. I'd say that it's a succesful project. The Linux kernel is C, which i'd say has been successful...

      Now, who said that functional programers never make it to the Real World?

      -ben.c

  40. What ever happened to real programming? by Emperor+Shaddam+IV · · Score: 1

    Use printf()!

  41. score -1, offtopic by mkettler · · Score: 3

    I agree, it's quite ridiculous that this post has been moderated up. It's purely off-topic.

    I've actually USED paradigm C++, along with paradigm link and locate tools. It's for embedded application development. (ie: raw rom hanging off an x86 processor bus with no bios (you actually run where a BIOS would be), no OS, etc). The dev tools themselves run on ms-windows.

    This tool has little to do with multithreading, in fact I don't belive it contains a thread library at all. (I could be wrong, but I never saw one and it's not a listed feature) It supports real mode, and if you're x86 can do it, protected. It will target as low as 80186's and NEC v## processors.

    It also has nothing to do with UNIX. It's for people building non-pc x86 based systems that have no BIOS and no OS. It's for bare-metal embedded c++. You can't even run the IDE on UNIX, much less the target.

    They have a site at devtools.com, visit if you're bored, see how much Multithreaded Unix support they have...

    My personal opinions of this software aren't very high, but mostly because my opinion of x86 for raw-soldered embedded is pretty low. The product itself is relatively well written.

    --
    -Matt
  42. Things to consider... by wd123 · · Score: 2

    First off, I'll say I recommend a combination of C, Unix (any flavor will do), any compiler that is ANSI standard, your favorite editor, make, debugging statements and light gdb use. These get me farther than any IDE I've had to work with or tried to work with. Incidentally, every developer I can think of who I admire for producing absolutely brilliant code, especially quickly, tends to use the above. Just a favorite editor, whatever their language choice is, and simple tools. Remember the KISS principle.

    #1: Can you really switch your language or OS?
    At best I'm dubious as far as your suggestion of switching language or operating system. Unless your project is only at the very first stages, you have almost undoubtedly invested far too much effort to reasonably consider backing out. Why did you choose C++ and GNU/Linux in the first place? Surely more thought went into it than "we like C++" and "Linux is nifty", so go back to those decisions and sift for clues.

    #2: Why are you spending so much time in a debugger?
    You should be spending more time with your concepts, flow charts, and whatever else you came up with before you laid it all into code. Spend some time pondering what exactly you're trying to do, then go look at your code and make sure it's really doing what you want. A few well-placed debugging output statements (printf/cout/whatever), some good comments, and a clear head will get you much farther than a debugger, even the best. Debuggers absolutely cannot tell you what you're thinking.

    #3: Do you really need threads?
    Is your application specifically designed to be run on parallel systems? Is it designed to take the majority of a system's resources? Chances are you don't need threads, most programs don't. There are usually better ways to do things than multithreading. Also, writing threaded code is considerably more time-consuming than non-threaded code. Are you writing something so complex you need threads? If you haven't really evaluated this, now is the time.
    -wd
    --
    chip norkus(rl); white_dragon('net'); wd@anduril.org
    mercenary albino programmer for hire

    --
    "question = (to) ? be : !be;" --Shakespeare
  43. Shouldn't be the major decision factor by photon317 · · Score: 3
    It worries me that you're willing to change platforms/languages/etc just to find the right debugger. If you stick to good programming practices, coredumps should happen rarely to begin with, and therefore the tradeoff is there to have a better language/os and a really hard time dealing with corefiles. Also, most good programmers, even when dealing with a serious bug causing a coredump, only use a debugger to get a backtrace... they don't really _use_ the debugger. And in many circumstances, marker statements in the source code are even simpler than using a debugger for a backtrace. In light of all these things, I could never justify changing my whole coding world arounda decision about a better debugger... something else is wrong here.

    --
    11*43+456^2
  44. If you thinking about switching from C++ to Java by Emperor+Shaddam+IV · · Score: 1

    And your already unit testing your app, you are a little late to be considering a platform/language switch.

  45. When I was in college... by Emperor+Shaddam+IV · · Score: 1

    We didn't have any debuggers. And we only got 5 compiles to get it right. Of course we are talking about Cobol here. MUHAHAHAHA

    1. Re:When I was in college... by localroger · · Score: 1
      Ah, Hollerith cards. I quickly found it was easier to write and debug the assignment in BASIC on a microcomputer and convert it to FORTRAN, than it was to try and actually write a program in FORTRAN directly into a card stack and debug it from the return printouts.

      Of course in those days most people didn't have home microcomputers on which to do this.

      --
      Brackets contain world's first nanosig, highly magnified:[.]
  46. threaded program state by xtp · · Score: 1

    I rely on debuggers for a traceback after crash. However, that rarely tells what the program was doing before it got into trouble. For that you need not only the current state, but the previous states looking back in time. Debugging a transport protocol under multi-client load is a good example. I'd suggest creating a tracebuffer fifo, simple means for annotating the threaded code with calls that log state in the buffer, and means for extracting the contents and displaying in various interesting ways. It's easy to do this. It's portable. And it will yield information far beyond what is possible with language/OS-centric tools that know nothing about the theory of operation of your app.

  47. Solaris Debugger by RedShodan · · Score: 1

    I see people talking about Solaris debugger, dbx and praising it. I can not see how anyone can like that program. Its the worst debugger I have ever used.

    I worked for 3 years at a large aerospace company and we did some truly large C++ projects. They were all at least nominaly threaded because they used a CORBA implementation (which was threaded itself). I can not count the number of times that dbx core dumped on me because I tried to look at the wrong symbol name.

    Granted, it had nothing to do with threads, but the linker and symbol demangling. But given the fact that it was almost impossible to use on any project of any good size, I do not count that as a good debugger. Also, about a 1/3rd of the time the debugger failed to actualy stop a progam at break points. In my experience, the MSVC++ debugger is much more stable and usable. Dont get me wrong though, I am a Linux person and cant stand Windows. I just have to port Linux apps to Windows for my current job.

    Just give me linux and I'll be a happy person. (that includes gdb, with its couple of flaws) Flaws in an Open Source product dont bother me at all. They will be fixed. Flaws in a coporate product will only be fixed if the company can make more money because of it. Guarenteed.

    --
    RedShodan --------- Never underestimate the bandwidth of a station wagon full of tapes.
    1. Re:Solaris Debugger by Serveert · · Score: 1

      Never once has Solaris dbx dumped core on me and I have used it extremely heavily. I debug running processes almost daily, I look at cores almost daily. It stands up extremely well. It sounds like you used an old version of dbx.

      --
      2 years and no mod points. Join reddit. Because openness is good.
  48. Never underestimate... by _fuzz_ · · Score: 1

    the power of printf. Create a trace mode that spits out a rediculous amount of information about what is happening. I have found this to be much more useful than a debugger in multithreaded apps.
    --

    --
    47% of all statistics are made up on the spot.
  49. Shared address space problems by dmelomed · · Score: 1

    If you have problems with debugging deadlocks and other thread-related problems, I strongly recommend state-threads. If you are struggling with the traditional thread libraries way of dealing with shared address space, State Threads could be the right choice for a threads library. State Threads were designed for server/client I/O intensive applications. The library is portable, scales extremely well on multi-processor machines, and locking is not necessary since it allows for private thread data natively (no mutexes and locks needed, everything is user-space also). The server.c that's shipped with this library is not your common multi-threaded application, very easy to understand and doesn't suffer from locks. It's GPLd. http://oss.sgi.com/projects/state-threads/

  50. CodeWarrior by kriegsman · · Score: 5
    When writing threaded code the developers must take the responsibility for understanding the threading issues and creating thread-safe code. But the right tools can help you get there more quickly and sanely.

    We've used Metrowerks CodeWarrior to develop and debug very heavily multithreaded applications on MacOS, NT, Solaris, and Linux for about five years now; the CodeWarrior tools seem very much 'up to the job' and thread-aware. As a nice plus, CodeWarrior runs on multiple platforms (including Mac OS X now), which is a nice plus for our development, which is all multiplatform.

    We now use a diversity of compilers/IDEs/debuggers, but CodeWarrior is still a favorite, even if it's just because of the "Blood, Sweat, and Code" T-shirts.

    1. Re:CodeWarrior by The+Rev · · Score: 1
      I've still got my Blood Sweat and Code T-shirt and Boxers that came with CodeWarrior 8!

      Back on topic. The CodeWarrior tools rock. I used to be the only Mac programmer working with 10 PC developers and I used to find their bugs before they did.

  51. Comments from Pro with Lots of Experience by Acceleration · · Score: 5
    Lot of good points already made.
    • Have small set of proven core threading routines.
    • Don't use threading unless it's really justified. At times, it seems right, but you can lose lots to context switches. So reducing threading can help too.
    • Can't debug this stuff to demonstrate correctness. Must THINK.

      To all this I'll add:
    • While staying in mainstream language land (which is worth a LOT), Java has great thread support. It works well. It works well on all platforms (excepting W95). You can use your OS of choice and switch at will for the most part. Linux/NT/Solaris/whatever. I use NT.
    • I like being able to use truss on Unix. It's *very* helpful in unraveling knotty problems. I have the most experience with this on Solaris. Solaris threading is good stuff.

      Java is a lot more productive than C++.
      C/C++ can be lots more runtime efficient.
    • In lots of circumstances, these efficiency gains are unimportant.
    • Usually more important to efficiency is algorithmic choices and quality of program implementation -- and few developers are worth a damn in this arena.
    • So C++/Java is usually moot point regards efficiency trade-offs, because programmers product is such slop anyway.
    • When programmer's code is good, then a small subset of the time, you're better off in C++ for runtime efficiency.
      Aside from that, you're better off in Java.

      I miss C++ (and even C) sometimes, but Java is usually a better language overall. Not hard to migrate.

      If you go with Java, take a strong look at Doug Lea's stuff.
    1. Re:Comments from Pro with Lots of Experience by Peaker · · Score: 1

      Java is a lot more productive than C++.

      Which C++ framework (/library) did you use?
      I used to find C++ quite a bad language, for example, until I learned how to implement true OO concepts in C++, and that the standard C++ library is simply crap.
      Using Qt, I can be a lot more productive, and hardly ever need to think about memory management. This really makes me wish a library like Qt could be used for non-GUI programming, because its the only library I know of implementing true OO concepts to create a comprehensive framework to work with, without having to fall back on ugly C-functions to work with, making the code an ugly hybrid of C++-style and C-style crap.
      Other than that, I don't see how Java would be more productive, especially with its lack of multiple inheritance (and if you claim, like others, this is a sign of bad design, I can enumarate more than one case in which you need it for a good design), its lack of nice syntatic sugar (overload operators, for one), etc.

      Do you believe Java is more productive than C++ in general, or just more productive than C++ in a specific setting you used it - with the crappy standard library?
      Please take a look at the Qt interfaces and how comprehensive they are before answering.

    2. Re:Comments from Pro with Lots of Experience by elflord · · Score: 1
      This really makes me wish a library like Qt could be used for non-GUI programming, because its the only library I know of implementing true OO concepts to create a comprehensive framework to work with,

      It can, but it requires that X11 be installed. Maybe you should write to Troll and ask if they can break off their non-GUI stuff (collection classes, sockets, XML, etc) into a seperate library.

    3. Re:Comments from Pro with Lots of Experience by elflord · · Score: 2
      n lots of circumstances, these efficiency gains Usually more important to efficiency is algorithmic choices and quality of program implementation -- and few developers are worth a damn in this arena.

      So C++/Java is usually moot point regards efficiency trade-offs, because programmers product is such slop anyway.

      I don't know about java, but at least in C++, there are generic container classes, and the C++ standard has performance gaurantees (big-O) on the effectiveness of these algorithms. So it's not accurate that the C++ programmers product is always "slop", because they can reuse well designed and implemented container classes for a lot of their work.

      Java is a lot more productive than C++.

      Or so they say. It's true that C++ code that makes heavy use of pointers is error-prone and needs extra care maintenance-wise, and should be locked up in a library where client code can't see it. But if we only require java-like performance, then why use pointer-arrays instead of vectors, and why use char* instead of string ? Most of the things that are error-prone in C++ boil down to instances of the developer choosing speed over safety. If you want to sacrifice a little speed and forget about pointer arithmatic, you can do that, and you'll still be faster than java.

  52. Re:[AGREE!!!] The best debugger is 'printf' by pranalukas · · Score: 1

    Hahaha, that's subtle, but I do it all the time too!

    Yeah, for debugging, I just use fprintf(stderr,..,...)! Save my time a lot, bro! ;)

  53. TotalView by Sax+Maniac · · Score: 4
    TotalView probably does what you need. Other people have said it here, but I can add a little more info.

    It's a parallel debugger, which means that it has built-in support for manipulating groups of objects, as if they were one: threads in a proceses, processes in a group, groups in a cluster, and so on. This means you don't need 20 windows to control a 20-thread app; we roll up an aggregated view into one window, commands work on the entire batch.

    And yes, we support Linux, as well as almost every other Unix out there. You can snag a free demo license and download the bits from our website. And for those of you who like printf(), you can add them on-the-fly without recompiling. That saves time.

    Disclosure: I am a developer on TotalView, but I do "eat my own dog food"- we use it every day on itself.

    --
    I can explanate how to administrate your network. You must configurate and segmentate it, so it can computate.
  54. Real real-time debugging by LJD65536 · · Score: 2

    If you are doing hard real time where timing tolerances are really critical, neither printf or a software debugger are of any use. The printf will alter the timing the very thing that you are trying to observe. Although there are some fairly expensive solutions, I like using the parallel port and an oscilloscope. Instead of printf's, insert direct io writes to the parallel port into your program. View the output on a multichannel oscilloscope or logic analyzer. Some people find this approach incongruous with an operating system like Linux where such bare metal tactics seem at odds with the prevailing higher levels of abstraction. But timing tolerances can only be observed by direct viewing. If this is a project with actual funding, there are solutions that are less improvisational. Many logic analyzers have bus preprocessor cards that can be inserted into an empty card slot of almost every conceivable chassis type. The logic analyzer also come with software that will display the traces in nice formats for viewing. You can then see the timing relationships of both your inserted I/O writes as well as any other activity. On a modern computer, often all the other activity is too confusing so the logic analyzer can be set up to filter it out. There are also complete logic analyzers that can be inserted into a card slot. In spite of all the modern gadgets now available for real time debugging, I still occasionally find use for some of the improvised tricks I learned before such devices were for sale. Larry

    1. Re:Real real-time debugging by Minix · · Score: 1

      Of course he's serious. A CRO and a few bits of output can be very useful:

      1) you can set/reset the bits to indicate some condition you're interested in, using a small fixed-time routine (so it impacts as little as possible on the behavior of the code under test.)

      2) the CRO as an output device is very sensitive, and completely unintrusive.

      Using logic analysers is ok, too, but I've found that you need to know what part of the execution is likely to give you the information you seek before you use one (they're like using a microscope, you have to prepare your slides carefully.)

      An unrelated point, from the ddd hints pages:
      `A good debugger is no substitute for careful thought, but careful thought is no substitute for a good debugger' (or words to that effect.)

      --
      "There are four boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order." Ed Howdershelt
  55. Dijkstra is no cure for being human. by Kieckerjan · · Score: 1

    > Here's the true version: 90% of programming bugs come from not reading Dijkstra.

    It is one thing to read Dijkstra and know what programming is about, and another thing to build a hundred thousand line , multithreaded application. If you are right (and I wish you were) someone who has reached the stage of programming Enlightenment can type in a application like that and have it work from scratch, in any given decent language. Someone who is able to do that needs no debugger at all. I personally know of no-one like that, and even if these people exist, the vast majority of the programmer-population (inluding you and certainly me) is confronted with his own mistakes on a regular basis. It is irritating and humbling in a way, but a problem we have to deal with anyway. And debuggers can be a great help.
    --

    --
    Being well balanced is overrated. -- John Carmack
  56. Re:Your problem is... that you used C++! by Peaker · · Score: 1

    OO programming is great.
    Data hiding and abstraction is great.
    Implementing the wheel again in every piece of code is not great.

    Perhaps you should learn the PHILOSOPHY behind OO programming at some point, rather than the syntax words behind its C++ implementaiton.

  57. kdbg by Anonymous Coward · · Score: 1

    By far, the most easy-to-use debugger I've seen
    for the Unices is kdbg:
    http://members.nextra.at/johsixt/kdbg.html

    The latest development versions have thread support. The latest development versions are more stable enough, btw :) I havn't used the thread support yet, but judging by the quality of the rest of the program, thread support should be very good.

  58. Threading considered harmful (was Re:Ada 95) by kevinank · · Score: 1

    <soapbox>

    About 30 years ago an upstart operating system called UNIX came up with a solution to all of the problems with two threads of control that are running simultaneously trying to get access to the same resources. Threads have race conditions, require synchronization primitives to avoid stepping on eachother's toes or access inconsistent data structures, and when out of control can modify data owned by other threads bringing the whole system down in a heap.

    The brilliant innovation of UNIX was to seperate threads into seperate processes, each with its own stack and data and memory barriers between processes so that no process should have to be completely dependent on the good behavior of another process.

    Since that innovation limited the interoperability of processes, UNIX also invented a series of interprocess communication tools including pipes, sockets, and explicitly shared memory. Together these tools have greatly simplified and are probably even responsible for popularizing multi-processing.

    So why are we ignoring these fine inventions?

    Because Microsoft is unable to implement an efficient multi-processing environment, threading is the only way to efficiently handle multiple simultaneous requests under Windows NT. I think that this limitation has made threading using no memory protection, and no IPC, into a fashionable approach for 'efficiency' and 'performance'.

    But is that really a good idea? Computers these days are extremely fast; so that even VMs like Java are often considered sufficiently fast for use in real projects. Under those circumstances, wouldn't it be better to avoid multi-threading in favor of multi-processing? Isn't it really debugging that takes the most time, so that losing a bit of performance for a massive increase in reliability should be an acceptable tradeoff?

    </soapbox>

    Submitted for your consideration. There are obviously technologies that don't work well in a multi-processing environment; CORBA for example depends heavily on threads, as does Java (running a single JVM is bad enough; can you imagine running a whole array of them one for each thread?) But I do think that people underestimate the value of Processes and IPC and often choose Threads when they are highly inappropriate.

    --
    LibBT: BitTorrent for C - small - fast - clean (Now Versio
  59. Stay with C++, use DDD to tame gdb by StandardDeviant · · Score: 2

    As many other posters have said wisely, switching tools midstream is a sure route to pain. Trust me, once you've made core tech decisions, stick with them! At least until you get version 1.0 out the door...

    I too don't like using gdb on the command line, but combined with DDD, the Data Display Debugger (works natively on pretty much any Unix, linux strain, I've seen ports to win32, etc) debugging is a much nicer experience. I don't write multitrheaded stuff being a pretty neophyte C++ programmer (eh, we all have to start somewhere :-) ), but I did notice in the online manual that it does have at least rudimentary support for threads.

    Plus it's free and doesn't require any changes to your environoment or toolchain. (Basically just install it, it defaults to using gdb as the "inferior" debugger (as opposed to dbx or any of the perl/python/java/whatever debuggers), and you type "ddd progname" instead of "gdb progname". It even has a command window to interact with gdb directly if you so wish...) Last but not least it has a cute logo. ;-)


    --

  60. In Java, I like by dubl-u · · Score: 2

    I'm currently building some server-side Java web applications. Since the Java Servlet stuff is inherently multi-threaded, I have indeed occasionally been reminded that multi-threaded applications are tricky.

    A few months back, we purchased a suite of tools from an outfit called Sitraka (nee KLGroup). They have three products that are part of the JProbe Suite, a CPU and memory profiler, a thread analysis program, and a code coverage tool.

    These are all good tools; when I was having some problems that I suspected were due to my less-than-perfect understanding of threading, I used their thread analysis tool under simulated load, and it immediately identfied my race condition, plus a couple more potential races I hadn't noticed yet.

    (This is a little off-topic, but I have to mention that their memory/CPU profiler is, pardon my french, fucking awesome; it is the best thing I have ever seen for visualizing the interior structure of a running program. After a day with the profiler, my Java code was substantially faster than the C it was replacing, despite having more features and being more secure.)

    Another tool I'm very pleased with is JUnit, a unit-testing framework. If you're interested in trying out the Extreme Programming-style approach to testing (wherein you make automated, integrated unit tests that are run more or less continuously) then this is for you. And if you are having so many problems with bugs that you are considering changing languages, then I would strongly recommend that you do this. Good unit tests slow initial writing down a little, and save you extraordinary amounts of time and agony later.

    Oh, and run out right now and buy several copies of Code Complete and Rapid Development for the team. If you are having such large problems on the project, the problem is probably not with your choice of debugger. These books will help you figure out what the problem actually is, and give you all sorts of solutions.

    --

    For the record, and I don't have any financial interest in any of the things I've mentioned here; I just use 'em and like 'em.

  61. fair enough by joss · · Score: 2

    You make some good points, and I over-reacted, but whenever someone mentions C++ someone says, hey - why not use java and all your problems will go away, I get a little tired of it.

    One thing though:
    "You're right that novice Java developers take longer to learn the value of reference handling than C developers, but this is mainly because Java extracts a much smaller penalty for those errors. By your logic, presumably, C++ would be even better if each time the developer left a dangling reference they received a high-voltage shock to the nipples."

    Exactly ! yes, that is an excellent idea. Having the program die horribly would probably suffice, but the high-voltage shock to the nipples would be even better. Immediate catastophic failure is a far more useful reaction to bugs during development than limping along, papering over the cracks.

    --
    http://rareformnewmedia.com/
    1. Re:fair enough by bpd1069 · · Score: 1

      By your logic, presumably, C++ would be even better if each time the developer left a dangling reference they received a high-voltage shock to the nipples.

      That could aslo lead to some unexpected sexual deviancy among the developers.

      You just can never know!

      --
      --
    2. Re:fair enough by dubl-u · · Score: 3

      I over-reacted, but whenever someone mentions C++ someone says, hey - why not use java and all your problems will go away, I get a little tired of it.

      Me too. As far as I can tell, these are people who have never done any serious work in Java. Or if they have, then Java is the only language they've used on a serious project.

      Luckily, these people get what they deserve. Eventually they will be dumb enough to say things like this to a boss, who will be dumb enough believe them. And then when their optimistically-scheduled, poorly-scoped, under-budgeted project goes up in flames, they will get fucked with the sandpaper condoms. The smart ones learn after the first time that no tool is perfect for every job. The dumb ones, of course, talk trash about last tool and find the next perfect tool to talk about.

      Having the program die horribly would probably suffice, but the high-voltage shock to the nipples would be even better. Immediate catastophic failure is a far more useful reaction to bugs during development than limping along, papering over the cracks.

      And people call Java a bondage-and-discipline language! Heh. Maybe we should dress this idea up in a lot of fancy talk about neuropsychology and maximizing feedback loop efficiency and see if we can get VCs to cough up a few million dollars to get us going.

  62. Solaris x86 by Vince · · Score: 1

    I've tried Solaris on x86 just for this reason. I've found that it's hard to install, and has limited hardware support. But once it gets working, it's very nice for multi-threaded programming. The license is free, so you might want to get one copy to try. We just used it to develop, remove the problems from the threaded areas, then run the code on Linux, in essense it's just another debugging tool for our Linux app.

  63. Poor multi-thread debug support on Linux by SLOGEN · · Score: 1

    What you say is true, but it's not the issue.

    I realize that, but I simply could not resist commenting on the change of devel tools after the sentece:

    We're looking for better tools, and if that means changing languages or going to another UN*X, we're ready to do it

    In my mind, this statement shows a common flaw in reasoning of IT project: changing tools based on a single premise (in this case, MT-debug support, normally the premise would be something like "easier GUI", "faster filesystem", "prettier icons",...), instead of making decisions based on the entire needs of the entire project.

    It seems to me, that you may actually share this wiew with me:

    you're gonna start thinking that a language that does memory management for you probably wouldn't be such a bad idea

    I agree with that phrasing. I would like to see a subset of C++, that allows real garbage-collection (not the ad-hoc analysis in currently availible gabage-collectors). Even though that would mean dumping C compatability.

    A story I hear particularly often is: you should use Java, it's better to debug than C++, and it's got Garbage Collection.

    Well, that are definatly pro's for Java, but what about the con's:

    1. Java has NO! parametrised types This means that generic programming is impossible. One specific consequence of that is, that collections cannot be type-safe, and you loose a lot of the help that type-errors can buy you.
    2. Java doesn't have "const" (and friends) which means that when you give someone an object reference you have no control over what they do with that. When returning read-only object, the only solution is to clone() them. Very expensive!
    3. Java cannot reference simple types In Java, you can only reference Object's not the simple types. Even the integerObject (and friends) are immutable, so that doesn't help you pass reference parameters which have simple types (I realize, that this is normally a sign of OO-design flaw, but I really want that flexibility, especially for JNI code!)
    4. There are more, but these should make my point.
    So, before switching some project to Java, do a cost-benefit analysis.

    Last but not least, I would like to second your statement, which gives me a chance to repeat something very wise you said:

    Support the developers, first, and everything else will follow.

    --
    SLOGEN [ http://ungdomshus.nu : Sebastian cover music]
    1. Re:Poor multi-thread debug support on Linux by ksheff · · Score: 2
      1. Java has NO! parametrised types This means that generic programming is impossible. One specific consequence of that is, that collections cannot be type-safe, and you loose a lot of the help that type-errors can buy you.
      2. Java doesn't have "const" (and friends) which means that when you give someone an object reference you have no control over what they do with that. When returning read-only object, the only solution is to clone() them. Very expensive!

      Could you be a little more specific when you say that collections can't be type-safe? Are you referring to putting several different instances of different objects into a collection and then being able to weed out the different instances by object type? I've done that in Java. It's really easy if they all implement the same interface. Once can iterate through the collection and call the same method for totally different objects. Also according to this page, one can create constants in Java. Or are you referring to defining parameters to methods as const so that the compiler won't let you modify them? I will admit that having to have wrapper classes for the primitive types is a pain.

      --
      the good ground has been paved over by suicidal maniacs
    2. Re:Poor multi-thread debug support on Linux by SLOGEN · · Score: 1

      When I say that collections can't be type safe, I mean: "No general class or interface can be written such that you can later specify the exact type of the arguments passed and returned".

      Example (C++, you could also use i.e. BETA, ML and whatnot..)

      std::vector long_list;
      long_list.push_back(10L); // OK
      long_list.push_back("10"); // COMPILE-TIME ERROR!

      JAVA

      Collection c = new SomeImplementerOfCollection();
      c.insert("10"); // OK
      c.insert(new File()); // OK, no warning!
      String s = (String) c.SomeMethodForGettingStuff(); // RUNTIME ERROR!

      If you actually want the JAVA behaviour in C++ (you can store anything in the collection) you do:

      std::vector unknown_list;
      /* Add string pointer */
      unknown_list.push_back(new String("X"));
      /* Add pointer to method foo */
      unknwon_list.push_back(&foo);
      But you miss out on the oppotunity to get a compile-time error if you try to push stuff of the wrong type into a collection.

      Const

      In JAVA, a constant is a value, in C++ "const" (usually ;) refers to a reference, with the sematics that, using this reference, you cannot change the referenced object. This is very different from the JAVA "final" stuff.

      You may wan't to read The common JAVA chant where I list some other problems with JAVA, C++ and concludes that basicly no good OO-languages exist (that I know of).

      --
      SLOGEN [ http://ungdomshus.nu : Sebastian cover music]
    3. Re:Poor multi-thread debug support on Linux by locust · · Score: 2
      1.Java has NO! parametrised types This means that generic programming is impossible. One specific consequence of that is, that collections cannot be type-safe, and you loose a lot of the help that type-errors can buy you.

      I can very easily override the insertion routeines for collections with, something that calls the instanceof operator... and return if it returns false. This gives me the sort of typesafety you're talking about.

      Java doesn't have "const" (and friends) which means that when you give someone an object reference you have no control over what they do with that. When returning read-only object, the only solution is to clone() them. Very expensive!

      Java does have final, so you can pass parameters can prevent thier alteration.

      But where I really take issue here is the statement that generic programming is impossible in Java. Consider how STL (C++ standard template librarary) defines the use of your own types in its defined datastructures and algorithms library. They say: you must provide your own implementations of (for example) the == operator for list searches to be effective (don't have my book in front of me so can't be more specific right now). This is exactly analagous to saying in java, you must implement a specific interface, and only those classes which implement that interface can be operated on. The fact that you don't have templates is offset by the fact that you do have a common base class (Object), so you don't need templates. I can define a method in java to accept an instance of an interface, I can also define a method in C++ to accept an instance of a base, or virtual base class. These both acomplish the same thing, accept a general type in some algorithm, and allow operation using just a set of base methods. In both cases I can (if I want a big maintenance headache later) try to cast the objects passed in to any type I want to in the method.

      The way you right generic code in Java and in C++ is different, but both allow it.

      --locust

    4. Re:Poor multi-thread debug support on Linux by SLOGEN · · Score: 1
      I can very easily override the insertion routeines for collections with, something that calls the instanceof operator... and return if it returns false. This gives me the sort of typesafety you're talking about.

      The whole point was to have type-safety, and get compile-time errors, instead of runtime error's which may occur after you shipped the product.

      Java does have final, so you can pass parameters can prevent thier alteration.

      Java has value constants, not reference constants. Please try to think a bit about the difference:

      class A {
      B bInstance;
      const b getbInstance() { return bInstance; }
      }
      Now, if someone was to call A.getInstance(), they will have a READ-ONLY reference, and will not be able to change A's bInstance through it. There is NO WAY to do this in JAVA. It prevents lot's of errors where programmer change data that was supposed to be constant seen from the outside.

      As for the part about generic programming. You obviosly have not understood generic programming and parametrised types. The trick is, that you wish to specify the concrete type that an algorithm work on (specializing the interface if you will, some call this compile-time type refinement), so that you will get compile-time type-errors if the (type-instantiated) algorithm is applied to data of the wrong type.

      A good example of Generic Programming is a collection, putting stuff into and iterating over a collection requires no specific knowledge of the types of the elements of the collection (which is why the JAVA collections can accept Object), but when you actually use the Collection, you want a typed collection, which you can specify to hold only class X objects. Therefore you need to specify the return types and argument types for the methods og the collection down to some type T, so just like you normally pass other stuff as parameters, you parametrise the collection with the type T.

      --
      SLOGEN [ http://ungdomshus.nu : Sebastian cover music]
    5. Re:Poor multi-thread debug support on Linux by arafel · · Score: 1

      >The whole point was to have type-safety, and get compile-time errors,
      >instead of runtime error's which may occur after you shipped the product.

      Er ... you do build and test your apps before you ship them, yeah? :-)

    6. Re:Poor multi-thread debug support on Linux by drudd · · Score: 1

      Yes, but just try to prove the correctness of your program.

      Can you test every possible combinations of input and machine conditions? Even just all combinations of input? Tested your program 10,000 times? Test it 10,000 more times.

      You can never be certain that you've caught every runtime error or bug (assuming a complicated program).

      Doug

      --
      Venn ist das nurnstuck git und Slotermeyer? Ya! Beigerhund das oder die Flipperwaldt gersput!
    7. Re:Poor multi-thread debug support on Linux by elflord · · Score: 2
      Should we insult your intelligence by explaining why compile-time errors are preferred to run-time errors, or do you understand this ?

    8. Re:Poor multi-thread debug support on Linux by locust · · Score: 2
      The whole point was to have type-safety, and get compile-time errors, instead of runtime error's which may occur after you shipped the product.

      Given that in java I can load a class from anywhere at anytime, the class cast exception may be generated by my code, but might have its root in some code that was made to invoke my code long after I finished it. I don't know if this is completely feasible in Java.

      Java does have final, so you can pass parameters can prevent thier alteration. Java has value constants, not reference constants. Please try to think a bit about the difference: class A { B bInstance; const b getbInstance() { return bInstance; } }

      I never claimed that you could return a constant from a function in general. However, once a final reference is initialized it cann't be changed. So I can go:
      B getB(final C c){...}
      and in the invoking function declare:
      final B b = a.getB(new C())
      They (final B b, and final C c) are reference constants, but I realize this is not what you're after... You want to specify the constness, not to rely on the invoker, then again in C++ what prevents me from casting away the constness? So whats the diff? A properly constructed B will prevent me from altering its internals, and if I lose my reference to it, well its my own damn fault. So if you don't want me to change it, you shouldn't be returning it. You should provide accessors to the relevant data memebers.

      The trick is, that you wish to specify the concrete type that an algorithm work on (specializing the interface if you will, some call this compile-time type refinement), so that you will get compile-time type-errors if the (type-instantiated) algorithm is applied to data of the wrong type.

      I think they might want compile time refinement for the speed... Its faster to figure it out at compile time than runtime. In any case, if I create a class foo. and then declare: list<foo*&gt bar;
      now I try to do a bar.find on this list for some specific foo. Unless I've overridden the == operator for the foo* type this operation will compare pointers not the values of the foo objects. No compile time check will catch this.

      Further after a look around the web, I came across a comparison of OO and GP and to quote the author: We note that a significant part of the generic programming paradigm can be expressed in terms of C++ language constructs; other parts cannot be expressed by means of the programming language. There are requirements to containers, iterators, and algorithms that are not expressed by means of language features and hence will not even be detected at compile or template instantiation time.

      Under the premise that generic programming requires full knowledge of types at compile time. Java cannot (at least under java 1.2 not sure about 1.3) support generic programming (neither can C++ using virtuals) yet Java Collections looks and behaves a hell of a lot like STL. The latter is by all acounts an example of generic programming. The STL (to me at least) and Java collections represent abstract generic data structures, algorithms, and access methods. The implementation differences are mainly syntactic, as are the compile/runtime differences. These last are a result of the implemtation language not a fundamental property.

      --locust

    9. Re:Poor multi-thread debug support on Linux by arafel · · Score: 1

      No, I don't test every possible combination. The test harnesses do cover a good subset of them, though, which is my point. We're not talking about testing every combination of input and conditions; a test harness should ideally take the program down each code-path, and you'd expect this kind of error to show up then. Certainly not after you've shipped it.

      But, to make it clearer - yes, I agree that compile-time checking would be preferred, and cut down the time taken for testing. It was just the statement that it might occur after the app had been shipped which I was replying to. :)

    10. Re:Poor multi-thread debug support on Linux by SLOGEN · · Score: 1

      First of all, this will be my last reply to this (and other) threads (sipposedly) about debugging MT code. We are way off topic here.

      About compile-time type refinement (templates in C++)

      What you get from compile-time type-refinement is a valuable tool to detect and diagnose common errors that are made in OO-programming: putting the wrong type of object into an instance of structure. i.e. inserting real's into a list of (conceptually, when you dont have parametrised types) integers.

      On dynamicly loaded code

      It does not matter that you can later (i.e. at runtime) specialize the methods of a type-instantiated class or algorithm, since it must nessesarily accept the same types as it's parents. Types have a natural partial ordering, which is commonly refered to as specialization, this ensures that stuff that gets put into a method has at least the structure that the method requires. Therefore you will not have problems with later loaded dynamic code.

      On the other hand, you cannot further refine the types of arguments to methods of a type-parametrised method, since that would break the inheritance invariant: I must accept what my parents accept. This is why you need generic programming and parametrised types in the first place

      Unless I've overridden the == operator for the foo* type this operation will compare pointers not the values of the foo objects. No compile time check will catch this

      Neither should it be able to. You may wish to compare references (in this case pointers), or you may wish to compare values. It is not the business of the find() algorithm to select. One way is not better than the other. Actually, the find_if() allows you to specify another predicate than the default operator== to use for comparison.

      BTW: I did not say that compile-time type refinement made every error on collections compile-time analyzable.

      A properly constructed B will prevent me from altering its internals

      The problem is, that you wish to distinguish between those that should have a protected (kind of read-only) reference, and those that should not. The best example is a datastructure fullfilling the Monitor pattern, it may have either several readers or one writer at the time (very handy for collections). For the readers, you wish to return constant references to the contents of the monitor protected data, for the writer you wish to pass a reference that allows to change the data. The references are to the same class, and refer to the same value,but should allow different operations, therefore they should have seperate types, derived from the type: reference-to-value-of-class-X. Actually, I am starting work on my thesis where I aim to establish and implement other type-decorations, such as parametrised authentication (auth, encrypted, and others) to allow deduction of proofs of program security

      If I were to "provide accessors to the relevant data memebers", I would have to make a class hieraki to implement constant references, and I'm not even sure that could be done.

      You quote comparison of OO and GP to say that C++ support only a subset of generic programming, which is absolutely true, and which is the reason of many woes over inheritance from type-parametrised classes (deriving from templates).

      Then you state: Java Collections looks and behaves a hell of a lot like STL., to which I must diagree:

      The STL collections are programmed using generic programming, which means, that they operate on any compile-time refined type. Java collections are programmed using Object Orientation, which means that the operate on any type deriving from the type specified in the interface/class description (Object).

      There is a big difference here, You cannot specify a JAVA collection which can only hold i.e. integers, and have a compile-time type-check verify that invariant. You will get to rely on runtime checking of the types.

      The implementation differences are mainly syntactic

      No, it is ideological, generic vs. OO-ideology.

      These last are a result of the implemtation language not a fundamental property

      JAVA does not support the generic programming paradigm, therefore it implements collections in the OO-paradigm. The differences in implementation are definatly due to fundamental differences in which programming paradigm you choose to implement collections.

      BTW: In C++ it would be hard to implement collections in the OO paradigm, since classes do not inherit from a common base class.

      --
      SLOGEN [ http://ungdomshus.nu : Sebastian cover music]
    11. Re:Poor multi-thread debug support on Linux by locust · · Score: 2
      First of all, this will be my last reply to this (and other) threads (sipposedly) about debugging MT code. We are way off topic here.

      Feel free to take this off line if you like.

      i.e. inserting real's into a list of (conceptually, when you dont have parametrised types) integers.

      I guess, first off I don't see this as so common an error. Next, my point has been that in order to generate the above errors (at least in Java) you must wrap the Java collection in a class whose interface verifies the type. This will give you at least a basic compile time verification.

      On dynamicly loaded code

      Therefore you will not have problems with later loaded dynamic code.

      But then this is a compile time error, regardless of whether or not we have generic programming.

      This is why you need generic programming and parametrised types in the first place

      Parameterised types do guarantee that you don't try to further refine the parameters. But I thought that was just good programming practice, not to further refine the types of arguments, regardless of having or not having templates.

      On constant References, Reader-Writer, etc, and class hierarchies.

      Regardless of the implementation language you can't use finally or const to return your references because both of these rely on the cooperation of the invoker to use finally or not to cast away constness. For the writer, the relevant reference type must provide setValue and getValue operations. For the readers it must only provide get operations. In java this would mean two interfaces. A refValueReader interface and a refValueWriter interface that extend the first. The the monitor writer you put the data to be written in instances of the refValueWriter type, in the readers you are returned instances of the refValueReader interface. In C++ terms the difference is in how you override the functions of the operators on the type. You would have to (forexample) override the = operator to prevent the reftype from being an lvalue in some cases...

      The STL collections are programmed using generic programming, which means, that they operate on any compile-time refined type.

      In C++ it would be hard to implement collections in the OO paradigm, since classes do not inherit from a common base class.

      I'll quote again from the same source: In sum, we achieve genericity by means of a design idea, i.e. separation of data structures from algorithms, and by use of programming techniques supported by the programming language, i.e. C++ class and function templates. Although generic programming uses classical object-oriented C++ language features such as class (template) declarations, it is not object-oriented. How does generic programming contrast to object-oriented ideas? In object-oriented programs abstractions are expressed by means of base classes. In generic programs the abstractions are described in terms of formal, yet verbal requirements. Examples of such requirements are: A container must provide certain iterators. An iterator must provide certain operations, such as increment and dereference. An algorithm must work on iterator ranges.

      In my (admittedly brief) online search for definitions of generic programming that include compile time constraints as a fundamental property of genericity I've come up with: bubkas. The underlying feature is that inheritance is spearated from polymorphism. The problem with it as expressed in C++ is that there is no formal way to guarantee compliance with the stated verbal interface that can be gauraneeted by the programming language. If one looks at the base functionalities of types in C++, and compares them with the base functionalities of (reference) types in Java one notices that they are strikingly similar. Further if one speaks strictly, things such as operators are in fact short hands for function calls of the the nature int plus(int, int). Thus the fact that operator overloading is not allowed in java is irrelevant. The point is that C++ has an implicit common base type (operations I can do any any type, and infact it has a number of types derived from it (pointer types etc) but this is done by the language not the user), where as java has an explict one (Object). Template operations with in STL collections use these implicit common bases in order to be meaningfull. Java Collection operations use an explicit common base to be meaningfull (such is the language). In both cases a greater guarantee can be made of smenatic correctness of a program by insisting on an abstract base class that overrides given default operations. But this would taint the purity of the genericity.

      The key point is that generic programming sperates algorithm from data structure. I can do this in java, but I must stipulate that all reference are to Object. The most generic type. I can also stiplate some semantic ordering of the basic operations on arbirary types, but then the programming language cannot help me short of using object orientation. Java Collections (like STL) allows me precisely this separation of algorithm from datastructure.

      --locust

  64. Understand your architecture better by lamontg · · Score: 1
    Why are you trying to write a C++ app using threads on linux? I can think of several reasons why you've picked the wrong three things to try to use together.

    First of all, if you're going to do threads on linux, you're going to wind up debugging the race conditions in the standard library calls if you use C++. The GNU libstdc++ is not yet fully MT-safe. So, if your requirement is C++ and threads, you pretty much need to pick another platform other than linux.

    Second, there's threads on linux. Linus spent a lot of effort to make sure that fork()+exec() work well under linux. There's three reasons to use multithreaded code: faster creation, faster context switches, and easier/faster message passing through shared memory in threads vs. e.g. SysV IPC. Under linux you don't get any gains for the context switches. Context switches for processes are only about 10% slower than context switches for threads under linux. You also don't win a whole lot in process creation which is faster under linux than thread creation is under solaris (plus pthread_create() is broken and slow under linux). You should consider looking at your programming model and seeing if good old fork() will work for you. If you don't believe me, check out this and the entire thread here. Also read this whole thread.

    Then there's the fact that you've run into problems with the tools that you've got on linux not be adequate to handle threads. Not only is gdb broken, but strace isn't going to help you with threads either. And in disagreement to those who claim that printf() is good enough for everyone (e.g. Linus), I think that its good to have many different debugging tools in your toolbox. Strace and reading corefiles in gdb usually are my first line of getting a handle on what the problem is, then I usually read the code and use printf()s. So this is another strike against threads under linux.

    I can't speak on the virtues of C++ vs. Java. I'm merely a lowly sysadmin / system programmer who predominantely uses C. I do know though that lots of very good programmers make mistakes because they know how to program but don't understand the architecture of the systems that they're writing code for. They believe things like "threads are fast" without either hitting the linux-kernel mailing list or the linux sources to find out how threads and processes are actually implimented under linux.

    So, if you're going to stick with threads then stay the hell away from Linux and use some other OS like Solaris. If you can avoid using threads, though, Linux may be a perfectly sufficient platform for you to use. Once you've made that choice, then you need to decide if you're going to use Java or C++ and I'm out of my league there.

    And when you're considering if you should throw out threads, remember:

    "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." - Donald Knuth

    That suggests to me you shouldn't use pthreads unless you need to.

  65. [OT] Python Debugging by QuoteMstr · · Score: 1

    Speaking of Python, I know that ddd supports debugging of Python programs, but I've never been able to make it work. Any ideas?

    1. Re:[OT] Python Debugging by StandardDeviant · · Score: 1

      Sorry, I'm not a python programmer. I know that the switch --pydb will invoke the python debugger instead of gdb, but that's about it.


      --

  66. One coment on Solaris x86 vs. Sparc.... by trims · · Score: 2

    I've run production environments with Solaris on both x86 and SPARC. I'm primarily a SysAdmin/Architect, not a developer, so take your coding cues from someone else (I program, but not heavy-duty professionally).

    Previous to Solaris 8, there were A LOT of serious bugs in Solaris x86 that caused it to be unusable for serious work. For web serving and simiar crap it was fine, but any complex app tended to expose bugs in the OS. Solaris for SPARC doesn't have these problems.

    Solaris 8 for x86 seems to have fixed most of the egregarious problems, and I would trust it to run your app. HOWEVER, x86 still seems to have random low-level (ie driver and the like) problems with certain hardware. Thus, I would seriously recommend that you DEVELOP on a SPARC box, which doesn't have these problems. That way, you can be sure that the bug you've just found is really in YOUR code, and not some obscure problem in the OS. One you have stable code, Solaris 8 for x86 is stable enough to run as your production OS.

    Both x86 and SPARC use the same codebase - thus, the system libraries and similar stuff all work equally well (or at least, have identical bugs...). However, the Hardware Abstraction Layer implementaion for x86 is of poorer quality than the one for SPARC (which makes sense, given Sun's priorities).

    Best of Luck.

    -Erik

    --
    There are always four sides to every story: your side, their side, the truth, and what really happened.
  67. printf isn't thread safe by Carnage4Life · · Score: 2

    Obviously you have no idea what the poster of the "Ask Slashdot" is talking about.

    He is asking for a good debugger for multi-threaded programming such as dbx on Solaris because gdb cannot handle threaded debugging. Instead you respond with an uninformative post that describes the worst way to debug multithreaded programs. printf isn't thread safe so it's use in multithreaded programming as a debugging tool is frowned upon unless you are using additional mutexes for logging (adding complexity) or you are using a thread safe print function such as OutputDebugString in the Win32 API.


    Grabel's Law

    1. Re:printf isn't thread safe by Elias+Ross · · Score: 1

      printf is thread safe. At least on UNIX. The standard library is thread safe for pretty much all functions these days. I guess on Windows it isn't the case, eh?

  68. Come on, people by Mdog · · Score: 1

    I'm all for open source advocacy and gdb, etc...but telling someone who is trying to debug their huge MT app to "write a patch!" is ridiculous.

    1. Re:Come on, people by marcovje · · Score: 1

      How did he get a huge MT app without a debugger? I think that that app is the thing that is overrated then :-)

  69. not to mention the fact... by MeowMeow+Jones · · Score: 1

    That C++ programmers should be using cout and the string class instead of char[]

    --

    Trolls throughout history:
    Jonathan Swift

    1. Re:not to mention the fact... by carleton · · Score: 1

      Grr...
      I know I being pedantic, but using cout is like using stdout... printf is more roughly equivalent to >> (or if you prefer, fprintf is, since printf is just fprintf(stdout, blah and therefore fprintf more accurately maps to how >> works with multiple streams, not just cout/cin). It upsets me greatly that people are taught to use cout and end up completely missing the point of what >> means.

  70. Take those blinders off! by bbcat · · Score: 1

    C is great, so is C++
    C++ has some great features which can
    solve hours of work. It may get bloated
    sometime if you don't have a good
    optimizer but it is nonetheless a very good
    language.

    Use what you like and leave the rest of
    the world who love C++ alone.

  71. Paradigm C++ Debugger for Linux??? by bbcat · · Score: 1

    I've used their V25 debugger before but
    where the heck is a Linux version of any
    of their debuggers?
    I've never seen any Linux or Unix version
    of their debuggers.

    As for the V25 debugger I've used, it seemed
    a derivative of Borland turbo debugger and
    only runs on dos.

  72. Compile Java to Native Code by optikSmoke · · Score: 1

    I haven't had time to look into this, but there is a gnu compiler which allows compilation of Java into native code for your platform (thus eliminating the need for a VM and the performance drop). It also (I believe) allows for the use of byte-code classes along with the compiled code, if you wish. It is called gcj (GNU Compiler for Java) -- see http://sources.redhat.com/java/ for more info

  73. Are you kidding? by Carnage4Life · · Score: 4

    In the true open source mind, it would be be better to say:
    You are changing a debugger because it misses a feature? THEN IMPLEMENT IT


    Comments like this make me wonder exactly whether Slashdot is read by programmers or simply people who have heard about programming and think it's cool. Multithreaded applications are hard to design correctly and difficult to debug from an application writer's point of view. Your simplistic statements belie the fact that you must be an inexperienced programmer because in the real world people don't have time to start om mammoth projects simply to help with a medium sized one. Adding threading support to gdb is more difficult than writing a multithreaded application that uses the pthread library unless the application is very complex like a compiler, relational database management system or a web browser.

    Your comment is like telling someone to hack garbage collection into C when they complain about memory leaks instead of simply pointing the person to Purify or BoundsChecker.


    Grabel's Law

    1. Re:Are you kidding? by marcovje · · Score: 1


      Actually I do program, and a reasonably large project, and that project (though not me) partially patches GDB, because GDB lacked Pascal support. So I didn't cite some Open Source manual, I experienced it from pretty nearby.

      Besides, you are missing the point, besides hacking full GDB threading support, he could have made a small patch that would allow him to easier track the thread context. Or he could change the threading libraries to extract more information, which he could check while debugging.

      But the main point is, to be creative either in a minimal way, or a major one (read the full threading support), rather than whine about something people have put in a lot of effort.

      And BTW I don't want GC in C.

  74. Solaris 7/8 x86 or Sparc + SUNWSpro 5.0/6.0 by Anonymous Coward · · Score: 1

    Solaris 8 on x86 (and even more so sparc) is almost certanily what you are looking for. Their threading libraries are excellent (barring the very rare weird problems that were in Sol 7, but even then there were certainly less than the heap of dung which is Linux's "threading" situation, and then I have found any of these bugs, only through the grapevine... and i've coded a whole ton of MT code). Even better than their great threads implementation is their compiler and debugger. their debugger, dbx, is absolutely fantastic. I cannot emphasize enough how good this debugger is. gdb doesn't even warrant being called a debugger compared to this amazing bit of work. important for you, it's threading support is fantastic, especially in versions 5.0 and 6.0. It is possible to get the Solaris 8 source code (have to fax them something) and of course the OS itself is really cheap (just media costs or something, like $10). You can also get demo versions of all their compilers and tools, so you can see for yourself how amazing they are. I strongly recommend you do, you will certainly not be disappointed.

  75. The common JAVA chant by SLOGEN · · Score: 1

    JAVA has (according to you)

    1. No pointer errors: They are called runtime-exceptions in JAVA ;), You are better off handling them in JAVA, but if you don't do pointer arithmetic, and keep your casting to a minimum, you will have no more C or C++ errors with pointers than with JAVA references.
    2. No malloc errors: Well, not simple ones anyway (as you state), but you wan't to make sure you understand, that GC does not exclude memleak (through unused but referenced data!). On the other hand, I can't believe that GC for C and C++ subsets which doesn't do pointer arithmetic (and somekind of "decent" arrays) is not yet an ANSI standard.
    3. Exception handling: C++ has quite OK exception handling. there are just 2 points that are really missing:
      1. Exceptions are passed by value, and thus they will be "sliced" to the type that you catch, this requires you to have an "ObjectException" which has a pointer to the object you wish to throw.
      2. The possibility to declare exceptions that must be caught, I like the JAVA way of having runtime and "compile-time" exceptions.

    Java has other serious problems:

    1. Lack of parametrised types: Kill generic programming, prevents type-safe containers. There is no way the impact of this can be overestimates. Types are your friend, they catch many error, especially with inexpirienced/unskilled programmers
    2. Well defined destruction semantics: You are not guaranteed that objects are GC'ed -- Which means that you can't do clever stuff to auto-release of locks on data-structures when references go out of scope.
    3. "wrong" kind of multiple inheritance: The JAVA "interface" is too weak, you really want to be able to write code in an interface, using only the declared interface methods.
    4. No references to simple types: and the Object versions of simple types are immutable!
    5. No standardized preprocessor:(or other facility). the "__FILE__" "__LINE__" and hopefully "__CLASS__", "__METHOD__", macros in C and C++ are GOOD, they allow you to extract information about the program, without explicitly writing it. Also I HATE it when the JAVA compiler says: "Error: Code unreacable" -- I usually know that, how about just warning instead!
    6. Lack of type decoration: "const" keeps you from having to rely on programmer practice not to change objects that are "read-only". It also allow a lot of optimization. "mutable" is also nice...

    Basically, JAVA lack many of the advances in OO-technolgy that it should have embraced. The JAVA language is a very BAD OO-language, it just has a lot of nice standard libraries, and an emulator for the JVM is available for may machines.

    This just goes to show, that there are NO really good OO-languages out there (that I have had my hands on anyway)

    --
    SLOGEN [ http://ungdomshus.nu : Sebastian cover music]
    1. Re:The common JAVA chant by dubl-u · · Score: 3

      Really, I agree with many of your points in the abstract. As a language for top-tier, ass-kicking developers who are wise, subtle, and wily, Java has a lot of annoying constraints.

      They did this for a reason though. For a lot of real-world software development, you have to do the work with painfully small amounts of time, money, and talent. So they banned a number of things that it takes an expert to use wisely. E.g., pointers, multiple inheritance, allowing unreachable code, preprocessor macros, raw memory allocation, random memory access, self-modifying code, and so on. As cool as those features are in the hands of a genius, they are plain dangerous in the hands of a mediocre developer. And 99% of the time, the genius will be doing what Java would be doing anyhow; it's only the 1% of the time that it sucks.

      That's why I'd much rather inherit a bunch of J. Random Programmer's code in Java than almost any other language. There will be little impressive wizardry in it, but there are also unlikely to be many sections that will make me bleed through my eye sockets.

      And you're also right about some of the other feature lacks; the whole primitive type thing is just ugly, and it's clear that they haven't heard about the whole mutable/immutable thing yet. Really, it saddens me that they are just now catching up with a lot of the things that NeXT was doing right with Objective C 5-10 years ago.

      But as far as getting things done in the real world for server side stuff goes, it seems perfectly adequate for all the OO work I do. And to be fair to them, they're making a fair bit of progress; the java.lang.ref package, for example, answered a lot of my gripes about pointers and garbage collection.

      One thing I didn't understand in your post was the section "lack of parametrised types"; could you talk more about that?

    2. Re:The common JAVA chant by SLOGEN · · Score: 1

      For the parametrised type stuff, look at Re:Poor multi-thread debug support on Linux. Parametrised types are (weakly) implemented in C++ via templates.

      One OO-language which has compile-time type-refinement (another kind of parametrised types, which is more general than templates) is BETA (which has it's own -- mainly idiological -- problems with multiple inheritance)

      --
      SLOGEN [ http://ungdomshus.nu : Sebastian cover music]
  76. Are you out of your mind? by Elwood+P+Dowd · · Score: 1

    Of course. If you are writing... say... a high-level sysadmin tool, or a mail client, or any other sort of application that is far, far from the machine, printfs are perfect.

    But if you start doing anything low level at all, printfs are *completely* inadequate. Writing a user-land threading library, for example. If you're handling context switching, or stack size, or anything even remotely close to the hardware, it becomes fantastically easy to... break printf. In which case it's nice to have a debugger handy.

    Of course, for most of the higher level stuff, printfs should be all you need. What our VB coding friends would call "business logic," rarely escapes beyond the scope of printf. But everything underneath that really requires more powerful tools. In fact, debuggers are certainly the best way to tell if 'n' where you're overruning stack size. And they're even more necesary when you're working on machines without preemptive multitasking or protected memory.
    --

    --

    There are no trails. There are no trees out here.
  77. Togethersoft by _N0EL · · Score: 1

    This was the same app written in java that I thought of as well... I've used Togethersoft for about a year. It never crashes on me, but is only decently responsive to input on my system (a 600Mhz P3 with 128M ram). It's worthless or won't even work on machines with under 128 ram and a cpu less than P2/P-pro.

    --

    "My mother works for Microsoft now. A whole other cult."

  78. Stimulus-Response by _N0EL · · Score: 1
    By your logic, presumably, C++ would be even better if each time the developer left a dangling reference they received a high-voltage shock to the nipples

    You're making some assumptions about the character of C++ programmers (like myself) that may not lead to the intended results. Remember, we chose to become C++ programmers... what does this say about our (possibly masochistic) personality? Maybe those electric shocks would increase dangling references :-)

    --

    "My mother works for Microsoft now. A whole other cult."

  79. Use processes instead of threads by johnnyb · · Score: 3

    Use processes instead of threads in as many places as make sense. This makes many of your problems simply vanish. It makes you rethink your design in a much more thorough and thoughtful fashion, choosing distinct parts with obvious interfaces.

  80. Ada and GVD: GNU Visual Debugger by Alice+Terry · · Score: 1
    Yes, Ada is excellent advice. GNU GNAT is superb, and one of the best multi-threaded debuggers is ACT-Europe's GVD GNU Visual Debugger.

    GVD, the GNU Visual Debugger, incorporates all the features of regular debugger GUIs and is complemented with data display and visualization capabilities more powerful than those offered by DDD (the Data Display Debugger). GVD provides the ability to debug multi-process/multi-threaded applications in the same debugging session.

    Links for those interested in Ada and GVD:

  81. Get an Alpha by markd · · Score: 1

    I spent several years fixing other programmer's problems in a multi-threaded webserver in a very high traffic shop. We supported all sorts of unixes (HP-UX, Irix, Linux, Solaris), and by far my favorite platform for diagnosing and fixing problems was Digital Unix (I don't know what Compaq calls it these days) and their tool ladebug. They also have a tool for monitoring threaded control structures (mutexes et al) and could sometimes detect race conditions and potential race conditions. very cool.

  82. This doesn't quite hold up by athmanb · · Score: 1

    People everywhere are moving to not-so-performance-efficient but easier to work with platforms (Java is a prime example here, Mozilla another)

    No IT-Manager with a half a brain would frown upon buying new machines every year (or even every few months) for budget reasons, while losing thousands of $ because the programmers aren't working at top-efficiency on computers which don't support the best development tools.
    (And yes, sometimes vi _is_ the best tool. But for most of the applications it has ceased to be that at the start of the nineties...)

    --------------------------------------

    1. Re:This doesn't quite hold up by HalfFlat · · Score: 1

      Quoting:

      No IT-Manager with a half a brain would frown upon buying new machines every year (or even every few months) for budget reasons, while losing thousands of $ because the programmers aren't working at top-efficiency on computers which don't support the best development tools.
      Therein lies the rub. A disturbingly large number of IT-managers have less than half a brain. Besides, time wasted is not time paid for if it's unpaid overtime.

      (Two years since working for that company, and still bitter! On a possibly unrelated note, check out fatbabies for game industry goss.

    2. Re:This doesn't quite hold up by Dwonis · · Score: 1

      This is free software we're talking about. Not every FS programmer has an IT manager with unlimited funds.
      --------

  83. Re:Java has other serious problems by platos_beard · · Score: 1
    I hate to say this, but it sounds like you should love C#

    Ack! the end of my sig is missing (its a TSE fragment) and I'm too lazy to fix it now.

    --
    What's a sig?
  84. Re:The common JAVA chant -- parameterized types by HarpMan · · Score: 3

    Parameterized types are templates in C++. They allow you to do generic programming.

    With templates, you can write a function like this:

    template
    DataType max(DataType a, DataType b)
    { return (a>b ? a : b); }

    This function returns an object by value, and is type safe. By type-safe, I mean that it require s that the two arguments and the return type all be the same (or compatible) types. For example, this would be a compiler error:

    int x = 3;
    complex c(3,4);

    int y = max(x, c); // whoops -- different types!

    This is actually impossible to do Java. You can't make it return a by-value object, and it's awkward to enforce the type constraints.

    Templates allow generic programming, where you write functions and classes (think abstract data types) that are agnostic as to the exact type of some of their parameters. But, you still get compile-time type safety. Templates are great for container classes and algorithms. Container classes in Java are workable, but a bit awkward. You don't have compile-time type safety. The container's values get cast to Object going in, and have to be manually cast back to the desired type when getting an element from a collection. With C++ templates, you can declare containers of specific types, like 'vector' or 'vector'.

    For example:

    vector v(3); // three element vector of ints

    v[0] = 45;
    v[1] = 3;
    v[2] = 4;

    sort(v.begin(), v.end()); // sort the whole vector

    int first = v[0]; // no need to cast

    All of this is type-safe, and about as efficient as hand-written code.

    Also note that the sort function is generic too -- it works for lots of different container types (like list), including container types you write, that the author of sort did not anticipate. Templates are very 'pluggable', both horizontally and vertically. Generic programming has a very different feel from OO programming. It's less hierarchical, easier to plug and play things piecemeal. Of course, you can still use a vector of MyPolyMorphicObject references,('vector to combine OO and generic programming.

    There's a lot more to templates then what I just described. The STL is a great example of a powerful, flexible and efficient generic library. Some people say that ML's generic facilities are even better than C++'s. This may be true; I've never used ML. Other people say that you don't need templates at all, that the real problem is strong typing. In languages like Smalltalk, Python and Perl, you don't have to declare the types of arguments, so every thing is generic. Of course, you can get run-time errors if you pass in the wrong type. But you can also get run-time errors in Java if you try to cast to the wrong type.

    Strong typing without templates is the worst of both worlds, in my opinion. If you're going to have strong typing (which I personally like), then you really must have support for templates or something like them. Otherwise you get the huge proliferation of complicated interface hierarchies that you see in Java, just to make sure that classes are useable various contexts. Templates decrease the need for multiple inheritence (or interfaces) somewhat.

    --
    Stephen Molitor steve_molitor@yahoo.com
  85. Re:The common JAVA chant -- parameterized types by HarpMan · · Score: 2

    Some of my examples didn't get printed properly, leaving of the data type of the instantiations.

    vector v(3);

    should have been:

    vector<int> v(3); // three element vector of ints

    Hopefully that makes things clearer -- the point is you declare the exact type of a container when you instantiate (use) it.

    Should have used preview!

    --
    Stephen Molitor steve_molitor@yahoo.com
  86. C# by SLOGEN · · Score: 1

    Just because Microsoft "invented" it, it's not nessesarily bad. It's bad if Microsoft can use it to control a market which they already dominate completely.

    One thing we should learn from Microsoft is: embrace and extend.

    --
    SLOGEN [ http://ungdomshus.nu : Sebastian cover music]
  87. Is cross-platform development an option? by Moses+Lawn · · Score: 2
    This is going to sound heretical, but bear with me.

    If this is at all possible, try developing the initial framework under NT (yes, NT). Let me explain.

    If most of your code is platform-independent, and, in my experience, this is often the case, you will be able to develop on any platform that supports threads if you are willing to put simple wrapper classes around the platform-specific bits. This gives you the double advantage of being able to hide ugly or repetitive API details, as well as letting you port to another platform by reimplementing a simple inner class. I've put together 200-line or less wrappers for threads & mutexes, file IO, ODBC, etc., that work under BSD, Solaris and NT. This makes writing cross-platform code almost trivial.

    Now, about that NT business. NT supports Berkeley sockets, stdio, and almost-POSIX threads, so if you're writing daemons and such, you can write 90% of your code without ever cracking the Win32 SDK documentation. Just use main() and forget all the heinous Windows I/O stuff.

    As to the original question of the post, the development tools on NT are pretty damn robust. If you're willing to use commercial (i.e. pay-for, non-open source) tools, the VC++ compiler and Dev Studio debugger are mature and top-rate. You don't need to use the IDE except for debugging if you don't want - makefiles and the commandline compiler work 98% the same as Unix. The Dev Studio debugger handles multiple threads as smoothly as anything you can find, it has breakpoints and watchpoints, you can view and change memory easily.

    The other commercial tool for Win32 that is invaluable is BoundsChecker from NuMega (now Compuware). The is the most amazing thing for finding both kinds of memory problems - invalid memory reads/wriites and leaks. It runs your app like a debugger would, (optionally) popping up to the exact source line whenever anything tries to write past a buffer (static or alloced). After your app exits, it gives you detailed report of all memory leaks, their sizes, and the lines *and stack traces* where they were allocated. It can run standalone or plug into the Dev Studio environment. This is what I wish Electric Fence could do.

    I realize this is a big change to suggest, and may well be impossible depending on your application/financial requirements. However, if you're in the early enough stages that you're able to change languages/platforms, and you have a budget, then this would be my suggestion: develop the basic app core and threading logic under NT, using Boundschecker religiously. Use makefiles. Periodically move the code to the Unix platform and make required changes to compile. Keep all platform-specific code nicely #ifdeffed. Write simple wrapper classes around any system services that take more than one or two lines of code (again, threads).

    This is how I've been working for the last year or so. I've been writing utilities and daemons that run under NT and Unix, and I'm still amazed at how easily the ports go. It just works. And I will tell you this: The difference between tracing back in core files with gdb and letting your app run in the IDE until the debugger pops up with the exact line of source code, with stack context, where your bad pointer/divide by 0/whatever happened, with the app still running, is indescribable.

    All that said, I really miss Turbo Debugger. Now *that* was a debugger.

    --

    What if life is just a side effect of some other process and God has no idea we exist?

  88. Re:no problem by invalid+email · · Score: 1
    You are brave writing things like that on \. (g)

    Maybe if they signed a name to it.

    The VS debugger is nice, yes, and it'll beat GDB or DDD in a feature comparison anyday. However, for 95% of the debugging tasks that I need to do, they're equivalent. Set breakpoints, set watches, get stack traces--the other stuff is nice but hardly necessary.

  89. Thank Bob, I'm not alone by localroger · · Score: 1
    And I'll let you into a bit of not so secret architectural advice here, 9 times out of 10, you DO NOT NEED THREADS.

    It is amazing what you can accomplish by including calls to short tasks in a big inner loop. While it's a bit harder to define your own state machine than it is to write a linear algorithm within a thread, it is SO much cleaner to debug and you can ensure the system is always in a known state when you need to do something.

    With today's fast machines you can get away with stuff that would never have worked 10 years ago. At most in Windoze you might need ONE (1) extra thread to maintain the user interface, especially if you're using hoggy database tools instead of building your own files in an efficient manner. I have however updated flat sequential files of nearly a megabyte within single-threaded (don't laugh) VB apps (!) without noticeable UI glitches. Modern machines are just amazing. And that's not even to mention hauling an entire 5 or 10 megabyte array into RAM to do sorts and searches.

    Whatever environment you are in, you probably don't need more than 2 threads, and if you think about it you can make one of them really, really simple so that you can fully debug it before you get to work on the other one. You can also temporarily haul your interthread comms out into the file system so you can actually run your threads as separate applications, each with its own debugger, before combining them into a single app. (Really, if you need tighter interthread communication than this allows, you probably don't need to be using separate threads.)

    Just my $US0.02. But I write a lot of custom software which must run 24/7 and for which I am the only support staff, so I favor reliablility over all other considerations. I have started to write several threaded apps, but have never actually finished one. Unthreading them has always turned out to be easier than debugging the threads.

    --
    Brackets contain world's first nanosig, highly magnified:[.]
  90. -1 Redundant, maybe, but... by astroboy · · Score: 1

    I'm going to add, as someone who spends their days working on massively parallel (>1000 procs) programs, yet another endorsement for TotalView. It is the only usable, robust, multi-platform parallel debugger that I'm aware of, and this is something I try to keep an eye on.

  91. minimize debugging; use checks and abstractions by q000921 · · Score: 4
    I've written a number of pretty substantial multithreaded programs, and I have never used a debugger for fixing them. I don't even know what I'd be looking for with a debugger: serious bugs in multithreaded programs tend to be subtle race conditions, and that's not the kind of thing that's easy to track down with a debugger.

    A better way is to avoid bugs in the first place. And for multithreaded programs, a message passing paradigm is generally the best approach in my experience.

    I also use assertions and consistency check liberally, so that problems are caught close to where they occur. As a result, the few serious bugs that I have had were usually solvable by inspection of the source code alone.

    If you are looking for languages that make avoiding bugs easier, look beyond C++. Java is slightly better than C++ for multithreaded programs because errors tend to be more localized, but Java doesn't have much in the way of useful higher-level abstractions for building multithreaded programs. The currently conceptually best languages for multithreaded programs, in my opinion, are SML/NJ, OCAML, and Erlang.

  92. I find it rather astonishing... by djocyko · · Score: 1
    that Microsoft Visual Studio has not been mentioned in this entire conversation. You people are just completely clueless, aren't you? VS is the godsend of IDE's. It can make "hello world" for you without having to type a single keyboard stroke. It can make programs with GUI without any effort at all!

    Sometimes people amaze me...


    the above comment completely misrepresents the opinion of the author and should therefore not be heeded....no matter how accurate it may be. thank you

  93. The Truth In The Middle? by istartedi · · Score: 2

    I've used both the IDE and printfs for debugging. The IDE is great for tracing flow through deeply nested calls. It's also good for pinpointing problems like infinite loops. For example, you keep hitting F-10, and then it goes grey on line 532. Bingo! That's the function that's gone loopy.

    But then printf is better for checking the contents of things sometimes. For example, after you read in the data file, you can write a simple "dump" function for the data structure to check and make sure that it has the right contents. In general, printf is great when you know what value a variable should have at a particular point.

    As for threads, I can't really say since I haven't done any.

    --
    For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
  94. If you need a debugger to deal with your code... by Alex+Belits · · Score: 2

    ... you must make your code more simple, as you will never catch all possible troubles with a debugger. If multithreading caused it to be more complex, switch to either single thread with nonblocking operations, multiple processes or any combination of two.

    And, of course, Java will ALWAYS remain inadequate by both performance and reliability -- five years is more than enough to fix a bad product even for Sun (ex: Solaris) if it really cared about doing that.

    --
    Contrary to the popular belief, there indeed is no God.
  95. DDD? by Christian · · Score: 1
    I see a lot of people recommending the use of DDD. In my experience the DDD program can never stay running long enough to give me any useful debugging information! All the versions I've ever used just crash constantly and are buggy in other areas too. Am I doing something wrong?

    As an alternative, the Insight GUI component of GDB 5.0 has been MUCH more stable for me, although I don't know if it is any good at debugging threaded applications.

  96. WRONG! (mostly) by mkcmkc · · Score: 2
    Yes, it's true that newbies should learn how to use interactive debuggers well, but that doesn't mean that knowledgeable programmers make heavy use of them. The best programmer I've ever met made (or repeated) the observation that once you've dropped into the debugger, you've lost. I didn't fully understand the wisdom of this at the time, but now years later I can see that he's about 99% right on this.

    The wise programmer uses the right tool for the right job, and an interactive debugger is usually the wrong tool. If you have a core dump, it's worthwhile to take a quick look at the stack dump, etc., but beyond that, you should carefully question time spent on further interactive debugging. It's a mental monkey trap--it feels like work and it's the easy thing to do. And five hours later it'll still seem that way.

    The disadvantages listed for printf debugging are either incorrect, or also true for interactive debugging.

    Likewise, the advantages listed for interactive debugging are incorrect, or do not consider the tremendous timesuck that interactive debugging can be. Consider, for example, the first point: Yes, you may immediately discover that a null pointer was dereferenced, but this may well tell you nothing about what really happened. The true bug could have occurred hours ago in a completely different part of the program.

    Stepping through your program is no replacement for really thinking about what's going on.

    This of it this way: You go to a doctor saying you don't feel well. The printf doctor eyeballs you, carefully forms theories about what might be wrong with you and takes various measurements to validate/invalidate those theories. The (interactive) debugging doctor says, "Nurse--scalpel!"

    --
    "Not an actor, but he plays one on TV."
  97. GDB is not for MT; VC++ is, however by mcoyote · · Score: 1


    I develop MT daemon-type software that runs on a vareity of unices and NT and, with the occasionaly exception of dbx on IRIX, we can't debug squat in terms of MT-specific issues except on NT, using VC++.

    Look, some projects, esp. ones that work on platforms where threads really do work well, really lend themselves to MT designs, and that takes modern tools. GDB, even 5.0, just ain't all that (to add insult to injury, our project makes heavy use of shared libraries, making for a good ten minute core file load-up time when going over NFS -- not so w/DLLs and SMB).

    The VC++ IDE-based debugger is excellent, and will help you get work done. Period. Thread-specific stack-traces, memory editing, watching, tracing, the whole bit, in a fully MT situation. We have a unified, cross-platform, Make-based build system that allows us to bypass the IDE compeltely for coding, but the debugger just can't be beat.

    --
    "Professional coder on closed source. Do not attempt."
  98. Check the easy stuff first by Anonymous Coward · · Score: 1

    Check the easy stuff first:
    1. Make each c++ object have a validate(), assert_valid(), of similar funcation - through a base class - this function has no body if not in debug mode
    All that function does is to
    -- 1. verify that the object has not been destructed (use a boolean flag set to true in constructor and false in destructor)
    -- 2. whatever validation on the internal data in the object (e.g., verify that pointers are not null, file handles are open, etc.)
    2. set each pointer to null after it is free()'d or deleted
    3. (more difficult) write a wrapper library for each and every api function called:
    -- 1. make each function inline
    -- 2. make each function validate all arguments passed into it (e.g., pointers not null, file handles open, etc)
    -- 3. debug print before and after the api call
    -- 4. check return value - call a function that has a breakpoint in it if an error occurs - this function has no body if not debug compile - assert() kills the process in unix and does not allow you to dump the call stack/continue executing if an error occurs
    -- 5. provide you several ways to call the function - see all of the file handling functions in unix that eventually call fcntl(). Usually, you create on function that does everything, and lots of functions that do nothing but provide different interfaces to the do-everything function
    4. for device drivers and other things that are difficult to run under a debugger, set a control-c or similar type interrupt or ioctl() call to dump the contents of the data structures - NOTE see 5 below for problems with non-thread safe printf() type functions
    5. some os's (e.g., ms windows) behave badly if you call api calls or even malloc/free during an interrupt. It is much, much, much better to send/queue a request so that your application can finish whatever it is doing then process the interrupt request normally.
    6. put parameter/data structure validation assert_valid() type macro calls at the beginning of each function to catch bad parameters as soon as possible.
    7. write a function to validate each type of data structure - i.e., an overloaded validate() that takes whatever struct you pass it.
    8. use counting semaphores to watch for overly long queues waiting on each object.
    9. have each thread uses its own private object to store data and not let any thread access shared memory space in the application except through well defined static function calls that use appropriate semaphores/critical sections.

    whoops - black magic type coding secrets for the non-development people revealed.

  99. Use a CVS snapshot of gdb. by cduffy · · Score: 3

    The CVS snapshots of gdb have (for the last several months) had vastly higher quality multithreading support than the released versions. Indeed, I think threading only firmed up properly within the first month after gdb 5.0 was released! So grab the repository from :pserver:anoncvs@anoncvs.cygnus.com:/cvs/src, compile it and have fun!

  100. GDB supports threads quite nicely on the Hurd by macshit · · Score: 1

    Or rather, it did three years ago, the last time I used it. I assume this hasn't changed, but you never know (especially since Cygnus dragged their feet quite shamefully when it came to integrating the hurd changes into the mainline gdb).

    -Miles

    --
    We live, as we dream -- alone....
  101. Common Lisp by noc · · Score: 1
    Lisp may be the environment you're yearning for. Common Lisp has a fantastic object system, and Lisps have had multiprocessing (Lispish for threads) for 20 years -- and the development environment to go along with it.

    In the Free world, CMUCL has kernel-level threads support (for FreeBSD and Linux), but only in the current development versions.

    In the commercial world, Franz's Allegro CL has OS-native threads on Unix, Linux, and Windows.

    One of the advantages of Lisp is that it makes it very easy to get working code written very quickly, giving you time to change your design if need be, and to go back and optimize only the parts of the code that need it (no point optimizing code that gets run .001% of the time). One of the disadvantages is that it makes it easy for poor programmers (or naive Lispers) to write amazingly inefficient code that works correctly. But well written Lisp runs comperable to or faster than C++. Both CMUCL and ACL compile to the native architecture, of course.

  102. You're almost exactly right... by warrior · · Score: 1

    ...printf, make, gcc, (g)vi(m) are the perfect tools... however, gdb is also a must, use it to get the stack trace so you know where to put those printf's!

    Mike

    --
    Intel transfer the difficult from Hadware to software, for get more power, programmer need more technology. -- chinaitn
  103. Kernel patches exist to fix the core dump issue... by cduffy · · Score: 2
    ...and multithreaded debugging with gdb (gdb myprogram, not a core dump) works fine.

    Regarding those kernel patches, though: There are several available on linux-kernel. The simplest, by Patrick Wildi, is a patch for 2.2.x which dumps only the thread which actually failed. Another patch by Terje Malmedal against 2.2.x dumps each thread into an individual core file. I'd post links, but (I just realized) my mouse is unplugged so I can't cut+paste; they shouldn't be too hard to find.

    A quick search on Google shows another interesting-looking multithreaded core patch labeled as for 2.4.0t8 by John Jones and Jason Villarreal, apparently funded by Spinway Inc (good 'fer them!). At a quick glance-over, it looks to make a single combined core dump file for all threads. Once again, I can't cut+paste the URL, so you go find it yourself. :)

    There's other work ongoing on 2.4test on the topic; see the thread "Anyone working on multi-threaded core files for 2.4 ?" for more information.

    So fear not, folks, there's light at the end of the tunnel! :)

  104. Anything except Linux is good for threads by madbrain · · Score: 2

    I work on multiple platforms at the Sun-Netscape Alliance. We develop the web server on IBM AIX, HP-UX 11.0, DEC OSF1 4.0/5.0, Linux 2.2, IRIX 6.5, Solaris 2.6/2.8, NT 4.0. The web server is inherently a multithreaded application and a good debugger has been a must in the part of my day job. I find the two best platforms for debugging to be Solaris and WINNT. Sun has with its Workshop by far the best multithreaded debugging tools on any Unix I have seen. Microsoft has a very nice debugger as well for NT as part of VC++.

    IMHO the very worst Unix platform for doing anything thread-related is Linux. And it's got nothing to do with gdb, but with the Linux kernel. On Solaris, Irix and HP, gdb is available and works fine with threads.

    It doesn't work with Linux threads because threads are independent processes in Linux. When you have one applications with 500 threads, it's just not practical to launch 500 copies of gdb on each of the processes in order to set one breakpoint accross all threads. You have to use another platform with decent debugging tools in order to do that.

    FYI, at home I use OS/2, and IBM has an excellent multithreaded debugger too, as part of Visual Age C++ 3.0/3.6 for OS/2. IMHO it's the best debugger of all for threads. Unfortunately IBM hasn't got anything remotely close to it in its VisualAge C++ for AIX.

    --
    -- Julien Pierre http://www.madbrain.com/blog
  105. Multithreaded debugging by Samarian+Hillbilly · · Score: 1

    TotalView is your answer. It's the only thing I've found that really works under multi-threaded multi=processor environments

  106. Re:90% of C/C++ bugs are memory related by breadmaker · · Score: 1

    Dykstra, I hate you stupid Dykstra's algorithm why are you so stupid why, why! You and your foolish data structures, I'll data structure you mom. Haha woo,








    I got a c in cs310 cause of Dykstra

  107. printf by forged · · Score: 1

    printf owns me. Never used something else. Debuggers are for tarts.

    Don't like printf ? #ifdef DEBUG it !

    :->

  108. Rogue Wave Threads.h++ (incl. disclaimer) by TimTr · · Score: 1

    First - a disclaimer - I work for Rogue Wave so feel free to do all your own research et al. Just wanted to make you aware of it.

    Rogue Wave (www.roguewave.com) has a library that comes with source code called Threads.h++ that works on Linux (as well as Solaris, Windows, HP, AIX etc) designed for making threading programs easier. I invite you to look at the product but here's how this is related:

    First, the API is totally portable and more C++ like. More importantly, there is a really cool little tracing package included with the product (sometimes traces are a better way to debug threads than pure debugger usage.) And finally, I've read people commenting that most C/C++ bugs are memory related (very true) - the Threads.h++ product includes smart pointer classes (reference counting, etc) to help eliminate that when used properly.

    I appoligize for the shameless plug but it did seem related especially considering the platform switch as an option. Flame me if you must, just hope I helped. :)

    ~Tim

    --
    Tim T. ... Cupertino, CA
    1. Re:Rogue Wave Threads.h++ (incl. disclaimer) by TimTr · · Score: 1

      Um, I think everything I said implied exactly what you stated, except for not expressly pointing out that the product is not LGPL. I have no idea what you mean by "must prohibit software development use" and "no mainframe use". I gave the link to the website so he could make up his own mind based on the whitepapers. But the tool is a source code API just like pthreads is, and on Linux it uses pthreads as the implementation mechanism under the object-based API. The mainframe use I also don't understand as the Threads.h++ product has been ported to OS/390 and OS/400 as well as some custom ports for very unusual platforms.

      I appologize for not mentioning the LGPL but I didn't think I even remotely implied that it wasn't a commercial product and, as always, do your own due dilligence. Sorry if I implied anything other than it was a commercial product that may, and only may, help solve the posters problem. It seemed like it might be a product to ease his debugging and if they ever need to port to another platform might aid in that transition as well.

      btw: the original poster never mentioned anything about needing LGPL and also noted that all the other options they were looking at weren't free software either (Java, Solaris, other Unix, etc.)

      --
      Tim T. ... Cupertino, CA
  109. Re:no problem by invalid+email · · Score: 1

    What is necessary? 10 xterms running tail -f, 1 running the editor, 1 the debugger, 1 running xman and 1 running netscape 4.7?

    What's the difference between this and running a few command shells, Visual Studio, MSDN, and Internet Explorer?

  110. best debug method by cmaes · · Score: 1

    #ifdef DEBUG
    printf("blah %d",var);
    #endif

    then when you get annoyed with the extra info
    #undef DEBUG

  111. Re:WRONG! (mostly) by Reality+Master+101 · · Score: 1

    The wise programmer uses the right tool for the right job, and an interactive debugger is usually the wrong tool.

    Well said. There are definitely times and places for debuggers (particularly assembly language programming). And the other poster had it 180 degrees backward -- it's the newbies who have grown up with debuggers and IDEs. It's the old hands that have learned not to let it suck away endless amounts of time.

    And that's the point -- it's not about how easy it is to develop something, it's about how much time does it take? There is no question that debuggers make things easier, but I've found that it makes development far, far slower.


    --

    --
    Sometimes it's best to just let stupid people be stupid.
  112. It depends on app type/completeness by JohnZed · · Score: 3

    If you guys are far along in the development process with c++ already, or if you have limited experience with Java and Java threading, you'll just run into worse threading problems there by trying to fit the pthread paradigm into the Java platform.
    That said, I do a lot of multithreaded programming in both Java and C++, and I would give damn near anything to switch completely over to Java. The threading design makes it FAR easier to build correct programs from the ground up without using a debugger. We've known for 15 years that monitors (Java's synchronized blocks, basically) were a better way to write multithreaded programs, and it's embarassing that it took this long to get the idea into a mainstream language.
    Also, you should check out jlint (http://www.ispras.ru/~knizhnik/jlint/ReadMe.htm), which checks java programs for basic errors including many types of thread deadlocks. A lot of commercial Unix vendors have similar tools for C/pthread programs, but I haven't found one for Linux.
    As for actual debuggers, JBuilder 4 is quite good. I've only used the foundation (free) version, but the enterprise edition can also dynamically detect stalls, deadlocks, and race conditions (see http://www.borland.com/jbuilder/jb4/feamatrix/debu gging.html) and do remote, multi-platform debugging. Also, MetaMata (http://www.metamata.com) has a very good debugger that includes some advanced threading features even in their low-end versions.
    On the down side, you'll have to pick a good implementation of the JDK on Linux and stick by it, as the different JVMs tend to have threading incompatabilities. IBM's are quite good, and they support native threads very well. In Sun's 1.2 implementation, at least, native threads were an undocumented feature (with green threads only officially supported).
    Hope this helps!
    --JRZ

  113. Re:WRONG! (mostly) by Switchback · · Score: 1
    Am I advocating using a debugger to track down eveyr single bug? Of course not. But it's unproductive to track down a bug by continually adding printf's everywhere, recompiling, and cluttering the code. There is nothing that printf can do for me that a debugger can't.

    Just because someone is using a debugger doesn't mean they don't know what's going on. On the contrary, I would argue that anybody continuously adding printf's everywhere really doesn't know what's going on because they're shooting in the dark hoping for the miracle output that will point them to the error in their code.
    Using a debugger requires that you know your code fairly well, although it can also help you learn code you haven't seen before. If you don't know how your code works, how are you going to know where to set your breakpoints and watches appropriately?

    Using a debugger to track down a problem should only take a few minutes. Anybody spending hours just isn't using the tool properly. Debugging takes skill and experience. I know newbies who get into the debugger and step through everything. That's nuts and a waste of time. Learn to use the tool. It'll give you much more insight into how your code works and how it interacts with other libraries.

    My typical debugging sessions goes like this:
    • Something incorrect happens in the program.
    • I look at my diagnostic output. Usually the culprit is pretty obious and I fix it.
      • If it's not, I take a look at the code itself to see if I missed something. If I notice a problem in the code, I fix it.
      • If it's not obvious, I fire up the debugger and set appropriate breakpoints and/or watches based on my knowledge of the problem and the code. Usually I'll see the problem on the first pass and I fix the code within minutes.
    Enough of the doctor analogies :-) Let's try this one: The problem is like a game of battleship. Printf's are just like the game: hit or miss. If you hit, great, you fix the problem. But you can easily keep missing, wasting lots of time. Using the debugger is like using radar to find the ship. You find it nearly everytime. But, if you don't know how to use the radar, you might as well not use it at all.

    Debuggers aren't a a crutch. They are a tool to use...and a productive one at that. You are correct in your statement "The wise programmer uses the right too for the right job." Usually it's a combination of tools.

    - Rick Alther
  114. Re:WRONG! (mostly) by maw · · Score: 1
    An interactive debugger is often an excellent tool while developing. I frequently make use of gdb before I'm aware of any bugs -- obviously they exist, but at some stages, I'm not using gdb to catch them. Instead, I use gdb to run the program and step through it to make sure it really does what I think it does.

    Now that I'm in that habit of using gdb early and often, I reckon that my code has fewer bugs to begin with, although obviously I don't claim to write bug-free code.

    Having said that, I use gdb and printf() (actually, it's been syslog() for me lately, as I've been writing some daemon code) about 60%/40% for debugging. It's always good to use whatever tools you have at your disposal.

    I'm not going to make any bad analogies, however. Nothing hampers understanding like a bad analogy.
    --

    --
    You're a suburbanite.
  115. BeOS is natively highly multithreaded. by voidref · · Score: 1

    I would suggest you check out Be's platform and GUI debugger. As the OS is natively highly multi-threaded, they must have good tools to do the debugging. They also use gcc, so your stuff should be pretty portable to BeOS.

  116. Re:WRONG! (mostly) by mkcmkc · · Score: 1
    There is nothing that printf can do for me that a debugger can't.

    I think you would benefit by considering how a master programmer (which I don't claim to be) might beneficially use printf's in preference to interactive debugging.

    Here's an example that comes to mind. Suppose you have a large software system that depends on some sort of numerical computation library. It may be useful to trace all calls across the library interface, printing the trace in an easy-to-parse manner (perhaps to be checked by another program). It's relatively easy to do this with printf's; it's possible to do with a debugger (by maintaining a debugger script with the required breakpoints, along with breakpoint scripts), but fraught with problems. Maintaining complex debugger scripts is a nightmare.

    Also, printf's, or some similar logging mechanism, work just about everywhere. There are plenty of situations where invoking a debugger isn't practical or even possible.

    Using a debugger to track down a problem should only take a few minutes. Anybody spending hours just isn't using the tool properly.

    Maybe you've never run across a really subtle bug in a large software system before. By subtle, I'm talking about a bug which might occur hours (in execution time) before any externally visible aberrant behavior, during which time it has caused a cascading series of minor errors which finally lead to (say) a crash. You could spend your entire life trying to diagnose a problem like this with a debugger.

    I believe that interactive debuggers are very useful in their place, and that a good programmer must master them, but also that they should be used sparingly, and not as a substitute for really thinking about the problem at hand. Personally, I find myself spending less and less time inside a debugger as the years pass, and more and more time making sure my code is constructed so that those kinds of problems don't occur in the first place.

    --
    "Not an actor, but he plays one on TV."
  117. Forte (formerly Sun Workshop debugger) by Argon · · Score: 2

    Hi, We develop a fairly large multi-threaded application on various Unix platforms and Solaris Forte (formerly Workshop comes out tops). Multi-threaded debugging is very painful on Linux. strace doesn't work on multithreaded programs (this is the single biggest problem for MT debugging on Linux). I found insight, a tck/tk front end to gdb (available at sourceware.cygnus.com) invaluable during some development on Linux/Alpha. I used a cvs version of it and it is coming along pretty well. IMHO a GUI is a must for debugging, especially for MT apps. (What constitutes a GUI is open to debate, but for me emacs with gdb is good enough). Solaris Workshop debugger on the other hand is excellent to use, though it has it's problems. For example, you can control only one thread at a time. This is true for all multi-threaded debuggers I've come across. I've also encountered occasional crashes. But even with these warts it comes out tops. I've worked on MT applications for over 4 years on many platforms (Solaris, Tru64, Linux, Linux Alpha etc) and found Solaris the best supported among these (despite all the thread related bugs that others have mentioned here). If I can get strace working on Linux and have a stable release of insight on Linux, I'll be happy on Linux too.

  118. I'll take a stab. by Turin · · Score: 1
    Dear AC.

    I'm a member of the customer services department at Etnus, so I'm interested in helping you get TotalView working. You didn't give any information about your system, so it's a little hard to troubleshoot your problem. But I'll take a stab anyway.

    Since you are posting to Slashdot I'd say that the likelihood is good that you are on top of the latest releases of all things related to Linux, and that you are comfortable dealing with libraries.

    The latest versions of libbfd changed in a way that breaks functionality that TotalView relies on. If this is indeed what is happening in your case then the fix is simple. The fix is just to include the library that TotalView expects to find. Grab libbfd-2.9.5.0.22.so out of binutils-2.9.5.0.22-6.

    You can install it in /usr/lib/libbfd-2.9.5.0.22.so or you can place it anywhere you want and just update the symbolic link libbfd-2.9.1.0.15.so.0 in /usr/toolworks/totalview.4.1.0-2/linux-x86/shlib/ to point at your libbfd-2.9.5.0.22.so.

    Our release package will be changed to include a working libbfd sometime in the next week.

    Please feel free to contact us at support@etnus.com about this or any other problem.

    binutils and libbfd are licensed under the GPL.

    Cheers,

    Chris Gottbrath, Etnus

  119. Thread Debugging by Cwaig · · Score: 1

    The way I approach thread debugging is: 1)Plenty of diagnostics printf's, but via a macro. All diagnostics go via a macro that allows debug levels to be set, and also prepends line,file,time and thread to the diagnostics string. You can then analyse this output on a thread by thread basis, global timeline basis, etc. 2) Memory Tracking. Tracking memory leaks is reasonably easy - use a macro (say d_malloc) that calls a wrapper function to malloc that allocations a structure containing file, line, time & thread info for the point that the memory is allocated. You can then correlate that with you diagnostics to track leaks. 3) Resource Tracking. Use a similar approach to mutex / semaphore locks to spot points where you're not releasing resources. 4) If all that fails... GDB5 supports threads, and a recent version of Kdbg is a reasonable interface to it.

    --
    +++ BASELINE REALITY FAILURE+++ +++ PLEASE REBOOT UNIVERSE +++
  120. Don't Thread! by refactored · · Score: 1
    Ask yourself very seriously.

    Do you really honestly need to multithread or can you replace all or most threads by a "select" statement?

    Then most of your strangest of bugs will vanish like the mist in the morn, and gdb will be a magic bullet against the rest.

  121. Try Inferno, wm-debug and Limbo by porttikivi · · Score: 1

    ...And for multithreaded programs, a message passing paradigm is generally the best approaching my experience...

    If you are looking for languages that make avoiding bugs easier, look beyond C++...

    Inferno's Limbo uses just that. And has a nice GUI multithreaded debugger. Runs on all platforms. And the source is publicly available.

    --
    Anssi Porttikivi / app@iki.fi