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%

How do you like to debug?

This is a discussion on How do you like to debug? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I prefer to make programs without flaws in it . If they do appear, I look at the faults I ...

  1. #16
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    I prefer to make programs without flaws in it . If they do appear, I look at the faults I get, think of what might cause them, then correct it. Sometimes I use printf/cout/MessageBox to see if a certain piece of code is running or not, and what value it has.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #17
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    >for(int i = 0; i < strlen(char_array); i++)

    Should be:

    for(unsigned int i = 0; i < strlen(char_array); i++)

    If you start accepting warnings, you will not easily pick out important ones. Things like:

    if (a = b)

    Warning : Probable incorrect assignment

    With regard to your floating point example, I don't [think] I get a warning for this, but I'm probably using a different compiler.

    However, you can probably make the warning go away with:

    nvar = (int)fvar;

    I suppose it could be argued that this overly explicit.

  3. #18
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by face_master
    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;
    How about nVar = (int)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++)
    That error has never showed up for me, but then I rarely use that way either since the middle argument is recalculated in every iteration, thus a lot of calls to strlen(). It's better to have a temporary variable storing the length of the string (I assume it never changes size) and use it in the comparison instead.
    If you still get warnings, use a casting or change the variable as you said...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #19
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by face_master
    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++)
    That's why you'd explicitly type-cast. Then, it's very apparent that you want the conversion to occur. It should make your warnings go away as well.

  5. #20
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    i usually use the debugger for errors, but, non syntax related bugging (logic mistakes) i usually go and strip down all the fluff and print out variables as i go. That's the best approach in my opinion...pen and paper helps too.
    PHP and XML
    Let's talk about SAX

  6. #21
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    I usually use printf to see at the terminal what the devices I'm debugging are doing, also a logic analyser or other tracing tool is very usefull. And ofcourse, as Waldo2k2 also mentioned, analysis of debug logging with pen and paper is also very usefull.

  7. #22
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    How do I like to debug?

    I don't

  8. #23
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    i never found a use for my debugger. i cant figure out how to work with breakboints and whatnot so i basically reply on chance (call me stupid, but thats how i work). with C++ i go like this:

    i program the whole goddamned thing out, and i just KNOW im going to get errors. so i click "build", it starts to build it and gives me a WHOLE slew of errors, i go through each one and fix them, once thats all completes (takes from 5 minutes to a whole 4 days) i build it all again and it works and everything is good.

    my method is slow but it works.

    can someone tell me how to use the debugger in bloodshed dev c++? or at least tell me how to work with breakpoints and the debugger???
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

  9. #24
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    coding is like piece of cheese. think about that for a minute.
    hmm...
    it has holes in it, sometimes it stinks, and it goes great with ham??
    PHP and XML
    Let's talk about SAX

Page 2 of 2 FirstFirst 12
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, 12: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

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