Do you use a debugger?

This is a discussion on Do you use a debugger? within the C Programming forums, part of the General Programming Boards category; When I was a novice programmer I sometimes used a debugger. but now that I have a sound grasp of ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,471
    I have a sound grasp of C
    Oh, God!! You make me laughing...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,627
    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
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,627
    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,293
    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
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    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
    21,401
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,471
    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...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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.

Page 1 of 4 1234 LastLast
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, 05: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21