Featured

    Featured Posts

Debugging.

Debugging :->

     It is the process of making a program free from bug.  Bug can be defined as an unexpected value hold by the variable which makes the program to give wrong result.
        Bugs are errors in your program and debugging is the process of finding and eliminating them and debugging is an integral part of the programming process.  Every program that you write may contain bugs that you will need to try to expose find and eliminate if your program is to be reliable and effective so there are 3 phase:
  • A program bug is not necessarily apparent.
  • When it is apparent you may not know where it is your source code.
  • When you know roughly where it is it may not be easy to determine what exactly is causing the problem and thus eliminate it.
  • Many programs that you write will contain bugs even after you think you have fully tested them.
  • Program bugs can remain hidden in a program that is apparently operating correctly sometimes for years.
  • Programs beyond a certain size and complexity will always contain bugs.
Many potential bugs will be eliminated during the compile and link phases, but there will be quite a few left, even after you manage to produce an executable module for your program.  There are 4 broad strategies you can adopt to make debugging as possible.

-> Don't re-invent the wheel.  Understand and use the library facilities provided as part of VC++.  SO that your program uses as much pre-tested code as possible.
 -> Develope and test your code incrementally.  By testing each significant class and function individually
-> Code defensively - which means writing code to  guard against potential error.
-> Include debugging code that checks and validate data and conditions in your program from the outset.

# Debugging Toolbar :->

        Debugging has its toolbar of its own.  This is selected by.
Menu -> View -> Toolbar -> Debug.
This toolbar appear like this

Setting the Breaking Point :->

  • Place the cursor or caret where we want to set the break point in the program.
  • Press Fa key or click the button in the toolbar with a upraised hand icon.
  • This set the break point at that line where we have placed the cursor or caret.
    After setting the break points we can single- step through our code.  One line at a time by processing the F10 key, pressing that key once moves us to the next line of code.

# Removing the Break points :->  To remove the break point we replace the insertion point caret on the break point code line and press Fa again to toggle the break point off.
# Common Bugs :->  A useful way of cataloging bug is to relate them to the symptoms they cause.  Since this is how you will experience them in the first instance.  There are fire common symptoms is by no means exhaustive.



Symptom
Possible Causes
 Data Corrupted
Failure to initialize variable invalid pointer
loop condition error
Exceeding Integers type range.
Unhandled Exceptions
Invalid pointer or reference missing catch handler
Program hang or crash
Infinite loop
Invalid pointer
Failure to initialize variable
Stream input output data incorrect
Reading using the extraction operator and the getline() function.
 Incorrect Result
Typographical error :- = instead of ==
Omitting break in switch statement.


Post a Comment

www.CodeNirvana.in

www.posthatke.com. Powered by Blogger.
Copyright © www.posthatke.com | Blogger Templates | Designed By posthatke.com