-
Notifications
You must be signed in to change notification settings - Fork 1
10 Debugger
-
The VS Code debugger can be used to start a process in debug mode (i.e., with the
-debugReady
parameter). However, most OpenEdge applications require database connections, startup parameters, and Propath settings. Therefore, the easiest way to work with the debugger is in "Attach" mode. In this mode, an external process is started in debug mode, and the VS Code debugger attaches to this process.First, let's create a new task to start an OpenEdge application. Add the following section to
.vscode/tasks.json
:{ "label": "My GUI Application - Debugger", "type": "process", "command": "/path/to/nowhere", "args": [ "-basekey", "INI", "-ininame", "conf/gui.ini", "-db", "sports2000", "-H", "localhost", "-S", "12345", "-cpinternal", "iso8859-15", "-p", "test2.p", "-nosplash", "-debugReady", "3099" ], "windows": { "command": "C:\\Progress\\OpenEdge-12.8\\bin\\prowin.exe" }, "presentation": { "reveal": "silent", "panel": "new", "focus": true }, "options": { "env": { "DLC": "C:\\Progress\\OpenEdge-12.8" } }, "problemMatcher": [] }
-
Execute this newly created task. You should see a message indicating that the 4GL (marketing department never used the debugger...) engine is not ready for debugging:
Click on OK to discard the message.
-
Open ProEnv, and execute
prodebugenable -enable-all
:proenv>prodebugenable -enable-all OpenEdge Release 12.8 as of Fri Apr 21 08:42:13 EDT 2023 ============================================================================== PROGRESS Debug Enabler ============================================================================== Debugging is enabled for the Progress 4GL installed in C:\Progress\OPENED~2.8. proenv>
Note that
proDebugEnable
requires elevated privileges (administrator rights). Since you are using an administrator account for this workshop, you did not encounter the usual permission dialog box. -
You can now restart the task. You should see a message indicating that the process is ready for debugging.
Click on OK to discard the message and execute the procedure. You should see a message window.
Press space bar to exit the ABL application.
-
We'll now create the debugger configuration in VS Code. Create a file named
.vscode/launch.json
with the following content:{ "version": "0.2.0", "configurations": [ { "name": "Attach to ABL process", "type": "abl", "request": "attach", "hostname": "localhost", "mode": "legacy", "port": 3099, "pause": true, "localRoot": "${workspaceFolder}" } ] }
-
Open the "Run and Debug" view by pressing
Ctrl + Shift + D
. You will see an entry in the dropdown menu at the top of the view. -
Start the GUI task again in debugger mode. When the "Use port 3099..." dialog box appears, click on the green arrow next to "Attach to ABL process". VS Code will switch to the "Debug Console" view.
-
Click the OK button in the "Use port 3099..." dialog box. The AVM session will suspend at line 12, as shown in the "Call Stack" panel. You can inspect the content of the variables in the "Variables" panel.
-
You can control the execution of the process using the debugging controls in the top center of the window. These controls allow you to continue, pause, step over, step into, and step out of the code.
You can also use the following keyboard shortcuts to control the execution flow:
- F5: Continue until the next breakpoint.
- F10: Step over (execute the next statement in the current procedure).
- F11: Step into (execute the next statement in the current procedure or in subprocedures).
- Shift + F11: Step out (execute until the next statement in the calling procedure).
-
Breakpoints can be set by clicking in the left gutter:
-
You can now experiment with the debugger. Here are a few examples:
- Add executable statements in an include file. The debugger will follow the include stack.
- Add buffers to temp-tables or database tables, and watch the content of those buffers.
- Add procedures, functions, and objects, then observe the call stack, parameters, and variables.