Slashdot Mirror


How Would You Improve Today's Debugging Tools?

redelvis asks: "I recently came across an article by MIT's Media Lab on 'The Debugging Scandal and What to Do About It'. It's a few years old now, but it really got me thinking about how little the debugging process has improved over the last 5,10 or even 30 years. I have developed applications using modern IDE debuggers such as Borland's JBuilder, Microsoft's Visual C++, as well as standard tools like gdb and jdb. Despite the slick graphical interfaces, nice thread stack traces and local variable browsers, I still make sure I have on hand plenty of notepads, graph paper, pens and pencils so I can try to build up a picture of what state the program is in and to help me play detective in pinpointing what is going wrong with my (or other peoples) programs. Do other developers have similar problems? Do they find modern IDEs and debuggers have shortcomings in helping track down bugs? What would make a better debugger? Why do you think so much effort been invested in areas such as advanced modelling tools but so little in improving debugging tools?"

281 of 640 comments (clear)

  1. Perhaps.... by foxtrot · · Score: 5, Funny

    Why do you think so much effort been invested in areas such as advanced modelling tools but so little in improving debugging tools?

    Easy. As anyone who's ever tried to use software knows, nobody uses debugging tools anyway.

    -JDF

    1. Re:Perhaps.... by Joseph+Vigneau · · Score: 5, Informative
      As anyone who's ever tried to use software knows, nobody uses debugging tools anyway.

      Although I'm guessing your reply was intended as sarcasm, I don't think it's that far from the truth. Debugging is a slow, laborious process. Much of the server-side world doesn't use traditional debugging tools at all- they use small, well defined functions/methods, which are easy to unit test. That, coupled with configurable logging, eliminates many of the scenarios a debugger would be involved in, with the benefit of automation, reproducibility, and defect histories/log files. In my travels, I've seen as developers gain experience, they rely less and less on interactive debuggers, and more on automated testing and configurable logging.

    2. Re:Perhaps.... by L.+VeGas · · Score: 4, Funny

      Agreed, this is pointless.

      Anyone that's ever been buggered knows that you can never be debuggered.

      It's like the old joke:
      Q--What's the difference between Madonna and a lightbulb?
      A--You can unscrew a lightbulb.

    3. Re:Perhaps.... by Y+Ddraig+Goch · · Score: 2, Insightful

      Let's not confuse testing with debugging. Debugging occurs when a program does not function as planned, whether an error is thrown or a bug is found by a testor or client. In a ideal situation all bugs are located and corrected during the testing cycle of the development process. However, testing is an expensive and time consuming process and a great number of companies settle for finding the big and obvious problems.

      --
      Meddle thou not in the affairs of Dragons, for thou art crunchy and with most anything.
    4. Re:Perhaps.... by Titusdot+Groan · · Score: 5, Interesting
      I found that as I started using OO languages and techniques (Objective C and Java + MVC and Design Patterns) I almost stopped using debuggers. I almost always know exactly where the bug is as soon as I see the behaviour and can find it by inspection in a few seconds.

      This is also experienced based -- as I get older I use debuggers less and less but my code output has remained constant or improved (even though I don't put in all nighters any more :-)

      I'm finding it really hard to get excited by the fact that there is no effort being put into debuggers where as 10 years ago it would have been a big deal.

      Perhaps that's also part of the problem -- when I evaluate tools etc. I don't spend a lot of time looking at the debugger these days ...

    5. Re:Perhaps.... by Shamanin · · Score: 4, Insightful

      "Much of the server-side world doesn't use traditional debugging tools at all- they use small, well defined functions/methods, which are easy to unit test."

      Well, when you combine enough of your small functions/methods together into one big monolith of a program problems tend to surface. What then?

      Even when using some fully tested COTS library to solve all of your problems the programmer WILL run into integration issues due to unintended use or misunderstanding.

      "I've seen as developers gain experience, they rely less and less on interactive debuggers, and more on automated testing and configurable logging."

      I have been coding for over two decades and have yet to see a reason to abandon debugger use. It is essential, like an x-ray / CT-scan / ultrasound is to a surgeon. Black box and even white box testing will only tell you so much. Sometimes you need to see the cogs in motion.

      --
      come on fhqwhgads
    6. Re:Perhaps.... by gorilla · · Score: 3, Insightful
      Testing and debugging are two seperate activites, and it's important not to try to confuse them.

      Testing is to identify if there is a problem, and hopefully under what conditions they will occur. Debugging is to identify the cause of that problem, and what needs to be done to fix it. One is most definatly not a replacement for the other.

    7. Re:Perhaps.... by GreyPoopon · · Score: 2
      I have been coding for over two decades and have yet to see a reason to abandon debugger use.

      I stopped relying on debugging tools about 12 years ago when I ran into a bug that disappeared everytime I ran the program in the debugging environment. Yeah, it was "C" and yeah, I was shooting myself in the foot with a pointer. At that time, printf became my best friend. Since then, I've worked in many environments that have no debugging tools whatsoever, so I've had to get creative with debugging output to find problems. I still use a debugger as my first crack at finding a problem, but I'm always ready to add some code to track what's going on in the program.

      --

      GreyPoopon
      --
      Why is it I can write insightful comments but can't come up with a clever signature?

    8. Re:Perhaps.... by dubl-u · · Score: 4, Interesting

      Well, when you combine enough of your small functions/methods together into one big monolith of a program problems tend to surface. What then?

      Then you haven't written enough tests. Or you're trying to integrate too much at once.

      If you do test-first development and continuous integration (backed up with good black-box integration testing), then the number of bugs you get should be low. In my experience, that's circa one shipped bug per man-month.

      If I run all the tests frequently as I develop and check in often, I rarely need a debugger. If I break a test, I generally know exactly what the problem is.

      If I forget to run all the tests and check in, then the automated build box will send me email promptly, so it's still pretty easy to find the problem.

      It is essential, like an x-ray / CT-scan / ultrasound is to a surgeon.

      Note that the only time you see a surgeon is when something is pretty seriously wrong. Isn't it much better to make sure that things don't go so far wrong that a surgeon is necessary?

    9. Re:Perhaps.... by Joseph+Vigneau · · Score: 2
      Well, when you combine enough of your small functions/methods together into one big monolith of a program problems tend to surface. What then?

      You write tests to encompass these larger pieces of functionality. In general, debuggers are usually used at the lowest levels: checking variables and references, and sometimes as far as processor registers. At higher levels of abstraction, the debugger becomes less useful, as you're generally not looking for null pointers and the like.

      When unit testing, once you identify a bug, you write a test case that fails, that you would otherwise expect would pass. Fix the bug such that the test passes, and repeat. This works pretty well in the real world, and the proliferation of unit testing tools (both free (JUnit, CppUnit) and commercial (Parasoft)) is a testament to the usefulness of this technique. Many professional developers I work with haven't dusted off the debugger in years...

      [I] have yet to see a reason to abandon debugger use.

      I'm not advocating abandoning debugger use, if you find it truly productive. However, over the course of a project I spend less time writing unit tests than I would if I had to fiddle with a debugger.

      Sometimes you need to see the cogs in motion.

      And this is where configurable logging comes in. It's an automatic process. It's also a lot less painstaking than remembering what watchpoints and breakpoints you had to use when you saw this bug happen last week while fixing somethig else.

    10. Re:Perhaps.... by John+Wharfin · · Score: 4, Insightful

      Agreed. Since changing from C to Java several years ago I find that I never use debuggers anymore, relying instead on verbose logging to understand what my program is doing. I think in C debuggers help more because you can abuse memory in various ways that you don't need to worry about so much in Java. With a debugger it is really easy to see yourself walk off the end of an array, for example. I also observe that my peers who rely strictly on debuggers don't tend to do much logging. So when their software is in production they are mystified when it acts up. I also notice that they don't comment as verbosely either but I can't prove that's because they use a debugger. Maybe they wouldn't comment anyway.

    11. Re:Perhaps.... by __past__ · · Score: 3, Insightful
      I can't speak for smalltalk, but Lisp usually is compiled to native code these days, yet it still has a cool debugging environment, with the full language and program state available and ready to be tweaked. Some Lisps, for example the free CMUCL, even tend be able to give you the source of a form that caused the problem, right next to the asm listing of a compiled function.

      "Interpreted" is not the same as "dynamic". You can have both speed and a productive environment.

    12. Re:Perhaps.... by Shamanin · · Score: 2

      "I ran into a bug that disappeared everytime I ran the program in the debugging environment. Yeah, it was "C" and yeah, I was shooting myself in the foot with a pointer"

      Well, then the debugger was your greatest utility to identifying this stray pointer.

      --
      come on fhqwhgads
    13. Re:Perhaps.... by __past__ · · Score: 4, Informative
      Given that functions like "invoke-debugger" are part of the Common Lisp standard and hence every program can expect to be able to call them whenever it feels like it (although not much about how the debugger is supposed to work is standardized, for obvious reasons), yes, it usually ships with a Lisp app.

      The standard image shipped with CMUCL is about 20 MB on my FreeBSD box. This contains the whole standard library, including the compiler, debugger, profiling and tracing tools, embedded documentation (docstrings attached to functions/variables available programatically, like Python also has now) etc. To that, you add your own code, either as external libraries that get linked at runtime or integrated in the image - you load everything you wrote in a running image, both code and possibly data, and dump its state, so you don't have to re-load it on startup.

      It is possible to get rid of functionality, but I doubt it's frequently used. 20 MB for the runtime system are not too much, compare for example with a Java runtime environment (or a basic Unix system, that could be regarded as Cs runtime).

      Some commercial Lisps, for example Allegro Common Lisp support a more "conventional" way of delivering apps, as standard executables without the need for a runtime. Given that Franz charges higher license fees if you want to include the compiler/debugger in your app, I guess there is a way in ACL to get smaller executables.

      Yet another option is compiling to C, and use standard OS tools like GCC for the final step. Gnu CL and Embeddable CL support this. There is still less difference between the development/production environment than one would think: They also use plain .a/.so libraries to load compiled lisp code when you work interactively.

    14. Re:Perhaps.... by Shamanin · · Score: 3, Interesting

      "Note that the only time you see a surgeon is when something is pretty seriously wrong. Isn't it much better to make sure that things don't go so far wrong that a surgeon is necessary?"

      I would call a bug a serious problem. I made no statement about abandoning unit and integration testing, only that the utility of a debugger is essential for the development process. And, to be precise, I should have said a radiologist rather than a surgeon since this would be a pre-screening before any manipulation is done to the body, I mean code.

      --
      come on fhqwhgads
    15. Re:Perhaps.... by Mannerism · · Score: 2

      Testing and debugging are two seperate activites, and it's important not to try to confuse them.

      I think the two activities are converging. Tools like junit and methodologies like XP are extending testing to the point that when you want to find out what caused a bug, you might consider building tests instead of stepping through your code and watching variables. The resulting test then becomes not only a tool for debugging, but a tool for proactively detecting the bug again should you make a code change that would cause it to resurface.

    16. Re:Perhaps.... by Shamanin · · Score: 2

      "And this is where configurable logging comes in."

      What about when logging is not feasible due such as in some embedded realtime systems? Attaching to target with a debugger is sometimes your only scope into the device.

      On one project I am on, we have no console or flash to printf to. But, using a JTAG device and a gdb server, I am able to step the code and check memory, variables, etc.

      --
      come on fhqwhgads
    17. Re:Perhaps.... by netsharc · · Score: 2

      I think he meant: when the program was running with a debugger watching it, the bug doesn't show up. It only shows up when the program is run without a debugger.

      Hehe, like the bug that goes away when the tech guy shows up to see about it.

      --
      What time is it/will be over there? Check with my iPhone app!
    18. Re:Perhaps.... by Shamanin · · Score: 2

      I know, but by noticing that the problem only occured when the debugger was attached indicated a memory violation of some sort.

      --
      come on fhqwhgads
    19. Re:Perhaps.... by giel · · Score: 4, Informative

      I prefer verbose logging too. I've been working with WebSphere Application Developer during the last year and I've never used the debugger. However verbose logging - IMHO - should be considered as a form of debugging too. Sure, it's not the boring act of step-by-step stumbling through control structures and loops glaring at a huge set off watches, but instead it focuses on what is important in a certain context (if logging is done properly) and is works much faster, because the result simply stays in the form of a log which one can take all the time needed to examine.

      An important pro of verbose logging to traditional debugging is that proper log statements preferably combined with assertions which validate the state of an object at runtime also provide very usefull documentation of a program. The remaining contra is extra code slowing down execution, even dramatically depending on the log format (imagine the time needed to format date/time information for each 5 or so lines of code).

      Comes to my mind the fact that object oriented languages use runtime linkage for virtual methods at great scale. Hence it should be possible to keep two versions of code, one containing debugging code and one that has been cleaned - eg. by a modified class loader for example, whic removes all calls to a classes from a certain package. This should enable switching at runtime from a clean non-logging version to a logging-version, if a certain condition is met. For example during a suspicious error, or simply a flag a user can set at the moment he or she detects a bug. This means that even production versions of software could be equiped with shiploads of logging possibilities having nearly no affection at all to their execution speed.

      --
      giel.y contains 2 shift/reduce conflicts
    20. Re:Perhaps.... by Directrix1 · · Score: 2, Funny

      Well, you can always program using predicate calculus and get error free code from the start. Weeee!

      --
      Occam's razor is the blind faith in the natural selection of least resistance and in universal oversimplification. -- EF
    21. Re:Perhaps.... by scrytch · · Score: 2

      Better known as a heisenbug. Race conditions are notorious for being heisenbugs...

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
    22. Re:Perhaps.... by giel · · Score: 2

      That's is exactly why good developers prefer verbose logging instead of debugging.

      If verbose logging is applied in a smart way, errors will show up in such a way you will be able to see where and why the code fails. Then it's up to the developer to find out if either te predicates are wrong or the context to which they apply fails...

      eg. Given this:
      [True] S(); [False]

      It can't get any better, can it? For any X and Y the pre and post conditions apply: X => True and False => Y

      So for any X and Y the following: [X] S(); [Y] is valid.

      But what IF the S() crashes, it does not even reach the post condition? How are you going to find out why?

      Hmm. Well. Perhaps this is a far too complicated subject to discuss over here... Besides it was years ago when I learned to program using predicate logics.

      --
      giel.y contains 2 shift/reduce conflicts
    23. Re:Perhaps.... by lsdino · · Score: 2, Insightful

      That's is exactly why good developers prefer verbose logging instead of debugging.

      If verbose logging is applied in a smart way, errors will show up in such a way you will be able to see where and why the code fails. Then it's up to the developer to find out if either te predicates are wrong or the context to which they apply fails...
      (emphasis added)

      That's ridiculous! I'd say that good developers use both. And they also use assertions.

      Logging gives you a picture of your program over time. It's a great tool and can help find bugs that are otherwise difficult. You can watch states change, and see method calls, from your hand picked logging statements.

      On the other hand a debugger gives you an instant snapshot of your program, and allows you to inspect the state in detail. Again, another great tool.

      Logging's greatest weakness is it requires an edit-compile cycle to get new messages in. And it's real easy to end up not having messages in the right spots or not displaying enough information (or the right information).

      Whereas with a debugger you can load the program up, set a break point, run, and then step through and see what's happening. No edit, no compile, you're just there. But it's greatest weakness is watching the program state change over a long time.

      So they're both great tools and are good for different things. Good programmers know how to use the tools that are available to them.

    24. Re:Perhaps.... by canadian_right · · Score: 2

      This can also indicate an over zealous optimizer. Generally, the debug build turns of optimizations.

      --
      Anarchists never rule
    25. Re:Perhaps.... by refactored · · Score: 2
      Not really.

      You have a bug, what should you do next....

      Write a unit test that triggers the bug. This has two uses....

      1. It allows you to compile/link/debug fast! No long setup times to debug.
      2. It gaurantees that the bug won't silently reappear later.

      How should you fix a bug? Refactor until the code is so simple, that the bug is obvious. Then remove the bug.

      But to refactor safely you need a good suite of unit tests.

      No testing, and debugging are not that far apart...

    26. Re:Perhaps.... by dubl-u · · Score: 2

      In theory methodologies like this are good. In practice (at least in a startup environment) developers simply don't have time to follow such practice.

      In a startup environment, everything you do will have far-reaching effects in the future. In a startup environment, it's much harder to predict where your company will go, as both investors and your customers will pull you in new directions. In a startup environment, people will be promoted so quickly that you can't assume that in three months they'll be around to support (or even explain) the code they're written. In a startup environment, missing a deadline or delivering buggy software an be fatal.

      More directly: in a startup environment, you don't have time to do it in a half-assed way. Ergo, you should plan to do it right from the beginning.

      And yes, I've just done this in yet another balls-to-the-wall, full-on-stealth-mode startup. The only thing the CEO regrets is that we didn't make him do it better.

    27. Re:Perhaps.... by jimfrost · · Score: 2
      Since changing from C to Java several years ago I find that I never use debuggers anymore

      How much of that is because you wouldn't find it useful, versus the fact that there really haven't been any good Java debuggers?

      With program restarts in our Java applications into the ten-plus minute range, a debugger would be a serious time saver versus adding log or println entries.

      I note that with JDK 1.4 the JVM debug interfaces are finally good enough to actually make a working debugger, which will help things a lot.

      --
      jim frost
      jimf@frostbytes.com
    28. Re:Perhaps.... by jimfrost · · Score: 2
      Then you haven't written enough tests. Or you're trying to integrate too much at once.

      Must be nice to work in a world where you have time to write comprehensive supra-unit tests and can rely on all your co-workers to have fully tested their code.

      I'd like to visit that world sometime, because in my world schedules are allocated such that it's rare you have time to do more than just unit testing and they call integrated testing "beta".

      I'm only half joking. Then again, our problem domain scale is probably offset by a couple of orders of magnitude and that will certainly make a difference.

      --
      jim frost
      jimf@frostbytes.com
    29. Re:Perhaps.... by dubl-u · · Score: 2
      Then you haven't written enough tests. Or you're trying to integrate too much at once.
      Must be nice to work in a world where you have time to write comprehensive supra-unit tests and can rely on all your co-workers to have fully tested their code. I'd like to visit that world sometime, because in my world schedules are allocated such that it's rare you have time to do more than just unit testing and they call integrated testing "beta".

      If you want to go as fast as possible, then you don't have time not to not keep things clean by writing good tests, integrating continuously, keeping in close touch with your coworkers, and refactoring whenever you see a way to improve the design.

      In the very short term, say a week or two, you can improve your productivity by writing utter crap. But that's just storing up trouble; in effect, you borrow productivity from the future. But it's like borrowing from a loan shark: the interest rate is terrible, and the project ends up with broken kneecaps if you don't pay up pronto. If you're writing code that's only minorly crappy, then you build up cruft at a slower rate, but the problem's still there, and it will eventually lead to critical mass.

      So yes, it is to nice to work in a world like that. And it yields better software faster, so it's great for the suits, too. My advice: either change your organization or change your organization.
  2. All your need is a little of this... by jpt.d · · Score: 2

    Project Builder absolutely sucks for debugging on its own. But, I use it for break point management, but from there I use the GDB console it has. I know dick about getting gdb upto that point, but PB does it nicely. Then I can use p for a normal inspection, and po for an object inspection. I like it. If it weren't for the GDB console, PB would really suck debugging. But with it, it rocks!

    --
    What we see depends on mainly what we look for. -- John Lubbock Now search for that bug slave!
  3. Easy solution by stratjakt · · Score: 4, Funny

    Dont debug.

    Eventually someone else will find the bugs and fix them for you at their own expense.

    This is how the Open Source programming model works.

    --
    I don't need no instructions to know how to rock!!!!
  4. I'm sure loads of debuggers have got it... by koali · · Score: 4, Interesting

    But I'd like to be able to create 'conditional' breakpoints (i.e.: stop at this line when i==47).

    Other than that, I'd like generalized hot-swapping of code and 'step back' (which I don't know if it's always factible); or at least be able to view a variable's history.

    Shame that my IDE of choice (Eclipse) doesn't (AFAIK) support those.

    1. Re:I'm sure loads of debuggers have got it... by MisterFancypants · · Score: 2
      Yeah. Visual Studio .Net does this, and many more things, when it comes to advanced breakpoint support. It is REALLY NICE to go in and tell it to break on any line when a certain variable changes, in those cases where you see a variable is changing at some point but you're not sure exactly where it is happening.

      It pains me greatly to have to use lesser debuggers than the one in Visual Studio when I'm developing code for non-Windows platforms. The extensive breakpoint support, edit and continue, etc seemed a bit like fluff to me when I first started using them, now I find it hard to live without them.

    2. Re:I'm sure loads of debuggers have got it... by rvaniwaa · · Score: 5, Informative

      To do this in dbx do:

      "stop at 99 if (x == 17)"

      or in gdb:

      (gdb) break main.C:99

      Breakpoint 1 at 0x8048776

      (gdb) cond 1 (x = 17)

      (gdb)

      --
      main(i){(10-putchar(((25208>>3*(i+=3))&7)+(i ?i-4?100:65:10)))?main(i-4):i;}
    3. Re:I'm sure loads of debuggers have got it... by IPFreely · · Score: 3, Insightful
      or at least be able to view a variable's history

      That's one I've actually wanted before. I'd like to see something where you could specify a list of "Watch" variables, and snapshot points. then let the program run. It takes snaps of all variables at each point. you can then go back and review what happened. Get a nice grid of variable values by point in time.

      It's a lot faster then setting watches and breakpoints and having to write or remember what happened at each point.

      --
      There is nothing so silly as other peoples traditions, and nothing so sacred as our own.
    4. Re:I'm sure loads of debuggers have got it... by alannon · · Score: 2

      I'm guessing that main.C:99 is a point in your run-loop, meaning it would only ever be checked once every time through the run loop. I believe a more useful way of doing this in gcc would be as follows:

      1) use 'watch' to set a watch breakpoint on a variable, either on variable change, or variable read, respectively.
      2) set a condition on the watchpoint so that it only breaks when that variable equals a certain value. ...

      I just decided to test this and on 2 different platforms (OSX and linux) gdb does not do this properly. Anybody know why?

  5. This is no surprise -- It's not PB's job by krog · · Score: 2

    Project Builder is meant to integrate (as you said, through breakpoint control) with GDB. It is not meant to perform debugging on its own.

    It's a wonderful development environment -- Project Builder for the code, Interface Builder for the GUI, and GDB for debugging.

  6. Debugger improvements by exp(pi*sqrt(163)) · · Score: 5, Interesting
    • Reversibility. I'd like to be able to step backwards through code. No, this isn't a joke. Only a small amount of information needs to be stored as each instruction is executed in order to have an emulator go backwards again. You don't necessarily want to run an entire application reversibly. You might want to run a small loop until it crashes and then work backwards to find the cause.
    • Easy plugins I want to easily be able to load my own custom code into the debugger. For example I might want a custom routine to conveniently display a custom datastructure, or even give a graphical representation of some data.
    • Program control. More cooperation with the code itself. I'd like the debugger to provide a library against which I can link my code so that the code being debugged can control things like which variables are being watched and which breakpoints are active. I could then easily have breakpoints that are enabled only under certain conditions. Especially useful when the best way to detect those conditions is for the code itself to figure it out.
    --
    Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
    1. Re:Debugger improvements by rvaniwaa · · Score: 2


      Reversibility. I'd like to be able to step backwards through code. No, this isn't a joke. Only a small amount of information needs to be stored as each instruction is executed in order to have an emulator go backwards again. You don't necessarily want to run an entire application reversibly. You might want to run a small loop until it crashes and then work backwards to find the cause.


      This is obviously not always possible as many functions (squaring a number, sin of a number, ...) are not reversible

      --
      main(i){(10-putchar(((25208>>3*(i+=3))&7)+(i ?i-4?100:65:10)))?main(i-4):i;}
    2. Re:Debugger improvements by exp(pi*sqrt(163)) · · Score: 2

      You store a log. You'd do this at the machine level. So, for example, if you emulated the x86 instruction add eax,1 you'd need to store a copy of the flags before executing the instruction because some of those will be clobbered irreversibly. Note that you wouldn't need to store the value of eax as that part is reversible. For an instruction like mov eax,[ptr] you'd obviously need to log the value of eax before executing it. You might also need to store some extra flags to deal with branch instructions.

      --
      Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
    3. Re:Debugger improvements by Coward+Anonymous · · Score: 3, Interesting

      You might want to add execution history to the list.
      A stack trace gives you the current calls but what were the previous 5 calls made?
      An execution history would tell you what the last N calls were and in what order they occured.
      It would be easy to implement as a series of stack snapshots.

    4. Re:Debugger improvements by Dr.+Evil · · Score: 2

      Stuff like jumping gets hairy, I'm not sure how you could really "run backwards". But you should be able to save a program trace in a circular queue and simulate the behaviour of running backwards. The instructions combined with the changes to the processor state should let you use a core-dump to walk backwards through the changes.

      That is, you store all the changes to the registers, along with the intstruction pointer, any changes in memory, anything done anywhere using the CPU.

      When the app cores, you could then watch it in the debugger like a movie... forwards and backwards. You couldn't make changes to variables or anything fancy since you would be limited as to how much state information you've stored... but I know it would help me from time to time.

      I doubt the CPU could help create such a dump... but an emulator could.

    5. Re:Debugger improvements by Anonymous Coward · · Score: 2, Informative

      - The WATCOM C/C++ debugger has reverse execution support. (No, I am not kidding.)

      - Dumping data structure support is something that you can integrate into your application. That said, the MSVC++ debugger's data structure dumping is not that bad.

      - The plug in idea is a good one. However, I believe that Soft-ICE may have at least some such ability.

      I think perhaps the fact that the above post was moderated so high is evidence of an earlier post -- that nobody actually uses debuggers?

    6. Re:Debugger improvements by EvlG · · Score: 2

      Easy plugins I want to easily be able to load my own custom code into the debugger. For example I might want a custom routine to conveniently display a custom datastructure, or even give a graphical representation of some data.

      It's worth nothing that Visual Studio already has this capability, at least to some degree.

    7. Re:Debugger improvements by IanBevan · · Score: 2, Informative
      Reversibility was available with the Borland IDE some years ago. Can't remember how well it worked.

      Plugins is an interesting one. Although it's not a well known feature, the MS Visual Studio IDE allows arbtrary formatting of a datatype (it's specified in a configuration file IIRC). This is only formatting though, so there's no code to be executed and certainly no way of displaying the data graphically.

      As for program control, try
      if (mycondition) { asm int 3; }

      Under Windows
      if (mycondition) { DebugBreak(); }

      The Visual Studio IDE can also set conditional breakpoints. Hit F9 to set a breakpoint, then open the Edit Breakpoints dialog box (Edit|Breakpoints) and hit the Conditional button.
      Since we're here, I would very strongly recommend Jon Robbin's Debbugging Applications book for lots of tricks and traps using Win32/ MS Visual Studio. All of the code there is win32 specific though, so not much use to Linux development. Amazon says it's out of print, but I see it in local nerdy bookshops from time to time.
    8. Re:Debugger improvements by FattyBoeBatty · · Score: 2, Funny

      "...Program control. More cooperation with the code itself. I'd like the debugger to provide a library against which I can link my code so that the code being debugged can control things like which variables are being watched and which breakpoints are active. I could then easily have breakpoints that are enabled only under certain conditions...."

      You know, that's actually a great idea -- and if you think of the logical continuation of it, it would only be a matter of time before you needed a debugger for your debugging code. How cool would that be!

      -Fatty

    9. Re:Debugger improvements by bob_jenkins · · Score: 2

      Reversibility -- for singlethreaded, something just about as good would be to dump the state of the program at some chosen point and be able to reload it at that point. The real gain of reversibility is you don't have to spend the hour setting up the problem.

      The first thing I do already when debugging something is whittle down the testcase to make the overhead of reproducing it as small as possible.

    10. Re:Debugger improvements by exp(pi*sqrt(163)) · · Score: 2

      Are you talking about that file, whose name I can't remember, where you can give a crude format specifier? It's OK for some stuff, but not great.

      --
      Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
    11. Re:Debugger improvements by Gaijin42 · · Score: 2

      Uh.

      2^2 = 4.

      -2^2 = 4.

      Given 4, x^(1/2) is not reversable, if your original input could include a negative number.

    12. Re:Debugger improvements by exp(pi*sqrt(163)) · · Score: 2

      I've had the Visual C++ debugger crash and kick up another debugger to debug itself many times now...

      --
      Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
    13. Re:Debugger improvements by EvlG · · Score: 2

      There is that, but there is also a plugin interface so that the debugger can call a function to provide a custom representation of the data.

    14. Re:Debugger improvements by jimfrost · · Score: 2
      More cooperation with the code itself. I'd like the debugger to provide a library against which I can link my code so that the code being debugged can control things like which variables are being watched and which breakpoints are active.

      In a different posting I talked about Saber-C and some of what we did that was useful, but I totally forgot about this particular feature. We did have the ability to link in debugger control functions like "break now". It was, indeed, quite useful.

      --
      jim frost
      jimf@frostbytes.com
  7. Teach people to use already available tools by rvaniwaa · · Score: 5, Insightful

    One of my biggest problems with people on my current project is the lack of knowledge of how to use even the most basic tools. We program in C++ on Unix and many developers find calling up dbx to be a chore and, even when they get dbx up, have trouble using it. We have many other tools, ddd, other graphical debuggers but people just don't use them, relying on printfs and couts...

    --
    main(i){(10-putchar(((25208>>3*(i+=3))&7)+(i ?i-4?100:65:10)))?main(i-4):i;}
    1. Re:Teach people to use already available tools by rvaniwaa · · Score: 2

      I was probably a bit strong on my opinions on printfs. I use them myself but it is usually only for the initial debugging. When the problem starts to get deeper, it is generally faster to run it in a debugger if only because building the entire application takes too long (half a day or more if you change the wrong file...).

      Also, I am frequently the one called in when someone else's code does not work. Since I don't know the code, as you say, debuggers help greatly in figuring out the flow...

      --
      main(i){(10-putchar(((25208>>3*(i+=3))&7)+(i ?i-4?100:65:10)))?main(i-4):i;}
    2. Re:Teach people to use already available tools by EvlG · · Score: 5, Informative

      You are dead on here.

      How many ppl here are clamoring for conditional breakpoints, when VS.NET can do this already?

      Or clamoring for the ability to see what changed your variable, no matter where it was changed? Breakpoints on memory can do this too. In VS.NET I just set a breakpoint on a given memory address, and anything the address changes, it takes me right to the instruction (or statement, if it has src) that changed it. Absolutely critical feature for tracking down memory corruption.

      But how many people know about these facilities?

    3. Re:Teach people to use already available tools by irix · · Score: 2

      But how many people know about these facilities?

      Indeed. I don't use VS.NET, but I can tell you that dbx on Solaris can do the same things. It can also check for buffer overruns, memory leaks, and do performance profiling. However, many people seem not to know about these features.

      Somehow I think the "use printf!" crowd here are debugging their university CS assignments, and not any type of complex real-world application.

      --

      Do you even know anything about perl? -- AC Replying to Tom Christiansen post.
    4. Re:Teach people to use already available tools by EvlG · · Score: 2

      I agree 100%. Speaking from my own experience, printf() or other log-based debugging was only effective on projects up to about 3000 lines of code. Beyond that, the debugger was the only way to go (and it is certainly the only way to debug very large systems with 100k+ loc).

      One place I did find logging to be better than the debugger though was in debugging distributed applications. I had a couple of university assignments in a distributed OS class; log files were really the only way to go because of the nature of the interactions between the processes (many of the bugs were time-dependent, and you just couldn't catch them in a debugger).

    5. Re:Teach people to use already available tools by irix · · Score: 2

      One place I did find logging to be better than the debugger though was in debugging distributed applications.

      Actually, I code distributed applications for a living :-) We do some logging that can be turned on and off on the fly so that we can help debug distributed problems both in house and in the field.

      I guess I didn't mean to imply printf() is useless, just that it is just one small tool in debugging a problem. If printf() is the only thing you use, then you either have a simple problem or you are going to have to spend a lot of time debugging. I also get some use of of packet sniffers like Ethereal, and as I said you can do a lot with dbx. This all goes back to the original point - use all of the tools you have available, and learn how to use them well!

      --

      Do you even know anything about perl? -- AC Replying to Tom Christiansen post.
    6. Re:Teach people to use already available tools by Darth_Burrito · · Score: 2

      You make it sounds as if using printf isn't as good as using a debugger

      Well, for a lot of stuff, it really isn't nearly as good as a debugger. Compiling takes a long time. You can't explore a complex data structure in an interactive environment. Can you even use printfs when there is only a gui and half the application is setup so it can run on a remote machine via com+?

      I find that method is usually faster than trying to use a debugger.

      How could it possibly be? With a good debugger you can move to any section of code and instantly check the value of any variable or complex object. With printf, you have to recompile every time you want to add or remove a printf. I suppose you could macro in your debugging code and that way you could automatically generate traces of information... but every time a new problem came up you'd have to set up new debugging code to solve it. And all that compiling.... Am I missing something?

      [RANT] It really bothers me when people ignore good development tools because they think their way is faster. For example, with Interdev and IIS you can debug ASP applications, but you have to do a little work to make sure the debugger will work. The place I work at now doesn't use Option Explicit in vbscript or use strict in perl. They write perl scripts in notepad for gods sake. It's like being asked to run a marathon in flip flops. [/RANT]

    7. Re:Teach people to use already available tools by EvlG · · Score: 2

      I'd be interested to hear what techniques you use to debug your distributed apps, and on what sort of scale you deal with them.

      My apps were relatively small (around 10 nodes) being part of a semester university course and all. I found that the debugger was effective of course for verifying small blocks of code and overall program flow, but I quickly got frustrated with it trying to debug the system as a whole.

      The problem with log files was of course the parsing stage. At one point I toyed with the idea of make a perl script that could verify correctness, but I decided that was more risky than just reading the logs by hand to make sure things were correct or to find out where the problem was.

      What techniques do you use?

    8. Re:Teach people to use already available tools by statusbar · · Score: 2

      I agree with all your points. However I have found debug logging more useful than debuggers on a few occasions. Specifically, to trace the actions of code during a hardware interrupt routine. In this case, a debugger doesn't cut it and if you want something better than prints then you have to get a hadware cpu emulator hooked up - Or a cpu with a JTAG interface.

      Of course, I'm not speaking of normal prints here, I devised a priority level logging system that was efficient enough to call during an ISR, and then only when a specific trigger condition was encountered.

      However, being involved in porting linux 2.4.20 to a custom powerpc board made me REALLY appreciate the power of the JTAG interface connected to a gdb running remotely to do source level debugging of the kernel!

      --jeff++

      --
      ipv6 is my vpn
    9. Re:Teach people to use already available tools by irix · · Score: 2

      The application I work on is a 2-node cluster, but it can have dozens of clients.

      Debugging the distributed nature of the problem usually comes down to two things - content of the message (we use our own protocol on top of TCP) and the timing. Our debug logging can log both on the server and client sides, so usualy I just end up looking at the logs (just a visual examination) to see where a problem lies. I can see what messages were sent by whom and when, and what was recieved.

      If the problem gets more complex, I have used perl to parse the logs, especially if we have a problem in the field and we get a lot of data back. As I mentioned before, I have also used Ethereal to examine what is being sent across the wire when some even more bizarre problems surfaced. I have also been using a Linux router running NIST Net to help simulate various network conditions when trying to debug problems.

      --

      Do you even know anything about perl? -- AC Replying to Tom Christiansen post.
  8. I'm not a professional developer, but... by reimero · · Score: 5, Insightful

    I'm a total amateur, but I personally find that software tools can ultimately only go so far in debugging. The two most important debugging tools I'm aware of can't be solved with software: a short break from the project to clear your train of thought, and another set of eyes which might better see what you've overlooked.

    --

    ----------

    Something clever
  9. Problem Solving Skills by kvn299 · · Score: 2, Interesting

    Debugging is essentially problem solving and if you don't have well developed skills doing that, then it's not going to be very easy to do. However, every person thinks differently and hence approaches to problem solving varies. It seems to me that although computers can help narrow down the scope of this issue, in the end, it's the brain that is the most powerful tool.

    Remember those high school days of comparing the green text on your TRS-80 monitor to the print in your Softside magazine. Now that was fun... har har.

  10. Visual Basic debugger.. by mumblestheclown · · Score: 3, Interesting

    As much as everybody here likes to make fun of Visual Basic, I encourage all to have a look at VB's debugger. While there are a few improvements here and there that could be made, in general it far, far surpasses anything else that I have seen out there. (I have yet to play with VB.net--I am referring here to VB6).

    1. Re:Visual Basic debugger.. by stratjakt · · Score: 3, Interesting

      I use it every day, and take it for granted sometimes. I miss it when I'm using another language and lacks its features.

      The call stack is at your fingertips, I add/remove conditional watches with a couple keystrokes, stepping into, out of, and over functions, and the immediate pane makes a great scratchpad/interface to the internals of the program. You can break on all errors, unhandled errors, or arbitrarily.

      It wouldnt be nearly as easily to quickly put together apps in VB without it's debugger. It truly turns a half-assed language into a really good tool for rapid prototyping.

      --
      I don't need no instructions to know how to rock!!!!
    2. Re:Visual Basic debugger.. by MisterFancypants · · Score: 3, Informative
      For the C/C++ people out there, try checking out the debugging facilities in Visual Studio .Net in general. The debugger for C++ is great as well. Edit & Continue support allows you to recompile code and keep debugging a running process in memory. Tons of options for conditional breakpoints (break anywhere if variable x changes). Support for automatic buffer overflow checking. Interactive variable watch that you can even call functions in (eg. you can set a watch on strlen(myString), it will display the result of the strlen call (and that's just one example, works with any function/method/data).

      Whatever you think of Microsoft, the debugging support in Visual Studio .Net is very top notch and well supported in all languages (C#/VB/C++ (both managed and unmanaged)).

    3. Re:Visual Basic debugger.. by Chris+Burke · · Score: 2

      Interactive variable watch that you can even call functions in (eg. you can set a watch on strlen(myString), it will display the result of the strlen call (and that's just one example, works with any function/method/data).

      Ah, that's cool they finally got that. I greatly missed the ability to call functions and execute code from the debugger when I had to go from gdb to VS 6-something. I was becoming one of the "printf() crowd" until I learned about this feature. :)

      --

      The enemies of Democracy are
  11. Real Men Don't Use Debuggers by dilute · · Score: 3, Redundant

    Strategically embedded print statements - the time-honored way to find bugs.

    That plus printing out and actually READING the code. Amazing what you can find by walking out of range of the screen and keyboard and just reading through the stuff.

    1. Re:Real Men Don't Use Debuggers by Pinball+Wizard · · Score: 3, Insightful
      Strategically embedded print statements - the time-honored way to find bugs.


      Doesn't work very well with recursive functions. Especially recursive functions that call other recursive functions. Ever tried to write a recursive descent parser? Next to impossible without a good debugger. You need to be able to step through the code line by line and watch variables as they are loaded on to(and popped off) the stack. No way are print statements going to be nearly as helpful.

      --

      No, Thursday's out. How about never - is never good for you?

    2. Re:Real Men Don't Use Debuggers by lakeland · · Score: 2

      I don't entirely disagree with your point, but print statements can debug recursive functions. Just print a number of spaces equal to the recursion depth at the start of the line.

    3. Re:Real Men Don't Use Debuggers by sholden · · Score: 2
      I don't entirely disagree with your point, but print statements can debug recursive functions. Just print a number of spaces equal to the recursion depth at the start of the line.

      How do you know the recursion depth?

      Adding a global/static/whatever_the_language_uses variable and the code to increment and decrement it is not just adding print statements after all.

      Way back when I did CS2 all of us (other than the wussy Engineers) had to write a recursive descent parser for a pascal like language, to generate MIPS assembler. 99% of the student didn't use a debugger aside from using gdb to get a stack trace from a core file (ie. not running the code in the debugger at all). Most of us managed to get it working using fprintf(stderr,"How the fsck did it get here") statements...

    4. Re:Real Men Don't Use Debuggers by Matts · · Score: 2

      I wrote perl's XML::SAX::PurePerl - a pure perl recursive descent parser entirely with the aid of print statements. I never use a debugger - I can't recall the last time I used one except for getting a stack trace.

      However I used to use debuggers. I just find that the more mature a programmer I become the more I know almost exactly where the bug is as soon as its described.

      --

      Matt. Want XML + Apache + Stylesheets? Get AxKit.
    5. Re:Real Men Don't Use Debuggers by ctr2sprt · · Score: 2

      Then you're doomed to use truss or strace or whatever, because a normal debugger won't help you there anyway.

    6. Re:Real Men Don't Use Debuggers by Pinball+Wizard · · Score: 2
      Way back when I did CS2...99% of the student didn't use a debugger

      Well, being a somewhat experienced programmer who decided to go back to school and finish my degree - I agree with you, most students haven't bothered to learn how to use a debugger.

      BUT...I did a few programming projects with some friends of mine and I showed them how much easier it was to follow what was going on with a debugger. It was like a light turned on for them. And they were thankful for the hours of work it saved them.

      I'd have to believe that if nothing else learning how to debug would save lots of hair being pulled out by CS students. Especially those little errors like a variable going out of scope or a line or two of code that is in the wrong place - a debugger will help you catch those types of things immediately, whereas even with the print statements you still might take a while before you catch those types of things.

      --

      No, Thursday's out. How about never - is never good for you?

  12. println debugging by kisrael · · Score: 4, Interesting

    I don't know if it's my greatest failing or greatest success as a developer, but I tend to be a println debugger all the way.

    Recently I remember seeing some justification/defenses of this technique, I think it's sometimes called "logging based debugging".

    When something goes wrong I figure out the related assumptions I'm making, and then test 'em by output to STDOUT or STDERR or a file. It avoids some of the "Heizenbug" problems debuggers can bring on (so long as dumping output can be reasonably expected to be reliable w/o bringing on crossproblems) and by thinking of your assumptions, you're tying into principles similar to "write tests first", part of XP practices.

    One set of things this doesn't handle well is memory leaks and bottlenecks and looking out for runaway object creation and the like, but garden variety debuggers usually don't cover that too well either, you need special profiling tools anyway.

    --
    SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
    1. Re:println debugging by William+Tanksley · · Score: 2

      Logging based debugging is excellent, and with a slight refinement can give HUGE benefits. Specifically, every time you want to log some debug information in a function, instead refactor the function to make all the information available via an API, and test that API in your unit tests.

      As a result, your unit tests grow to express how you think your software should work; thus, later changes can be made without having to worry about violating implicit assumptions (because all the assumptions you know about are explicitly and automatically tested).

      As a bonus, you don't wind up inserting print statements into the control flow, and therefore you can catch more bugs in more situations.

      This has worked for me for quite a while. It gives you superb testing almost for free -- and it also has the nice side effect of teaching you better API design, since when you make a bad API you'll have to correct it later in order to debug it. (This effect isn't as nice as it is in Test Driven Design, where you can't code a bad API because your design was implemented to satisfy and already-written test).

      -Billy

    2. Re:println debugging by jgerman · · Score: 2

      I believe that all methods of debugging are useful at some point. But I tend to use the print debugging first. Not only does it do the things you said, but it also tells you very quickly if you're assumptions are wrong, giving you a clear idea of the correctness of the program very quickly.

      --
      I'm the big fish in the big pond bitch.
    3. Re:println debugging by Synn · · Score: 2

      I do this with PHP all the time. I write up some code and certain classes a few levels down don't call or work like I expected, so I toss in some print "made is this far" lines here and there and I can see where it's making it or not making it.

      Then I use prints to inspect values to see where I'm messing something up.

      It's worked for 5 years, though I supposed I should use some sort of "real" debugger or something.

    4. Re:println debugging by kisrael · · Score: 2

      It's very time consuming to use logging-based debugging to examine complicated interrelationships in your code. If all you need to know is "What was the value of variable xyz at this point in the code?" then anything other than println's is probably overkill.

      I'm not sure how I'd use a regular debugger to examine a complicated interrelationship, honestly. (which probably says something about my debuggerability (eww, that sounds gross)) Could you or someone come up with some example of the kind of view a good debugger provides, that moves beyond the "value of variable xyz", and would be helpful in seeing the relationship side? (This isn't a rhetorical point I'm trying to make, I'm just not smart enough to think of an example myself.)

      --
      SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
  13. Debuggers are mostly useless by Julian+Morrison · · Score: 2

    Real debugging uses (1) printf calls to trace execution path, dump variables, and detect the crash point down to the nearest few lines (2) eyeballs and brain to spot the goof now its position is locked down. Debuggers are just for the wierdass bugs, and mostly they break differently in those cases anyway, because they're singlestepping not running full tilt.

    A good debugger for those cases whern one's needed is DDD.

  14. Durr by mao+che+minh · · Score: 2
    "How Would You Improve Today's Debugging Tools?"

    Make them work better at debugging. What a pointless story/question this is.

    1. Re:Durr by Anonvmous+Coward · · Score: 2
      "How Would You Improve Today's Debugging Tools?"
      Make them work better at debugging. What a pointless story/question this is."


      "What is the cause of most plane crashes?"

      "What a dumb question. It's gravity!"
  15. Eclipse debugger by LadyLucky · · Score: 2

    Is miles in advance of earlier versions of debuggers. Change code at runtime, you sexy beast.

    --
    dominionrd.blogspot.com - Restaurants on
  16. some ideas on why debuggers are in this state by Shaleh · · Score: 5, Interesting

    a) it is hard to make money on debuggers

    b) making a good debugger is definately not easy

    c) many developers prefer puzzling out the code on pen and paper then walking it in a debugger. Quite a few I have talked to believe that they make better code if they can solve the problem without resorting to debuggers. This BTW is why Linus does not like kernel debuggers.

    d) most of the debuggers are good enough and as we all know from open source, a good enough solution will live forever. The existence of a debugger that mostly works gives most people a reason to spend their time elsewhere.

    In my experience I have truly benefited more from programs like Purify or Insure (and now the great valgrind) than I have from a debugger.

    1. Re:some ideas on why debuggers are in this state by anshil · · Score: 2

      -- Debugging using printf's and #if's is poor programming practice but the tool most programmers use.

      Why can you say is it poor programming practice? Any proofs on that, or just a postultate. It's experience after the years we learned how to find a bug quickest, most expirienced programmers tried both ways, using a debugger, using printfs, using debug() macros etc. We will use the ones we find out which work fastest, and honestly most times I find bugs in highlevel applications the fasted way using printf's. Why? First using a debugger can significantly change the behaviour of a program, not all programs can be stepped, when in example the application talks to hardware, talks network protocols, uses GUIs, you get timeouts other timing behaviour, or often when the bug results out of reading undefined memory, it's often different in a debugger environemnt. The bug just isn't there then. Second reason is printf you get on stdout very quick an overview whats happening where, while in a debugger you have to step into evey point. Honestly there are error that can be found quicker with and ones that can be fount quicker without a debugger. Experience should tell you when to use which.

      --

      --
      Karma 50, and all I got was this lousy T-Shirt.
    2. Re:some ideas on why debuggers are in this state by iabervon · · Score: 2

      Purify and valgrind (an open-source memory debugger) are debuggers; I just wish that valgrind had the features of ddd and would show you the contents of memory (or had gdb-like features, so ddd could connect to it). In particular, it would be really helpful for finding memory leaks where you're still holding references but will never drop them (a problem that occurs even in garbage-collected languages like Java).

      But it's really great to be able to debug UMRs, FMRs, and FMWs, which generally cause rare unpredictable behaviour or crashes at a random location later in the program (usually in malloc). I just wish there were also checks for "this pointer, which started out pointing to this chunk of memory, now points to a location in a different chunk of memory due to arithmatic not involving the two addresses", which would catch buffer overflows. I recently fixed about a dozen memory leaks and UMRs in a few evenings in a large program with a straightforward application of valgrind.

      I also think there's a lot of progress in static debuggers, which are more similar to the pen and paper method, but without the programmer's possibly incorrect expectations. Of course, the program (the Stanford checker) hasn't yet been released to the public, but they say they will eventually.

  17. VB has one of those debuggers by sdjunky · · Score: 5, Informative

    Visual Basic supports a "watch" that allows you to break on condition such as when a variable changes at all or if a variable is set to a certain value. This is beautiful when trying to figure out how the currency value you just had disappeared. Add the watch saying when the currency = 0 and run the app so it breaks at ANY MODULE at ANY TIME.

    This saves me time by not having to go into each module and watch the code to see if the value changes.

    As for wanted features ( so as to not be totally off topic ) I really can't think of any that I would need per se. Since my favorite language is VB ( watch the flames poor in on that statement ) I have many tools for debugging that are perfect.
    From the immediate window so I can run small snippits of code in break mode to the stack and watch windows.

    1. Re:VB has one of those debuggers by Anonvmous+Coward · · Score: 4, Insightful

      "Since my favorite language is VB ( watch the flames poor in on that statement )..."

      I don't really understand Slashdot's attitude about VB. I don't consider myself a programmer, but I've been able to use it to automate some stuff in Windows. I think it's great, especially when it comes to creating GUIs.

      Every language has its strengths. Making of of VB because it doesn't do something another language does is like making fun of cars because they can't fly. Nobody's going to use a 747 to take a trip to 7-11.

    2. Re:VB has one of those debuggers by fredrikj · · Score: 3, Insightful

      Since my favorite language is VB

      Personally, I think of VB as a scripting interface for Windows GUI work rather than an actual programming language, but that is also its strength. There is no perfect programming language - they all have their pros and cons, and while VB is slow compared to C++ for calculations, VB is extremely handy for operating a GUI - an area where C++ is tricker.

      One shouldn't try to drive a screw with a hammer just because the hammer is more 'elite' - use the right tool for the job.

    3. Re:VB has one of those debuggers by vadim_t · · Score: 4, Insightful

      Ah, but here's the problem. People fail to understand the purpose of VB far too often.

      VB is great for writing small apps. If say, you want to write a program that takes photos at an interval and automatically saves them in /images/yyyy/mm/dd/hh_mm_ss.jpg then it's a wonderful thing. Add a webcam component, then another for jpg (VB can only save BMP), and in a few minutes it will be done.

      Now, the problem begins when this little program grows. If you try to write big apps with VB you'll fairly soon start hitting its limitations, writing workarounds, having to put up with completely idiotic bugs like project files that break by themselves... and you end with a complete piece of crap.

      Also, pretty much anything that can be done with VB can be done in Linux with Perl and PerlQt, perhaps with some help from other apps. Pretty much the only thing I couldn't find a replacement for is such a great debugger.

    4. Re:VB has one of those debuggers by sqlrob · · Score: 2

      Not completely.

      Where's threads?

    5. Re:VB has one of those debuggers by NanoGator · · Score: 2

      "Making of of VB because it doesn't do something another language does is like making fun of cars because they can't fly. Nobody's going to use a 747 to take a trip to 7-11."

      A friend of mine ran across a porn site that gave away 10 free images a day. He got sick of manually saving and renaming all of the images from that site at a given interval. One evening I wrote him a little VB app where he could plug in URLs to the JPGs, then set the interval, then set the destination folder so he could automatically download and save the images with incremental file names.

      I didn't have to do anything fancy to do this. Most of the hard work (like opening a URL and downloading the images, or the Save As dialog, etc) was already written and ready to go. I just needed to tie it all together with a UI. It's not something I'd want to give away, but for this guy it did exactly what he wanted.

      Personally, I think VB'd have a nice little market if it came with Windows. For doing quick little hack jobs it's great. It's hard to justify the price tag it has today.

      --
      "Derp de derp."
    6. Re:VB has one of those debuggers by Anonvmous+Coward · · Score: 4, Funny

      "The attitude is easy to explain: VB sucks ass."

      Whoah, I'm glad you showed up! My opinion of VB has completely changed now that you've tuned me in to that little fact. I didn't fully realize the scope of the problem until I realized that my ass would be sucked!

    7. Re:VB has one of those debuggers by sdjunky · · Score: 2

      Spell checking the post would have been a good idea.

      Good job on catching me on that one.

    8. Re:VB has one of those debuggers by Iamthefallen · · Score: 2

      Where are the buttons in assembly code?

      While threads and multithreading surely is nice, the typical VB app can easily live without them. VB is hardly the language to use for heavy number crunching. You use VB to present a frontend to the user and do lighter processing on the user end, if you need to, you use C/C++ behind it to get the heavy stuff done.

      --
      Wax-Museum Fire Results In Hundreds Of New Danny DeVito Statues
    9. Re:VB has one of those debuggers by dillon_rinker · · Score: 2

      I like VB; it does well what it does well, like any tool. When misused, of course it's problematice (ever drive a screw with a hammer?) VB is not an application development language. It is a scripting language that was originally conceived as a GUI prototyping tool. You could quickly and easily find out where your users liked where you'd placed OK and Cancel in dialog boxes. You can write usable apps with it if they're not too large, and, quite frankly, most business apps that VB is suitable for are better implemented as standalone Access databases. Where it shines is in Windows administration (which is how I pay the bills).

      It's seen wide usage in application development because the PHBs of the world have realized they can hire a kid with two semesters of VB programming under his belt and watch him and churn out commercially acceptable results. Ask yourself this...would you design a commercial airliner that was powered by a lawnmower engine? Would you build a skscraper out of wood? Would you write a 100,000-user database in VB?

      Note that in the early days of flight, airplanes were run by small engines, early commercial buildings were built out of wood. Large business apps are currently written in VB. Eventually there will be some sort of licensing or regulation for programmers and the situation will change dramatically. (We can't have large numbers of buggy programs installed on the National Information Infrastructure, after all...*cough* Windows *cough*...somebody could zombie them and DOS the internet out of existence!)

      Shrug. Do what works for you. But remember that the makers of VB are the people who, before the release of VB5, hyped at EVERY VB conference that there would be NO VBRUN50.DLL! (instead there was a MSVBVM50.DLL - same problem, different name)

    10. Re:VB has one of those debuggers by dubl-u · · Score: 5, Insightful

      Now, the problem begins when this little program grows. If you try to write big apps with VB you'll fairly soon start hitting its limitations, writing workarounds, having to put up with completely idiotic bugs like project files that break by themselves... and you end with a complete piece of crap.

      Amen. If people knew that whenever they needed write a program longer than a page that they should switch away from VB, I'd have no complaints with it. Instead, it is marketed in such a way that it gives amateurs the notion that they're just as good as any professional programmer. It's as if people thought that buying a Tinkertoy kit made them able to build houses.

      I don't know how many projects I've seen where someone has knocked together a prototype in some half-baked language like VB. Then people want another feature and another, and nobody is willing to say: "Stop! We must throw this crap out and start again using appropriate tools."

      (For the record, I hear that VB.NET is a big improvement over the execrable VB6. Of course, given that all .NET languages seem to be minor syntax variations on Java, maybe that's not too surprising.)

    11. Re:VB has one of those debuggers by Iamthefallen · · Score: 2

      Ah, I read your other post and I see what you mean, and I agree to some extent. A while ago I was taking some MS certification classes, and it was not an uncommon thing to see the behaviour you speak of. Well, that, and various other weird stuff...

      Not because of the way VB itself works, but because at times it seems some of the bad practices out there are promoted by MS marketing staff writing technical documents.

      --
      Wax-Museum Fire Results In Hundreds Of New Danny DeVito Statues
    12. Re:VB has one of those debuggers by blincoln · · Score: 2

      Personally, I think VB'd have a nice little market if it came with Windows. For doing quick little hack jobs it's great. It's hard to justify the price tag it has today.

      You can write VB scripts without any additional tools. Your pr0n process would (IMO) be easy to set up as a vbs file.

      --
      "...always new atoms but always doing the same dance, remembering what the dance was yesterday." -Richard Feynman
    13. Re:VB has one of those debuggers by MrResistor · · Score: 2

      My problem with VB is the same problem I have with all MS products: features are more important to the developers than stability or consistency. It's the little braindead things like (in VB.NET) 'Dim MyArray(4)' creates a 4 element array (0-3), but 'ReDim MyArray(4)' gives a 5 element array (0-4), that make me hate VB. There were similar stupid things in VB6, but thankfully it's been long enough since I've used it that I can't think of an example off the top of my head.

      This is only aggravated by the fact that VB seems to actively encourage unorganized source code, which makes VB source much more difficult to work with.

      Anyway, those are my own dislikes about it. I hope that gives you some insight into the general feeling on /.

      --
      Under capitalism man exploits man. Under communism it's the other way around.
    14. Re:VB has one of those debuggers by smallpaul · · Score: 2

      VB is a good tool. It is a great environment. But it is a terrible, terrible programming language. Slashdotters flame VB because it offends us that such a horrible language could rise to widespread popularity because it happens to be wrapped in a very productive GUI development environment.

    15. Re:VB has one of those debuggers by Anonvmous+Coward · · Score: 2

      "Anyway, those are my own dislikes about it. I hope that gives you some insight into the general feeling on /."

      Not really. Thing is, you've used it. It's obvious you've used it, and you have legitimate complaints about it. I don't normally see that here when I see anti-MS sentiment here. It's usually "MS is completely incompetant, it's a totaly mystery to me why they're so used so much. Everybody must be stupid"

      Believe me, I wouldn't be complaining if I heard more comments like yours instead of the FUD crap I normally hear.

    16. Re:VB has one of those debuggers by crazyphilman · · Score: 3, Insightful

      Wow, you really hate VB. Before I answer your post, let me say that I hate VB's syntax, the fact that it's not truly object oriented, and the weird, back-asswards way it does things. So I'm not totally against you on this. I'd rather be working in C++ or even C, so take the following in context, ok?

      VB *CAN* be used for relatively larger projects, BUT, it depends on what kind of programmer is involved. I've inherited some semi-large VB projects, including a three-tier client-server setup built from VB programs, MTS dlls, ASP pages, and a pretty big database, with a lot of lines of code (not just a page). Luckily for me, the original programmer had an engineering background, so his code was pretty tight and the project was in pretty good shape. I made beaucoup changes to it, updating it to account for a number of policy changes. I had to totally redesign chunks of it because of changes in the way a number of pieces of data were going to be handled in the future, etc, and of course I had a great deal of bug-hunting to do. But, overall, despite the fact that this was a big, complex project, it all went pretty well. We're now moving into a phase where the system's going to be expanded again, to add features. It's growing, in other words -- bigger and bigger. And, it's not giving us that much trouble in the process.

      I think where large projects run into trouble with VB is when they are run by people who do NOT have a solid computer science background. All too often, a secretary or clerk is sent off to a VB class, baptized as a programmer, and handed a copy of VB, Professional Edition. Then this clueless person is expected to be able to handle a large project. No knowledge of data or file structures, no knowledge of relational database design or algorithms, but they're given the tools and admin access to a test database, plus a big project. Naturally, the person A) shits his pants and runs to Border's to buy a VB picture-cook-book with lots of yummy recipes in it, B) makes a good faith effort and totally fucks it up, and C) doesn't know what the hell hit him when the project implodes the day before the deadline (or am I being too harsh here?).

      But don't blame VB for it; blame the manager who's too stupid to know that computer programming is an engineering task requiring more than a six-week VB course to learn how to do properly. I feel sorry for the poor noob who gets flattered into thinking he's a programmer; he's the one that takes it in the shorts, generally.

      Sorry for the elitist rant, but...

      --
      Farewell! It's been a fine buncha years!
    17. Re:VB has one of those debuggers by crazyphilman · · Score: 2

      Vadem_t said: "ActiveX. Major pain in the arse. For some reason references to ActiveX objects that work just fine on one computer might disappear if you move the source to another."

      I've run into something like this, and I found that in my case, it was because the libraries weren't installed on the target computer, but they HAD been installed on MY computer because I'm a developer and had Visual Studio. This is actually a giant pain in the ass not limited to Active X, because you can't really predict what's going to be available on the target machine when your company (like mine) has people running some machines so old they have IE 3.3 on them (really!).

      Microsoft put out an extension to Visual Studio called Visual Studio Installer, which you can download from their site (I don't remember the URL, but you can search the site). Basically, it works almost like an interdev project and it creates a windows installer (msi) file which covers all your dependencies. You can see which files are being brought in to handle dependencies, where you might have a conflict, etc. It's kind of neat. It might help you; it helped me with my problem, at least.

      FYI... ;)

      --
      Farewell! It's been a fine buncha years!
    18. Re:VB has one of those debuggers by sqlrob · · Score: 2
      Where are the buttons in assembly code?

      Same place they are in C

      VB is hardly the language to use for heavy number crunching

      No, but it's still nice to have something running in the background that's interruptible. I'd rather the thread management for this occur in the UI, since that's what's effected by having something blocking, But because of VB's limitation, it's in the backend component, where, IMHO, it doesn't belong.

    19. Re:VB has one of those debuggers by MrResistor · · Score: 2

      Dim or ReDim?

      Sorry, but I know for a fact that Dim works the same as in C, meaning Dim MyArray(4) gives a 4 element array. This is the correct behavior, IMNSHO. ReDim MyArray(4) gives a 5 element array, basically the old VB 1-based array plus a 0 element since VB.NET arrays are 0-based.

      In fact, I had to prove it in front of my class for a point on one of my tests.

      If they released a fix in the last month that makes Dim act the same way then that's even more braindead, since the change to 0-based arrays was for compatability with the C-style languages that are part of the .NET framework, and in any C-style language declaring myArray(4) gives a 4 element array (0-3).

      So, VB.NET will be getting no appology from me.

      --
      Under capitalism man exploits man. Under communism it's the other way around.
    20. Re:VB has one of those debuggers by dubl-u · · Score: 2

      Wow, you really hate VB. [...] I'd rather be working in C++ or even C, so take the following in context, ok? [...]VB *CAN* be used for relatively larger projects [...]

      Oh, I agree. Any language that is Turing-complete (and some that aren't) can be productively used by a programmer who is sufficiently smart, careful, disciplined, and intensely aware of both the big picture and those who follow in his footsteps.

      So if we were all omniscient, self-programming robots, I'd say that assembler was for sissies, that real programmers only had two keys on their keyboards: zero and one. And fuck the backspace.

      Alas, programming is done by real humans, ambulatory sacks of meat, albeit with occasional fits of brilliance. Good toolsmiths know this, and make appropriate tools. People who make bad tools (like VB) are either fools or inhumanly cruel. I can never decide which explanation I prefer.

    21. Re:VB has one of those debuggers by crazyphilman · · Score: 2

      dubl-u said: "Alas, programming is done by real humans, ambulatory sacks of meat, albeit with occasional fits of brilliance. Good toolsmiths know this, and make appropriate tools. People who make bad tools (like VB) are either fools or inhumanly cruel. I can never decide which explanation I prefer."

      Yes, but are you saying that given two idiots of equal stupidity, one with VB and one with gcc, the idiot armed with VB will do a worse job? I submit to you my theory that neither idiot will create anything functional, BUT, the idiot armed with gcc will be unlikely to even figure out how to run the compiler. The idiot armed with VB will probably at least have a weird little form built while the idiot armed with gcc is stuck wondering whether to use vi, emacs, or pico. This may be a Good Thing.

      My point is: no tool can save an idiot, or even make him useful. Therefore, complaining about VB because there are idiots in the world isn't fair. ;)

      --
      Farewell! It's been a fine buncha years!
    22. Re:VB has one of those debuggers by crazyphilman · · Score: 2

      Ah... Sorry, I should have realized you'd have that covered. I was trying to look for a potential cause of your problem when someone posted something amazingly informative about it -- but he posted as an A/C so I can't be his fan (what a drag). It's a great post though. I wish I could mod it up.

      --
      Farewell! It's been a fine buncha years!
    23. Re:VB has one of those debuggers by MrResistor · · Score: 2

      Perhaps you have an old beta version?

      Doubtful. I don't own it myself, I was using the school lab machines. I don't know what version it was but I would be extremely surprised if my school rated a beta version. The admins were pretty prompt about applying updates, too.

      I still say that behavior you're seeing is wrong, though. (Re)Dim myArray(4) should give an array of 4 elements, 0-based. Anything else breaks the compatability that is supposed to be the guiding princilpal of .NET

      Out of curiosity what do you get with this?

      Dim myArray(4) As Integer
      MsgBox("After Dim " & LBound(myArray) & Chr(32) & UBound(myArray))

      Basically, I'm wondering if assigning a value to myArray(4) creates that element as if one used a ReDim. I have no way of checking it on my own, and I don't remember trying such a thing.

      --
      Under capitalism man exploits man. Under communism it's the other way around.
    24. Re:VB has one of those debuggers by dubl-u · · Score: 2

      Therefore, complaining about VB because there are idiots in the world isn't fair. ;)

      Actually, I'm saying something a little different.

      I'm saying that people are all idiots. The tools we build should reflect that.

      One swell example is from years ago: a Chevette that a friend of mine drove. The car was a crappy, lightweight econobox. If you got into an accident at high speed, you'd be strawberry jam. That's fine; there's a place for low-budget cars in the world.

      If you took this car at anything above 60 mph, it felt like the car could come apart at any moment. It felt dangerous. And, IMHO, that's exactly how the car should feel. It kept foolish teens like myself from going too fast.

      Now compare that with many of the modern SUVs. These cars are designed to feel big and tough. But it turns out that they're just as dangerous to the drivers as your average mid-size (and even many of the small cars). And worse, they're twice as dangerous to the people you hit. But since the don't feel that way, people don't drive them as carefully as they should.

      So VB is (or at least was last I used it) like a golf cart inflated to SUV size. It is really only safe for tooling around your subdivision, but it sure looks like it should be able to handle the autobahns.

    25. Re:VB has one of those debuggers by crazyphilman · · Score: 2

      Hmm... Taking a few of your points one at a time:

      You said: "Actually, I'm saying something a little different. I'm saying that people are all idiots. The tools we build should reflect that."

      You're wrong here: all people are not idiots, and tools should NOT reflect this way of thinking. I think there is a clear spectrum between complete idiots and true geniuses. No matter what type of compiler you build, or how well you build it, sooner or later an idiot is going to get his hands on it and hurt himself. You can't do anything about that, and anyway, it's the idiot's problem, not yours. It's better to build a compiler for the brilliant people who will be able to make the best use out of it, and the competent people who will be able to make good use out of it -- empower THESE people, and don't put arbitrary limitations on what they can do with your tool. Build for the wise, in other words. And, let managers who think they can drag Sophia in from the steno pool for a quick VB class and a promotion, get hoist on their own petard.

      "...So VB is (or at least was last I used it) like a golf cart inflated to SUV size. It is really only safe for tooling around your subdivision, but it sure looks like it should be able to handle the autobahns."

      I disagree. VB6 is capable of very serious development. However, you have to use it where it makes sense. It's an applications programming language. It's good for applications programming. Database frontends, transactional dlls, stuff like that. Banks, government agencies, etc, all make very good use of VB. Would you write a game engine in it? Of course not. The very idea is ridiculous. But a large, distributed client-server application turns out just fine (I maintain a couple of them myself).

      As far as your car analogy goes, well, I don't think it fits. However, I agree with you about cars. I think it comes down to the fact that most students don't take physics, and don't understand what happens in a crash. An SUV will protect you from injuries due to the crushing of the vehicle -- because the vehicle probably won't crush easily. However, if you flip it, or you slam into something like a tree, the car's coming to a sudden stop, and YOU are NOT. Seatbelts and airbags only go so far, and it's SO easy to break your neck, or slam your head into the window or side pillar...

      --
      Farewell! It's been a fine buncha years!
    26. Re:VB has one of those debuggers by MrResistor · · Score: 2

      All I can say is that I was able to prove otherwise in front of about 15 witnesses, and without using any special tricks. Why you aren't seeing the same behavior, I don't know.

      However, if the new behavior is to create an array of N+1 elements, I still say that's wrong. Every other language I've used has had arrays of N elements, 0 to N-1. At the very least N+1 element arrays break compatability with C/C++, and I think we can agree that C/C++ is still important enough that compatability with them is essential for any language claiming compatability with other languages.

      --
      Under capitalism man exploits man. Under communism it's the other way around.
  18. Ignore the MIT Media Lab by timeOday · · Score: 2

    Every time I hear something from the MIT Media Lab, it's a searing indictment of something terribly wrong software engineering or computer science, and how they are here to fix it with avatars or wearable computers or something. And then you never hear about the idea again.

  19. Good ol' command line. by grahamlee · · Score: 2
    Why do you think so much effort been invested in areas such as advanced modelling tools but so little in improving debugging tools?

    I think that very few people use them often enough to justify spending lots of R+D hours+$$$ on the debugging tools. How often do you see "-DDEBUG" in Makefiles? You'd think that if debuggers were so useful, you wouldn't need to switch in debugging code in the app. But many programmers feel more at home locating the bug using printfs or similar, then just reading through the code. Pencil and paper often helps too.

    Something I learnt from my BASIC days, which I still use in *sh/Python code is the use of the interactive interpreter (a.k.a. "command line" :-). This is especially helpful when trying to debug someone else's code - you can enter it line-at-a-time and see what happens. Yeah, so gdb can do that. But you think more about the code if you're typing it in yourself than you do repeatedly pressing the "step" key.

    I have used debuggers such as disassemblers and monitors as well as gdb, the Delphi debugger etc. While they have uses I just don't find they do anything sufficiently different from manual debugging to make them worthwhile.

    There's my £1E-2 :-)

    1. Re:Good ol' command line. by grahamlee · · Score: 2

      While I believe (out of kindness :-) that you're being sarcastic, this is exactly what I would do. I recently undertook a project that needed LISP, Perl and Pascal. Well I know a little Perl, it's been ages since I did Pascal and all I knew about LISP was that it's that scary thing with all the brackets in it. When I got stuck I found it easier to "debug" my code by printing it out, and sitting in the pub with a cup of coffee poring over the listing than I did by staring at the code on the screen. Of course, YMMV.

      Aeroflot, where the plane flies you.

  20. Fix the programmer, not the program by doi · · Score: 3, Interesting
    A debugger does nothing to improve software, commercial, professional, or otherwise. All you have to do is look at Bugtraq to prove it.

    The best way to learn how to write bug-free code is to NOT use a debugger at all. Every programmer should begin writing code in Notepad or some other basic, no-frills text editor. Just like everyone should learn how to type on a typewriter and not a computer. It forces you to NOT make mistakes, instead of correcting them (you don't have to "debug" a program if you don't put the bugs in in the first place!) It forces you to slow down and think about what you're doing, instead of blasting through a procedure and then run the debugger on it. If everyone programmed for at least a year without ever using a debugger, the quality of their code will improve far greater than any fancy IDE debugger will improve it.

    --
    A man's reach must exceed his grasp, or what's an erection for?
    1. Re:Fix the programmer, not the program by MarcoAtWork · · Score: 5, Insightful

      the best way to build a skyscraper is not to use CAD programs at all, but a slide rule and pen'n'paper, which force you to think about what you're doing instead of making mistakes and 'correcting them later'.

      come on! You can't tell me that to be a Real Programmer one has to forgo color syntax highlighting, automatic indentation, automatic code formatting, automatic brace insertion, etags, man-on-symbol-at-point, folding, autodoc of functions, gcc -Wall -Weverything-but-the-kitchen-sink etc. etc. etc.

      Personally I believe that being able to isolate myself to having to indent manually the next line and similar stuff makes me a better programmer, as I'm able to think about structure & what I want the function to be doing vs why the %##*%^ editor doesn't do what I want.

      I'd also like to see you 'not put the bugs in in the first place' if you're adding a complex piece of functionality to a 2,000,000 lines program: I can write perfect 'hello world' code on a napkin, but considering doing it for real work is ludicrous.

      Debugging is also an art, and I don't think I've ever found a bug I wasn't able to trace via judicious use of the tools currently available on the market right now, which are (from less to most esoteric):

      - compile with as many warnings on as you can
      - reading the docs/code comments (some bugs are really features ;)
      - the mighty printf/cout/cerr
      - find/grep
      - vanilla breakpoints in your debugger of choice
      - tcpdump/openssl s_client/telnet/other packet monitoring stuff
      - purify/ad-hoc malloc library
      - hardware watchpoints in gdb (saved me a few times)
      - sleeping on it/going for a walk (let your subconscious do its thing)

      Only thing I'd like that current debuggers on unix don't have is what you can do in windows by inserting a certain line in your code that when is reached it automagically halts and pops up the debugger: when debugging multithreaded/multiprocess stuff that has bugs only when not running singleprocess/singlethread it's invaluable: anybody knows how to do that in unix?

      --
      -- the cake is a lie
    2. Re:Fix the programmer, not the program by xenocide2 · · Score: 2

      So what do Grown Men do when their powers imbued by a spartan interface fail them? Not every bug is a matter of misplaced semicolons or bad spelling. Easiest way to fix that is to use a higher level language that has a method of including low level languages when needed.
      A good example: writing an interpreter in OCaml. The language is very well written and with emacs its damned near impossible to fuck up the syntax. But that doesn't mean it works right. Once you've got your initial infrastructure set down in the first five minutes the hard part starts. The interactive environment saved me countless hours on Programming Languages assignments.

      Sometimes the bottom line is that the line of code you wrote doesn't do what you thought it would. I find this happens far less often in OCaml than C++, although theoretically my C++ are multithreaded capable which would easily explain my entire comment away =)

      --
      I Browse at +4 Flamebait

      Open Source Sysadmin

    3. Re:Fix the programmer, not the program by clem.dickey · · Score: 2

      People will use the tools which are convenient. If the debugger is most convenient, code gets fixed via the debugger. Unfortunately, those fixes are expensive. (The cost to fix a bug goes up an order of magnitude with each development step.) So spending money developing good debuggers turns out to be counter-productive!

      Better to put the money into front-end tools (HLLs, lint, etc.) so you will have fewer items to debug.

    4. Re:Fix the programmer, not the program by MarcoAtWork · · Score: 2

      doing test-driven development = finding bugs via unit testing, the poster I was replying to advocated that if code was written on paper (rock + chisel, ed, whatever) bugs aren't going to be created thus making debugging unnecessary.

      Test-driven development = debugging your own code if you see that you broke something, and to do that you do need debugging tools...

      --
      -- the cake is a lie
    5. Re:Fix the programmer, not the program by dubl-u · · Score: 2

      poster I was replying to advocated that if code was written on paper (rock + chisel, ed, whatever) bugs aren't going to be created thus making debugging unnecessary.

      If that were what he said, you'd have a point. But really, he never said, "never use a debugger,' just that programmers who learn to do without them are better programmers.

      In my experience, he's right.

      Test-driven development = debugging your own code if you see that you broke something, and to do that you do need debugging tools...

      For you, perhaps. I ocassionally find a debugger convenient, but only slightly more convenient than inserting the occasional printf. Many experts in test-driven development say the same thing.

      My point, though, is that spending much time in a debugger is a sign that there's something wrong elsewhere in your process. If you need to use a debugger, that means there's a problem and you don't know where it is. That, in turn, means that your test suite has got some pretty big holes in it.

      Rather than wandering through in the debugger, you should add tests until you find one that is broken. Then not only do you find the bug, but you also make it so that the bug can never return.

    6. Re:Fix the programmer, not the program by seaan · · Score: 2

      I basically agree with the idea that overuse of a debugger can be bad. But in 20+ years of programming I recall times when debuggers really made a difference! My favorite two examples (actually since they were embedded systems I used ICE not software debuggers, but same basic concept):

      1) We were doing real-time analog-to-digital conversions in a data logger, but an intermittent bug was really bothering us. We were using an Orion which is more of a logic-analyzer than an in-circuit-emulator - important difference is that Orion does not replace the CPU with its own pod unlike a normal ICE. Finally after much debugging, it turned out that our version of the 64180 had a mask error (known to the manufacturer naturally), which occasionally caused interrupt routines to not meets specs. There was no way studying code was going to tell us what was wrong here. Even a normal ICE might have had problems.

      2) We had a device with memory backed-RAM which became "unstable" after an extensive code change - becoming "unstable" was intermittent and only occurred after a long period of use. After lots of code inspection, I started examining memory dumps of returned units. After looking at about 20 units, I finally got lucky, and found a device in the "early" part of being unstable. The code area of the device was being overwritten by a recognizable pattern. Turns out the new code made an existing feature optional, but missed a part of the code that expected it to be there. The rogue code was trying to update a non-existent global variable (all this was complicated by the MMU, and the fact that the device had several features like code checksums that were supposed to detect this kind of problem - but obviously didn't).

      Two extreme examples I'll confess, but I can think of other situations where debuggers have saved days of debugging time. Debuggers do have their uses.

    7. Re:Fix the programmer, not the program by MarcoAtWork · · Score: 2

      it's my turn to ask you to read my post ;) obviously I'm not gonna fire up gdb to debug code I wrote an hour ago or for trivial stuff that's covered by printfs...

      On occasion, though, it does happen that functionality that you add breaks the product in interesting ways, due to long-existing bugs that just weren't triggered before: it's in these cases that having a debugger is invaluable.

      I can't really relate to 'programmers who learn to do without a debugger are better programmers', because when I learned how to code (in pascal/assembly on a very niche Z80-based computer in the early 80s) the only debugger was really printf, and having an infinite loop meant resetting the computer: the above poster, though, was saying that people program better when writing on paper or using a 'no-frills' editor like notepad vs an ide like VC/Emacs, and I still strongly disagree with that...

      --
      -- the cake is a lie
    8. Re:Fix the programmer, not the program by tony_gardner · · Score: 2

      " the best way to build a skyscraper is not to use CAD programs at all, but a slide rule and pen'n'paper, which force you to think about what you're doing instead of making mistakes and 'correcting them later'."

      Except that using a CAD program forces yyou to draw to scale. I've seen a surprising number of hand drawings which have two bolts intersecting.

      Using tools is supposed to prevent stupid mistakes, allowing you to concentrate on preventing smart mistakes. If your debugger doesn't fall into this category, then something needs to be fixed.

  21. I'd get rid of them by greechneb · · Score: 2

    Too many people were dependant on them when I took programming classes in college. They'd write code carelessly, and then run it through the debugger, and do exactly what it said, instead of learning to code properly.

  22. Current debuggers do the job. by Java+Pimp · · Score: 2

    It's been my experience that current tools like Visual Studio are just fine. Once in a while maybe a kernel level debugger. Most often bugs are the result of some logic error in some algorithm you just know should be working. And with a little tracing and memory dumps you can find the problem.

    However, if the error is such that cannot be tracked down within a reasonable amount of time and isn't confined to a small section of code then I wouldn't consider it a bug but a flaw in the design. A good design would eliminate such difficult bugs and then the smaller ones only need the simpler tools we currently have to track them down.

    In my opinion, the advances in modeling tools help reduce the number of potential problems so there isn't as much of a need for advanced debuggers.

    I'm sure some will disagree but this has been my experience. I've redesigned sections of code to eliminate an elusive bug and it's made for a more solid application.

    --
    Ascalante: Your bride is over 3,000 years old.
    Kull: She told me she was 19!
  23. Reversable debugger by mahlen · · Score: 3, Interesting
    For Java coding, take a look at RetroVue, which indeed lets you wind back the clock and see exactly HOW that reference became null (among other things).

    mahlen

    1. Re:Reversable debugger by dcuny · · Score: 2, Interesting
      Years ago, I programmed in a Forth shop, and there was a "mysterious" problem somewhere in the code that was bringing the system to a halt.

      Being the junior member of the programming team, I was naturally the primary suspect. And my boss was quite vocal about it.

      Finally, he broke down and brought in a logic analyzer. It only had something like 32K memory, so by the trap triggered, the error was typically out of the buffer. And each time, my boss would again loudly complain about my poor coding skills, and how much money it was costing him because of some bug in my code.

      After many attempts, he finally trapped the bug. It turned out to be a trivial error in his code, of course - we were working with zero based arrays, and he allocated n slots. So when message number n came along, it offset just beyond the jump table and grabbed some random address.

      Of course, he never apologized for the weeks of insults - just changed the n to n+1, and went back to his office.

      The moral: a good debugger is worth its weight in gold.

    2. Re:Reversable debugger by jimfrost · · Score: 2
      Back in the early 90s there was a group at Boeing whose entire job was trying to find this one bug in their avionics code. It was nasty and subtle enough that they hadn't been able to find it for years.

      They got a demo copy of ObjectCenter (formerly Saber-C), a superdebugger I used to work on which performed a lot of runtime error checking. They loaded the code, ran it, and it pointed out the error for them. Their job finished, the group was disbanded.

      I don't know if we got the product sale :-) but certainly they shared your opinion. I do, too, although the near total lack of functional debuggers in Java (until 1.4, which unfortunately I still can't use) has kept me in printlns. Thank God that Java incorporates runtime checking and dumps stack traces on error or we'd never get anything written.

      --
      jim frost
      jimf@frostbytes.com
  24. Best way to debug : Better Code by Viking+Coder · · Score: 3, Insightful

    The real problem is that the majority of software that is written is fairly lousy. People often code to moving requirements, push code in directions it was never intended to go in, and work with designs that are in desperate need of landing on the compost heap.

    Honest debugging is most useful when something is being developed in the first place. Domain knowledge is what is most useful when ancient and decrepit software is being modified to do something it shouldn't.

    Software applications should be thought of as prarie lands. From time to time, lightning strikes, and burns out a huge chunk, which is all replaced by newer and healthier stuff. You need talented people to make sure the new code will work well with what's already there - but the end result is that the application will be healthier if frequent refactoring is done intelligently.

    --
    Education is the silver bullet.
  25. Debuggers:The red-headed step child of development by Azar · · Score: 3, Informative

    Debuggers aren't flashy or glamorous. I don't know anybody that thinks debuggers are cool. The tools and pieces of a development environment that are going to catch a programmers eye first are what's focused on most. You look at a nicely developed IDE that's polished and slick, and you'll be impressed. It's eye candy that sells products more than anything else.

    Sadly, most -programmers- even look at a development environment's debugger as an afterthought. IMHO, it's one of the single most important tools (if not THE most important) and it's what I check out first.

    Have you ever used the Gnu Visual Debugger at the GNAT Libre software developers' site? It's a multi-platform (Linux/Unix/Windows), open-source debugger with a "different view" of the world. Check it out, you may be pleasantly suprised.

  26. My Dream Debugger by Rary · · Score: 5, Interesting
    Some of these features exist in current debuggers, and some do not. What I want is all of them.

    1) The ability to set conditional breakpoints.
    2) The ability to see not only a variable's current value, but a stack of all of its previous values.
    3) The ability to select a variable's previous value and jump to the line of code that set it to that.
    4) The ability to change the value of a variable at any point.
    5) The ability to add/change code on the fly.
    6) The ability to jump into the debugger at any point in the program, even when I hadn't planned to before running it.
    7) Auto-logging of method calls and (optionally) variable values, to be started and stopped as I see fit either while stepping through code or running it.

    That's all that comes to mind off the top of my head.

    --

    "You cannot simultaneously prevent and prepare for war." -- Albert Einstein

    1. Re:My Dream Debugger by mav[LAG] · · Score: 2

      I've browsed quite far down all comments and have yet to see someone mention the Data Display Debugger. I find it an absolutely indispensible tool for debugging anything longer than a small utility. Off the top of my head, it supports all but one of your requirements (the exception is #6 which I think is unreasonable for compiled code but I can see why you like the possibility). Hmmm - not sure about #3 mainly because I've never tried it. Don't see why not though - set a watchpoint to stop whenever the variable's value changes and then go back a frame. And yes #7 is supported if gdb is your inferior debugger through user-defined commands.

      While I was RTFA, I was intoning "DDD" to just about every complaint the author brought up. Quite apart from its support for Python, Perl and Java, its visual display of data structures is unique. Array getting mangled? Display it as a graph and see exactly how and where it gets clobbered. Threads getting you down? Display the data that needs to be mutexed and attach to process.

      --
      --- Hot Shot City is particularly good.
    2. Re:My Dream Debugger by oolon · · Score: 2

      I would also like to be able to turn off traversal of code (black boxing) some libraries.. step finish is so boring particularly when they have no symbols for the code anyway! Likewise to mark some functions within my code like that step whoops not interested in this bit, not go into this function again sort of thing.

      And someway to display encasulated data which has been repeatedly encapulated with void * as it get passed into sub functions. It may be oops but its a pain to debug.

      James

    3. Re:My Dream Debugger by mav[LAG] · · Score: 2

      Doh! Of course you can - not thinking straight today ...

      --
      --- Hot Shot City is particularly good.
  27. I asked my boss.. by Anonvmous+Coward · · Score: 3, Funny

    ... about Debugging Tools. He felt that engineers should just learn to write software without bugs in it.

  28. The problem is with debugging, not the debugger by AlphaHelix · · Score: 2
    One major problem is that the very concept of debugging is problematic. It assumes that you will make mistakes, and that the only way to track down mistakes is to painstakingly find each one. This process takes O(n) time, but the number of bugs grows more like O(exp(n)) with the program size, so when programs become non-trivial, you'll never be able to track down all the bugs.



    What's actually needed is more intelligent languages and automated code checking tools, as well as better code review and coding practices. Strict code review and coding practices help make programming more like a real engineering endeavor, instead of the fly-by-the-seat-of-your-pants garage hack-fest that seems prevalent in a lot of existing code. But, the real challenge is to develop languages with features like the ability to detect potential problems in code using partial evaluation, and alert the programmer at compilation time rather than run time.



    Basically, we're still in the hunter-gatherer stage of software development, and the Bug Problem needs to be fixed by a fundamental shift in paradigm that can move us beyond the need to deal with "bugs" explicitly. Until then, a snappier debugger interface and new debugging features will only have marginal impact on the ability to develop fault-free software.

    --
    * mild mannered physics grad student by day *
    * daring code hacker by night *
    http://www.silent-tristero.com
  29. My debugger by Jonboy+X · · Score: 2

    System.out.println(). Works fine for me most of the time. If not, I can print a stack trace and see what's going on...assuming Java, of course.

    The only place I've seen that a debugger comes in handy is stepping through poorly understood code. Really, the code should be documented well enough to explain what's going on, but that's rarely the case.

    --

    "In a 32-bit world, you're a 2-bit user. You've got your own newsgroup, alt.total.loser." -Weird Al
  30. People...Bugs who need People... by mcmonkey · · Score: 2

    At some point debugging comes down to, the computer can only do what people tell it to do. A lot of advancement has been made in making it easier for programmers to communicate with computers. Advances are made in methods for reporting just what is being done or why something can't be done. But in the end, the bottleneck is the programmer who has sit down with his pencil and paper and slide rule and figure out, "is this really what I want to tell the computer to do?"

  31. Alternatives to traditional debuggers by mbessey · · Score: 2

    There's an article in the latest issue of Embedded Systems Programming about using visualization tools for debugging. Well worth reading.

    -Mark

  32. Debugging by bytesmythe · · Score: 3, Insightful

    Debugging is difficult primarily because debuggers do not appear to use any kind of intuition.

    Let's say I have a break point on an if statement. The debugger should automatically show me the values of any variables in the condition, as well as the truth values of the individual expressions in that condition.

    A debugger should have an "intelligent" step button that steps into code that has debugging symbols, but steps over system calls. It should also automatically skip to the end of loops if desired.

    Debuggers should have "sanity" checks for values. Any time a pointer is null, or an long integer is set to some really wild value (like -3492883773642) that is nowhere close to the values that it originally contained, or a string doesn't have a null terminator, the debugger should alert you with a little icon, even if you aren't actively watching that variable.

    One thing that sucks about debugging is when programs behave differently in the debugging environment than they do once compiled. We had several problems related to event handling in Visual Basic only occured if the program had been compiled. In debug mode, it worked fine.

    Debuggers should keep a "state" history, especially for loops or recursive functions, so you can see the entire progression of a set of variables until the point of failure. This eliminates having to write in a bunch of printf statements to get a snapshot of each loop iteration or function call.

    The debugger should be integrated into the IDE so you don't have to switch back and forth. Also, it would be really nice if debuggers executed under some kind of virtual machine that allowed you to more easily freeze execution, rewind it, tinker with it as it's running, etc. Visual Basic allows you to do some of this, but certain code changes require you to restart the whole program. I'd like it if you never had to restart, and the line between "debug mode" and "design mode" were almost entirely blurred.

    Just my $0.02.

    --
    bytesmythe
    Hypocrisy is the resin that holds the plywood of society together.
    -- Scott Meyer
    1. Re:Debugging by dubl-u · · Score: 2

      Debugging is difficult primarily because debuggers do not appear to use any kind of intuition.

      Perhaps instead of making the debugger intuitive, you should make your code intuitive.

      In particular, you can write unit tests, so that you make sure that your code does what it should. And if that's not enough, each method or function can contain assertions about pre- and post-conditions for the code.

      Then instead of just catching the errors when you happen to be looking at something in the debugger, you can catch them all the time.

  33. More is bad by FortKnox · · Score: 5, Insightful

    Sure, we all like debuggers with conditional breakpoints and backward stepping, but the more you add to the debugger the less opportunity you will of finding the bug (unless its a 'smack in the face' bug).

    The only way of truely solving bugs is to know exactly whats going on in the code (and, also as important, is knowing the language, operating system, and the things going on in the background. IE - in Java, although it appears as if you aren't dealing with pointers, you are, and you should treat all objects like a reference, cause that's what they are). If you can't study the code (cause it was written poorly), it is a terrible terrible thing, because most bugs are not just one line fixes (and even those that are require you to know exactly what all is going on around them).

    "Cherry picking" (just tuning up one line and "guessing" that that's the problem) is what most 'amateurs that taught themselves coding' do, and on major/enourmously large projects, this will do nothing more than cause trouble.

    The best way to beat a bug is knowledge.

    --
    Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
    1. Re:More is bad by Casca · · Score: 2

      Just finding a bug is seldom the whole battle. To fix it you need to know why it is broken. More often than not when debugging a program that I had written, it would only take a few minutes to locate the source of the error, figuring out what was causing the error could sometimes take hours.

      --
      Casca
    2. Re:More is bad by scrytch · · Score: 2

      > The only way of truely solving bugs is to know exactly whats going on in the code

      Ah, isn't that sort of a given? That's like saying the only way to find your keys is to know exactly where everything is. Debuggers exist to let you see exactly what's going on.

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
  34. Perhaps it's an economic issue. by RelentlessWeevilHowl · · Score: 4, Interesting
    Why do you think so much effort been invested in areas such as advanced modelling tools but so little in improving debugging tools?

    A debugger is going to help you find and fix the bugs that got through:
    • Requirements analysis
    • Specification analysis
    • Design analysis
    • Code analysis

    Studies have shown repeatedly that the cost of fixing each bug increases at each stage. So if you are going to invest $1000 in new development tools, is it more economical to buy tools to detect bugs when they're cheap, or when they're expensive?
  35. Great Development Tools by repetty · · Score: 2, Interesting

    The original poster's questions are all loaded with the presumption that something is wrong with using graph paper, pens and pencils.

    Why on earth do so many people feel all development tools need to be built into a software debugger or they are inferior???

    One great tool he did not mentiong is the napkin.

    1. Re:Great Development Tools by EvlG · · Score: 2

      Sure, pens and paper are useful, but I think the poster was trying to say he felt that a lot of this could be automated by the machine. And frankly, he's right in many ways.

      Why not let the computer do what it does best (collect and process data to generate different representations) and let people do what they do best (take varied data and past experience, and through a process of logical reasoning, deduce where the problem is)?

      I would love for the debugger to be able to assemble, rearrange, etc... all that data of my choosing with the push of a button. It would save me the time (and errors) in doing it myself.

  36. Reversable debugger by interiot · · Score: 2

    For embedded programming, logic analyzers will let you store X number of steps before your program crashes. Of course, they cost $80,000, but it's still an alternative for the top 10% of employees of the top 100 tech companies...

  37. Java by gUmbi · · Score: 2

    Exception stack traces are a godsend.

    Jason.

  38. Slightly OT by buss_error · · Score: 2
    More thought to how a problem is solved BEFORE coding would solve a lot of debugging problems. I've seen too many programmers start coding first thing when they are given a problem. Sometimes the answer isn't code per se, but how you think about the problem.

    Good example is a damaged database. If you say "You have a damaged record", the customer says, "Well, fix the record and get all my data back!". If you say, "All your data is lost, but I think I can get most of it back if I get rid of this one record.", the customer says "DELETE that record!".

    --
    Necessity is the plea for every infringement of human freedom. It is the argument of tyrants; it is the creed of slaves.
  39. Getting it right the first time by theonetruekeebler · · Score: 5, Interesting
    Okay, so debugging hasn't gotten any better in the last couple of decades. I gotta say it's because the focus of methodology research has been on the development process itself, and that's an extremely good thing.

    The more work goes in before you get to the debugging stage, the less buggy your product will be. A well-designed system does not need as much debugging later. I know I'm idealizing, but I've seen this bear out, especially when version N > 1 comes out and it's been hacked to smithereens because of poor design choices in the previous iteration.

    Probably the most amazing bit of self-fulfilling prophecy you'll ever hear on a software project is a manager saying, "We'd better start coding now, because we're going to have a lot of debugging to do."

    As for catching things ahead of time, I've always put breadcrumbs in my code to spew to stderr or a Java error console class or wherever. Very easy to #ifdef out later and trivial to turn back on later.

    --
    This is not my sandwich.
    1. Re:Getting it right the first time by leandrod · · Score: 2
      > the focus of methodology research has been on the development process itself, and that's an extremely good thing.

      I am not so sure. All I have seen up to now is shuffling around, compressing, expanding or more generally fiddling around with phases of development. The issue is not to know any methodology, but not cutting corners where your successor, employer, customer or subordinates would later regret. And that seems to be above either the moral, intellectual or organizational standards mostly everywhere.

      --
      Leandro Guimarães Faria Corcete DUTRA
      DA, DBA, SysAdmin, Data Modeller
      GNU Project, Debian GNU/Lin
  40. Comment removed by account_deleted · · Score: 2

    Comment removed based on user account deletion

  41. A great feature by Avumede · · Score: 2

    One feature I really liked, that exists in a few places such as VC++ and edebug (for emacs), is the ability to jump around in the code and set values at runtime. You can do a lot with these two features, from running the same code over and over at runtime with different values, to skipping over a part of the code you consider problematic and seeing if it helps.

  42. It's ironic by TerryAtWork · · Score: 2

    One of the best debuggers I ever used is what I'm currently coding in - CA Clipper. Does it all, and I use VB 6 as well, so I know this is true.

    --
    It's Christmas everyday with BitTorrent.
  43. Debuggers are for chimps by torpor · · Score: 2, Interesting

    Been writing code since 1978, and the only debugging tool I've ever needed is:

    printf();

    Seriously, an over-reliance on debugging tools is something I've *definitely* seen come into this industry.

    Bah. Chimps.

    --
    ; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
    1. Re:Debuggers are for chimps by fredrikj · · Score: 2

      Amen. When I encounter a bug, I generally:

      1. Try to figure out through logic in which part of the code the bug could have occurred.

      2. Use printf()'s to track the progress from the main structures to their branches until I've found the malfunctioning function or code snippet.

      3. If the error isn't obvious, I insert printf()'s that tell the location in the code or values of variables, until I've been able to find the bad statement.

      Works about always.

    2. Re:Debuggers are for chimps by EvlG · · Score: 2

      I don't understand the insistence that printf() is the only way to go, and those that use automated tools are surely lazy or doing something wrong.

      As I said in another post, why not let the computer do what it does best, so that people can focus on what they do best?

      The biggest problem with printf() debugging is the code littering process, and the constant recompiles. Say you have a bug in a subsystem that is writted in approximately 20,000 lines of code. How do you determine where the bug is? You insert printfs() into all the functions/methods to find the culprit(s), and then gradually refine the inspection until you locate the problem. Fine, this is quite similar to how one uses the debugger. The problem is, inserting all those printf() statements is quite time consuming, and removing them and modifying them is even more time consuming. Additionally, it is possible that the printf() statements themselves can cause additional problems or mask the true nature of the problem. Finally, each time you update the printf() statements, you need to recompile the code. That step alone can prove to be a real bottleneck manytimes. The programmer using the debugger can simply inspect values as much as he likes at runtime, without many of the time-consuming problems.

      In short, the programm with a debugger works just as you do, but is typically much more productive because the computer is doing the tedious steps for you.

    3. Re:Debuggers are for chimps by torpor · · Score: 2

      Easy: test often.

      Whenever a SEGV rears its ugly head, I can usually think back through the last 45 minutes of code I've written and see where changes I might've made could introduce the bug. Then I just put printf()'s where needed until its clear, and I'm off again...

      This is why the mantra "Test Often" is a good one ...

      Incidentally, I've run into similar problems with uClinux, though these days I try real hard not to make changes to my kernel ...

      --
      ; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
    4. Re:Debuggers are for chimps by VAXman · · Score: 2

      Everything you can do with printf (i.e. examine variables), you can do in a debugger. The advantage being that you don't have to recompile everytime you want to examine another variable.

      It is almost impossible to debug certain types of bugs with printf - e.g. if a bug is exposed after calling a particular small function 10 million times, with three different parameter values, you simply wouldn't be able to do this with printf.

      That said, you can do significantly more with debuggers besides examine variables, such as data breakpoints and watchpoints. You can cascade different conditions together to trigger after condition A in function X occurs, and condition B in function Y has occurred, and after condition C in function Z has occurred. You can't do this with printf's since you don't have access to any variables except that function's local variables so you can't monitor what's going on in other functions.

  44. Reversibility is very hard by mbessey · · Score: 3, Informative

    You can implement reversibility on a per-thread basis (though that's harder than it sounds, in my experience). For multiple threads, it's basically impossible.

    It's much easier to implement back-stepping in a processor simulator or virtual machine than it is in a native-code debugger. Unless you single-step through all the instructions, keeping snapshots of all the relevant state along the way, you can't go back.

    And if you do single-step, the performance will likely be so poor that you might as well use a simulator.

    -Mark

    1. Re:Reversibility is very hard by exp(pi*sqrt(163)) · · Score: 2
      Reversibility could be done in at least two ways. One is to emulate and the other is to insert extra instructions into the code. Several tools do stuff like the latter - I think purify does and pixie (under Irix) definitely did.

      You don't need to store full snapshots. Some instructions require very little information to be stored to be reversible. Eg. add eax,1 only needs a few bits from the flags register to be logged.

      --
      Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
  45. Debuggers can be good but.... by MartinG · · Score: 2

    Debuggers have their place, but in some cases, to have to resort to a debugger can mean that the code is too complicated, or badly designed in the first place. Furthermore, having to use a debugger many times on the same bits of code is a clear sign that the stlye of the code is bug-prone and it should be rewritten.

    --
    -- MartinG To mail me: echo kewyjlcxyzvjfxbqwh | tr bcefhjklqvwxyz .@adgimnoprstu
  46. Better approaches are needed by JoeBuck · · Score: 2

    Almost all comments ignore the main problem with debuggers: they let you verify that a program works correctly for a given input, but tell you nothing about what happens for other inputs you haven't tried. Did you miss something? Are there buffer overflows or security holes? Coverage tools can help, but then you've got to come up with directed tests to reach all of the code, or prove that it can't be reached.

    Complete formal verification for large programs is a pipe dream, but there is a lot that can be discoverd through static analysis. Consider Dawson Engler's Meta-Level Compilation project, which automatically found hundreds of errors in the Linux kernel, for an example of what is possible.

    Engler and gang have gotten quiet lately, I wonder if they are trying to start a company.

    There are other approaches, used in hardware verification, that can mix directed testing with symbolic methods (from a state that is reached in a simulation, can I reach some "bad" state? If so, generate a test vector that takes me there).

    While waiting for these tools to be developed, get a four-year old. Let him/her play with your GUI. If it's a Gnome or KDE app, it will probably crash in under ten minutes, because the kid will do things that would never occur to the developer or tester.

    1. Re:Better approaches are needed by Error27 · · Score: 2

      If you liked the Stanford Checker, but you want something that is a little bit crappier then you should try out Smatch.

      As far as I can tell, it's the functional equivelent of the Stanford Checker, but it not as elegant or complete.

      Also I wrote it.

    2. Re:Better approaches are needed by JoeBuck · · Score: 2

      Perhaps you'd be interested in working with the GCC team to get your patch integrated, so that it gets maintained, works with newer compiler versions, etc.

      I'm certain that major cleanups will be required before it could be accepted, but the experts may be able to help you do things in a more elegant, powerful way. And if every gcc version had something like this, free software would be less buggy.

    3. Re:Better approaches are needed by Error27 · · Score: 2

      Perhaps by next fall I'll be ready to do something like that. For smatch to be really useful that's the way to go.

      Right now I keep on changing the intermediate format and trying new things. Once it gets included then you have to worry about backwards compatability etc...

  47. Re:Perhaps.++ by Anonymous Coward · · Score: 2, Interesting

    One of the reasons debuggers are so far behind, is that they attempt to make the vonNeuman paradigm real for debugging programs.

    I write CPU simulators. In this kind of environment, there may be hundreds of threads each performing one little iota of work per (simulated CPU) cycle. When a bug is encountered, the code that encounters the bug is not in any way related to the code that created the bug. And the cod that created the bug may have made its mistake thousands of simulated CPU cycles (billions of actual CPU instructions) before the code that stumbles over the bug-incarnate.

    Stack back traces, and other vonNeuman-like debuggers are totally useless in this kind of programming environment. I am simulating real parallel things (circuits) on a sequential turing machine. Its no wonder that a debugger is useless--it is based on the wrong mental model of what I am programming.

    I have to build the degugger into the actual simulation code--which I proport--is the right way to debug programs anyway.

  48. one word... by outsider007 · · Score: 4, Funny

    Clippy!

    --
    If you mod me down the terrorists will have won
    1. Re:one word... by silhouette · · Score: 2

      You look like you're trying to track down a memory leak! Would you like me tojg80;/aOUT OF MEMORY

      --
      Experts agree: everything is fine.
  49. Sometimes it's interesting not to use a debugger.. by alyosha1 · · Score: 2, Insightful

    I use debuggers every day, and find them indespensible for tracking down obscure bugs. (Like the one I just hit a few minutes ago - why does MSVC barf when calling vector::clear? The debugger stops app execution in _free_base() in free.c. This doesn't happen if I recompile using STLPort instead of the default stl library. ) That said, when I don't use a debugger I'm sure I find myself writing more robust code - I'm more inclined to spend more time on proper exception handling, thinking about my design instead of: write, compile, run, oh it failed on line 2493, fix that line, run again, now it fails at line 2547, fix that .... which results in code that works under the exact set of circumstances that you test it, but has no guarantee as to what will happen if the parameters change any. (And those pesky users always find those annoying 'special cases').

  50. FLOW CONTROL and visual debuggers by goombah99 · · Score: 2
    One language I have used is "g" by National Instruments. They market it as "labView". Here one does not write code. in stead one places icons on a screen and wires their input and ouput nodes. A scalar operation like cosine has one input and one output node. A loop is a box with wires that pass in and out of the box, inputs for the loop length, and internal wiring for local variables. Inside the box you put more circuits.

    subrountins are just hierarchical encapuslations of these with inputs and outputs.

    a given subroutine does not "fire" (is called) until all of the input wires have delivered there data. Thus one does not (usually) explicity control the order in which subroutines execute. as long as they have no dependencies (i.e. output wires from one leading to input wires of the other) then they are free to execute whenever their inputs are filled.

    to debug in this language one watched the diagram. Graphicaly a value passes down a "wire" like a pig in a python and stops when it reaches an input (or maybe it splits if the wire splits, and goes to more than one input icon). once the subroutine icon has all its inputs filled, it pops open and reveals all the witing in side. the data again passes from the input connectors to the internal wires and so on. once all the outputs are satisfied, the window closes and were back in the original diagram.

    you can place text boxes or graphs or chart recorders, or image plots on any wire. these show you the contents or changing contents of the wire in the format if the viewer. e.g. a strip chart recorder plots single or array values on a strip char that scrolls with time so you can watch them change.

    you can selectively debug any part of the wiring diagram and let the other perform normally.

    The neat part of the language is there is NO SUCH THING as a syntax error, or wrong pointer, or memory location overlap. Indeed there are no variables at all. just wires and controls that inject values into wires or display values in the wires. this makes it very suitable for control systems where those sort of programming errors are undesirable. Better to have wrong functionality that weird unexpected memory errors

    the other cool thing about the language is that because it is inherently concurrent and event driven rather than sequenctial, the data flow language is easy to parallelize. It's also relatively easy to use an FPGA to hard code the functions of the icons into hardware.

    the problem with the language is it requires garbarge collection and is the memory management is not so good as implemented. It's not too speedy either. But as I said it may be that its parallel advantages and near bug free coding and easy debugging outweigh single cpu speen in applications.

    --
    Some drink at the fountain of knowledge. Others just gargle.
  51. The best debugging tool I've ever used... by leecho · · Score: 2, Interesting

    Is a stuffed frog I've got from my gf that sits on top of my monitor. When I need to ask something about a hard bug, I ask him first, and just by asking most of the time the problem gets solved.

    It's interesting to note that a lot of those day-to-day bugs can be solved by simply straightening out your train of thought by posing a question in a manner that someone who doesn't know the system can understand.

    1. Re:The best debugging tool I've ever used... by cant_get_a_good_nick · · Score: 2

      This may sound silly, but extremely effective. I had a professor who I did this to. I was staring at some homework that was bombing for 3 hours. Went to ask him what I fscked up. In the process I see that I used the wrong var as an index. I thank him for his time, and leave. If I had a frog, would have saved me some walking and him about 5 minutes.

      The trick is that you have to explain it to the frog (or whatever object) completely enough for them to understand it if they were a real person. Sometimes just the act of organizing your thoughts force a different organization which shows you what you were looking at for 5 hours but couldn't see.

    2. Re:The best debugging tool I've ever used... by JohnFluxx · · Score: 2

      Leecho, I want to buy your frog.

  52. State preservation by selderrr · · Score: 2

    Some sort of smart dump of every variable & call in your app at any point. (Offourse for a short period of time only to avoid overflowing your memory. For instance limited to the last 5 function calls)

    This could allow you to replay a certain function with exact parameters as they were. I now often find myself repeating 5 minutes of clicking & typing to reproduce a certain function behavior of one line of code which *sometimes* crashes.

  53. Check out this debugger ... it REALLY works!! by mustangdavis · · Score: 2
    What would make a better debugger?


    In Java:

    System.println("MyVar = "+MyVar);


    In C:

    printf("MyVar is %d\n", MyVar);


    In C++:

    cout

    In PHP

    echo "MyVar is $MyVar <br>";


    In Perl

    print "MyVar is $MyVar\n";


    Works better than any debugger I've ever used .. and it saves my sanity too!!

    1. Re:Check out this debugger ... it REALLY works!! by djmurdoch · · Score: 2

      In C:

      printf("MyVar is %d\n", MyVar); ... [ Then save, make, wait, run ...]

      Works better than any debugger I've ever used .. and it saves my sanity too!!


      That "save, make, wait, run" part has been pretty hard on my sanity. Give me a good GUI debugger any day.

    2. Re:Check out this debugger ... it REALLY works!! by mustangdavis · · Score: 2

      OK, I give ...

      My "debugger" from the parent post probably works best with interpreted languages, but I still don't like most debuggers ....

      I feel like I accomplish something if I debug it myself ...

      Besdies, many GUI debuggers just aren't that user friendly (but I'm not saying print statements are either .. but they are mine) :)

  54. Easy capturing/debugging post-deployment by Fastolfe · · Score: 2

    I find myself routinely investigating problems with applications where I don't have immediate access to the source code, or where it's difficult to replicate the problem and we find that we have to correct it (restart, etc.) without getting an adequate opportunity to investigate.

    I would love to be able to grab a snapshot of a process and identify exactly what it was doing. In some respects, this can be satisfied by getting a process to core dump and analyzing the core, but to date this has always been an annoying and time-consuming process, requiring source code to see anything useful.

  55. I'm tired of this useless drivel by Ars-Fartsica · · Score: 2
    Sure, we'd all like to make it perfect the first time. If there was a tool, methodology, etc that could deliver this, don't you think we would be using it???

    When the codebase reaches a certain size and complexity, you are going to be using a debugger, thats why this thread is taking place.

    1. Re:I'm tired of this useless drivel by theonetruekeebler · · Score: 2
      There's no magic bullet, yah. No the methodology. But just because there's no eliminate doesn't mean there's no minimize.

      I must admit the largest project I've worked on so far had only 350,000 lines of code, and given the then sorry state of Jave debugging, we pretty much settled for leaving footprints in the code.

      --
      This is not my sandwich.
  56. Custom data type viewers. by SteveX · · Score: 2

    Often the data I'm working on is tough to just look at to see if it's right; being able to write something that would plug into the debugger to display some data would be cool.

    For example, lets say I'm writing a scanner driver and I'm receiving buffers of data from the scanner. There's no way to know in the debugger if they look right or not - but if I could write a debugger plugin that could basically be given access to the entire address space the program is in with a target of "show me your data starting at this address if you can" it'd be awesome.

    Same would be true for any data that isn't represented as a data structure or ASCII. I found often doing Win32 GDI work that I wanted to see what a particular HBITMAP looked like at a given point of the program's execution and the only way to do it was to blit it onto the desktop or something.

    - Steve

    1. Re:Custom data type viewers. by dair · · Score: 2, Informative

      Often the data I'm working on is tough to just look at to see if it's right; being able to write something that would plug into the debugger to display some data would be cool.

      This is one of the features in CodeWarrior 8 (at least in the Mac versions, and presumably the Windows version too). You can describe how the data should be organised so that the debugger can view it sensibly (e.g., where to find the string data in a std::string or that a CFloatRect is 4 floats), or write a plug-in to display it using your own code.

      E.g., you could display an image as a square of RGB data and a square of alpha data - or as individual color planes, or whatever you like.

      There was also a Mac tool a couple of years ago called General Edit (not by Metrowerks), although not a debugger as such - you type in a templated description of what your data looks like (with nested definitions, fields that rely on other fields, etc) and it pops up a structured view of the data. Very useful for poking around in data that normally you'd be trying to interpret with a hex editor, as you could tweak your decoding description until you had it right.

      -dair

  57. More good stuff is good by djmurdoch · · Score: 2

    The only way of truely solving bugs is to know exactly whats going on in the code

    This is the key. Anything that makes it easier to know what's going on in the code is good.

    Modern debuggers like the one in Delphi (probably similar to J Builder's) make this fairly easy. You need the GUI interface so you're looking at the source all the time, command line debuggers obscure it. It needs to be absolutely easy to find out the state of any relevant variables. You need to be able to drop down into an assembly view (or some equivalent if you're in an interpreter) to see what code got generated at a low level.

    The more *well-designed* stuff you add to the debugger, the better the opportunity for understanding the state of the program. Delphi doesn't have backward stepping; it would be great if it did, because it's often easy to detect that something has gone wrong, but hard to detect exactly when it happened. Conditional breakpoints are essential. Hardware breakpoints (which let the program run at full speed, but break when a particular memory location changes) are great.

    You also want to be working in an environment where it's easy to add custom views of data structures, so that you'll see when things have gone wrong. Delphi (and probably Visual Basic, though I've never used it) are very good at that. If you've got a lot of numerical data, it's basically a one line addition to generate a graph of it, and one keypress and a second or two to wait to compile a new executable containing that addition.

    You want tools like the various heap diagnostic utilities to be built in to the debugger, and you want system libraries to be written cleanly. It's easy to detect that you've got a memory leak if on exit your heap is always supposed to be completely empty; it's much harder if the run-time library leaves variable amounts of junk there, or if it's hard to determine what's there at all.

    Knowledge about your program is good. Adding features that make it easier to see how your program runs makes debugging much easier.

  58. It is the interface by Kefaa · · Score: 2

    Despite the slick graphical interfaces, nice thread stack traces and local variable browsers, I still make sure I have on hand plenty of notepads, graph paper, pens and pencils so I can try to build up a picture of what state the program is in and to help me play detective in pinpointing what is going wrong with my (or other peoples) programs. Do other developers have similar problems?

    Several people have mentioned feature enhancements, many I would also like to see. However, your statement about stuck me as being a little deeper. Yes, we have the same problems. However, it is not the debugger it is the interface in general. Your desires are for the "paperless office." For years we heard about it, but it never came to fruition. In fact, it may never come. The problem with a User Interface is it presumes users think, and behave in the a similar fashion doing the same job. Ask two secretaries how they file paperwork for themselves. Look at the notes written by two experienced developers during a debugging session. Similar results? Certainly. Similar approaches? Possibly. Identical methods for getting there? Doubtful.

    You need hand plenty of notepads, graph paper, pens and pencils because the task at hand requires you to keep track of abstract data. Why not screen prints, cut/paste of images, text, etc? Because the #2 pencil in your hand forces your to iterate you understanding (I am writing down X=2, then 3, then 4, then -32767 -- whoa!). In addition, you remove the "clutter" while also reducing the effort. Consider that you could cut/paste any sub area of the screen. X=2, now becomes X=2, cut, paste. X=3, cut, paste. X=-32767, cut, paste. X=2, 3, 4, 5, 6, 7 , 9, 37, -32767 looks very obvious. 37 records you must now relate together do not.

    I have also come to believe that the device interface is part of the issue. It is easier (for me) to mentally connect the window on a monitor with the printed surface than it is two windows. Perhaps the solution is a 36 inch monitor where I can have multiple windows open, so I can see everything at once. But it would still suffer from relating data, which also includes looking away from the code. Perhaps avoiding the "deer in the headlights" visual lock.

  59. Web Application Debugging by techsoldaten · · Score: 2, Insightful

    As a Web developer, time is on the line and almost everything I do is in a rapid development environment. That being said, debugging information is extremely important.

    On the ASP.NET and Cold Fusion MX application servers, the debugging information provided by each is excellent and thorough. On CFMX, each error is specified by line on the template on which it occurs and provides a 'stack trace' (meaning a list of all the pages involved in generating that particular Web page), execution times for each template, and a complete list of all variables in all scopes. Complex variables, such as structures and arrays, are output along with all the rest in an easy-to-understand format.

    The one thing that could be done better by every application system, IMHO, is a self-documetation feature. I would like to be able to look at the source code and see a breakdown of all variables on the page right away. This may sound a little simple and not really a debugging tool, but I look at it as preventive maintenence.

  60. Cardboard cutout dogs. by sbaker · · Score: 2

    Peer review - without the peer:

    http://www.sjbaker.org/humor/cardboard_dog.html

    --
    www.sjbaker.org
  61. Re:Very True! by ashitaka · · Score: 2

    How many times I've had another developer come to me saying "Dammit! I've been through this a million times and I JUST CAN'T FIGURE OUT WHY IT'S NOT WORKING!!!"

    I then take a quick scan through the code and see the problem in a minute or two.

    The reverse situation has also happened.

    --
    If you don't want to repeat the past, stop living in it.
  62. Use ddd, but with one improvement... by unixpro · · Score: 2, Insightful

    ddd is, by far, the best debugger I've ever used. I used to hate visual debuggers, but ddd turned me around.

    That being said, however, there is one improvement I'd like to see in all debuggers. That's a way to do memory checking. In other words, integrate Purify or Insure++ functionality into the debugger and have it break anytime there is a memory stomp. Memory problems are the biggest issue facing programmers of large, complex systems.

    For those of you who say to write small objects and give them unit tests, or to rely on things like printf(), I suggest that you get a job in the real world. Complex systems are written by large groups of people. When you hit a problem, it may or may not be in your own code. It may or may not be because you're using an object incorrectly. You need a debugger to figure out where things are blowing up and why. Using printf() will work, but it's slow and requires multiple compile/link/test cycles. Not the best use of your time.

    1. Re:Use ddd, but with one improvement... by Bill+Currie · · Score: 2

      Link your program with the electric fence library. Not perfect (can't handle really big (huge quantities of malloc calls) apps), but it makes your program segault at the right time (eg, in free when freeing invalid memory, on the line accessing freed memory, etc). valgrind seems to help a lot too (though I haven't used it much yet, just tracked down memory leaks).

      --

      Bill - aka taniwha
      --
      Leave others their otherness. -- Aratak

  63. Memory allocation tracking by oliverthered · · Score: 2

    I'd like to see a debugger that told me where memory had been allocated/deallocated.

    Things like the last content of an object (if it has been deleted) and where that memory was allocated etc...

    --
    thank God the internet isn't a human right.
    1. Re:Memory allocation tracking by EvlG · · Score: 2

      This is already possible:

      wrap malloc/free or whatever your memory interface is with one that tracks the location and initial parameters of the allocation.

      Set breakpoints on this code when needed, and viola, you can track exactly what goes on. It's quite simple to do, and there is no need for the debugger to really do this.

  64. And another I forgot by exp(pi*sqrt(163)) · · Score: 2
    Breakpoints should be settable not just on a position in the code, but how you got there. I'd like to be able to set a breakpoint in function A() that only triggers if it was called from function B(). That can be interpreted in two ways: either when A() is called directly from B() or when A() is called from B() maybe via some intermediaries. Or I'd like to be able to set a breakpoint that activates only when the call stack is at a certain depth. Good for debugging those recursive functions!

    There's probably a technical term for the pair consisting of a position in the code and the path taken to get there. It's a bit like what a mathematician would call in a point in the universal cover.

    --
    Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
  65. Debugging means to understand the code by kune · · Score: 2
    My law for debugging code is: "Debugging means to understand, what the code really does." That's reason, why you need pencil and paper.

    So debugging code is easier for simpler, cleaner code. So KISS (Keep it simple and stupid) will be the best debugging tool, we will ever have.

  66. Write-time debugging by JohnFluxx · · Score: 3, Interesting

    How about instead of not using any debugging tools, you debug at write time?

    For a lot of code, the compilier should be able to work out the pre and post conditions of a function, and then just check that when you call that function you don't violate them.

    Also I'd like to be able to hover my mouse over a variable and see what range of values it could have. From here you can check that you never go outside the bounds of a variable, and so on.

    Obviously you can never get it to work on all cases due to the halting problem, but it will work with a lot of code - and on confusing code you can manually add the special comments for the post and pre conditions - a good idea anyway for complex code.

    1. Re:Write-time debugging by JohnFluxx · · Score: 2

      not at all. Take a really simple example:

      int x;
      int myarray[5]; //then initialise myarray..
      scanf("%d", &x);
      myarray[x]++;

      So you ask the user to type in a number. The value of x after the scanf statement is [MININT - MAXINT]. But the legal range of myarray is [0-5]. So compare ranges, detect there is a value outside the range, and error.

      Threading will be really hard to do right, but will offer the greatest advantages (since threading is really hard to debug conventionally)

    2. Re:Write-time debugging by BrodieBruce · · Score: 2, Interesting
      Also I'd like to be able to hover my mouse over a variable and see what range of values it could have. From here you can check that you never go outside the bounds of a variable, and so on.

      Try using DDD. It's a graphical frontend to gdb. Also, it's open source.

    3. Re:Write-time debugging by JohnFluxx · · Score: 2

      Thanks - that would be useful info if it had any relevance at all to my message :P I'm talking about at write-time, not run time. I'm talking about ranges a value can be in all possible executions, not one particular execution.

    4. Re:Write-time debugging by The+Panther! · · Score: 2

      Another feature that I really wanted to see would be a popup that tells you what O() order a function call would be, and have the compiler determine it based on analysis and corrective comments for difficult functions. Again, the halting problem applies here, but it would move a certain type of documentation into the face of a programmer, rather than obscurely in the middle of several nested functions.

      The pre/post-condition validation at write time is an idea I've been toying with for the past two years. The problem is that (most) languages do not extend pre- and post-conditions into the language itself. Rather, you have to infer them based on types. This isn't strong enough. What you really need is a language that allows you to define not only the types, but the values or ranges that are legal as input and legal as output.

      So, what I did was started from there and modified the grammar of C++ until it met all my requirements, then removed some things that would make such analysis impossible (like pointer arithmetic and anything else that contributes to weak typing), then added a few tweaks that I always wanted in my own language.

      The result? An almost purely functional language, using C++ like syntax, with some unique features... for instance, one of my favorites was that scoping with braces { } works differently, such that you must declare all variables you take _into_ scope from the parent block, and you could poke locally declared variables _out_ of that scope into the parent block through another declaration. This follows exactly the same syntax as declaring a function, which made it trivial to rearrange blocks of code or inline things manually, etcetera. It also solves the problem of scope reduction for temporaries which are used only to call the constructor on a non-default constructor class.

      Alas, I have no time to write the language, and considerably less to write an analysis tool like you describe, but it would have been neat to play with. A nearly perfectly functional language, as you know, parallelizes really well so I'd planned to put it on a cluster. Even bought the machines for it, then sold them when my interest waned. :-)

      --
      Any connection between your reality and mine is purely coincidental.
    5. Re:Write-time debugging by JohnFluxx · · Score: 2

      Well I was thinking why not integrate these compile-time checks into my editor? If the checker can't do something, then let the programmer help out - it's good to do post and pre conditions on complex code anyway..

      But yeah, this is actually what I want to do for phd ;)

    6. Re:Write-time debugging by JohnFluxx · · Score: 2

      pointer arithmetic was something that bothered me. But, from a naive point of view, how hard can it be? Famous last words I know, but sure 90% of the cases are:
      *) Point to something of known type (easy case)
      *) Point to something of type void * (I don't even know what the compilier does, so I'll ignore this case)
      *) Increment point by one, or some smallish number (Easy again - turn it into an array reference)

      You would need some kind of simulated memory to make it easier to update arrays when you update the pointer to an array.

      Remember that in the areas where it gets hideously complicated I can just give up and set the variable to unknown. If that is too wide, the programmer can add special-comments.

    7. Re:Write-time debugging by JohnFluxx · · Score: 2

      Actually these are the cases that I hope to tackle. For example when I finish writing a function, and then notice that my editor has added a post-condition that, say, x>0, and I thought I had written my alogirithm to include x in the output, then I know I have made a mistake.
      Same with preconditions - If I wrote a function and it says the precondition was that x!=0, I might realise I made a mistake, or what have you.

      Obviously this won't tackle all, or even most, of the cases - but it helps.

      The only way you are going to check what you wrote is truely correct is to compare it against a formal specification - which is another topic entirely.

    8. Re:Write-time debugging by scrytch · · Score: 2

      > Another feature that I really wanted to see would be a popup that tells you what O() order a function call would be, and have the compiler determine it based on analysis and corrective comments for difficult functions

      Collect your nobel prize when you do this. It's not possible. Okay, you could do a 99% solution, but I don't see a demand for it in debugging, and it's something a code coverage tool and a profiler will point out in very short order anyway.

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
    9. Re:Write-time debugging by The+Panther! · · Score: 2

      I never claimed it would be 100%. Notice I specifically referenced the halting problem... Typical usage would benefit tremendously from such a feature, much of which is already known to the compiler. The last 1% of cases are for academics to bicker over. I'm a programmer, dammit. :-)

      --
      Any connection between your reality and mine is purely coincidental.
    10. Re:Write-time debugging by BrodieBruce · · Score: 2, Insightful
      Hmmm...I didn't even think of that. I guess I just skimmed over part of your post rather quickly.

      However, such a debugger, even if it did exist, probably wouldn't be incredibly useful. Sure, you could catch some errors. But most non-trivial programs I've written consist of so much on I/O (user & device) and system calls that a write-time debugger couldn't possibly tell me the values of enough variables such that it would be nearly as useful as a decent run-time debugger.

      And c'mon, who wants to debug until it doesn't work? That's what testing is for. :-)

    11. Re:Write-time debugging by JohnFluxx · · Score: 2

      user and device IO is dead easy, since you should check the input and should assume that it can be anything - that's the easiest case.

      I was thinking of manually adding info system calls so that you wouldn't have to parse glibc etc everytime.

    12. Re:Write-time debugging by JohnFluxx · · Score: 2

      I would guess that in 99% of cases you should assume the user input can be anything. It would also be nice to assume as little as you can about the data being fed in from hardware and drivers and filters.

      Handling multiple allowable ranges is trivial, and I never said anything about restricting it to just min,max. You are right you have to allow for multiple ranges (like 1-2,140-700,800-900) but that is trivial.

  67. Re: GVD by Black+Parrot · · Score: 2


    > You might take a look at GVD, the GNU Visual Debugger, which can generate graphs of datastructures.

    It also has pluggable language support, so $SOMEONE can add support for your favorite language to it.

    --
    Sheesh, evil *and* a jerk. -- Jade
  68. Re:Very True! by JohnFluxx · · Score: 2

    This is actually one of the reasons I like the pair-based programming style set out in XP. Admittedly it is not really supposed to be for this sort of thing, but it is a really nice benefit

  69. I only need 1 command in a debugger by grmoc · · Score: 3, Funny


    I just need the "why" command..
    =)

  70. Re:More is bad - WHY? ego is bad by Suicyco · · Score: 2

    A good debugger/disassembler is invaluable in finding obscure bugs. No amount of knowledge of your code and its structure can help you if a system call mangled a stack in a subtle way, especially with cumulative effects of buggy functions that have very very subtle bugs. Unless you are writting embedded code or something that doesn't rely on other code (an os, libs, etc.) you will never have a total view of what is going on. Debugging tools can help pinpoint generally where trouble is, and then it is up to the programmer and his detailed knowledge of the code to figure out what exactly is being affected and by what.

    There is no right/wrong answer because "debugging" is such a vague term as well. Use all the tools available to you, and arrogance is not one of those. Nobody has perfect understanding of the internal intricacies of software running on top of an operating system running on top of a cpu.

    The best way to beat a bug is to be knowledgable enough to use the right tool, at the right time, to find the correct cause of trouble. That could be anything from a cable tester, to a disassembler, to a coffee break, to another human being.

  71. Debugging race conditions. by Rimbo · · Score: 2

    The hardest thing I've ever had to chase down were race conditions.

    Race conditions don't act the way you'd think they would. If two threads both try to read a variable, you wouldn't necessarily think there'd be a problem, much less a problem that causes your program to suddenly decide to corrupt your hard drive and crash your program. And there's no really effective way to find out where the crash happened, because it happens at random, when you don't expect it.

    Even printf()'s fail you here.

    The only way to find a race condition is to hand-inspect code, and make sure every shared variable is protected by mutual exclusion.

    If I ever got back into grad school, I could probably dedicate an entire career to solving just this one problem.

    I think the real problem, though, is not that there's a lack of good debugging tools, but rather that the really good debugging tools are rare, and the more common ones may have power but are difficult to use. And digging even deeper than that, the real problem is that people tend not to use languages that will enforce programmer discipline and help to prevent programmer errors from getting into the software in the first place.

    1. Re:Debugging race conditions. by JohnFluxx · · Score: 2

      I'm just finishing uni and want to spend a lot of time on this sort of problem.

      I feel that the solution is not run-time debugging, but write-time debugging - why can't my _editor_ at least try to spot race conditions, buffer overflows, etc.

    2. Re:Debugging race conditions. by Rimbo · · Score: 2

      And here, I thought I was the only person in the world who would be interested in pursuing such a thing! :) I'm glad to hear someone else is interested in this too.

      What you say sounds reasonable. I've had similar thoughts as well. It seems that once a race condition gets into a program, the results are typically impossible to debug once the program starts, so some form of analysis -- possibly by the compiler -- seems to be the most likely route to success.

  72. One Word: TotalView by Gudlyf · · Score: 2
    TotalView

    'nuff said

    --
    Trolls lurk everywhere. Mod them down.
    1. Re:One Word: TotalView by mz001b · · Score: 4, Informative

      I agree, Totalview is a really impressive program. When you have a bug that only manifests itself on 16 or 32 (or more) processors, print don't help as much. Stepping through code with totalview can really help figure out what is going on.

  73. I don't use debugging tools for much.. by defile · · Score: 5, Interesting

    But I only use debuggers for two purposes.

    Purpose 1. Segmentation Fault (core dumped). Uhm, now where did that happen? Whip out gdb, find the line that generated SIGSEGV, and it's usually obvious how it happened. If not, I have it print out a stack backtrace. If I really can't figure it out then, a 5 minute walk around the block and I'll have figured it out as soon as I sit back down.

    When writing in high level languages, I'm finding that debuggers are wholly unnecessary. In fact, I can't remember the last time I spent more than 20 minutes trying to track down a bug. *shrug*

    It'd be nice if debuggers solved my problems automatically, but I'm really finding that I don't need them. I might even go so far as saying use of debuggers encourages dependency on debuggers, which in turn discourages thinking about the program itself. Not saying that EVERYONE does this, just that some of the best work gets done remarkably well even without debuggers.

    The Linux kernel, for example, was largely developed without the aid of a debugger, and the core developers seem to eschew them. Here's a good thread on why the developers don't want to include a debugger.

    Purpose 2. On the other hand, debuggers are remarkably good at helping you break program code. With having almost no experience using gdb, I was able to break the license key check on Intel's C Compiler in about an hour. I was amazed at how easy it was to attach a debugger to the compiler and skip the subroutine that performed the license key check. With no debugging symbols to work with. Disassemblers rule. It took another 10 minutes to turn this into a script that could be distributed as a wrapper for icc (called xicc), so all you had to do was set CC=xicc in the Makefile.

    Sure I could have used LD_PRELOAD so that time() always returned a date within the trial period, but breaking program code with a debugger is just so gosh darn fun.

  74. backtrace by Bill+Currie · · Score: 2

    (call stack, what have you). If a debugger won't give you a stack trace (optimized code excepted:), throw it out. I've found that fixing a null pointer error is often as simpile as running the program in gdb until it crashes and then reading the results of backtrace. function name, parameters, source file and line nummber: (almost) everything you need to find out how that null got passed to your function.

    --

    Bill - aka taniwha
    --
    Leave others their otherness. -- Aratak

  75. Re:As somebody who uses printf... by ckline · · Score: 2, Interesting

    I believe you are referring to the Omniscient Debugger: "A software tool written with Java[TM] technology allows developers to step backwards through the execution of a program to determine where and how programming errors occurred. By recording each state change in the target application, it allows the developer to navigate "backwards in time" to see what the values of variables and objects WERE, enormously simplifying the task of debugging programs. "

  76. Debuggers are useful to a point ... by uw_dwarf · · Score: 2, Interesting

    While knowledge of a debugger is useful, it is only a part of the debugging arsenal. You can't beat the wisdom gained by experience. Some people are better at finding bugs than others. Some people have a broader knowledge of the interactions of various layers of software than others. The more bugs one finds and fixes, the better one gets at finding and fixing them. But move from one environment to another, and only the thought process is portable--you need to re-learn the context (which gets easier the more contexts you've worked in). And sometimes that environment doesn't have the debugger you're most familiar with. So again, the tool itself is devalued, and the ability to "debug outside the box" is emphasised. Sometimes you can't put a debugger on a system (live telephone switch); sometimes you can use a debugger but can't put a debuggable image on (same example--how's your hex and 68x00 assembler?). In short, a better tool isn't going to make debugging easier. It may shorten the time to identify the problem area, but it doesn't make the process of removing the bug easier, especially in huge systems with many interacting layers and heterogeneous nodes. That being said, I use stack traces, breakpoints, variable/parameter dumps, and registers when I can get them--and that's about it. The other features don't provide value to me (my opinion, but I'll share without imposing it). Design for debuggability--somebody will feed your software something that's out of spec. Controllable tracing is useful here, but put the control flags in a piece of shared memory that a utility can toggle on and off, because you can't modify environment variables for a running process outside that process. And if your execution environment is guaranteed to have a debugging environment available, master the debugger if you can, but make sure it doesn't master you so you can't debug without it. The best debugging toolset is, in order of importance, your mind, the source code, the occasional invitation to others to look at the code with you, a whiteboard or notebook, and a room free of distractions. Surface for air and refreshment every 45 minutes or so, and food every few hours (there's a reason the Jargon File has an entry for "rotary debugger"). Debugging software will inform this process, but feature-rich debuggers will not speed it up much.

    --
    The Seventh Rule: Take others more seriously than yourself, particularly when you are leading them.
  77. I don't use them, and here's why: by under_score · · Score: 2

    I've been developing software professionally for over 10 years and I can count the number of time I've used a debugger on my fingers.

    I've programmed in c, Objective-C, Java, and a little in C++. I've worked in healthcare, oil and gas, high tech, and most recently the financial field. In all cases I have found that I can track down my bugs by using my brains and sometimes inline print statements (yes, I admit it). I spend approximately 1/10 of my total development time doing debugging work as opposed to design or coding.

    Debuggers are too big a context switch. They don't act like part of the IDE. The best I have ever seen is the debugger in Visual Age (by IBM). It allows some pretty amazing things: you can roll back the stack and continue executing, and you can change any code dynamically while debuggin (the debugger figures out how much of the stack needs to be rolled back to allow for the changes). It also has all the usual stuff like value inspectors, conditional breakpoints, etc.

    The one thing I would really like is to have a more sophisticated watch system that allows me to use the IDE (not the debugger) to insert development-time only code. This would allow me to put in such things as print statements that would not be part of the "real" source code, but rather just part of my project. It would also allow logging, performance measurment, etc. to be done at development time. Note: I don't want to context switch into a debugger to do this!!!!

  78. GDB the millstone by DrXym · · Score: 3, Interesting
    I don't know about others but I find it an immense pain in the backside to debug anything on Linux. The reason is GDB which has to be the biggest hinderance to development on Linux. Arcane, slow and unintuitive would be words best used to describe it. You could grow a beard while waiting for a backtrace when debugging a stack overflow in an app like Mozilla. I've seen GDB page my system to death before now, such must its memory requirements must be for some operations.


    Even front end tools are little help. DDD is much better than the cli but it still suffers the same performance faults as GDB and introduces some fun issues of its own. Even a 'commercial' tool such as Project Builder on Mac OS X groans to a halt with GDB running underneath and has some very odd concepts concerning when breakpoints are hit or not.


    All this would be understandable if Win32 were the same but it isn't. Debugging on Win32 is a snap - just in time debugging, compile in time debugging, a debugger that works, integration with the editor and more. It is sad to say that if asked and irrespective of open / closed source issues, which OS were the better for development I would say Windows. In fact, if I'm faced with a bug in Mozilla, I'd rather fire up Windows and replicate the problem there than wade through the shit that GDB throws in my face.


    Die GDB! Linux really needs a decent debugger and all the mod cons that Windows developers have benefited from in the past decade.

    1. Re:GDB the millstone by EnglishTim · · Score: 2

      Amen to that!

      It'd be nice if kdevelop didn't rely on gdb - it often takes 3-4 seconds just to step to the next line fer frick's sake! And that's not even in a big program!

  79. Debuggers do more than debug! ("Ask the code") by Lumpish+Scholar · · Score: 3, Interesting

    Recently I was given some Java code and asked to port it to C++. At the time, my knowledge of Java was pretty much at the "Where is the bathroom, please?" level. In particular, I could see where the reflection package was being used, but not how the program went from one particular bit of client code to another. I loaded the code into the debugger, started the program, set a few breakpoints at the really puzzling parts, and ran through it a few times. At that point, the student achieved enlightenment.

    As I've gotten more skilled at software development, I've become better able to read a bunch of code and analyze it ... and become more likely to run the darned thing and see what it really does. Sometimes, in this job, inspection is theory, and debugging and testing are experimentation.

    An MIT animal physiologist is said to have told his students, "The animal is always right. When in doubt, ask the animal." Ask the code; the code is always right. (It may be right in knowing what the bug is, but sometimes that's what you need to ask.)

    P.S.: I've learned more Java since then. Running some programs through its debugger was one good way to help learn it.

    --
    Stupid job ads, weird spam, occasional insight at
  80. And if you don't have somebody around... by dubl-u · · Score: 5, Funny

    If you don't have another programmer handy, try the practice of Rubber Ducking.

    This is where when you are completely stuck, you take a little break. Then you come back, pull a rubber duck out of your drawer, and put it on your desk. Then you turn to it and say, "Rubber duck, here's my problem," and explain your troubles to it, just as you would to a fellow programmer.

    About two thirds of the time I try this, I stop half way through and say, "Aha! That's the problem!" And even if the solution doesn't occur to me, the process of explaining the problem makes me go over it in an orderly way, so that I always think of new places to look.

    1. Re:And if you don't have somebody around... by dubl-u · · Score: 5, Funny

      What if the fellow programmer walks in and catches you talking to a rubber duck? :)

      When you tell him how many problems little Ducky has solved, your main problem is that he will try to steal your duck.

      But if you're really worried about appearances, write Ducky an email about the problem. If by the end of the email you still are mystified, you can always send the email to a colleague.

    2. Re:And if you don't have somebody around... by Kymermosst · · Score: 2

      What if the fellow programmer walks in and catches you talking to a rubber duck? :)

      Better than if he walks in and catches you talking (or worse) to a rubber chick...

      --
      "Alcohol, Tobacco, Firearms, and Explosives" should be a convenience store, not a government agency.
    3. Re:And if you don't have somebody around... by clickety6 · · Score: 2

      But if you're really worried about appearances, write Ducky an email about the problem. If by the end of the email you still are mystified, you can always send the email to a colleague.

      Just be sure you remove the initial "Hello, Ducky" before sending it to a fellow employee!

      --
      ----------------------------------- My Other Sig Is Hilarious -----------------------------------
    4. Re:And if you don't have somebody around... by Bert+Peers · · Score: 2
      But if you're really worried about appearances, write Ducky an email about the problem. If by the end of the email you still are mystified, you can always send the email to a colleague.


      Or try the Magic Mailing List trick : describe the problem and send it to a mailing list for which it is appropriate. The mailing list software will then telepathically send you a fix so that 5 seconds after you hit Send, you already go "Oh shit, DUH, that's it" and you can try covering up your stupidity by replying to yourself and trying to make the one-line fix sound really complicated, "from an architectural point of view".

    5. Re:And if you don't have somebody around... by pne · · Score: 2

      I agree. Though here at work we usually do it with live ducks, and we call them "dogs" (I guess after the way some people talk to their dog).

      So I might ask some co-worker to "come over and play dog" and while I'm explaining the problem to them, often I go "and then I ... um, never mind, I think I found it. Thanks!".

      I guess it's the fact that you order things in your head in order to be able to explain them that helps you fix the problem by yourself.

      --
      Esli epei etot cumprenan, shris soa Sfaha.
  81. what about non-iteractive debugging ? by sir_cello · · Score: 2, Interesting

    Most of this discussion seems to be about interactive debugging tools, but as an individual concerned with mission critical telecommunications software where an outage can take out customer private networks, I tend to find less need for interactive debugging, and greater need for post-mortem diagnostic analysis that results from the following:
    - faults generated in house system / integration testing
    - faults generated in house automated unit / component testing
    - faults generated in house automated system / scalability / performance testing

    I need to isolate sometimes highly obscure run-time failures and discover what went wrong, then resolve the issue, which I do with:
    - high levels of run-time instrumentation using (a) method / object / runtime c++ trace style classes, (b) trace back mechanisms for exception handling and, (c) assertion handling and (d) run-time verification mechanisms; all of which generate output to debug logs (sometimes when returned to support, these logs are multi-gigabyte in size, fortunately our development workstations are very high spec)
    - post-mortem analysis scripts to interpret the contents of debug logs and look for faults, inconsistencies and other issues
    - application level mechanisms to allow testing, deployment and other experts to enable run-time debug instrumentation (if it were enabled all the time, it would constitute considerable performance loss) sometimes at the direction of developers or deployment / field support personnel, and sometimes these personnel don't have access to machines where the components are installed (because the components are distributed CORBA components, and these personnel have access to host / user interfaces, but not to components in a silo in another country)

    The problem is that we've had to design all of this from scratch: (a) general purpose c++ based debugging / tracing modules with command line / run time configuration options, (b) tools to stimulate the debugging facilities to do things [set / change debug trace levels / activation tags / identifiers], (c) tools to capture / wrap up and return trace logs back to support, including capturing host information (processes, memory, installed modules, environment, configuration) and other debugging items (debug stack traces, core dumps) and version information (component version, etc), (d) tools to analyse / work with / process logs for developers, (e) work instructions / process / documentation to educate developers, deployment experts and others about the use of these facilities, (f) make sure that there's a balance between getting the right level of detail, yet avoiding gigabytes of detailed code / method level information

    Typically, once I have a debug log returned to me (as I am developer), I need to look at what was going on, and try to reproduce the fault with a unit test case, then inspect the component for faults of a similar type, and correct those with appropriate unit tests as well, then verify regression test for the component, make changes to multiple development branches, and wait for the scheduling of scalability / system / automated testing to ensure no other significant side effects, then safely know that the next release will have corrections.

    We shouldn't have had to develop all of this in house: there should be standards for this. Other companies that I have worked with have the same adhoc construction of debugging facilities - for these situations were you need to analysis a running system, or obtain post-mortem results.

    Interative debugging dwindles in comparison: unless you are working with obscure hardware, or related sorts of embedded systems, I think that an excessive need to use interative debugging says more about the lack of design / defensive coding / other engineering approaches to reliability of the constructed software. Interative debugging consumes about 10% of my debugging efforts (not including time spend on unit / component / system test design).

  82. Must be nice by Tintin · · Score: 2, Interesting

    It must be nice to be one of you folks who work on one of those projects where you can just use your brain to understand all the relationships among data structures and various pieces of code or where you can make sure that you only ever work on code where you can be sure that it's structured cleanly with nice small functions that can be tested individually.

    Out here on the wild frontier we're stuck working on code that was written many many years ago by people who weren't quite so clever as the average slashdot poster. These people left behind badly structured code with inelegant data structures and comments that don't accurately describe how the code works. This code consists of several tens of thousands of lines in the component I'm directly involved with and several hundreds of thousands of lines in the larger project.

    So while it sure would be swell if all the functions were small, the data structures elegant, the code tidy, and the comments accurate, that's just not the way it is for many of us.

    And it pains me to say, but much of the debugging we do is done using printf() because most debuggers are such unredeemable sacks of $#!].

    I do much of my debugging using msdev from VC++ v6, and I find it to be even less useful than the CodeView debugger that I used in 1987. There's a few things that are better but there are a lot of things that are worse. How can I get msdev v6 to show some of my variables in hex and some in decimal? Is this such an esoteric request that the developers at MS couldn't be expected to anticipate it?

    The number of things that the MS debugger can't do that I could do in 1992 using IBM's VisualAge C++ debugger is even longer. Is this progress?

    1. Re:Must be nice by iangoldby · · Score: 2

      How can I get msdev v6 to show some of my variables in hex and some in decimal? Is this such an esoteric request that the developers at MS couldn't be expected to anticipate it?

      No, it's not too much to ask at all.

      I think this is what you want. E.g. to display a value as a short hex integer in the watch window:

      myVal,hx

  83. Log4j by Petronius · · Score: 2

    Log4J is my debugger. 'cuz my webserver has no stinking GUI!

    --
    there's no place like ~
  84. Savestates. by RyanFenton · · Score: 3, Interesting


    If you've ever followed the popular system computer simulators known as emulators, you've likely seen savestates. It's effectively saving all the variables of a system en bulk, to be leaded back again later so another approach might be taken. They have been very useful to emulator developers who often need to return to an exact point where a virtual machine breaks down, without having to re-run to a certain point.

    It would be nice if debuggers could automate the process of saving the state of functions (and everything they immediately touch), so you could go "back in time" rather than need to restart a program in order to return to a non-bugged state. On small programs, it would also be very convenient to be able to save the state of the entire program.

    Possible extentions of this idea would be a breakpoint-like auto-savestate at a certain line, and a "step back" feature to be able to rollback one line.

    Of course, there would be many possible complications involved in using savestates - but I believe the potential dangers are far outweighed by the opportunities for quicker and more comprehensive testing and code-observation.

    Ryan Fenton

  85. Superdebuggers by jimfrost · · Score: 5, Interesting
    Well, it just so happens that there have been a few debuggers much more functional than the likes of Visual Studio.

    I used to work for a company called Saber, who later changed their name to Centerline. We produced a product called Saber-C (and later Saber-C++, and the products were renamed CodeCenter and ObjectCenter).

    This product was a C/C++ superdebugger. It started out as a C interpreter developed at Harvard. Now, an interpretive environment allowed a lot of neat features: You could tell whether or not variables had been initialized at reference time, you had complete stack and context information, it was pretty easy to unload and reload code in source modules (dynamic reloading). You also got dynamic type checking, which caught errors in downcasting (for instance). And everyone's favorite, array bounds checking.

    With this tool debugging C code often meant: Loading the code, running your test case, and seeing where the debugger complained. The first time you ran your code through it was a humbling experience ... almost all production code has serious (but normally benign) errors.

    Unfortunately the tool didn't scale well because it took time to load the interpreted code into the debugger and the heap and runtime requirements of interpreters stressed machines of the time (this was when Sun3s were common, and 3/50s couldn't even have more than 4MB memory).

    I think it was 1990 when we released version 3, whose big new feature was object code debugging (it's not really that easy to have object code debugging as well as interpretive code, although we could certainly have implemented it more easily than we did). We of course maintained the ability to dynamically reload code fragments, so you could do a "make", reload the affected modules, and be on your way in a few seconds. This sure beat the several minute wait you normally had with the linker and debugger restart. But what you lost was some of the runtime checks -- including most of what made the product interesting. Still, the ability to have superdebugger capabilities on some code and still scale to large programs was very valuable.

    About a year, maybe two years later we got visited by the people who eventually started Purify. They had a neat approach where they'd get most of the benefit of our tool, but in object code, by disassembling the object code, adding extra code to perform checks, and putting it back together. This would give about 80% of the functionality of our debugger but with much lower runtime costs and work even if you didn't have source code.

    We ended up re-implementing this functionality such that we had a Purify competitor (and getting sued, and losing, even though Sun later patented the same technique we used).[1] Integrating it into the debugger allowed you to fine-tune the debugging capability you wanted on a module-by-module basis. This was a superb tool.

    Now, what are the raw capabilities that made this stuff really neat?

    1. Incremental reload of modules. That removes the debugger restart cost (symbol loading is a huge time sink).
    2. Supply worst-case scenarios for code. In our tool, we'd initialize heap and stack memory to 0xbfbfbfbf patterns, which tended to trigger bugs in code that had intitialization errors.
    3. Track heap allocations. Knowing who allocated something is remarkably valuable, particularly for tracking down memory leaks.
    4. Augment the code with error checks that are sensible for the source language. For instance, we knew the type that was assigned to memory so we used that to detect all manner of type mismatches.
    5. Augment the code with bounds checking for arrays. The bounds checkers worked with the heap system, which of course tracked the size of all allocations. This caught a lot of off-by-one errors.

    The tool also provided two additional interesting features. One was called "action points". Since we had a C interpreter in the product it was no big deal to allow you to type C code into it and run it at arbitrary times. We'd allow you to attach any code you wanted to any line in the program or to just type code at the debug prompt and it would run in the current scope. This was useful for things like adding print statements without recompiling, for instance, and for adding assertions, and many other things.

    The other feature was a graphical heap inspector. All this did was display structures as tables of their internal values and allow traversal of references to other structures, which would be displayed (including links between the structures). This made the shape of data a LOT easier to determine.

    Several people talked about adding reverse execution. That was actually done for Java by a tools company back in 1996 (maybe 1997). It didn't always work, but it was pretty neat. The problem is that the recording code was pretty expensive and there's a limit to people's patience and what they'll spend on hardware (although I grant that hardware is a lot less of an issue today than it was even in 1997, to say nothing of 1989). Anyway this feature is a lot less interesting if your debugger can find errors at the point they occur.

    Anyway, back in 1995 when I started to work with Visual-C++ on a regular basis I was appalled by what Microsoft was calling a "state of the art" debugger. Feh! It was 1985 technology with a pretty face. It really has not improved much since then either, although they do at least have a pessimistic heap allocator now. With their ability to hook in with the compiler they could do a phenomenal job with heap allocation tracking and instrumentation of code with error checks but they don't bother (because, I suppose, they make their money even without it).

    Now, using a language with runtime error checking built in - such as Java, C#, or Visual Basic, seriously undermines the amount of effort you have to put into the debugger. Still, I'd like to see a lot better heap debugging features built into compilers and runtime environments.

    Hope this gives people some ideas, and that they lead to tools I can use.

    [1] One thing that could be done to avoid the Purify patents would be to have the compiler emit the instrumentation. For the OSS world, where you always have the source code, that is eminently practical. Furthermore you can get all the benefits of an interpreter but at higher performance. A big problem with Purify's technology, and the technology we came up with, was that you're doing a lot of heuristics during code inspection. It's easy to miss code or misinterpret code, and of course the code inspector is VERY architecture and compiler dependent. What I would like to see is a gcc/glibc/gdb combination where the compiler, libraries, and debugger all worked together. That wasn't possible back when the vendor controlled the compiler and you didn't have access to library source. Today it is, at least for the OSS world.

    --
    jim frost
    jimf@frostbytes.com
    1. Re:Superdebuggers by jimfrost · · Score: 2
      Alot of what your product does really reminds me of Lisp

      When I interviewed one of my comments was, "Hey, that's like a Lisp environment for C!" I had been building a lisp-based shell at the time so that was really cool :-).

      --
      jim frost
      jimf@frostbytes.com
    2. Re:Superdebuggers by jimfrost · · Score: 2
      I haven't seen Parasoft's stuff in years, but it was good when I last looked. Nice that it runs on Linux.

      So.. is this Saber-C stuff Open Source/Free yet?

      Nope, but it doesn't matter because it needed a rewrite anyway. Were I to do it today I'd move the instrumentation code into gcc, augment glib, and add some hooks to gdb to allow programmatic control (ie allow the inferior to ask the debugger to do things like stop). That would all be easier than most of our ports of Saber-C to new platforms, and would end up being largely platform independent.

      Getting module swapping/incremental loading to work is a royal pain. Valuable, for sure, but maybe not worth the development agony. It's a lot less of an issue with demand loaded languages like C# and Java anyway.

      --
      jim frost
      jimf@frostbytes.com
  86. class/struct access tracking by captaineo · · Score: 2

    This is more of an IDE thing than a debugger thing, but I'd really like to have an automated way of finding all the call sites that access a particular class or struct member.

    e.g. if I have
    struct foo { int count; ... };

    I want to see all lines of code that access the 'count' member of struct foo. (WITHOUT showing all other occurrences of the string 'count' like a simple grep would).

    Bonus points if the feature can track pointer aliasing - e.g. in the example above, *((int*)&foo) should also count as a hit... Or if I have an array 'int arr[]' and I want to see all access to arr[3], including *(arr+3) and arr[i] where i could equal 3.

    1. Re:class/struct access tracking by MikeBabcock · · Score: 2

      I hate to say it, but Visual C++ will do this. Not quite intuitively, but it does do it.

      --
      - Michael T. Babcock (Yes, I blog)
  87. Delphis weak points by SnapperHead · · Score: 2

    I mainly use PHP for my development, but when it comes to client side applications I use Delphi / Kylix. For your basic simple things, it works quite well and has some nice debugging and error reporting. However, when doing things like database working using the BDE, its a nightmare. Most of the time the errors don't point to anything to help debug it. The errors are sometimes so general, it could mean someone forgot to put the toliet seat down.

    I have found that many developers (of the debuggers or IDEs) don't spend enough time creating error messages for all sorts of common problems.

    They have gotten 10 times better in recent years. I personally *hate* most C / C++ IDEs becuase the application just segfaults, or what not instead of saying what the hell happened. I am a poor C / C++ programmer, so it doesn't help me move any futher into it.

    --
    until (succeed) try { again(); }
  88. Automatic debugging/testing by bored · · Score: 2

    To a certain extent programs like purify and bounds checker do automatic program debugging. BC will check for all kinds of runtime errors. Coupled with tight coding standards enforced by a lint like tool of your choosing a _LOT_ of bugs will be easily isolated automatically. When you combine these tools with a code coverage utility, a decent set of unit tests, a test utilty that can fail system and library calls you will discover a the bug count in released code will go down to nearly 0. Finding these bugs in developement is a lot easier that trying to do it with a core dump from the customers site. Take it from me I've worked for companies that released software where bugs that cause crashes, lost data etc were simply not acceptable.


    People complaining about the debuggers themselves missing functionality are complaining because their code is either to poor to isolate the bug when it happens (causing it to propigate into areas where the bugs arn't ovious), or they simply arn't using all the tools avialable to them. Don't underestimate how useful enforced coding guidelines can be for writing bugfree code. There are whole classes of bugs that can be caught by a lint, but will result in hours of debugging. Variables that never get initialized are the perfect example.

  89. Eh? by Theatetus · · Score: 2
    x^2=y, then y^1/2 = x. its a square-root!

    Hate to break it to you, but if y^1/2 is implemented as a true function with a single return value, it is not the reverse of x^2.

    Say you have y = 9. Was the x that was squared to produce that 3, or was it -3?

    Similarly with sin. You know that y received the value of 0 after assignment from sin(x). But was x 0, pi, 2*pi, 3*pi, etc.?

    That's just the theoretical problem; there's a bigger practical one involving floating point values. When an operation or cast causes precision loss there's no way to get that precision back. Let's say y is a float and you shift it to the right by 3 bits. Those 3 LSbs are gone forever, and there's no operation that can reverse that unless you log the value of every variable that undergoes an irreversible change.

    --
    All's true that is mistrusted
  90. I agree with Brian W. Kernigan by ry4an · · Score: 4, Interesting
    In The Practice of Programming Brian W. Kernigan and rob pike said:


    As personal choice, 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 details of complicated data structures and
    control flow; we find stepping through a program less productive
    than thinking harder and adding output statements and self-checking
    code at critical places. Clicking over statements takes longer than
    scanning the output of judiciously-placed displays. It takes less
    time to decide where to put print statements than to single-step to
    the critical section of code, even assuming we know where that
    is. More important, debugging statements stay with the program;
    debugging sessions are transient.
  91. Re:I wouldn't let the retards at microsoft by AlphaHelix · · Score: 2

    That's a pretty untutored opinion. I've used debuggers on about ten different platforms and found the MS Visual C++ debugger to be the best designed one I've used. It's well integrated, easy to look at, it has machine code disassembly built in and displays it between the code lines (if you want), it has intuitive hot keys, et cetera. There are some really bad debuggers out there. dbx on AIX was absolutely retarded, and couldn't set watch points without crashing. Their GUI for it was harder to use than the command line. The MS debugger is a dream by comparison.

    --
    * mild mannered physics grad student by day *
    * daring code hacker by night *
    http://www.silent-tristero.com
  92. x86 disassemblers by blincoln · · Score: 2

    I would kick someone in the knees for an x86/Win32 disassembler that's as intuitive and easy to use as PS2Dis is for Playstation 2 MIPS code.

    I'd been using that one for awhile (finding hidden bits in games I like), and I decided to check out the same kind of software for x86 disassembly. I felt like I was back in 1992 using DOS tools. Essentially all of the interfaces seem to be text-only, and there's none of the "click on an address and modify the code" functionality of PS2Dis, or the ease of navigation.

    Since I'm only doing this for fun, it's just an irritation, but I imagine it would be very frustrating for a full developer.

    --
    "...always new atoms but always doing the same dance, remembering what the dance was yesterday." -Richard Feynman
  93. Teach people to use them by PhotoGuy · · Score: 2

    I think the biggest advance in debugging would be teaching people to use them.

    I know a lot of programmers, but I think I'm the only one I know that actually uses a debugger to find problems. I haven't personally seen any University courses on debugging techniques or tools.

    I think it's an essential skill (like typing) that makes programmers *so* much more productive.

    -me

    --
    Love many, trust a few, do harm to none.
  94. Re:Another type of conditional breakpoint by EnglishTim · · Score: 2

    Come on. Move over to the dark side. Use Visual C++!

  95. What is a debugger anyway? by Pseudonym · · Score: 2

    Most of the responses are missing the point, I think. Step outside the box for a moment...

    When you write software, you have an intended interpretation, namely, what you intend the program to do based on what you meant to write. The compiler, on the other hand, has its own interpretation of your program, based on what you actually wrote. Debugging is the process of finding discrepancies between those two interpretations.

    Understanding this reveals what directions debugging tools should go. Current tools put the programmer in the driving seat, trying to understand how the system has interpreted their program. The next generation will put the system in the driving seat, asking the programmer what they meant that operation should do. Like with a human teddy bear, the act of explaining it to the system might even clarify things enough in the programmer's mind that the problem may become obvious. Or, we may end up in a kind of "pair debugging" situation where the system becomes a code reviewer.

    --
    sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    1. Re:What is a debugger anyway? by MikeBabcock · · Score: 2

      I want the ability, along these lines, to not show my debugging code and testing code while looking at my code, then have it display again while writing debugging code.

      Programs should do their own code audits which should simply be disabled in proper builds. These audits should not ever modify internal variables or state though; that causes a nightmare.

      --
      - Michael T. Babcock (Yes, I blog)
  96. Powerful debugging software in every MS app by Snafoo · · Score: 3, Funny

    It runs during installation. To activate it, click 'I do not agree' when some incomprehensible gobbledegook called a 'EULA' is shown. A EULA is a kind of bug. Unless you refuse to accept, it will bug you again and again. Don't confuse bugs with viruses, however: Microsoft's debugger can't handle viral licenses, which is why they don't like the GPL. Once activated, the powerful EULA non-acceptance debugging option leaves your system bug-free.

    --
    - undoware.ca
  97. Re:Debugger improvements (reversability) by Jamie+Zawinski · · Score: 4, Interesting


    Yes, I could really use a debugger that runs backward for a problem I'm having recently. I wrote about it here last month:

    Shaver pointed out this message. Apparently Michael Chastain wrote the very program I'm looking for, back in 1995. Nobody cared, the kernel APIs kept changing underneath it, and it died on the vine.

    [...] The replayer is the cool part. It takes control whenever the target process executes a system call, annuls the original system call, and overwrites the target process registers and address space with the values that I want to be in there.

    [...] If I put memory-access rule checking in at replay time, I can do better than e-fence, on stock binaries with no recompilation. Hell, I can do better than Purify on stock binaries and without tangling with their object-code-insertion patents.

    I have enough information available in the proxy ptrace filter to implement PTRACE_SINGLESTEP_BACKWARDS. How would you like to have that capability in gdb? "Execute backwards until this data watchpoint changes." Imagine a graphical debugger with a scrollbar for time, where the top is "beginning of execution" and the bottom is "end of execution."

    Yay progress.

    Ok, the rest of his message reads as a ``why does my genius go unappreciated'' whine, but still, I want this program! The code is still available, but I'm sure not feeling motivated to try and port it to run on a modern kernel (it doesn't even support ELF binaries...)

    It looks like after this message was sent to the linux-kernel list in 1999, there was a whole lot of talk, then three years of zilch. I mailed to ask if any progress was ever made. The answer was no: nobody ever made it work on modern systems.

  98. No more garage door... by M.C.+Hampster · · Score: 2
    Wouldn't you say that's more akin to figuring out if your new SUV will fit in your garage by just driving it in instead of measuring the garage and the SUV first? I.e., knowing what you're doing?

    I can confirm that this is a bad idea.

    --
    Forget the whales - save the babies.
    1. Re:No more garage door... by The+Bungi · · Score: 2
      I can confirm that this is a bad idea.

      HAHAHAHAHAHAHA! You so... oh, never mind.

  99. Yeah, i completely agree by jon_c · · Score: 2

    But I doubt this is true anymore as the VB we know and love is pretty much dead, it's VB.NET now, which is little more then a node to BASIC syntax for a .NET CLR.

    -Jon

    --
    this is my sig.
    1. Re:Yeah, i completely agree by jon_c · · Score: 2

      i ment dead as far as support, microsoft is abandoning it and it will eventually die, hopefully sooner then latter - of course i didn't mean that no one used it, thats stupid; i mean cobal's still a top language for fucking god.

      -Jon

      --
      this is my sig.
  100. Re:Which is what multiple monitors are for by snatchitup · · Score: 2

    I've got 1 and 3 in one window. The latest technology I use, I re-build while the server is running. Sometimes it's a little slow.

    But I'd like something more like the debugger in multiple windows.

    1. Call Stack
    2. Variables ( but this needs to be much better for objects.
    3. Line of code that I'm actually on.

  101. Re:Debuggers cause problems and are IDE-dependent. by Oculus+Habent · · Score: 2

    Or you could define a function, dbprint, for example, that all your flow notes call, make dbprint do nothing when you don't need it, and delete any dbprint calls when you're done debugging.

    Of course, that would be much easier...

    --
    That what was all this school was for... to teach us how to solve our own problems. -- janeowit
  102. Re:It never changes by Oculus+Habent · · Score: 2
    I don't know how beneficial writing your own assembler or DBMS is. If your plan on becoming a programmer with a foot in DBMS, this might be a good thing, as it teaches you the underlying functions and limitations.

    To me, and I quite probably am very alone on this, it would be better to conceive of a DBMS (forgive the gravitation toward this one example) - to chart the program flow at a general level. Not:
    When an "Insert" is called, run the Entry function, which handles insertion, integrity, keys, indexes, etc...
    But instead of spending the time sitting down and creating a whole DBMS, why not understand how to do so. It is part of the writing process to understand the function of your application (hopefully), but what we need more than rote programming is imaginative conceptualizing.

    And, if you choose, you can take your concept, and follow the iterations down and break modules into components, components into functions, functions into code.

    Of course, none of this has much to do with debugging.

    And poor spelling doesn't mean poor organization skills. Poor mental organizers tend to have sequencing problems more than specific spelling problems, and crap classes like Study Skills in high school teach all the wrong ways to remember things (you "web" a database, not a textbook. Textbooks are almost always sequential, not relational).

    Some people were never properly taught to spell, and some people don't type well. This does not make them poor organizers.

    "There is no worse lie than a truth misunderstood by those who hear it." - William James
    --
    That what was all this school was for... to teach us how to solve our own problems. -- janeowit
  103. Maybe it's because of our programming languages by voodoo1man · · Score: 2, Insightful
    about how little the debugging process has improved over the last 5,10 or even 30 years.

    A big part of the reason is that the languages paradigms that are popular today are directly copied from what was popular 5, 10, or even 30 years ago, with a little bit of a half-baked object system thrown on top (think C++, Java, etc.). Statically compiled "structured" programs don't lend themselves well to debugging, period. First of all, the debugger has to do a lot of contortion to do relatively simple stuff like stack and variable inspection. Then comes the problem of the "structured" style itself, which depends heavily on variable assignment and is very un-modular.

    OO-design does reduce the granularity of program modularization and lessens the dependence on global variables somewhat, but inside, the objects are still programmed in a "structured" way. Even worse, object-overuse leads to a rat's nest of an object graph (my big beef with single-inheritance only object systems is that they encourage this).

    For debuggers, steppers and stack-tracing to be really effective, a program has to be modularized with as fine granularity as possible. This is why functional and pseudo-functional languages generally tend to have and develop the best debuggers. Even before implementing any features, an interactive top-level is probably the best debugging tool available. But implementing stuff like advanced condition handling/breakpoints, stack-tracing/variable inspection, and function-tracing/steppers fits naturally into the language environment with minimal detriments to code size (anyone up for a little Java catch?) and performance.

    --

    In the great CONS chain of life, you can either be the CAR or be in the CDR.

  104. There has been progress... by alonz · · Score: 2, Interesting

    ... Only people are not adopting the new ideas.

    For example, I used to work with a tool called BugTrapper from MuTek Solutions (it's now called AppSuite, and the company is now called Identify Software). It can record an application's runtime trace, replay it, rewind it and provide many more helpful debugging tools. Unfortunately it never caught on (maybe because of its price), and nobody has copied the idea to open-source tools :-(

  105. Re:Write-time debugging-Software is a process. by JohnFluxx · · Score: 2

    The trouble, as I see it, is that practically there is a huge amount of inertia when it comes to programming languages and methods.
    People still don't use debuggers (not saying good or bad, just stating it factly), people still use C very heavily, few people use lisp (although I do find more ppl using than I expected), and so on.
    Visual programming never seemed to take off that well (the whole 'a routine is a box, connect the boxes' type thing), etc.

    Going offtopic even more, I'm currently trying to redo all of the main command-line gnu tools, but am suffering from the same sort of problems. The command line tools suffer from really horrible problems that shouldn't exist, and the code is horrible for most of them, but they will never be fixed. For example, I patched 'tar' to autodetect the filetype (.gz or .bz2), but I didn't have a hope of getting the main tar changed, because ppl don't like change. Another was a cleanup of ifconfig - but the changes weren't commited, even tho there were just bug fixes etc, because it would require testing on so many different platforms and libraries, that it wasn't worth it.

    My solution is to try to fix it all, break compatibility, and hope I can get enough done before I release it to have enough momentum to get somewhere.

  106. Re:Debuggers cause problems and are IDE-dependent. by Tony-A · · Score: 2

    I suspect debuggers are somewhat like console debugging a mainframe. While there are times it is the only expedient mechanism, the less one has to do it the better. For almost everything, there is a better way to do it, usually by including enough consistency checks or such and output of enough state to conveniently tell what's going on.
    Against debuggers is that they occupy address space and time space. The program being run under the debugger is not the same as the production program. Each will have a different set of bugs and anomalous behaviour. After being burned a few times by debugging the wrong system, (with debugger instead of production), I would imagine there are more than a few developers who have a strong dislike for debuggers.
    One strong argument for Open Source is that, assuming they don't take up too much resources, there is a tendency to just leave the bug-catchers in the production systems.

  107. OO Debuggers by Ripplet · · Score: 2, Interesting

    One of my bugbears is that debuggers don't seem to have caught up with object oriented programming yet. For example, often when I want to set a breakpoint, it would be really useful to be able to specify which object I want to break on as well, as I can usually narrow the problem down to a particular bit of code with a narrow set of objects. Now if there are thousands of identical objects like the one I want to debug, I have a problem. At the moment I have to solve it by finding a unique objet that will be activated just before the one I'm really interested in, breaking on that, then setting the breakpoint I really want, then running to that. Each time I do this I have to unset the breakpoint again, run to the first one, set it again etc.
    This one single feature would greatly improve my productivity.
    Also, simply generating a list of objects of a certain type would also be useful, so I can see how many there are in the system etc. And I'm sure there could be lots more OO-specific features other than these too. Come on debugger designers - please!

    --

    Skiing? Check out The Independant Skiers Portal

  108. plan9 has a leap forward - acid by DrSkwid · · Score: 2

    http://plan9.bell-labs.com/sys/doc/acidpaper.html

    Acid: A Debugger Built From A Language

    Phil Winterbottom
    philw [ a t ] plan9.bell-labs.com

    ABSTRACT

    NOTE: Originally appeared in Proc. of the Winter 1994 USENIX Conf., pp. 211-222, San Francisco, CA

    Acid is an unusual source-level symbolic debugger for Plan 9. It is implemented as a language interpreter with specialized primitives that provide debugger support. Programs written in the language manipulate one or more target processes; variables in the language represent the symbols, state, and resources of those processes. This structure allows complex interaction between the debugger and the target program and provides a convenient method of parameterizing differences between machine architectures. Although some effort is required to learn the debugging language, the richness and flexibility of the debugging environment encourages new ways of reasoning about the way programs run and the conditions under which they fail.

    --
    There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
  109. My debugger feature request by ThaReetLad · · Score: 3, Insightful

    I've been writing vc++ for a few years now, but one feature I'd REALLY like to see would be to be able to easily set conditional breakpoints on a particular instance of an object. In fact, more object awareness across the board would be nice. I'd also like to be able to be somewhere in a windows message handler, and be able to see where the message had come from. I'd like to be able to call functions from the watch window like I could in DEC FORTRAN. I'd like to see the VC++ debugger be able to enumerate over collection objects using for_each, and examine COM properties as if they were variables. I want the VB watch and immediate windows for VC++.

    --
    You can't win Darth. If you mod me down, I shall become more powerful than you could possibly imagine
  110. Re:Nails are for chimps by torpor · · Score: 2

    Building houses is one thing.

    Writing code in a way that avoids unneeded tools is another thing altogether.

    --
    ; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
  111. Team Teso by kris · · Score: 2

    The Teso people held a superb lecture on reverse engineering and systematically finding security problems in binary code at this years Chaos Congress in Berlin.

    They demonstrated a way to automatically analyze and segment binary code into basic blocks. A basic block is a segment of binary code that is being executed from top to bottoms, that is, it does not contain any jumps out of the block and is not the target of a jump into the code.

    Team Teso then performed graph algorithms and data flow analysis algorithms on the basic block graph their primary tool produced. This is where things get interesting for debugging.

    For example, the teso people were able to trace which basic blocks are being touched during code execution. You can imagine this as a graph of the program where each basic block is a block (node) and each jump is a vertice between the blocks. Upon execution, each basic block is colored as the code is being executed.

    They also were able to reconstruct C program structures from binary, and they were able to reconstruct where data comes from that ends up in a certain buffer in a structure. This allowed them to check for matching buffer sizes automatically (!) and to retrace how to inject data into a program that has mismatching buffer sizes somewhere on the inside. Makes for some very easy, instantaneous exploit generation.

    For more information, have a look at their slides from the lecture.

    Kristian

  112. Write-time debugging isn't a be-all-to-end-all by jimfrost · · Score: 2
    Assuming you know the pre- and post-conditions (you don't always) then assertions can be a very valuable debugging technique, I agree.

    But the real fallacy with "write-time debugging", and in fact all of the code-bug-free methodologies, is that there is very significant amounts of code that you must use to write your program that was written by someone else who is almost certainly not using your methodology (or, often, any methodology). So, even if your methodology worked on your own code it wouldn't work on the application as a whole.

    I note that some of the most insidious bugs I've ever had to track down were caused by operating system errors. My favorite bug ever was under AIX where a call to select() with a 30-second timeout was returning in about 900 nanoseconds saying it had timed out. This caused a chain of failures. And, of course, it would only happen in some pretty unpredictable situations. In this case you needed two programs running under ptrace at the same time on the system for the bug to show itself - and it would only occur about one in five thousand calls to select() even under the failure conditions.

    No amount of programmer effort on our part would have prevented this bug from biting us. We could certainly have put in a postcondition tester to check to see if the system call operated correctly (in fact that's how we worked around this problem) but can you realistically do that for every system call you ever make? Every library call you ever make? It's not practical to do so.

    I'm all for doing things to minimize code errors, although to be completely honest the best method (as opposed to methodology) I've found to do that is to use languages that include their own run-time error checking, which are strongly typed, have mandatory exception handling, and which use garbage collection for heap management (Java being the only one I've used). The combination of such features leads to about 90% fewer bugs out-the-door and boosts programmer productivity by 200-400% over the long term versus something like C++ (that's data from several large programming projects I've been on).

    It's that good because the environment tends to report problems as early as possible in the development process, when they are easiest to fix, and because of mandatory exception handling code more often gets written with failure handling in mind.

    Even so, and even with methodologies that reduce bug rates even more, tools are often invaluable to producing good code. I find that heap inspection and profiling tools are very valuable for Java, for instance, as are techniques such as log instrumentation and assertion. (Unfortunately Java provides no facilities for any of this in-the-box, sigh.)

    Anyway, to maximize programmer productivity and minimize bugs it pays to use an array of techniques and tools. Those who believe debuggers don't have their place, that they can be rendered pointless by technique, are badly mistaken.

    --
    jim frost
    jimf@frostbytes.com
  113. Learn debugging through teaching by Stu+Charlton · · Score: 2

    I find modern tools to be pretty sufficient. Some of the following features are quite important:

    - Edit/Continue debugging.... VB used to do this (not in .NET for now), JDK 1.4.1 does this.
    - Watchpoints (when is something edited?)
    - Jumping back stack frames (though you'll have to be careful to manually reset your shared state)

    Tracking down bugs requires a certain kind of expertise. Usually it's harder to debug than to write new code, so that could be one reason why debuggers don't proliferate as much as modelling tools.

    One way of gaining this expertise is to have experience in teaching other programmers in a hands-on course. You learn to spot common bugs quickly, and diagnose more complex ones. It's in an environment where you have 15+ people that all need your help at once... kinda pushes you towards honing that debugging sense.

    In my experience, most "tough" debugging problems would have been solved if the developer just set the breakpoint and analyzed the code instead of sitting on their thumbs and thinking about it for 15 minutes. This might be fine for Kernhigan, Ritchie, Pike, and all those who suggest that "thinking" is the best way, but these guys also have *decades* of experience to do this without assistance. A debugger is a catalyst to this thought process.

    Also, logging techniques are crucial, they isolate the location of a potential problem. But they're very time consuming to figure out WHY something is going wrong (because you never quite know what variables to dump out to stdout).

    A debugger to seek stack traces & peek inside variables, change variable values, and edit/continue with your changes adds significantly to agility. It's partially why VB was so successful, and Eclipse is so popular in the Java world (and why most Smalltalkers have migrated to Java/Eclipse).

    --
    -Stu
  114. Exactly what would anyone WANT from debuggers?? by mnmn · · Score: 2


    They might incorporate LINT and run the program with mprof and thru a replacement malloc() to check leaks. Other than these, stepping into procedures and watching variables, what else is there to do with debuggers?? Theres no understandable direction to go from the debuggers' current state; theyre doing well.

    On the other hand people seem to use debuggers less to take out program bugs. They rely more on reliable library functions, and post their problems in newsgroups for the library maintainers to fix. I personally use printf excessively to output the programs variables and state at each moment, then remove them from the final program. Its a more straightforward path than compiling with -g, powering up gdb and watching the variables, but then again gdb has its place.

    --
    "Give orange me give eat orange me eat orange give me eat orange give me you." -Nim Chimpsky
  115. Programming by contract by Raedwald · · Score: 2
    When writing in high level languages, I'm finding that debuggers are wholly unnecessary.

    Is that because of the high level language, or because high-level languages encourage better coding styles?

    I'm thinking of programming by contract here. My C++ and C is fairly sprinkled with assert()s, and my Java will be be likewise, when I move to version 1.4. With assertions on preconditions and postconditions and some unit tests, you can locate a bug to one method almost immediately, and if your methods are small (the current bast practice), that means only a handful of lines for you to inspect.

    One of your repliers says:

    I would like to add a third purpose that you should consider using a debugger for: Understanding other peoples code.

    If you need a debugger to understand what some code does, I suggest it it is badly written.

    --
    Ne mæg werig mod wyrde wiðstondan, ne se hreo hyge helpe gefremman.
    1. Re:Programming by contract by defile · · Score: 2

      I would like to add a third purpose that you should consider using a debugger for: Understanding other peoples code.

      If you need a debugger to understand what some code does, I suggest it it is badly written.

      That reminds me..

      The author of MaraDNS had to inspect BIND network traffic captures because he couldn't deduce from either the RFCs nor the source code just what exactly a valid DNS packet looked like.

  116. Re:You sound very condescending by FortKnox · · Score: 2

    I wasn't lumping the cherry pickers with the debugger users.

    In fact, I was trying to make the point that using a debugger is good (hell, I use one!), just that you need the basic functionality that bebuggers have today without any extra bells and whistles. The submitter asks "what ELSE do you want?" My response is "nothing, we're at a good equilibrim point of debugging features now. Adding more will take away from the fact of understanding the code, and will become more dependent on solely using the debugger."

    --
    Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
  117. Great idea, but not enough on its own by Anonymous+Brave+Guy · · Score: 2
    If you do test-first development and continuous integration (backed up with good black-box integration testing), then the number of bugs you get should be low. In my experience, that's circa one shipped bug per man-month.

    I envy you your success rate. :-)

    Where I work, we are blessed with enlightened management and team leaders. Our tests are automated, and we have clean builds from the source control system and test runs overnight every night, with summaries generated and mailed to the team in time for the morning. To those who haven't adopted such an automated approach, I cannot advocate it enough. The difference between this and an environment where you're bogged down running numerous tests by hand according to different levels of test spec that took some poor soul weeks to write is staggering. This is from bitter, and then much happier, personal experience.

    I'm not entirely convinced by the "test first" philosophy. That's always struck me as more of a political point than a practical one. Where we work, when we want to add a feature, someone first writes a proposal summarising the requirements. We then go through a very iterative development phase, effectively doing the design work by repeated prototyping, and then filling in the blanks.

    The key thing we get right, I think, is that as we do this, and we're happy with the results, we actually generate the automated tests from what happens: our software can record the actions it's taken, and various checksum-type information about the results, and can later replay that recording and match (or not) against the previously saved checksums. Making a test is as simple as hitting the record button and then running through some actions that give the correct results, and running the test is as simple as playing back the test file that was previously generated.

    It obviously requires a certain amount of effort to implement such a system: you effectively need some sort of "macro language" for the test files, and you need to have a checksumming facility to verify all the data in your system at a given moment and flag discrepancies. Furthermore, these do need to be updated when new features are added (extra macros) or new state is introduced into your model (extra info in the checksums). For the amount of time, and developer tedium, this saves, though, I'd guess it's an investment well worth making for many development shops. It's not even as much work as it first sounds, because many apps are essentially event-driven or based on some sort of command pattern architecture anyway, which means you've already got most of the framework in place.

    Even with all of this in place, it's still quite possible to get bugs that are hard to find, though. Just because you know such a test failed, if that test was based on complicated processing, the fault could be anywhere within that process. Still, at least you can always look back at the overnight test records to pinpoint where something was checked in that caused the change.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:Great idea, but not enough on its own by dubl-u · · Score: 2

      It sounds like y'all are doing better than about 80% of the industry. Congrats!

      But you should consider extending your test coverage further. Or, more accurately, testing smaller units.

      I look at it this way: when I'm forced to use a debugger, that means that I don't really know what the code is doing. I have hypotheses, of course. So instead of setting breakpoints and examining values, I just start adding tests to check the hypotheses.

      That way I get the benefit of my careful thinking not just when I'm in the debugger, but every time anybody runs the test suite.

      I'm not entirely convinced by the "test first" philosophy. That's always struck me as more of a political point than a practical one.

      You should give it a try, at least for a couple of weeks. It completely changes the experience of developing. But make sure to do it in very small increments: write a few lines of test, and then a few lines of production code to make it pass. Then repeat.

      The feeling of confidence it gives you in your code is incredible. It is also more fun; your day becomes a hundred small victories. And because you're always working from the tests, interruptions just aren't a big deal. And most people find that it substantially improves their OO design, too.

      Personally, I find it very practical. For something that's a page or two, I can just crank out the code and not worry about the tests. But for any serious project, I find the tests save me more time than they cost.