View Poll Results: Which method of debugging do you use most?

Voters
28. You may not vote on this poll
  • A debugger

    8 28.57%
  • printf

    7 25.00%
  • cout

    7 25.00%
  • ofstreams and other file output methods

    3 10.71%
  • weight training so i can throw the monitor through the window with just one hand

    3 10.71%

Thread: How do you like to debug?

  1. #1
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743

    Question How do you like to debug?

    Well, how do you usually debug?
    My Website

    "Circular logic is good because it is."

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Lately; the debugger as all of my work has involved SDL and I haven't written a printing routine yet. But otherwise it's normally a combination of cout and the debugger, or MessageBox and the debugger if i'm programming with windows.

  3. #3
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    I dont think I have written a program longer than 1000 lines, so I usually use the printing way of debugging. I have never used a bebugger, I guess I should learn one day.
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  4. #4
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > I dont think I have written a program longer than 1000 lines,
    Wow, I've done that with BASIC(remember hello world is replaced by PRINT "Hell world!" and nothing else). Not that I'm bragging or anything..but, are you SURE? That seems...odd to me.

    And, I prefer my compiler's error output messages and a modular program.
    And if i'm not getting errors on compiling, I just fiddle till it's fixed.
    The world is waiting. I must leave you now.

  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >Well, how do you usually debug?

    I insert many, many breakpoints, isolate the problem, and then swear at it until it goes away.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  6. #6
    Evil Sock Puppet MadHatter's Avatar
    Join Date
    Nov 2002
    Posts
    176
    >swear at it until it goes away.
    that never works for me.. have any pointers? have you found particular words that work better?



    on-topic, i usually use cout.. though most bugs i have are from typos

  7. #7
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    bad subscript indexing usually goes away when you make bad jokes about its mother.
    hello, internet!

  8. #8
    Ecologist
    Join Date
    Aug 2001
    Location
    Utah.
    Posts
    1,291
    Sometimes I think the compiler screwed up, so I compile my
    project about 3 more times before I actually try to fix anything.
    Staying away from General.

  9. #9
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    I like your style, man.

    Well, if there's no butterfly effect type predicament, I simply comment out a function call until I nail it. Printing works good too, except in Windows sometimes (MSGBOXES can cause crashes, lol).

    99% of the time it's a dereferenced null pointer, and index violations of course.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  10. #10
    >>99% of the time it's a dereferenced null pointer, and index violations of course.

    Yup.

    I use a large combination of techniques. They all have their advantages. The debugger is useful for the stupid mistakes: The aforementioned dereferenced pointers, and index violations, but its not much good for those application specific bugs that dont cause crashing or OS specific errors. So my applications (Windows or otherwise) usually display a running debug output on top of the viewscreen. This way the last consecutivly called functions or areas of the program are displayed in the event of a lockup. Debug data is also always able to be output to file in case of a total system crash. Current functions being executed and any other possible data that can be gathered is also output to file in the event of unexpected termination.

    The worst ones are where you reboot and the problem refuses to surface again for three months, at which point you've completly forgotten about it.
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

  11. #11
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    BAH! My programs don't have bugs!

  12. #12
    Evil Sock Puppet MadHatter's Avatar
    Join Date
    Nov 2002
    Posts
    176
    >BAH! My programs don't have bugs!

    mine either. they just have "hidden features"

  13. #13
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    How bout exeptions? Personally, I think they're too much work - cant be bothered putting them all over the place...yeh and my programs seem to like adding their own little features to them selves

  14. #14
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    When I programmed in Delphi I used to make extensive use of the debugger. However, when I moved to the first version of C++ Builder, I had real problems with it. So I switched to using MessageBoxes. Later Borland fixed the problems with the debugger, but by that time I had lost all dependence upon it.

    Now I have my own DebugLog class which I used in all my projects. I puts everything to file, including class names, method names etc.

    >How bout exeptions? Personally, I think they're too much work

    Exceptions are a really good idea. They make your errors explicit, denying them a place to hide, and forcing you to fix them. However, I prefer the way Java forces the user to declare exceptions at method interfaces, which is even more work, but reduces errors.

    Here's tip. Never ever accept compiler warnings of any kind when compiling your project. Fix them. Years ago I used to ignore warnings because I thought I knew best, but consequently my programs were full of bugs. Now I won't accept them & I have far fewer bugs. In Java, there are no warnings, just errors. This is much better.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  15. #15
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Here's tip. Never ever accept compiler warnings of any kind when compiling your project. Fix them. Years ago I used to ignore warnings because I thought I knew best, but consequently my programs were full of bugs. Now I won't accept them & I have far fewer bugs. In Java, there are no warnings, just errors. This is much better.
    Yeh, but what about warnings like those that you're not worried about and are part of your code, like assigning an floating point variable's data to an integer's data, even though you may have wanted this rounding to occur, it still warns you. eg,,
    Code:
    int nVar;
    double fVar = 2.9;
    nVar = fVar;
    And how about in the following code:
    Code:
    for(int i = 0; i < strlen(char_array); i++)
    you would get a warning becuase the return type of strlen() is of unsigned int and you're comparing it to an int (i). Is it needed to change it to this?
    Code:
    for(unsigned int i; i < strlen(char_array); i++)
    Last edited by face_master; 12-11-2002 at 05:12 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary not built with debug info - why?
    By ulillillia in forum C Programming
    Replies: 15
    Last Post: 12-11-2008, 01:37 AM
  2. makefiles - debug & release?
    By cpjust in forum C Programming
    Replies: 6
    Last Post: 10-26-2007, 04:00 PM
  3. Debug --> Exceptions in Visual Studio 2005
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 08-10-2007, 02:12 AM
  4. Results in Debug and Release mode are different
    By jaro in forum C Programming
    Replies: 11
    Last Post: 05-27-2006, 11:08 AM
  5. Ask about Debug Assert Failed
    By ooosawaddee3 in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2002, 11:07 PM