Thread: Do you use a debugger?

  1. #1
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794

    Do you use a debugger?

    When I was a novice programmer I sometimes used a debugger. but now that I have a sound grasp of C and and the mistakes a novice would make I find I do not need to use one at all,
    I find any mistakes I make are usually typing errors etc or simply common oversights which I
    can fix immediately.
    So how many of you use a debugger?

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    I have a sound grasp of C
    Oh, God!! You make me laughing...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    This only proves you've never worked on a complex program, nothing more than hello world it seems.

    > I find any mistakes I make are usually typing errors etc or simply common oversights which I can fix immediately.
    Yes... but *how* do you find them?

    I use a debugger to answer your question.

  4. #4
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I thought it would be fair to repost to what you are responding to, esbo. Tear it apart as you see fit:
    Quote Originally Posted by citizen View Post
    Quote Originally Posted by esbo
    This is probably why I don't use a debugger, it is easy to get bogged down in the detail,
    it is usually better to step back and think about what is going on and often quicker, also
    I have known programs which run fine when you compile in debug mode but crash when you
    compile it normally!
    I manage on a few debug printf statements, more thought, less data which is better than
    megabytes of data but little thought about what might be wrong!
    Well, we've really strayed from the matter at hand thanks to esbo entirely. Somehow, now we're stuck discussing what you feel to be proper practice. We may as well discuss it somewhat seriously. Maybe we'll change your mind one of these days.

    Quote Originally Posted by esbo
    I have known programs which run fine when you compile in debug mode but crash when you compile it normally!
    I have written programs which run fine when you compile in debug mode but crash when you compile it normally!
    Fixed!

    On the whole I imagine that these programs are simply poorly written on your part. The whole purpose of debug mode is to find and fix problems; I can't imagine why it's okay to do it bass ackwards and expect that a release build makes it possible to encounter all the bugs you sneak in. I mean, I depend on my debugger to break execution when the program is about to crash. At least I likely know the area of the problem after that.

    I'm not really against people stepping back and thinking, as you noted, but programmers who deserve to be employed already learn to do that. You're also endorsing a system of development that saps their productivity:

    The whole notion that you can effectively debug a large project with printf's seems like a bit of a fallacy to me. I can't imagine working on even an open source project where volunteers were depending on printf to bump into errors. To track down a segmentation fault somewhere without the aid of another tool, for example, you would have to bloat your part of the code base considerably with printf calls and write sufficient wrappers for them so all those extra calls aren't compiled at all when you want to release. You probably won't agree with me here, but that seems like an excellent way to tack on kilos of useless information to your intermediate executables. Such a waste of effort! Because even after all of that you still have to hope that you made an appropriate guess at the problem area, then actually fix it.

    I'm assuming one hell of a bug, but they happen to people and programmers quite indiscriminately.

  5. #5
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Citizen, if you feel you need to change my quotes, by editing them, to make me look a fool
    then you are the fool.

  6. #6
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    People can easily read what you actually wrote. It's also a simple matter for them to go to the original thread and read what I said there, what you said there, and how the discussion was curtailed into this. Please make no frivolous accusations.

  7. #7
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    Quote Originally Posted by esbo View Post
    So how many of you use a debugger?
    Every experienced programmer on this forum and many programmers that are still learning. I didn't bother to count.
    Don't quote me on that... ...seriously

  8. #8
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by esbo View Post
    So how many of you use a debugger?
    There's no such thing as even an intermediate level programmer that doesn't use a debugger.
    If you don't use a debugger, you are nothing but an absolute beginner.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  9. #9
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I would be 100% completely lost without the debugger. It is my best friend (although MSVS debugger does not always play nice with threads).

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    now that I have a sound grasp of C and and the mistakes a novice would make I find I do not need to use one at all
    I find that my own experience is the opposite: when I am new to something (be it the programming language or when experimenting with a library), it is easiest to use the "find the smallest and simplest (compilable) program that demonstrates the error" technique, and of course for a small and simple program I can visually inspect the output to see what happened. With a larger project, it becomes infeasible to use this for the entire project, thus a debugger becomes very useful.
    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

  11. #11
    Registered User
    Join Date
    Feb 2008
    Posts
    19
    I'm just a noob at C, but usually the compiler output gives a good insight of the mistakes you made, and where you did. Or not?

    I have to learn how to debug yet

  12. #12
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    but usually the compiler output gives a good insight of the mistakes you made, and where you did. Or not?
    Compiler just checks the syntax - not the logic
    If you forget to increase your loop counter - you get the infinite loop compiler will not warn about...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  13. #13
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    Actually i have used debuggers not so much either, but it is nice to be able to BREAK the program at the SUSPICIOUS function entry and go a few steps to see exactly what the series of some complex statements one might need to have written actually perform on data.

    I use gdb, or some frontends of it, but usually as i am at the console working, the fast and furious method of invoking gdb like make xxx && gdb ./xxx is console power to the extrema. Besides you never have to leave your hands off the keyboard that way. :P

    Another nice case for using a debugger is conditional breaking in a loop that goes millions of times, when a specific condition is met. Doing the same debugging with printf's is also possible, but might overflow your screen with messages.
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

  14. #14
    Registered User
    Join Date
    Jan 2008
    Posts
    69
    Sorry, esbo, I use a debugger. I guess I've doomed myself to never having a "sound grasp of C."

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    When there is a debugger available for the system I'm programming, I will use it. Sometimes there is no real debugger available, in which case you have to resort to other debug techniques.

    If the application is small, then the debugger isn't quite as necessary as when you have a large code-base. When YOUR sub-system that you work on is 100K lines out of a whole system of 1M lines, then it tends to be impossible to understand ALL of the code all of the time - some of the code may well be written by someone who is a couple of levels sharper than you in the particular area that you need to debug.

    --
    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.

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