Tutorial 3: Running and Debugging Your Code

Tutorial 3: Running and Debugging Your Code

Running Code in Visual Studio Code

In this tutorial, we’ll explore how to run and debug our code using Visual Studio Code, our integrated development environment (IDE) of choice.

Using Launch Profiles

Launch profiles in Visual Studio Code allow us to configure how our code is executed and debugged. We’ll set up a launch profile to run our code within the context of an OpenFlow instance.

  1. Open your project in Visual Studio Code.
  2. Navigate to the Debug view by clicking on the debug icon in the activity bar on the side or pressing Ctrl+Shift+D.
  3. Click on the gear icon to open the launch.json file, which contains the configurations for debugging.

Debugging Code

Debugging allows us to inspect and troubleshoot our code as it runs. We’ll set breakpoints and step through the execution of our code.

Setting Breakpoints

  1. Navigate to the source code file where you want to set a breakpoint.
  2. Click on the area to the left of the line number in the code editor to set a breakpoint. A red dot should appear, indicating that the breakpoint is set.

Stepping Through Code Execution

  1. Start debugging by selecting the appropriate launch configuration and clicking on the play button in the Debug view.
  2. Once your code hits a breakpoint, you can inspect variables, step through lines of code, and observe the state of your program using the debugging controls provided by Visual Studio Code.

Congratulations! You’ve learned how to run and debug your OpenFlow Agents code in Visual Studio Code. In the next tutorial, we’ll explore how to deploy your code as a package.