Skip to content

gdbplugin: Debugger Adapter Protocol backend

Basic implementation of DAP for the GDB plugin.

It allows to run debugging sessions attached to DAP servers (with managed or unmanaged process). All the features present for GDB have been impemented in the new backend.

Tested for:

  • delve (go)
  • debugpy (python)
  • perl language server

UI

The bottom-panel allows to choose the backend (GDB or a DAP server profile). The input widgets are adapted to match the variables in the selected profile.

Screenshot_20220515_110810

In the lateral panel, variables are grouped by scopes (provided by the client).

Screenshot_20220515_171702

Debugging actions are enabled only if the server supports them.

Configuration

Profiles are defined in a resource JSON file, but can be overriden by a user config file (<user config>/gdbplugin/dap.json).

The proposed syntax allows to define variables, which will be shown at the GUI panel. The format of a variable is:

${variable}
${variable.name}
${#variable.name}

A variable is considered to be a string, unless a filter is used to transform its value.

The following variables will use predefined input widgets:

  • ${file}: use the GDB profile widget for the executable path.
  • ${workdir}: use the GDB profile widget for the working directory.
  • ${args}: use the GDB profile widget for the arguments.
  • ${pid}: use an integer input widget.

Server settings templates

Each server requires two sections defined:

  • run: server invocation and supported protocol features.
  • configurations: a map with different ways to debug a program when using that server (eg. launch or attach).

Run sections

Options:

command: [string] : Server process invocation.

environment: {string: string} : Environment variables for the process invocation. If not defined, use system defined variables.

host: string : Server host. If not defined, "127.0.0.1"

port: int : Server port. If port == 0, a random port will be used.

redirectStderr: bool : Redirect standard error output to output events with category==console. By default, false.

redirectStdout: bool : Redirect standard output to output events with category==stdout. By default, false.

supportsSourceRequest: bool : Set to true if the server supports the DAP source request.

If command and a socket variable (host, port) are defined together: run process and listen to socket.

Configurations

In each configuration section, global commands can be overriden.

Required variable:

request: {string: any} : Arguments required by the server implementation of launch or attach requests.

request.command: launch|attach

Options:

commandArgs: [string] : Append this array to the command variable.

Placeholders

A generalised configuration can be created by using variable placeholders:

${variable} : Replace with the string value of a defined variable called variable.

${variable|base} : Replace with the string value of a defined variable called variable, interpret it as a filename and remove the extension.

${variable|dir} : Replace with the string value of a defined variable called variable, interpret it as a filename and remove the file part.

If the placeholder template is the only content in the string, it can be used to cast to other variable types:

${variable|int} : Convert variable to integer.

${variable|bool} : Convert variable to boolean.

${variable|list} : Convert variable to string list

There are two references:

${#run.port} : Use the value of port variable defined in the run/configuration section.

${#run.host} : Use the value of host variable defined in the run/configuration section.

Edited by Héctor Mesa Jiménez

Merge request reports