http://www.dotnetperls.com/debugging has a few basics until I finish this tutorial.

What is a debugger?

A debugger is for viewing the values of your variables while your code is executing. This should make it easier for you to compare what your code is actually doing with what you intended it to do.

Breakpoints

You begin debugging by stopping your program at a certain line. You do this by inserting a breakpoint. Once you begin executing your code, the breakpoint will stop your code when it gets to that line. If you have some idea of which part of your code is producing an error, you will stop the program there. Otherwise just stop the program near the beginning.

  • Insert a breakpoint by positioning your cursor on the preferred line.
  • Right click and select to insert a breakpoint.

Breakpoints.jpg

Once you execute your code, it should stop or break once it reaches this line. If it doesn't, your breakpoint is probably not reachable with the way the code is currently written or the inputs the program is given.

Stepping through your program

Once you begin executing your program and hit a breakpoint, you have several options with how to step through the program from that point. The buttons that allow you to do this will appear once you begin executing or running your program. They will be on the top toolbar, as seen in picture below, circled in red.

  • Step into: When you select stepping into, the code will execute the entering of a function and then stop again.
  • Step over: When you select stepping over, you are choosing to go to the next step without viewing any of the code within a function.
  • Step out: When you select stepping out, you are choosing to allow the rest of the code in a function to execute without stopping until you reach the end of that function and return to the code that called that function. At that point, the code will once again stop executing.

To the left of these buttons is the second green arrow. Pressing this button will run the program until it encounters another break point. This is helpful when you don't want to step through every instruction in a loop.

cs-142/debugging-in-visual-studio.txt · Last modified: 2015/01/07 09:12 by ryancha
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0