Restriction: This topic applies to native COBOL only.
To debug a Windows service you must be logged on to the console of the computer running the service.
You can debug the service either using library routines or using JIT debugging.
Using library routines
If you are using
a Visual Studio project to build the Windows service:
- Start
Visual Studio as an administrator.
- Add a call to CBL_DEBUGBREAK or CBL_DEBUG_START in the application.
- Configure your project properties to launch using
Wait for application attachment.
- Start
debugging.
- When CBL_DEBUGBREAK or CBL_DEBUG_START is executed,
Visual Studio starts debugging the service.
If you use CBL_DEBUG_START you can then use CBL_DEBUG_STOP to detach the debugger from the application, which resumes running
without the debugging features.
If the Windows Service is not built in a project, you need to specify the path to the Service's
.idy files, and the Service must include calls to CBL_DEBUGBREAK or CBL_DEBUG_START:
- Start Visual Studio as an administrator.
- Open the main COBOL program file for your service.
- Using the banner at the top of the editor, browse for program symbols files (.idy files) and add them to the program properties.
- Add a call to CBL_DEBUGBREAK or CBL_DEBUG_START in your Windows service code.
- Run your Windows Service.
- The debugger starts automatically when CBL_DEBUGBREAK or CBL_DEBUG_START is executed.
If you use CBL_DEBUG_START, you can then use CBL_DEBUG_STOP to detach the debugger from the application, which resumes running
without the debugging features.
Using JIT debugging
- Enable just-in-time debugging.
- Add a call to CBL_DEBUGBREAK or CBL_DEBUG_START in your Windows service code.
- Run your Windows Service.
- The debugger starts automatically when CBL_DEBUGBREAK or CBL_DEBUG_START is executed.