Debugging with VS Code
The Genero BDL VS Code extension can be used to debug programs with VS Code debugger capabilities.
VS Code extension setup
Genero BDL provides a VS Code extension to be plugged into your VS Code editor. Setup instructions to install the VS Code extension for Genero BDL are provided in Visual Studio Code extension.
Once the VS Code extension for Genero BDL is installed, you can debug your programs from the VS Code editor.
Using the Launch task
-
Select the .4gl source containing the
MAIN
block. -
Select (4gl) Launch.
: This will execute the selected launch task, by default it will be -
The program starts in debug mode, and debugger stops at the first instruction of the program. You can control this with the
"stopAtEntry"
property in your launch task (check tasks.json configuration file). -
Go to the DEBUG CONSOLE panel: The prompt at the bottom allows you to evaluate expressions (for example, type sqlca + enter)
-
Go to the source code, and add a break point in one of the next lines.
-
Continue the program with F5, the program continues until the break point.
-
Right-click on the break point, and edit the break point (to add for example a condition)
Using the Attach task
VS Code can attach to a running fglrun
process.
With VS Code having a folder opened with the source code of your project, start an attach debug session as follows:
-
Go to the TERMINAL panel or go to another terminal emulator, and start a program with GUI interface, using the same Genero environment.
-
In VS Code, select the Run and Debug option, choose (4gl) Attach, start debugging (F5), then choose a running fglrun process.
-
The program should stop at the current instruction, and you can debug the source code.
Several debug sessions are possible. For example, when a program starts a child program with
RUN
, another debug session will start.
Debugging a TUI program
-
In the environment, make sure that TERM and INFORMIXTERM variables are properly set to display program forms in your terminal emulator, for example:
$ export TERM=xterm $ export INFORMIXTERM=terminfo
-
Start VS Code with this environment set.
-
In the launch.json file, modify (or copy and modify) the "(4gl) launch" task to set the
externalConsole
property totrue
:
This will enable TTY output of fglrun to the TERMINAL panel."externalConsole": true,
-
Select the program source to execute.
-
Select the Run and Debug option and start the modified launch task.
-
Click on Continue or press F5 to give the control to the runtime system.
-
The TUI program interface should display in the TERMINAL panel.
-
To switch to the TERMINAL panel, remember using the CTRL-` shortcut.
-
To automatically give the focus to the TERMINAL panel when continuing with F5, configure a custom F5 shortcut as follows:
-
Go to
. -
Click on the Open Keyboard Shortcuts button on the top right corner.
-
Append new key bindings as follows:
- When paused, to continue (or start) program execution and give the focus to the
terminal:
{ "key": "f5", "command": "runCommands", "args": { "commands": [ "workbench.action.debug.continue", "workbench.action.terminal.focus" ] }, "when": "debugState==stopped && debugType==fgldb-dap && terminalIsOpen" }
- When paused, to step over the current line of code and give the focus to the
terminal:
{ "key": "f10", "command": "runCommands", "args": { "commands": [ "workbench.action.debug.stepOver", "workbench.action.terminal.focus" ] }, "when": "debugState==stopped && debugType==fgldb-dap && terminalIsOpen" }
- When paused, to step into a function and give the focus to the terminal:
{ "key": "f11", "command": "runCommands", "args": { "commands": [ "workbench.action.debug.stepInto", "workbench.action.terminal.focus" ] }, "when": "debugState==stopped && debugType==fgldb-dap && terminalIsOpen" }
- When paused, to step out of the current function and give the focus to the
terminal:
{ "key": "shift+f11", "command": "runCommands", "args": { "commands": [ "workbench.action.debug.stepOut", "workbench.action.terminal.focus" ] }, "when": "debugState==stopped && debugType==fgldb-dap && terminalIsOpen" }
- When paused, to continue (or start) program execution and give the focus to the
terminal:
-
-
To get a separate TERMINAL window:
-
Open the command palette with CTRL-SHIFT-P
-
Type "Create a new terminal in the editor area", select the command, this creates a new TERMINAL panel in the editor area.
-
Drag & Drop the new created TERMINAL panel outside the VS Code main window.
-