visual studio features - sluczak/cpp_by_example GitHub Wiki

Return to the previous lesson streams

Selected 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: CPP

  1. Solution Explorer - shows all the projects inside of specific solution. Here you can manage your .cpp and .h files, define dependencies and project settings.
  2. 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.
  3. 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

debug

  1. 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"
  2. 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:

debug2

  1. 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.
  2. Stop (CTRL+F5) and Restart (CTRL+SHIFT+F5) - this buttons lets you quickly stop or restart the application execution
  3. 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.
  4. 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.

debug3

  1. 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.
  2. 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.