Debug Server
The debug server is a separate server which whom the client (Visual Studio Code) communicates to debug a program. The debug server responds to commands to pause, step, and resume execution, step into, and out of functions. Breakpoints can be configured to pause the program at specific points in the code or when certain conditions are met (such as when an exception is thrown). Information about the current state of the program, including its stack and local variables, can be queried by the client.
Debugging a Program
To debug a program in the experimental Visual Studio Code instance, add the
PAPLJ Debug
launch configuration to the project. It looks like this:
{
"version": "0.2.0",
"configurations": [
{
"type": "paplj",
"request": "launch",
"name": "PAPLJ Debug",
"program": "${workspaceRoot}/program/bintree.pj",
"stopOnEntry": true
}
]
}
This debug configuration will automatically start the debug server when needed.
Debugging the Debug Server
To debug the debug server, you need to use the Launch Extension + Debug Server
launch configuration of the extension (or alternatively the Launch Debug
Server launch configuration to only launch the server without the Visual Studio
Code extension). This will make the debug server listen on port 4711 for
connections. To use the running debug server instead of starting a new instance,
set the PAPLJ launch configuration of the project you’re working on to use the
server on port 4711 by adding "debugServer": 4711
to launch.json
,
for example:
{
"version": "0.2.0",
"configurations": [
{
"type": "paplj",
"request": "launch",
"name": "PAPLJ Debug",
"program": "${workspaceRoot}/program/bintree.pj",
"stopOnEntry": true,
"debugServer": 4711
}
]
}
Tracing the Debug Server
To see all the requests, responses, and events sent and received by the debug
server, enable tracing by adding "trace": true
to the launch configuration to
the project’s launch configuration. For example:
{
"version": "0.2.0",
"configurations": [
{
"type": "paplj",
"request": "launch",
"name": "PAPLJ Debug",
"program": "${workspaceRoot}/program/bintree.pj",
"stopOnEntry": true,
"debugServer": 4711,
"trace": true
}
]
}