Skip to content
Daniel Larraz edited this page Jul 27, 2023 · 2 revisions

Debugging the client and server using VS Code

The LSP server can communicate with the client through either the stdin/stdout interface or TCP connection. By default, the client uses the stdin/stdout interface. For debugging the server, however, it's better to use the TCP interface.

Debugging the client

  1. Ensure that all the tools for (z3, kind2, and kind2-language-server) are installed in the right locations.
  2. Put a breakpoint in the lines that you want to debug.
  3. From the client workspace, press F5 to run the Extension host debugger. This should open a new window of VS Code with extension enabled.
  4. Open a Lustre file and reproduce the steps that trigger the breakpoint.

Debugging the client and server

  1. Ensure that all the tools for (z3 and kind2) are installed in the right locations.
  2. Modify lines 58-59 of src/extension.ts:
    // Create the language client and start the client.
    client = new LanguageClient(
      'vscode-kind2',
      'Kind 2',
    - serverOptions,
    - // connectToTCPServer(),
    + // serverOptions,
    + connectToTCPServer(),
      clientOptions
    );
  3. Put a breakpoint in the lines that you want to debug.
  4. From the client workspace, press F5 to run the Extension host debugger. This should open a new window of VS Code with extension enabled.
  5. Open a Lustre file.
  6. Add the following debug configurations to .vscode/launch.json in the server workspace:
    {
      "version": "0.2.0",
      "configurations": [
        {
            "type": "java",
            "name": "Launch Main",
            "request": "launch",
            "mainClass": "edu.uiowa.kind2.lsp.Main",
            "projectName": "kind2-language-server",
            "args": [
                "23555"
            ]
        }
      ]
    }
  7. From the server workspace in a Java file, press F5 to run the Java debugger (a Java debugger is included in extensions such as Extension Pack for Java).
  8. Reproduce the steps that trigger the breakpoint.

After you finish debugging, restore lines 58-59 of src/extension.ts:

// Create the language client and start the client.
client = new LanguageClient(
  'vscode-kind2',
  'Kind 2',
- // serverOptions,
- connectToTCPServer(),
+ serverOptions,
+ // connectToTCPServer(),
  clientOptions
);
Clone this wiki locally