debugging projects using c++.net click with the mouse button to control the flow of the presentation

14
Debugging Projects Debugging Projects Using C++.NET Using C++.NET Click with the mouse button to control Click with the mouse button to control the flow of the presentation the flow of the presentation

Upload: clifford-sullivan

Post on 12-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

Debugging ProjectsDebugging Projects

Using C++.NETUsing C++.NET

Click with the mouse button to control the flow Click with the mouse button to control the flow of the presentationof the presentation

Page 2: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

Three Debugging Three Debugging TechniquesTechniques

• BreakpointsBreakpoints

• Stepping Through CodeStepping Through Code

• Watching Values in VariablesWatching Values in Variables

Page 3: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

Setting BreakpointsSetting Breakpoints

• Right-click – with the mouse on the Right-click – with the mouse on the line of code to break atline of code to break at

• Select “Insert Breakpoint” – from the Select “Insert Breakpoint” – from the menu and a red dot will appear at menu and a red dot will appear at the beginning of the line.the beginning of the line.

Page 4: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

Using the BreakpointUsing the Breakpoint

• Click the Click the Debug menuDebug menu

• Click “Start” (or just press the F5 Click “Start” (or just press the F5 button)button)

The program will execute and will pause The program will execute and will pause when it reaches the breakpointwhen it reaches the breakpoint

Note the yellow arrow. It indicates the Note the yellow arrow. It indicates the next line of code to be executed. At next line of code to be executed. At this point there are some optionsthis point there are some options

Page 5: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

Breakpoint OptionsBreakpoint Options

• Peeking the Value Peeking the Value of the variableof the variable

Hold the mouse over Hold the mouse over the variablethe variable

• You can continue You can continue running the running the program by program by pressing pressing F5F5..

Page 6: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

The Debug ToolbarThe Debug Toolbar

• If your program is currently executing If your program is currently executing the toolbar becomes available and the toolbar becomes available and allows short-cuts to many of the debug allows short-cuts to many of the debug operations.operations.

• If at a breakpoint, the options to If at a breakpoint, the options to StopStop or to or to RestartRestart the program are available. the program are available.

• The Show Next Statement – option on The Show Next Statement – option on the toolbar will show the next line to be the toolbar will show the next line to be run.run.

Page 7: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

The Debug Toolbar (contd.)The Debug Toolbar (contd.)

The toolbar includes the following options: The toolbar includes the following options: Step intoStep into, , Step overStep over, and , and Step outStep out..

Page 8: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

•Step IntoStep Into

Allows the viewing of each line of code Allows the viewing of each line of code as it is being executed. If the line of as it is being executed. If the line of code calls an external piece of code, code calls an external piece of code, the IDE will go to the code and the IDE will go to the code and continue stepping line-by-line as continue stepping line-by-line as before.before.

Page 9: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

•StepStep Over Over

Allows the debugger to execute but Allows the debugger to execute but not step through a sequence of code. not step through a sequence of code. For example calling a function but For example calling a function but not stepping line-by-line through the not stepping line-by-line through the function.function.

Page 10: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

•Step OutStep Out

Allows the termination of stepping Allows the termination of stepping through code. For example if a through code. For example if a function is being executed with function is being executed with stepping – selecting “Step out” will stepping – selecting “Step out” will continue execution but the stepping continue execution but the stepping will stop until the execution return to will stop until the execution return to the function call line.the function call line.

Page 11: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

Debugging OptionsDebugging Options

• Menu – all options are available from Menu – all options are available from the the Debug MenuDebug Menu on the Menu bar on the Menu bar

• Keyboard Shortcuts – most common Keyboard Shortcuts – most common debug operations are available as debug operations are available as “Function Key” operations.“Function Key” operations.

Page 12: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

Function Key operationsFunction Key operations

• F5 – Start (with Debugging)F5 – Start (with Debugging)

• <Ctrl>-F5 – Start (without Debugging)<Ctrl>-F5 – Start (without Debugging)

• <Ctrl>-B – Set a New Breakpoint<Ctrl>-B – Set a New Breakpoint

• F10 – Step OverF10 – Step Over

• F11 – Step IntoF11 – Step Into

• <Ctrl>-<Shift>-F9 – Clear All <Ctrl>-<Shift>-F9 – Clear All BreakpointsBreakpoints

Page 13: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

WatchWatch

Watch allows the tracking of values in a Watch allows the tracking of values in a variable within the program. To create a variable within the program. To create a “Quick Watch”:“Quick Watch”:

• Press F11 to start Stepping into the codePress F11 to start Stepping into the code

• When the first line is marked with a When the first line is marked with a yellow arrow – right click on a variable.yellow arrow – right click on a variable.

• Then click Then click QuickWatchQuickWatch

Page 14: Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation

Watch (contd.)Watch (contd.)

• Click on Click on Add WatchAdd Watch

Don’t be surprised if you see an error Don’t be surprised if you see an error value (i.e. “CXX0072 Error: variables value (i.e. “CXX0072 Error: variables need stack frame”). It just means you need stack frame”). It just means you have not started yet.have not started yet.

• Click the “Close” Button on the Click the “Close” Button on the windowwindow

• Press F5 to allow the program to run.Press F5 to allow the program to run.