How to debug in the Cloud Shell Editor - SimplyFaisal/sps-team-39-project GitHub Wiki

How to enable the debugger in Cloud Shell Editor

The debugger in the Cloud Shell Editor can be enabled with a little bit of configuration:

1. Set a remote debug configuration

First we have to set up a debug configuration that tells the debugger how to actually attach to our application. Click on the bug icon on the left hand side of the editor. Then click on the drop down to the right of the green arrow. Select the "Add Configuration" option. This should open a launch.json file in the editor with several options. Scroll down and click "Java: Attach to Remote Program". Add the following to the configuration "configurations" list:

{
   "type": "java",
   "name": "Debug (Attach) - Remote",
   "request": "attach",
   "hostName": "localhost",
   "port": 8000
}

2. Set a break point

Set a break point by navigating to your code and clicking to the left of the line number that you want the debugger to break at.

3. Start the application in debug mode

The web application must be started in "debug" mode. This can be done by running the application using the mvnDebug command: mvnDebug package exec:java. You should see the following output in the console:

Preparing to execute Maven in debug mode
Listening for transport dt_socket at address: 8000

Up until now you've been using the mvn command to run your application. mvnDebug differs from mvn in that it passes additional commands to the Java Virtual Machine which enables a debugger to "hook" into your running application.

4. Launch the debug configuration

Return to the debug panel. Make sure the debug configuration that you set up in step #2 is displayed next to the green arrow. Click the green arrow. You should see a lot of output in the console as your application is launched. Click the web preview button near the top right and navigate to the page that triggers your break point. Return to the editor and your code should be paused at the breakpoint that you set in step 3.