# Remote Debugging Scenario

This topic applies to Fortran applications for Windows only.

The remote debugging scenario described here includes the cross-platform and cross-compilation remote debugging features. The following parameters apply:

Host platform: | IA-32
Remote platform: | Intel® 64
Name of host machine: | HOST_MACHINE (domain name of host machine)
Name of remote machine: | REMOTE_SERVER (domain name of remote machine)
Host OS: | Windows* 10 - 32 Bit
Remote OS: | Windows 10 - 64 Bit
Executable for debugging: | Win64 (x64)
Type of executable: | Console application
Microsoft Visual Studio*: | Microsoft Visual Studio 2017 or 2019 ### Note Support for Microsoft Visual Studio 2017 is deprecated as of the Intel® oneAPI 2022.1 release, and will be removed in a future release.
Connection types: | Remote with/without Windows authentication
Sessions: | Remote debugging, remote execution, attach to process on a remote machine

1. HOST_MACHINE

   Start Microsoft Visual Studio 2019 on the host machine (HOST_MACHINE).

2. Create a new console application; for this example, use remote_2019.

3. Add the following lines to the remote_2019.f90 file:

       REAL, DIMENSION(1) :: xxx = 0
       PRINT *, 'Type one number: '
       READ  (*,'(F10.3)') xxx

4. Open Project > Properties and create a new platform configuration for x64 using the Configuration Manager.

5. Make sure, that current (target) configuration is Debug|x64 and build the solution (Build > Build Solution). This invokes the cross-compiler and causes the 64-bit executable file remote_2019.exe to be built.

6. Run the remote_2019.exe application to make sure that it is 64-bit code. An error should result, explaining that it is not a valid Win32 application.

7. Run the Remote Desktop Connection program (%SystemRoot%\System32\mstsc.exe) and connect to the remote machine (REMOTE_SERVER).

8. Create C:\remote_dir on REMOTE_SERVER and copy remote_2019.exe from HOST_MACHINE to REMOTE_SERVER.

9. On the HOST_MACHINE open the remote_2019.f90 source file in the Visual Studio editor.

10. Set a breakpoint at line 27.

11. Open Project > Properties and select Debugging. In the Remote Settings section, set the following properties:

    Connection: Remote with Windows authentication

    Remote Machine: REMOTE_SERVER

    Remote Command: C:\remote_dir\remote_2019.exe

12. Press F5 to start debugging.

    If there is a firewall you will get an Unable to start debugging error message. In this case go to REMOTE_SERVER, locate, and run the Remote Debugger application (64-but mode). Find msvsmon.exe in the location where it was installed, or open the Start menu and search for Remote Debugger. Go back to LOCAL_SERVER and press F5 to start debugging.

13. Go to REMOTE_SERVER and make sure that the remote_2019 application is started.

14. Type 5 and press Enter. Go back to HOST_MACHINE.

15. Verify that the Debugger reaches the breakpoint at the line 27.

16. Open the Locals window and make sure that value xxx is 64-bit.

17. Press Shift+F5 to stop debugging and terminate the application on the remote server.

18. Open the project properties again, select Debugging, and set Attach to Yes.

19. Press Ctrl+F5 (remote execution).

20. Press F5 for attaching to a process.

21. Repeat steps 12-17 to check that the attach to process works correctly.

22. Open Project > Properties and set Attach to No.

23. Open Project > Properties and set Connection to Remote with no authentication (Native only).

24. Go to REMOTE_SERVER and switch debugging monitor to No Authentication mode using the Tools > Options menu.

25. Repeat steps 12-22 to check that Remote with no authentication (Native only) mode works correctly.

## Results of Remote Debugging Exercise

The results of this remote debugging exercise for Microsoft Visual Studio 2019 are summarized in the table below.

Connection Type | Session | Result | Debugging Monitor status
--- | --- | --- | ---
Remote with Windows authentication | Debug (F5) | Works | Monitor should be run in Windows Authentication mode.
Execute (Ctrl +F5) | Works
Attach to Process | Works
Remote with no authentication (Native only) | Debug (F5) | Works | Monitor should be run in No Authentication mode.
Execute (Ctrl +F5) | Works
Attach to Process | Works

Parent topic: Using Remote Debugging