Debugging?

This is a discussion on Debugging? within the C++ Programming forums, part of the General Programming Boards category; Since the day i started programming ; i've been using premitive methods to debug my programs (they weren't big in ...

  1. #1
    former member Brain Cell's Avatar
    Join Date
    Feb 2004
    Posts
    472

    Post Debugging?

    Since the day i started programming ; i've been using premitive methods to debug my programs (they weren't big in general anyway). So i found about these debugging techniques , the only thing i know about them is their names :

    1. Break points.

    2. Step into.

    3. Watchers (or watches).

    and a few more i can't recall.


    Is there a tutorial or a guide that shows me how to use these stuff to hunt errors in my programs?


    thanks for your time.
    My Tutorials :
    - Bad programming practices in : C
    - C\C++ Tips
    (constrcutive criticism is very welcome)


    - Brain Cell

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    Would help to know what IDE/Debugger you are using?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    former member Brain Cell's Avatar
    Join Date
    Feb 2004
    Posts
    472
    sorry i forgot to mention that. Visual C++ 6.0
    My Tutorials :
    - Bad programming practices in : C
    - C\C++ Tips
    (constrcutive criticism is very welcome)


    - Brain Cell

  4. #4
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712
    Here, Brain Cell I think this will help you:
    http://www.cem.uvm.edu/~upe/resource.../visualCDebug/
    Good Luck!
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    2. Step into.
    Allows you to step through your code line by line and watch what happens. To start debugging try: Build(menu item)>Start Debug>Step into. After you do that, you should see a toolbar appear with some braces and arrows. If you hover your cursor over each brace/arrow combination, a tool tip will popup identifying those icons as: step into, step over, step out, run to cursor.

    Start with step into and see what happens. The problem you may encounter with step into is that it steps into all functions, and if you step into a standard library function, the code will suddenly be unrecognizable. When that happens, don't panic--just click on 'step out' to get out of the function. After you play around with 'step into' and 'step out' you will get the hang of . If you anticipate when you are going to dive into a standard library function that you don't want to see, like any line with cout<< in it, then click on step over--the function will still execute, you just won't go inside it.

    Run to cursor is kind of neat: after you start debugging, just click your cursor on a line, and then click on the 'run to cursor' icon--execution will occur at normal speed until the line with the cursor on it is reached, whereupon execution will halt.

    3. Watchers (or watches).
    The variables that are encountered in the program appear automatically in one of the panes, but if there is one you want to isolate, you can set a watch variable in the Watch pane. The easiest way to do that, is left click on the variable name if it is currently visible in one of the panes(for me it's in the left pane), and while holding the left button down, drag the name over to the Watch pane(for me it's on the right) and release it. For some reason, when you drag the name, a "do not enter" icon will display-- like you are doing something wrong--but if you ingnore it and continue dragging the name over to the Watch window, you can drop it and it will be set as a watch variable. Or, you can just type the variable name in the Watch pane.

    You may notice that some variables, like objects of a class, can be expanded by clicking on the + sign next to their variable name, which allows you to see all their members.

    1. Break points.
    You set breakpoints before debugging starts. The idea is to set a break point, and instead of clicking Build>Start Debug>Step Into, you click on Build>Start Debug>Go. The program will execute at normal speed until it encounters a breakpoint, and then execution halts. I set breakpoints using the Build mini bar. The Build mini bar has the Build and Execute icons on it. It also has a hand icon. The hand icon is for setting breakpoints. Set the cursor on the line you want, and click on that hand icon, and it will add a maroon dot to the left "gutter". Then, click on Build>Start Debug>Go.

    I got a coupon with my VC6 compiler that allowed me to send away for a substantial MS book(700 pages) that is a VC6 instruction manual, so I can look something up if you are having problems with a feature, or some of the pros probably know the whole thing by heart.

    Good luck.
    Last edited by 7stud; 03-29-2005 at 05:52 PM.

  6. #6
    former member Brain Cell's Avatar
    Join Date
    Feb 2004
    Posts
    472
    Micko : that link is great ! thanks

    7stud : Thank you so much for your reply. I haven't thought i could use all of these stuff right away.
    My Tutorials :
    - Bad programming practices in : C
    - C\C++ Tips
    (constrcutive criticism is very welcome)


    - Brain Cell

  7. #7
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Quote Originally Posted by Brain Cell
    7stud : Thank you so much for your reply. I haven't thought i could use all of these stuff right away.
    Just write a simple Hello World program with one function, and start playing around with the debugger.

  8. #8
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712
    Quote Originally Posted by Brain Cell
    Micko : that link is great ! thanks

    7stud : Thank you so much for your reply. I haven't thought i could use all of these stuff right away.
    I'm glad you find it useful!
    And also, thank you 7stud for your time and effort!
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev-C++: Problems with Breakpoint Debugging
    By Thileepan_Bala in forum C Programming
    Replies: 1
    Last Post: 01-17-2008, 09:48 AM
  2. Problem in debugging in Eclipse
    By Bargi in forum Linux Programming
    Replies: 1
    Last Post: 08-21-2007, 09:53 AM
  3. Debugging Dev C++
    By tuurb046 in forum Tech Board
    Replies: 10
    Last Post: 08-16-2007, 12:51 PM
  4. Debugging book recommendation
    By dagans in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 09-13-2005, 07:35 PM
  5. debugging directx apps
    By confuted in forum C++ Programming
    Replies: 1
    Last Post: 08-16-2003, 08:56 AM

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