Thread: Do you use a debugger?

  1. #46
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by laserlight View Post
    Just wondering, besides observing the program's behaviour, eyeballing the code and using a debugger, do you guys use tools like strace and dtrace?
    I love strace. Couldn't live without it. Or rather, I would have written it myself if it wasn't already provided.

    It's one of the few options you've got when you don't have the source code to the program you're having problems with.

  2. #47
    abyss - deep C
    Join Date
    Oct 2007
    Posts
    46
    nice thread :-)
    am going to start using a debugger now...

    cheers
    maverix

  3. #48
    Registered User
    Join Date
    Feb 2008
    Posts
    147
    I dont use a debugger. If you are in the habit of not ussing it, you learn to programm with "good techniques", like variable initialization, 'assert', log and debug own subroutines, buffer overflow control, correct error handling, ..... Practice and learn by doing is what teach you to avoid the situation that need a debugger.

    If you use the debugger, you dont learn how to avoid "dark mistakes".

  4. #49
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I dont use a debugger. If you are in the habit of not ussing it, you learn to programm with "good techniques", like variable initialization, 'assert', log and debug own subroutines, buffer overflow control, correct error handling, ..... Practice and learn by doing is what teach you to avoid the situation that need a debugger.

    If you use the debugger, you dont learn how to avoid "dark mistakes".
    What do you do when you make a mistake?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #50
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Kempelen View Post
    I dont use a debugger. If you are in the habit of not ussing it, you learn to programm with "good techniques", like variable initialization, 'assert', log and debug own subroutines, buffer overflow control, correct error handling, ..... Practice and learn by doing is what teach you to avoid the situation that need a debugger.

    If you use the debugger, you dont learn how to avoid "dark mistakes".
    I take it you rarely need to debug code that isn't YOUR OWN code, then? Or code that you wrote a long time ago?

    Like so many things, a debugger is a tool. Use it when it's the right thing to do - you don't use a screwdriver to hammer in a nail, nor does a chisel make a particularly good screwdriver.

    Adding for example an assert() is a good way to detect something went wrong, but if you want to know HOW you got to that situation a back-trace/call-stack is very handy to show that. Of course, for easily repeatable problems, the log will also tell you what happened - if it's detailed enough.

    Logging is useful for finding the exact circumstances for the error condition.

    Writing perfect code is great, but if you work in a group of people, there will probably be someone that doesn't produce absolutely bug-free code all the time [or someone that doesn't quite know how to use some functionality in the system], and this causes problems to where you may be the one to debug it - even if you didn't write the code that causes the bug.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #51
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Kempelen View Post
    I dont use a debugger. If you are in the habit of not ussing it, you learn to programm with "good techniques", like variable initialization, 'assert', log and debug own subroutines, buffer overflow control, correct error handling, ..... Practice and learn by doing is what teach you to avoid the situation that need a debugger.

    If you use the debugger, you dont learn how to avoid "dark mistakes".
    This is exactly what I disagreed about with brewbuck. Just using a debugger doesn't make you more efficient. On the contrary, it might make you less efficient. It takes far long to find out what has gone wrong with just eying or scanning your code than using the debugger.
    The debugger is a tool, and you musn't be afraid to use it.

    The debugger is, of course, not enough many times. Using safe versions of functions to catch buffer overruns and using asserts to check for bad program states helps a lot.
    I would say it's on the contrary. IF you use a debugger, you learn to avoid these dark mistakes because you catch them quite easily and find, oh no, I really must add this and that to avoid all these silly mistakes in the future.

    Btw brewbuck, if it looks like I know everything and I'm right and you're wrong, then I'm sorry. I never do mean it that way. I was simply disagreeing with your way, nothing more. I don't claim anyone of us are right.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting a C# program with a manifest file to run in the debugger
    By Xarzu Athanasop in forum C# Programming
    Replies: 0
    Last Post: 01-18-2008, 06:34 PM
  2. executing from debugger
    By hedwin in forum C++ Programming
    Replies: 8
    Last Post: 10-11-2007, 04:05 PM
  3. Replies: 3
    Last Post: 07-24-2007, 04:25 PM
  4. MSVC++ Debugger (it kills me)
    By lightatdawn in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 06-29-2002, 07:37 PM