visual studio features - sluczak/cpp_by_example GitHub Wiki
streams
Return to the previous lessonSelected Visual Studio 2013 features
Visual Studio is a powerful tool, but we should focus on several basic functionalities.
This page is supposed to be a reminder of basic execution and debugging process tools.
Screenshots below were captured in VS2013 Professional, but most of the interface should be corresponding with Express Edition.
Main solution view
Visual Studio specifies an artifact of "solution". Solution is a project set, some kind of folder in which user may store several projects, which may, but don't have to be self-dependent.
Following screenshot highlights several points of screen with opened solution:
- Solution Explorer - shows all the projects inside of specific solution. Here you can manage your .cpp and .h files, define dependencies and project settings.
- Local Windows Debugger button - this button is used to run the application. Visual Studio assumes that every application run should be performed in debugging mode, therefore there is no option to simply "run the application". VS re-compiles application automatically, if any changes has been made on project files.
- Editor area - here you can write the code of your application. Editor alows you to open several files in separate tabs.
Debugging features, before running
- Breakpoint - Breakpoint makes program execution stop on desired line of code. Programmer may set a breakpoint on each non-empty line of code by clicking left mouse button on the gray border of editor, or by clicking right mouse button on the line of code and selecting "Breakpoint->Insert breakpoint"
- Run To Cursor - Selecting this contextual option runs the application down to the selected line of code. It is some kind of a breakpoint-on-demand. Hint: a very useful option during the SW development and debugging.
Debugging features, while debugging
After starting the debugging process (by selecting Local Windows Debugger or Run To Cursor option), user interface slightly changes:
- Continue (F5) - This button is shown only when debugger "stays" on the breakpoint. It lets you resume the program execution from the point where it stopped.
- Stop (CTRL+F5) and Restart (CTRL+SHIFT+F5) - this buttons lets you quickly stop or restart the application execution
- Debugger navigation buttons - When debugger "stays" on the breakpoint, programmer may manually proceed execution step-by-step and investigate further the details of execution. Buttons in this group may come in handy in such situations.
- Yellow arrow - current location of debugger - this arrow shows the current location of debugger in the source code. Please notice the movement of the yellow arrow, when you press the buttons from 3. section. Here we can see, that debugger stays on the 7th line, directly on the breakpoint.
Debugging features, bottom part of screen
Debugger allows not only to have a control over the program execution process, but also provides rich information about current status of variables etc.
- Variable details - this element shows the currently assigned values of variables and threads. What is more, programmer may change the assigned values by double clicking the "value" cell, next to the variable name, for ex. in order to check the reaction of application for a specific value.
- Stack trace - here you can check the call stack of functions in your application. In this simple application there is only one function (
main()
) on stack, but in future, you will see many nested functions. Clicking on the function name will direct you to the file that contain its definition and the proper line of code.