Thread: debugging

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    630

    debugging

    Hello

    I've been programming for about 3-4 years and using MSVC 2005 at the moment.
    However, I havent used the MSVC debugger until now because I didnt know how to use it..

    Are there any tutorials, any helpful/beginner tips?

    I would really like to learn how to use it.

    I used std::cout to print the data (to fix the bugs) and see the point that program reaches.

    Thanks a lot for help

    Regards

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    If I remember correctly, I learned the debugger from a single chapter in my first book plus playing with it a lot. For an introduction, Google produces some info.

    http://ei.cs.vt.edu/~cs1205/c_debug/intro.html
    http://www.cs.iit.edu/~resource/supp.../vc_debug.html

    The two links may be for VC++6, but the basic functionality is the same as in later versions, only the UI may have changed a little.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > I used std::cout to print the data (to fix the bugs) and see the point that program reaches.
    When you next use this technique to find a bug, and subsequently fix it, add the bug back into the code and try and find it again using the debugger (knowing more about what you're looking for).

    Most of the time, it's just
    - breakpoints to halt the program
    - step, step into, step over to control the execution
    - watch variables, to replace your debugging 'cout' statements.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    630
    How to recover memory leaks?

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    http://msdn2.microsoft.com/en-us/lib...e9(VS.80).aspx

    1. You enable this feature in your code.
    2. You run the program, and at the end you'll get a list of leaked blocks. Along with each block is an allocation number.
    3. The next time you run the program, you can use the allocation number to 'break' when that block is allocated once more. You then trace carefully to see who ultimately owns that block, and from that perhaps understand why they failed to free it.

    As with all things, practice on a small program which say calls malloc twice and free once.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    May 2006
    Posts
    630
    Thanks for help..
    Sorry, but how can I enable this feature in MSVC 2005?

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    630
    I found this website: http://msdn2.microsoft.com/en-us/lib...h3(VS.80).aspx
    Seems like it works!

    Thanks again.

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, 10: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