pax_global_header00006660000000000000000000000064144607632240014522gustar00rootroot0000000000000052 comment=eaf866ef37a6668a27ef2d16d8c9d5a0b9bece27 golang-github-google-go-dap-0.10.0/000077500000000000000000000000001446076322400167465ustar00rootroot00000000000000golang-github-google-go-dap-0.10.0/.github/000077500000000000000000000000001446076322400203065ustar00rootroot00000000000000golang-github-google-go-dap-0.10.0/.github/workflows/000077500000000000000000000000001446076322400223435ustar00rootroot00000000000000golang-github-google-go-dap-0.10.0/.github/workflows/go.yml000066400000000000000000000011051446076322400234700ustar00rootroot00000000000000name: tests on: push: branches: [ main ] pull_request: branches: [ main ] jobs: build: strategy: matrix: os: [ubuntu-latest, macos-latest] go-version: [1.20.x] include: - go-version: 1.19.x os: ubuntu-latest runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - name: Set up Go uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} - name: Build run: go build -v ./... - name: Test shell: bash run: 'internal/test.sh' golang-github-google-go-dap-0.10.0/LICENSE000066400000000000000000000261361446076322400177630ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. golang-github-google-go-dap-0.10.0/README.md000066400000000000000000000015231446076322400202260ustar00rootroot00000000000000# go-dap: Go implementation of the Debug Adapter Protocol [![PkgGoDev](https://pkg.go.dev/badge/github.com/google/go-dap)](https://pkg.go.dev/github.com/google/go-dap) [![Build Status](https://github.com/google/go-dap/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/google/go-dap/actions) [![Go Report Card](https://goreportcard.com/badge/github.com/google/go-dap)](https://goreportcard.com/report/github.com/google/go-dap) For an overview of DAP, see https://microsoft.github.io/debug-adapter-protocol/overview ## Contributing We'd love to accept your patches and contributions to this project. See [docs/contributing](https://github.com/google/go-dap/blob/master/docs/contributing.md) for more details. ## License This project is licensed under the Apache License 2.0 This is not an officially supported Google product. golang-github-google-go-dap-0.10.0/cmd/000077500000000000000000000000001446076322400175115ustar00rootroot00000000000000golang-github-google-go-dap-0.10.0/cmd/gentypes/000077500000000000000000000000001446076322400213475ustar00rootroot00000000000000golang-github-google-go-dap-0.10.0/cmd/gentypes/README.md000066400000000000000000000014231446076322400226260ustar00rootroot00000000000000The schema for DAP messages is defined in JSON at https://github.com/microsoft/vscode-debugadapter-node/blob/main/debugProtocol.json The auto-generated TypeScript representation of the schema is at https://github.com/microsoft/vscode-debugadapter-node/blob/main/protocol/src/debugProtocol.ts ---- In this directory we have a copy of the schema, which is licensed by Microsoft with a [MIT License](https://github.com/microsoft/vscode-debugadapter-node/blob/main/License.txt). This copy must be updated whenever the schema changes. To generate Go types from the schema, run: ``` $ go run cmd/gentypes/gentypes.go cmd/gentypes/debugProtocol.json > schematypes.go ``` The generated ``schematypes.go`` is also checked in, so there is no need to regenerate it unless the schema changes. golang-github-google-go-dap-0.10.0/cmd/gentypes/debugProtocol.json000066400000000000000000005104301446076322400250550ustar00rootroot00000000000000{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Debug Adapter Protocol", "description": "The Debug Adapter Protocol defines the protocol used between an editor or IDE and a debugger or runtime.", "type": "object", "definitions": { "ProtocolMessage": { "type": "object", "title": "Base Protocol", "description": "Base class of requests, responses, and events.", "properties": { "seq": { "type": "integer", "description": "Sequence number of the message (also known as message ID). The `seq` for the first message sent by a client or debug adapter is 1, and for each subsequent message is 1 greater than the previous message sent by that actor. `seq` can be used to order requests, responses, and events, and to associate requests with their corresponding responses. For protocol messages of type `request` the sequence number can be used to cancel the request." }, "type": { "type": "string", "description": "Message type.", "_enum": [ "request", "response", "event" ] } }, "required": [ "seq", "type" ] }, "Request": { "allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, { "type": "object", "description": "A client or debug adapter initiated request.", "properties": { "type": { "type": "string", "enum": [ "request" ] }, "command": { "type": "string", "description": "The command to execute." }, "arguments": { "type": [ "array", "boolean", "integer", "null", "number" , "object", "string" ], "description": "Object containing arguments for the command." } }, "required": [ "type", "command" ] }] }, "Event": { "allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, { "type": "object", "description": "A debug adapter initiated event.", "properties": { "type": { "type": "string", "enum": [ "event" ] }, "event": { "type": "string", "description": "Type of event." }, "body": { "type": [ "array", "boolean", "integer", "null", "number" , "object", "string" ], "description": "Event-specific information." } }, "required": [ "type", "event" ] }] }, "Response": { "allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, { "type": "object", "description": "Response for a request.", "properties": { "type": { "type": "string", "enum": [ "response" ] }, "request_seq": { "type": "integer", "description": "Sequence number of the corresponding request." }, "success": { "type": "boolean", "description": "Outcome of the request.\nIf true, the request was successful and the `body` attribute may contain the result of the request.\nIf the value is false, the attribute `message` contains the error in short form and the `body` may contain additional information (see `ErrorResponse.body.error`)." }, "command": { "type": "string", "description": "The command requested." }, "message": { "type": "string", "description": "Contains the raw error in short form if `success` is false.\nThis raw error might be interpreted by the client and is not shown in the UI.\nSome predefined values exist.", "_enum": [ "cancelled", "notStopped" ], "enumDescriptions": [ "the request was cancelled.", "the request may be retried once the adapter is in a 'stopped' state." ] }, "body": { "type": [ "array", "boolean", "integer", "null", "number" , "object", "string" ], "description": "Contains request result if success is true and error details if success is false." } }, "required": [ "type", "request_seq", "success", "command" ] }] }, "ErrorResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "On error (whenever `success` is false), the body can provide more details.", "properties": { "body": { "type": "object", "properties": { "error": { "$ref": "#/definitions/Message", "description": "A structured error message." } } } }, "required": [ "body" ] }] }, "CancelRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The `cancel` request is used by the client in two situations:\n- to indicate that it is no longer interested in the result produced by a specific request issued earlier\n- to cancel a progress sequence. Clients should only call this request if the corresponding capability `supportsCancelRequest` is true.\nThis request has a hint characteristic: a debug adapter can only be expected to make a 'best effort' in honoring this request but there are no guarantees.\nThe `cancel` request may return an error if it could not cancel an operation but a client should refrain from presenting this error to end users.\nThe request that got cancelled still needs to send a response back. This can either be a normal result (`success` attribute true) or an error response (`success` attribute false and the `message` set to `cancelled`).\nReturning partial results from a cancelled request is possible but please note that a client has no generic way for detecting that a response is partial or not.\nThe progress that got cancelled still needs to send a `progressEnd` event back.\n A client should not assume that progress just got cancelled after sending the `cancel` request.", "properties": { "command": { "type": "string", "enum": [ "cancel" ] }, "arguments": { "$ref": "#/definitions/CancelArguments" } }, "required": [ "command" ] }] }, "CancelArguments": { "type": "object", "description": "Arguments for `cancel` request.", "properties": { "requestId": { "type": "integer", "description": "The ID (attribute `seq`) of the request to cancel. If missing no request is cancelled.\nBoth a `requestId` and a `progressId` can be specified in one request." }, "progressId": { "type": "string", "description": "The ID (attribute `progressId`) of the progress to cancel. If missing no progress is cancelled.\nBoth a `requestId` and a `progressId` can be specified in one request." } } }, "CancelResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `cancel` request. This is just an acknowledgement, so no body field is required." }] }, "InitializedEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "title": "Events", "description": "This event indicates that the debug adapter is ready to accept configuration requests (e.g. `setBreakpoints`, `setExceptionBreakpoints`).\nA debug adapter is expected to send this event when it is ready to accept configuration requests (but not before the `initialize` request has finished).\nThe sequence of events/requests is as follows:\n- adapters sends `initialized` event (after the `initialize` request has returned)\n- client sends zero or more `setBreakpoints` requests\n- client sends one `setFunctionBreakpoints` request (if corresponding capability `supportsFunctionBreakpoints` is true)\n- client sends a `setExceptionBreakpoints` request if one or more `exceptionBreakpointFilters` have been defined (or if `supportsConfigurationDoneRequest` is not true)\n- client sends other future configuration requests\n- client sends one `configurationDone` request to indicate the end of the configuration.", "properties": { "event": { "type": "string", "enum": [ "initialized" ] } }, "required": [ "event" ] }] }, "StoppedEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event indicates that the execution of the debuggee has stopped due to some condition.\nThis can be caused by a breakpoint previously set, a stepping request has completed, by executing a debugger statement etc.", "properties": { "event": { "type": "string", "enum": [ "stopped" ] }, "body": { "type": "object", "properties": { "reason": { "type": "string", "description": "The reason for the event.\nFor backward compatibility this string is shown in the UI if the `description` attribute is missing (but it must not be translated).", "_enum": [ "step", "breakpoint", "exception", "pause", "entry", "goto", "function breakpoint", "data breakpoint", "instruction breakpoint" ] }, "description": { "type": "string", "description": "The full reason for the event, e.g. 'Paused on exception'. This string is shown in the UI as is and can be translated." }, "threadId": { "type": "integer", "description": "The thread which was stopped." }, "preserveFocusHint": { "type": "boolean", "description": "A value of true hints to the client that this event should not change the focus." }, "text": { "type": "string", "description": "Additional information. E.g. if reason is `exception`, text contains the exception name. This string is shown in the UI." }, "allThreadsStopped": { "type": "boolean", "description": "If `allThreadsStopped` is true, a debug adapter can announce that all threads have stopped.\n- The client should use this information to enable that all threads can be expanded to access their stacktraces.\n- If the attribute is missing or false, only the thread with the given `threadId` can be expanded." }, "hitBreakpointIds": { "type": "array", "items": { "type": "integer" }, "description": "Ids of the breakpoints that triggered the event. In most cases there is only a single breakpoint but here are some examples for multiple breakpoints:\n- Different types of breakpoints map to the same location.\n- Multiple source breakpoints get collapsed to the same instruction by the compiler/runtime.\n- Multiple function breakpoints with different function names map to the same location." } }, "required": [ "reason" ] } }, "required": [ "event", "body" ] }] }, "ContinuedEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event indicates that the execution of the debuggee has continued.\nPlease note: a debug adapter is not expected to send this event in response to a request that implies that execution continues, e.g. `launch` or `continue`.\nIt is only necessary to send a `continued` event if there was no previous request that implied this.", "properties": { "event": { "type": "string", "enum": [ "continued" ] }, "body": { "type": "object", "properties": { "threadId": { "type": "integer", "description": "The thread which was continued." }, "allThreadsContinued": { "type": "boolean", "description": "If `allThreadsContinued` is true, a debug adapter can announce that all threads have continued." } }, "required": [ "threadId" ] } }, "required": [ "event", "body" ] }] }, "ExitedEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event indicates that the debuggee has exited and returns its exit code.", "properties": { "event": { "type": "string", "enum": [ "exited" ] }, "body": { "type": "object", "properties": { "exitCode": { "type": "integer", "description": "The exit code returned from the debuggee." } }, "required": [ "exitCode" ] } }, "required": [ "event", "body" ] }] }, "TerminatedEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event indicates that debugging of the debuggee has terminated. This does **not** mean that the debuggee itself has exited.", "properties": { "event": { "type": "string", "enum": [ "terminated" ] }, "body": { "type": "object", "properties": { "restart": { "type": [ "array", "boolean", "integer", "null", "number", "object", "string" ], "description": "A debug adapter may set `restart` to true (or to an arbitrary object) to request that the client restarts the session.\nThe value is not interpreted by the client and passed unmodified as an attribute `__restart` to the `launch` and `attach` requests." } } } }, "required": [ "event" ] }] }, "ThreadEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event indicates that a thread has started or exited.", "properties": { "event": { "type": "string", "enum": [ "thread" ] }, "body": { "type": "object", "properties": { "reason": { "type": "string", "description": "The reason for the event.", "_enum": [ "started", "exited" ] }, "threadId": { "type": "integer", "description": "The identifier of the thread." } }, "required": ["reason", "threadId"] } }, "required": [ "event", "body" ] }] }, "OutputEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event indicates that the target has produced some output.", "properties": { "event": { "type": "string", "enum": [ "output" ] }, "body": { "type": "object", "properties": { "category": { "type": "string", "description": "The output category. If not specified or if the category is not understood by the client, `console` is assumed.", "_enum": [ "console", "important", "stdout", "stderr", "telemetry" ], "enumDescriptions": [ "Show the output in the client's default message UI, e.g. a 'debug console'. This category should only be used for informational output from the debugger (as opposed to the debuggee).", "A hint for the client to show the output in the client's UI for important and highly visible information, e.g. as a popup notification. This category should only be used for important messages from the debugger (as opposed to the debuggee). Since this category value is a hint, clients might ignore the hint and assume the `console` category.", "Show the output as normal program output from the debuggee.", "Show the output as error program output from the debuggee.", "Send the output to telemetry instead of showing it to the user." ] }, "output": { "type": "string", "description": "The output to report." }, "group": { "type": "string", "description": "Support for keeping an output log organized by grouping related messages.", "enum": [ "start", "startCollapsed", "end" ], "enumDescriptions": [ "Start a new group in expanded mode. Subsequent output events are members of the group and should be shown indented.\nThe `output` attribute becomes the name of the group and is not indented.", "Start a new group in collapsed mode. Subsequent output events are members of the group and should be shown indented (as soon as the group is expanded).\nThe `output` attribute becomes the name of the group and is not indented.", "End the current group and decrease the indentation of subsequent output events.\nA non-empty `output` attribute is shown as the unindented end of the group." ] }, "variablesReference": { "type": "integer", "description": "If an attribute `variablesReference` exists and its value is > 0, the output contains objects which can be retrieved by passing `variablesReference` to the `variables` request as long as execution remains suspended. See 'Lifetime of Object References' in the Overview section for details." }, "source": { "$ref": "#/definitions/Source", "description": "The source location where the output was produced." }, "line": { "type": "integer", "description": "The source location's line where the output was produced." }, "column": { "type": "integer", "description": "The position in `line` where the output was produced. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." }, "data": { "type": [ "array", "boolean", "integer", "null", "number" , "object", "string" ], "description": "Additional data to report. For the `telemetry` category the data is sent to telemetry, for the other categories the data is shown in JSON format." } }, "required": ["output"] } }, "required": [ "event", "body" ] }] }, "BreakpointEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event indicates that some information about a breakpoint has changed.", "properties": { "event": { "type": "string", "enum": [ "breakpoint" ] }, "body": { "type": "object", "properties": { "reason": { "type": "string", "description": "The reason for the event.", "_enum": [ "changed", "new", "removed" ] }, "breakpoint": { "$ref": "#/definitions/Breakpoint", "description": "The `id` attribute is used to find the target breakpoint, the other attributes are used as the new values." } }, "required": [ "reason", "breakpoint" ] } }, "required": [ "event", "body" ] }] }, "ModuleEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event indicates that some information about a module has changed.", "properties": { "event": { "type": "string", "enum": [ "module" ] }, "body": { "type": "object", "properties": { "reason": { "type": "string", "description": "The reason for the event.", "enum": [ "new", "changed", "removed" ] }, "module": { "$ref": "#/definitions/Module", "description": "The new, changed, or removed module. In case of `removed` only the module id is used." } }, "required": [ "reason", "module" ] } }, "required": [ "event", "body" ] }] }, "LoadedSourceEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event indicates that some source has been added, changed, or removed from the set of all loaded sources.", "properties": { "event": { "type": "string", "enum": [ "loadedSource" ] }, "body": { "type": "object", "properties": { "reason": { "type": "string", "description": "The reason for the event.", "enum": [ "new", "changed", "removed" ] }, "source": { "$ref": "#/definitions/Source", "description": "The new, changed, or removed source." } }, "required": [ "reason", "source" ] } }, "required": [ "event", "body" ] }] }, "ProcessEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event indicates that the debugger has begun debugging a new process. Either one that it has launched, or one that it has attached to.", "properties": { "event": { "type": "string", "enum": [ "process" ] }, "body": { "type": "object", "properties": { "name": { "type": "string", "description": "The logical name of the process. This is usually the full path to process's executable file. Example: /home/example/myproj/program.js." }, "systemProcessId": { "type": "integer", "description": "The system process id of the debugged process. This property is missing for non-system processes." }, "isLocalProcess": { "type": "boolean", "description": "If true, the process is running on the same computer as the debug adapter." }, "startMethod": { "type": "string", "enum": [ "launch", "attach", "attachForSuspendedLaunch" ], "description": "Describes how the debug engine started debugging this process.", "enumDescriptions": [ "Process was launched under the debugger.", "Debugger attached to an existing process.", "A project launcher component has launched a new process in a suspended state and then asked the debugger to attach." ] }, "pointerSize": { "type": "integer", "description": "The size of a pointer or address for this process, in bits. This value may be used by clients when formatting addresses for display." } }, "required": [ "name" ] } }, "required": [ "event", "body" ] } ] }, "CapabilitiesEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event indicates that one or more capabilities have changed.\nSince the capabilities are dependent on the client and its UI, it might not be possible to change that at random times (or too late).\nConsequently this event has a hint characteristic: a client can only be expected to make a 'best effort' in honoring individual capabilities but there are no guarantees.\nOnly changed capabilities need to be included, all other capabilities keep their values.", "properties": { "event": { "type": "string", "enum": [ "capabilities" ] }, "body": { "type": "object", "properties": { "capabilities": { "$ref": "#/definitions/Capabilities", "description": "The set of updated capabilities." } }, "required": [ "capabilities" ] } }, "required": [ "event", "body" ] }] }, "ProgressStartEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event signals that a long running operation is about to start and provides additional information for the client to set up a corresponding progress and cancellation UI.\nThe client is free to delay the showing of the UI in order to reduce flicker.\nThis event should only be sent if the corresponding capability `supportsProgressReporting` is true.", "properties": { "event": { "type": "string", "enum": [ "progressStart" ] }, "body": { "type": "object", "properties": { "progressId": { "type": "string", "description": "An ID that can be used in subsequent `progressUpdate` and `progressEnd` events to make them refer to the same progress reporting.\nIDs must be unique within a debug session." }, "title": { "type": "string", "description": "Short title of the progress reporting. Shown in the UI to describe the long running operation." }, "requestId": { "type": "integer", "description": "The request ID that this progress report is related to. If specified a debug adapter is expected to emit progress events for the long running request until the request has been either completed or cancelled.\nIf the request ID is omitted, the progress report is assumed to be related to some general activity of the debug adapter." }, "cancellable": { "type": "boolean", "description": "If true, the request that reports progress may be cancelled with a `cancel` request.\nSo this property basically controls whether the client should use UX that supports cancellation.\nClients that don't support cancellation are allowed to ignore the setting." }, "message": { "type": "string", "description": "More detailed progress message." }, "percentage": { "type": "number", "description": "Progress percentage to display (value range: 0 to 100). If omitted no percentage is shown." } }, "required": [ "progressId", "title" ] } }, "required": [ "event", "body" ] }] }, "ProgressUpdateEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event signals that the progress reporting needs to be updated with a new message and/or percentage.\nThe client does not have to update the UI immediately, but the clients needs to keep track of the message and/or percentage values.\nThis event should only be sent if the corresponding capability `supportsProgressReporting` is true.", "properties": { "event": { "type": "string", "enum": [ "progressUpdate" ] }, "body": { "type": "object", "properties": { "progressId": { "type": "string", "description": "The ID that was introduced in the initial `progressStart` event." }, "message": { "type": "string", "description": "More detailed progress message. If omitted, the previous message (if any) is used." }, "percentage": { "type": "number", "description": "Progress percentage to display (value range: 0 to 100). If omitted no percentage is shown." } }, "required": [ "progressId" ] } }, "required": [ "event", "body" ] }] }, "ProgressEndEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "The event signals the end of the progress reporting with a final message.\nThis event should only be sent if the corresponding capability `supportsProgressReporting` is true.", "properties": { "event": { "type": "string", "enum": [ "progressEnd" ] }, "body": { "type": "object", "properties": { "progressId": { "type": "string", "description": "The ID that was introduced in the initial `ProgressStartEvent`." }, "message": { "type": "string", "description": "More detailed progress message. If omitted, the previous message (if any) is used." } }, "required": [ "progressId" ] } }, "required": [ "event", "body" ] }] }, "InvalidatedEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "This event signals that some state in the debug adapter has changed and requires that the client needs to re-render the data snapshot previously requested.\nDebug adapters do not have to emit this event for runtime changes like stopped or thread events because in that case the client refetches the new state anyway. But the event can be used for example to refresh the UI after rendering formatting has changed in the debug adapter.\nThis event should only be sent if the corresponding capability `supportsInvalidatedEvent` is true.", "properties": { "event": { "type": "string", "enum": [ "invalidated" ] }, "body": { "type": "object", "properties": { "areas": { "type": "array", "description": "Set of logical areas that got invalidated. This property has a hint characteristic: a client can only be expected to make a 'best effort' in honoring the areas but there are no guarantees. If this property is missing, empty, or if values are not understood, the client should assume a single value `all`.", "items": { "$ref": "#/definitions/InvalidatedAreas" } }, "threadId": { "type": "integer", "description": "If specified, the client only needs to refetch data related to this thread." }, "stackFrameId": { "type": "integer", "description": "If specified, the client only needs to refetch data related to this stack frame (and the `threadId` is ignored)." } } } }, "required": [ "event", "body" ] }] }, "MemoryEvent": { "allOf": [ { "$ref": "#/definitions/Event" }, { "type": "object", "description": "This event indicates that some memory range has been updated. It should only be sent if the corresponding capability `supportsMemoryEvent` is true.\nClients typically react to the event by re-issuing a `readMemory` request if they show the memory identified by the `memoryReference` and if the updated memory range overlaps the displayed range. Clients should not make assumptions how individual memory references relate to each other, so they should not assume that they are part of a single continuous address range and might overlap.\nDebug adapters can use this event to indicate that the contents of a memory range has changed due to some other request like `setVariable` or `setExpression`. Debug adapters are not expected to emit this event for each and every memory change of a running program, because that information is typically not available from debuggers and it would flood clients with too many events.", "properties": { "event": { "type": "string", "enum": [ "memory" ] }, "body": { "type": "object", "properties": { "memoryReference": { "type": "string", "description": "Memory reference of a memory range that has been updated." }, "offset": { "type": "integer", "description": "Starting offset in bytes where memory has been updated. Can be negative." }, "count": { "type": "integer", "description": "Number of bytes updated." } }, "required": [ "memoryReference", "offset", "count" ] } }, "required": [ "event", "body" ] }] }, "RunInTerminalRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "title": "Reverse Requests", "description": "This request is sent from the debug adapter to the client to run a command in a terminal.\nThis is typically used to launch the debuggee in a terminal provided by the client.\nThis request should only be called if the corresponding client capability `supportsRunInTerminalRequest` is true.\nClient implementations of `runInTerminal` are free to run the command however they choose including issuing the command to a command line interpreter (aka 'shell'). Argument strings passed to the `runInTerminal` request must arrive verbatim in the command to be run. As a consequence, clients which use a shell are responsible for escaping any special shell characters in the argument strings to prevent them from being interpreted (and modified) by the shell.\nSome users may wish to take advantage of shell processing in the argument strings. For clients which implement `runInTerminal` using an intermediary shell, the `argsCanBeInterpretedByShell` property can be set to true. In this case the client is requested not to escape any special shell characters in the argument strings.", "properties": { "command": { "type": "string", "enum": [ "runInTerminal" ] }, "arguments": { "$ref": "#/definitions/RunInTerminalRequestArguments" } }, "required": [ "command", "arguments" ] }] }, "RunInTerminalRequestArguments": { "type": "object", "description": "Arguments for `runInTerminal` request.", "properties": { "kind": { "type": "string", "enum": [ "integrated", "external" ], "description": "What kind of terminal to launch. Defaults to `integrated` if not specified." }, "title": { "type": "string", "description": "Title of the terminal." }, "cwd": { "type": "string", "description": "Working directory for the command. For non-empty, valid paths this typically results in execution of a change directory command." }, "args": { "type": "array", "items": { "type": "string" }, "description": "List of arguments. The first argument is the command to run." }, "env": { "type": "object", "description": "Environment key-value pairs that are added to or removed from the default environment.", "additionalProperties": { "type": [ "string", "null" ], "description": "A string is a proper value for an environment variable. The value `null` removes the variable from the environment." } }, "argsCanBeInterpretedByShell": { "type": "boolean", "description": "This property should only be set if the corresponding capability `supportsArgsCanBeInterpretedByShell` is true. If the client uses an intermediary shell to launch the application, then the client must not attempt to escape characters with special meanings for the shell. The user is fully responsible for escaping as needed and that arguments using special characters may not be portable across shells." } }, "required": [ "args", "cwd" ] }, "RunInTerminalResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `runInTerminal` request.", "properties": { "body": { "type": "object", "properties": { "processId": { "type": "integer", "description": "The process ID. The value should be less than or equal to 2147483647 (2^31-1)." }, "shellProcessId": { "type": "integer", "description": "The process ID of the terminal shell. The value should be less than or equal to 2147483647 (2^31-1)." } } } }, "required": [ "body" ] }] }, "StartDebuggingRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "This request is sent from the debug adapter to the client to start a new debug session of the same type as the caller.\nThis request should only be sent if the corresponding client capability `supportsStartDebuggingRequest` is true.\nA client implementation of `startDebugging` should start a new debug session (of the same type as the caller) in the same way that the caller's session was started. If the client supports hierarchical debug sessions, the newly created session can be treated as a child of the caller session.", "properties": { "command": { "type": "string", "enum": [ "startDebugging" ] }, "arguments": { "$ref": "#/definitions/StartDebuggingRequestArguments" } }, "required": [ "command", "arguments" ] } ] }, "StartDebuggingRequestArguments": { "type": "object", "description": "Arguments for `startDebugging` request.", "properties": { "configuration": { "type": "object", "additionalProperties": true, "description": "Arguments passed to the new debug session. The arguments must only contain properties understood by the `launch` or `attach` requests of the debug adapter and they must not contain any client-specific properties (e.g. `type`) or client-specific features (e.g. substitutable 'variables')." }, "request": { "type": "string", "enum": [ "launch", "attach" ], "description": "Indicates whether the new debug session should be started with a `launch` or `attach` request." } }, "required": [ "configuration", "request" ] }, "StartDebuggingResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `startDebugging` request. This is just an acknowledgement, so no body field is required." } ] }, "InitializeRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "title": "Requests", "description": "The `initialize` request is sent as the first request from the client to the debug adapter in order to configure it with client capabilities and to retrieve capabilities from the debug adapter.\nUntil the debug adapter has responded with an `initialize` response, the client must not send any additional requests or events to the debug adapter.\nIn addition the debug adapter is not allowed to send any requests or events to the client until it has responded with an `initialize` response.\nThe `initialize` request may only be sent once.", "properties": { "command": { "type": "string", "enum": [ "initialize" ] }, "arguments": { "$ref": "#/definitions/InitializeRequestArguments" } }, "required": [ "command", "arguments" ] }] }, "InitializeRequestArguments": { "type": "object", "description": "Arguments for `initialize` request.", "properties": { "clientID": { "type": "string", "description": "The ID of the client using this adapter." }, "clientName": { "type": "string", "description": "The human-readable name of the client using this adapter." }, "adapterID": { "type": "string", "description": "The ID of the debug adapter." }, "locale": { "type": "string", "description": "The ISO-639 locale of the client using this adapter, e.g. en-US or de-CH." }, "linesStartAt1": { "type": "boolean", "description": "If true all line numbers are 1-based (default)." }, "columnsStartAt1": { "type": "boolean", "description": "If true all column numbers are 1-based (default)." }, "pathFormat": { "type": "string", "_enum": [ "path", "uri" ], "description": "Determines in what format paths are specified. The default is `path`, which is the native format." }, "supportsVariableType": { "type": "boolean", "description": "Client supports the `type` attribute for variables." }, "supportsVariablePaging": { "type": "boolean", "description": "Client supports the paging of variables." }, "supportsRunInTerminalRequest": { "type": "boolean", "description": "Client supports the `runInTerminal` request." }, "supportsMemoryReferences": { "type": "boolean", "description": "Client supports memory references." }, "supportsProgressReporting": { "type": "boolean", "description": "Client supports progress reporting." }, "supportsInvalidatedEvent": { "type": "boolean", "description": "Client supports the `invalidated` event." }, "supportsMemoryEvent": { "type": "boolean", "description": "Client supports the `memory` event." }, "supportsArgsCanBeInterpretedByShell": { "type": "boolean", "description": "Client supports the `argsCanBeInterpretedByShell` attribute on the `runInTerminal` request." }, "supportsStartDebuggingRequest": { "type": "boolean", "description": "Client supports the `startDebugging` request." } }, "required": [ "adapterID" ] }, "InitializeResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `initialize` request.", "properties": { "body": { "$ref": "#/definitions/Capabilities", "description": "The capabilities of this debug adapter." } } }] }, "ConfigurationDoneRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "This request indicates that the client has finished initialization of the debug adapter.\nSo it is the last request in the sequence of configuration requests (which was started by the `initialized` event).\nClients should only call this request if the corresponding capability `supportsConfigurationDoneRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "configurationDone" ] }, "arguments": { "$ref": "#/definitions/ConfigurationDoneArguments" } }, "required": [ "command" ] }] }, "ConfigurationDoneArguments": { "type": "object", "description": "Arguments for `configurationDone` request." }, "ConfigurationDoneResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `configurationDone` request. This is just an acknowledgement, so no body field is required." }] }, "LaunchRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "This launch request is sent from the client to the debug adapter to start the debuggee with or without debugging (if `noDebug` is true).\nSince launching is debugger/runtime specific, the arguments for this request are not part of this specification.", "properties": { "command": { "type": "string", "enum": [ "launch" ] }, "arguments": { "$ref": "#/definitions/LaunchRequestArguments" } }, "required": [ "command", "arguments" ] }] }, "LaunchRequestArguments": { "type": "object", "description": "Arguments for `launch` request. Additional attributes are implementation specific.", "properties": { "noDebug": { "type": "boolean", "description": "If true, the launch request should launch the program without enabling debugging." }, "__restart": { "type": [ "array", "boolean", "integer", "null", "number", "object", "string" ], "description": "Arbitrary data from the previous, restarted session.\nThe data is sent as the `restart` attribute of the `terminated` event.\nThe client should leave the data intact." } } }, "LaunchResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `launch` request. This is just an acknowledgement, so no body field is required." }] }, "AttachRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The `attach` request is sent from the client to the debug adapter to attach to a debuggee that is already running.\nSince attaching is debugger/runtime specific, the arguments for this request are not part of this specification.", "properties": { "command": { "type": "string", "enum": [ "attach" ] }, "arguments": { "$ref": "#/definitions/AttachRequestArguments" } }, "required": [ "command", "arguments" ] }] }, "AttachRequestArguments": { "type": "object", "description": "Arguments for `attach` request. Additional attributes are implementation specific.", "properties": { "__restart": { "type": [ "array", "boolean", "integer", "null", "number", "object", "string" ], "description": "Arbitrary data from the previous, restarted session.\nThe data is sent as the `restart` attribute of the `terminated` event.\nThe client should leave the data intact." } } }, "AttachResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `attach` request. This is just an acknowledgement, so no body field is required." }] }, "RestartRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Restarts a debug session. Clients should only call this request if the corresponding capability `supportsRestartRequest` is true.\nIf the capability is missing or has the value false, a typical client emulates `restart` by terminating the debug adapter first and then launching it anew.", "properties": { "command": { "type": "string", "enum": [ "restart" ] }, "arguments": { "$ref": "#/definitions/RestartArguments" } }, "required": [ "command" ] }] }, "RestartArguments": { "type": "object", "description": "Arguments for `restart` request.", "properties": { "arguments": { "oneOf": [ { "$ref": "#/definitions/LaunchRequestArguments" }, { "$ref": "#/definitions/AttachRequestArguments" } ], "description": "The latest version of the `launch` or `attach` configuration." } } }, "RestartResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `restart` request. This is just an acknowledgement, so no body field is required." }] }, "DisconnectRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The `disconnect` request asks the debug adapter to disconnect from the debuggee (thus ending the debug session) and then to shut down itself (the debug adapter).\nIn addition, the debug adapter must terminate the debuggee if it was started with the `launch` request. If an `attach` request was used to connect to the debuggee, then the debug adapter must not terminate the debuggee.\nThis implicit behavior of when to terminate the debuggee can be overridden with the `terminateDebuggee` argument (which is only supported by a debug adapter if the corresponding capability `supportTerminateDebuggee` is true).", "properties": { "command": { "type": "string", "enum": [ "disconnect" ] }, "arguments": { "$ref": "#/definitions/DisconnectArguments" } }, "required": [ "command" ] }] }, "DisconnectArguments": { "type": "object", "description": "Arguments for `disconnect` request.", "properties": { "restart": { "type": "boolean", "description": "A value of true indicates that this `disconnect` request is part of a restart sequence." }, "terminateDebuggee": { "type": "boolean", "description": "Indicates whether the debuggee should be terminated when the debugger is disconnected.\nIf unspecified, the debug adapter is free to do whatever it thinks is best.\nThe attribute is only honored by a debug adapter if the corresponding capability `supportTerminateDebuggee` is true." }, "suspendDebuggee": { "type": "boolean", "description": "Indicates whether the debuggee should stay suspended when the debugger is disconnected.\nIf unspecified, the debuggee should resume execution.\nThe attribute is only honored by a debug adapter if the corresponding capability `supportSuspendDebuggee` is true." } } }, "DisconnectResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `disconnect` request. This is just an acknowledgement, so no body field is required." }] }, "TerminateRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The `terminate` request is sent from the client to the debug adapter in order to shut down the debuggee gracefully. Clients should only call this request if the capability `supportsTerminateRequest` is true.\nTypically a debug adapter implements `terminate` by sending a software signal which the debuggee intercepts in order to clean things up properly before terminating itself.\nPlease note that this request does not directly affect the state of the debug session: if the debuggee decides to veto the graceful shutdown for any reason by not terminating itself, then the debug session just continues.\nClients can surface the `terminate` request as an explicit command or they can integrate it into a two stage Stop command that first sends `terminate` to request a graceful shutdown, and if that fails uses `disconnect` for a forceful shutdown.", "properties": { "command": { "type": "string", "enum": [ "terminate" ] }, "arguments": { "$ref": "#/definitions/TerminateArguments" } }, "required": [ "command" ] }] }, "TerminateArguments": { "type": "object", "description": "Arguments for `terminate` request.", "properties": { "restart": { "type": "boolean", "description": "A value of true indicates that this `terminate` request is part of a restart sequence." } } }, "TerminateResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `terminate` request. This is just an acknowledgement, so no body field is required." }] }, "BreakpointLocationsRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The `breakpointLocations` request returns all possible locations for source breakpoints in a given range.\nClients should only call this request if the corresponding capability `supportsBreakpointLocationsRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "breakpointLocations" ] }, "arguments": { "$ref": "#/definitions/BreakpointLocationsArguments" } }, "required": [ "command" ] }] }, "BreakpointLocationsArguments": { "type": "object", "description": "Arguments for `breakpointLocations` request.", "properties": { "source": { "$ref": "#/definitions/Source", "description": "The source location of the breakpoints; either `source.path` or `source.reference` must be specified." }, "line": { "type": "integer", "description": "Start line of range to search possible breakpoint locations in. If only the line is specified, the request returns all possible locations in that line." }, "column": { "type": "integer", "description": "Start position within `line` to search possible breakpoint locations in. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based. If no column is given, the first position in the start line is assumed." }, "endLine": { "type": "integer", "description": "End line of range to search possible breakpoint locations in. If no end line is given, then the end line is assumed to be the start line." }, "endColumn": { "type": "integer", "description": "End position within `endLine` to search possible breakpoint locations in. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based. If no end column is given, the last position in the end line is assumed." } }, "required": [ "source", "line" ] }, "BreakpointLocationsResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `breakpointLocations` request.\nContains possible locations for source breakpoints.", "properties": { "body": { "type": "object", "properties": { "breakpoints": { "type": "array", "items": { "$ref": "#/definitions/BreakpointLocation" }, "description": "Sorted set of possible breakpoint locations." } }, "required": [ "breakpoints" ] } }, "required": [ "body" ] }] }, "SetBreakpointsRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Sets multiple breakpoints for a single source and clears all previous breakpoints in that source.\nTo clear all breakpoint for a source, specify an empty array.\nWhen a breakpoint is hit, a `stopped` event (with reason `breakpoint`) is generated.", "properties": { "command": { "type": "string", "enum": [ "setBreakpoints" ] }, "arguments": { "$ref": "#/definitions/SetBreakpointsArguments" } }, "required": [ "command", "arguments" ] }] }, "SetBreakpointsArguments": { "type": "object", "description": "Arguments for `setBreakpoints` request.", "properties": { "source": { "$ref": "#/definitions/Source", "description": "The source location of the breakpoints; either `source.path` or `source.sourceReference` must be specified." }, "breakpoints": { "type": "array", "items": { "$ref": "#/definitions/SourceBreakpoint" }, "description": "The code locations of the breakpoints." }, "lines": { "type": "array", "items": { "type": "integer" }, "description": "Deprecated: The code locations of the breakpoints." }, "sourceModified": { "type": "boolean", "description": "A value of true indicates that the underlying source has been modified which results in new breakpoint locations." } }, "required": [ "source" ] }, "SetBreakpointsResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `setBreakpoints` request.\nReturned is information about each breakpoint created by this request.\nThis includes the actual code location and whether the breakpoint could be verified.\nThe breakpoints returned are in the same order as the elements of the `breakpoints`\n(or the deprecated `lines`) array in the arguments.", "properties": { "body": { "type": "object", "properties": { "breakpoints": { "type": "array", "items": { "$ref": "#/definitions/Breakpoint" }, "description": "Information about the breakpoints.\nThe array elements are in the same order as the elements of the `breakpoints` (or the deprecated `lines`) array in the arguments." } }, "required": [ "breakpoints" ] } }, "required": [ "body" ] }] }, "SetFunctionBreakpointsRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Replaces all existing function breakpoints with new function breakpoints.\nTo clear all function breakpoints, specify an empty array.\nWhen a function breakpoint is hit, a `stopped` event (with reason `function breakpoint`) is generated.\nClients should only call this request if the corresponding capability `supportsFunctionBreakpoints` is true.", "properties": { "command": { "type": "string", "enum": [ "setFunctionBreakpoints" ] }, "arguments": { "$ref": "#/definitions/SetFunctionBreakpointsArguments" } }, "required": [ "command", "arguments" ] }] }, "SetFunctionBreakpointsArguments": { "type": "object", "description": "Arguments for `setFunctionBreakpoints` request.", "properties": { "breakpoints": { "type": "array", "items": { "$ref": "#/definitions/FunctionBreakpoint" }, "description": "The function names of the breakpoints." } }, "required": [ "breakpoints" ] }, "SetFunctionBreakpointsResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `setFunctionBreakpoints` request.\nReturned is information about each breakpoint created by this request.", "properties": { "body": { "type": "object", "properties": { "breakpoints": { "type": "array", "items": { "$ref": "#/definitions/Breakpoint" }, "description": "Information about the breakpoints. The array elements correspond to the elements of the `breakpoints` array." } }, "required": [ "breakpoints" ] } }, "required": [ "body" ] }] }, "SetExceptionBreakpointsRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request configures the debugger's response to thrown exceptions.\nIf an exception is configured to break, a `stopped` event is fired (with reason `exception`).\nClients should only call this request if the corresponding capability `exceptionBreakpointFilters` returns one or more filters.", "properties": { "command": { "type": "string", "enum": [ "setExceptionBreakpoints" ] }, "arguments": { "$ref": "#/definitions/SetExceptionBreakpointsArguments" } }, "required": [ "command", "arguments" ] }] }, "SetExceptionBreakpointsArguments": { "type": "object", "description": "Arguments for `setExceptionBreakpoints` request.", "properties": { "filters": { "type": "array", "items": { "type": "string" }, "description": "Set of exception filters specified by their ID. The set of all possible exception filters is defined by the `exceptionBreakpointFilters` capability. The `filter` and `filterOptions` sets are additive." }, "filterOptions": { "type": "array", "items": { "$ref": "#/definitions/ExceptionFilterOptions" }, "description": "Set of exception filters and their options. The set of all possible exception filters is defined by the `exceptionBreakpointFilters` capability. This attribute is only honored by a debug adapter if the corresponding capability `supportsExceptionFilterOptions` is true. The `filter` and `filterOptions` sets are additive." }, "exceptionOptions": { "type": "array", "items": { "$ref": "#/definitions/ExceptionOptions" }, "description": "Configuration options for selected exceptions.\nThe attribute is only honored by a debug adapter if the corresponding capability `supportsExceptionOptions` is true." } }, "required": [ "filters" ] }, "SetExceptionBreakpointsResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `setExceptionBreakpoints` request.\nThe response contains an array of `Breakpoint` objects with information about each exception breakpoint or filter. The `Breakpoint` objects are in the same order as the elements of the `filters`, `filterOptions`, `exceptionOptions` arrays given as arguments. If both `filters` and `filterOptions` are given, the returned array must start with `filters` information first, followed by `filterOptions` information.\nThe `verified` property of a `Breakpoint` object signals whether the exception breakpoint or filter could be successfully created and whether the condition or hit count expressions are valid. In case of an error the `message` property explains the problem. The `id` property can be used to introduce a unique ID for the exception breakpoint or filter so that it can be updated subsequently by sending breakpoint events.\nFor backward compatibility both the `breakpoints` array and the enclosing `body` are optional. If these elements are missing a client is not able to show problems for individual exception breakpoints or filters.", "properties": { "body": { "type": "object", "properties": { "breakpoints": { "type": "array", "items": { "$ref": "#/definitions/Breakpoint" }, "description": "Information about the exception breakpoints or filters.\nThe breakpoints returned are in the same order as the elements of the `filters`, `filterOptions`, `exceptionOptions` arrays in the arguments. If both `filters` and `filterOptions` are given, the returned array must start with `filters` information first, followed by `filterOptions` information." } } } } }] }, "DataBreakpointInfoRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Obtains information on a possible data breakpoint that could be set on an expression or variable.\nClients should only call this request if the corresponding capability `supportsDataBreakpoints` is true.", "properties": { "command": { "type": "string", "enum": [ "dataBreakpointInfo" ] }, "arguments": { "$ref": "#/definitions/DataBreakpointInfoArguments" } }, "required": [ "command", "arguments" ] }] }, "DataBreakpointInfoArguments": { "type": "object", "description": "Arguments for `dataBreakpointInfo` request.", "properties": { "variablesReference": { "type": "integer", "description": "Reference to the variable container if the data breakpoint is requested for a child of the container. The `variablesReference` must have been obtained in the current suspended state. See 'Lifetime of Object References' in the Overview section for details." }, "name": { "type": "string", "description": "The name of the variable's child to obtain data breakpoint information for.\nIf `variablesReference` isn't specified, this can be an expression." }, "frameId": { "type": "integer", "description": "When `name` is an expression, evaluate it in the scope of this stack frame. If not specified, the expression is evaluated in the global scope. When `variablesReference` is specified, this property has no effect." } }, "required": [ "name" ] }, "DataBreakpointInfoResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `dataBreakpointInfo` request.", "properties": { "body": { "type": "object", "properties": { "dataId": { "type": [ "string", "null" ], "description": "An identifier for the data on which a data breakpoint can be registered with the `setDataBreakpoints` request or null if no data breakpoint is available." }, "description": { "type": "string", "description": "UI string that describes on what data the breakpoint is set on or why a data breakpoint is not available." }, "accessTypes": { "type": "array", "items": { "$ref": "#/definitions/DataBreakpointAccessType" }, "description": "Attribute lists the available access types for a potential data breakpoint. A UI client could surface this information." }, "canPersist": { "type": "boolean", "description": "Attribute indicates that a potential data breakpoint could be persisted across sessions." } }, "required": [ "dataId", "description" ] } }, "required": [ "body" ] }] }, "SetDataBreakpointsRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Replaces all existing data breakpoints with new data breakpoints.\nTo clear all data breakpoints, specify an empty array.\nWhen a data breakpoint is hit, a `stopped` event (with reason `data breakpoint`) is generated.\nClients should only call this request if the corresponding capability `supportsDataBreakpoints` is true.", "properties": { "command": { "type": "string", "enum": [ "setDataBreakpoints" ] }, "arguments": { "$ref": "#/definitions/SetDataBreakpointsArguments" } }, "required": [ "command", "arguments" ] }] }, "SetDataBreakpointsArguments": { "type": "object", "description": "Arguments for `setDataBreakpoints` request.", "properties": { "breakpoints": { "type": "array", "items": { "$ref": "#/definitions/DataBreakpoint" }, "description": "The contents of this array replaces all existing data breakpoints. An empty array clears all data breakpoints." } }, "required": [ "breakpoints" ] }, "SetDataBreakpointsResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `setDataBreakpoints` request.\nReturned is information about each breakpoint created by this request.", "properties": { "body": { "type": "object", "properties": { "breakpoints": { "type": "array", "items": { "$ref": "#/definitions/Breakpoint" }, "description": "Information about the data breakpoints. The array elements correspond to the elements of the input argument `breakpoints` array." } }, "required": [ "breakpoints" ] } }, "required": [ "body" ] }] }, "SetInstructionBreakpointsRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Replaces all existing instruction breakpoints. Typically, instruction breakpoints would be set from a disassembly window. \nTo clear all instruction breakpoints, specify an empty array.\nWhen an instruction breakpoint is hit, a `stopped` event (with reason `instruction breakpoint`) is generated.\nClients should only call this request if the corresponding capability `supportsInstructionBreakpoints` is true.", "properties": { "command": { "type": "string", "enum": [ "setInstructionBreakpoints" ] }, "arguments": { "$ref": "#/definitions/SetInstructionBreakpointsArguments" } }, "required": [ "command", "arguments" ] }] }, "SetInstructionBreakpointsArguments": { "type": "object", "description": "Arguments for `setInstructionBreakpoints` request", "properties": { "breakpoints": { "type": "array", "items": { "$ref": "#/definitions/InstructionBreakpoint" }, "description": "The instruction references of the breakpoints" } }, "required": ["breakpoints"] }, "SetInstructionBreakpointsResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `setInstructionBreakpoints` request", "properties": { "body": { "type": "object", "properties": { "breakpoints": { "type": "array", "items": { "$ref": "#/definitions/Breakpoint" }, "description": "Information about the breakpoints. The array elements correspond to the elements of the `breakpoints` array." } }, "required": [ "breakpoints" ] } }, "required": [ "body" ] }] }, "ContinueRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request resumes execution of all threads. If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true resumes only the specified thread. If not all threads were resumed, the `allThreadsContinued` attribute of the response should be set to false.", "properties": { "command": { "type": "string", "enum": [ "continue" ] }, "arguments": { "$ref": "#/definitions/ContinueArguments" } }, "required": [ "command", "arguments" ] }] }, "ContinueArguments": { "type": "object", "description": "Arguments for `continue` request.", "properties": { "threadId": { "type": "integer", "description": "Specifies the active thread. If the debug adapter supports single thread execution (see `supportsSingleThreadExecutionRequests`) and the argument `singleThread` is true, only the thread with this ID is resumed." }, "singleThread": { "type": "boolean", "description": "If this flag is true, execution is resumed only for the thread with given `threadId`." } }, "required": [ "threadId" ] }, "ContinueResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `continue` request.", "properties": { "body": { "type": "object", "properties": { "allThreadsContinued": { "type": "boolean", "description": "The value true (or a missing property) signals to the client that all threads have been resumed. The value false indicates that not all threads were resumed." } } } }, "required": [ "body" ] }] }, "NextRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request executes one step (in the given granularity) for the specified thread and allows all other threads to run freely by resuming them.\nIf the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true prevents other suspended threads from resuming.\nThe debug adapter first sends the response and then a `stopped` event (with reason `step`) after the step has completed.", "properties": { "command": { "type": "string", "enum": [ "next" ] }, "arguments": { "$ref": "#/definitions/NextArguments" } }, "required": [ "command", "arguments" ] }] }, "NextArguments": { "type": "object", "description": "Arguments for `next` request.", "properties": { "threadId": { "type": "integer", "description": "Specifies the thread for which to resume execution for one step (of the given granularity)." }, "singleThread": { "type": "boolean", "description": "If this flag is true, all other suspended threads are not resumed." }, "granularity": { "$ref": "#/definitions/SteppingGranularity", "description": "Stepping granularity. If no granularity is specified, a granularity of `statement` is assumed." } }, "required": [ "threadId" ] }, "NextResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `next` request. This is just an acknowledgement, so no body field is required." }] }, "StepInRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request resumes the given thread to step into a function/method and allows all other threads to run freely by resuming them.\nIf the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true prevents other suspended threads from resuming.\nIf the request cannot step into a target, `stepIn` behaves like the `next` request.\nThe debug adapter first sends the response and then a `stopped` event (with reason `step`) after the step has completed.\nIf there are multiple function/method calls (or other targets) on the source line,\nthe argument `targetId` can be used to control into which target the `stepIn` should occur.\nThe list of possible targets for a given source line can be retrieved via the `stepInTargets` request.", "properties": { "command": { "type": "string", "enum": [ "stepIn" ] }, "arguments": { "$ref": "#/definitions/StepInArguments" } }, "required": [ "command", "arguments" ] }] }, "StepInArguments": { "type": "object", "description": "Arguments for `stepIn` request.", "properties": { "threadId": { "type": "integer", "description": "Specifies the thread for which to resume execution for one step-into (of the given granularity)." }, "singleThread": { "type": "boolean", "description": "If this flag is true, all other suspended threads are not resumed." }, "targetId": { "type": "integer", "description": "Id of the target to step into." }, "granularity": { "$ref": "#/definitions/SteppingGranularity", "description": "Stepping granularity. If no granularity is specified, a granularity of `statement` is assumed." } }, "required": [ "threadId" ] }, "StepInResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `stepIn` request. This is just an acknowledgement, so no body field is required." }] }, "StepOutRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request resumes the given thread to step out (return) from a function/method and allows all other threads to run freely by resuming them.\nIf the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true prevents other suspended threads from resuming.\nThe debug adapter first sends the response and then a `stopped` event (with reason `step`) after the step has completed.", "properties": { "command": { "type": "string", "enum": [ "stepOut" ] }, "arguments": { "$ref": "#/definitions/StepOutArguments" } }, "required": [ "command", "arguments" ] }] }, "StepOutArguments": { "type": "object", "description": "Arguments for `stepOut` request.", "properties": { "threadId": { "type": "integer", "description": "Specifies the thread for which to resume execution for one step-out (of the given granularity)." }, "singleThread": { "type": "boolean", "description": "If this flag is true, all other suspended threads are not resumed." }, "granularity": { "$ref": "#/definitions/SteppingGranularity", "description": "Stepping granularity. If no granularity is specified, a granularity of `statement` is assumed." } }, "required": [ "threadId" ] }, "StepOutResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `stepOut` request. This is just an acknowledgement, so no body field is required." }] }, "StepBackRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request executes one backward step (in the given granularity) for the specified thread and allows all other threads to run backward freely by resuming them.\nIf the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true prevents other suspended threads from resuming.\nThe debug adapter first sends the response and then a `stopped` event (with reason `step`) after the step has completed.\nClients should only call this request if the corresponding capability `supportsStepBack` is true.", "properties": { "command": { "type": "string", "enum": [ "stepBack" ] }, "arguments": { "$ref": "#/definitions/StepBackArguments" } }, "required": [ "command", "arguments" ] }] }, "StepBackArguments": { "type": "object", "description": "Arguments for `stepBack` request.", "properties": { "threadId": { "type": "integer", "description": "Specifies the thread for which to resume execution for one step backwards (of the given granularity)." }, "singleThread": { "type": "boolean", "description": "If this flag is true, all other suspended threads are not resumed." }, "granularity": { "$ref": "#/definitions/SteppingGranularity", "description": "Stepping granularity to step. If no granularity is specified, a granularity of `statement` is assumed." } }, "required": [ "threadId" ] }, "StepBackResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `stepBack` request. This is just an acknowledgement, so no body field is required." }] }, "ReverseContinueRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request resumes backward execution of all threads. If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true resumes only the specified thread. If not all threads were resumed, the `allThreadsContinued` attribute of the response should be set to false.\nClients should only call this request if the corresponding capability `supportsStepBack` is true.", "properties": { "command": { "type": "string", "enum": [ "reverseContinue" ] }, "arguments": { "$ref": "#/definitions/ReverseContinueArguments" } }, "required": [ "command", "arguments" ] }] }, "ReverseContinueArguments": { "type": "object", "description": "Arguments for `reverseContinue` request.", "properties": { "threadId": { "type": "integer", "description": "Specifies the active thread. If the debug adapter supports single thread execution (see `supportsSingleThreadExecutionRequests`) and the `singleThread` argument is true, only the thread with this ID is resumed." }, "singleThread": { "type": "boolean", "description": "If this flag is true, backward execution is resumed only for the thread with given `threadId`." } }, "required": [ "threadId" ] }, "ReverseContinueResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `reverseContinue` request. This is just an acknowledgement, so no body field is required." }] }, "RestartFrameRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request restarts execution of the specified stack frame.\nThe debug adapter first sends the response and then a `stopped` event (with reason `restart`) after the restart has completed.\nClients should only call this request if the corresponding capability `supportsRestartFrame` is true.", "properties": { "command": { "type": "string", "enum": [ "restartFrame" ] }, "arguments": { "$ref": "#/definitions/RestartFrameArguments" } }, "required": [ "command", "arguments" ] }] }, "RestartFrameArguments": { "type": "object", "description": "Arguments for `restartFrame` request.", "properties": { "frameId": { "type": "integer", "description": "Restart the stack frame identified by `frameId`. The `frameId` must have been obtained in the current suspended state. See 'Lifetime of Object References' in the Overview section for details." } }, "required": [ "frameId" ] }, "RestartFrameResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `restartFrame` request. This is just an acknowledgement, so no body field is required." }] }, "GotoRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request sets the location where the debuggee will continue to run.\nThis makes it possible to skip the execution of code or to execute code again.\nThe code between the current location and the goto target is not executed but skipped.\nThe debug adapter first sends the response and then a `stopped` event with reason `goto`.\nClients should only call this request if the corresponding capability `supportsGotoTargetsRequest` is true (because only then goto targets exist that can be passed as arguments).", "properties": { "command": { "type": "string", "enum": [ "goto" ] }, "arguments": { "$ref": "#/definitions/GotoArguments" } }, "required": [ "command", "arguments" ] }] }, "GotoArguments": { "type": "object", "description": "Arguments for `goto` request.", "properties": { "threadId": { "type": "integer", "description": "Set the goto target for this thread." }, "targetId": { "type": "integer", "description": "The location where the debuggee will continue to run." } }, "required": [ "threadId", "targetId" ] }, "GotoResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `goto` request. This is just an acknowledgement, so no body field is required." }] }, "PauseRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request suspends the debuggee.\nThe debug adapter first sends the response and then a `stopped` event (with reason `pause`) after the thread has been paused successfully.", "properties": { "command": { "type": "string", "enum": [ "pause" ] }, "arguments": { "$ref": "#/definitions/PauseArguments" } }, "required": [ "command", "arguments" ] }] }, "PauseArguments": { "type": "object", "description": "Arguments for `pause` request.", "properties": { "threadId": { "type": "integer", "description": "Pause execution for this thread." } }, "required": [ "threadId" ] }, "PauseResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `pause` request. This is just an acknowledgement, so no body field is required." }] }, "StackTraceRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request returns a stacktrace from the current execution state of a given thread.\nA client can request all stack frames by omitting the startFrame and levels arguments. For performance-conscious clients and if the corresponding capability `supportsDelayedStackTraceLoading` is true, stack frames can be retrieved in a piecemeal way with the `startFrame` and `levels` arguments. The response of the `stackTrace` request may contain a `totalFrames` property that hints at the total number of frames in the stack. If a client needs this total number upfront, it can issue a request for a single (first) frame and depending on the value of `totalFrames` decide how to proceed. In any case a client should be prepared to receive fewer frames than requested, which is an indication that the end of the stack has been reached.", "properties": { "command": { "type": "string", "enum": [ "stackTrace" ] }, "arguments": { "$ref": "#/definitions/StackTraceArguments" } }, "required": [ "command", "arguments" ] }] }, "StackTraceArguments": { "type": "object", "description": "Arguments for `stackTrace` request.", "properties": { "threadId": { "type": "integer", "description": "Retrieve the stacktrace for this thread." }, "startFrame": { "type": "integer", "description": "The index of the first frame to return; if omitted frames start at 0." }, "levels": { "type": "integer", "description": "The maximum number of frames to return. If levels is not specified or 0, all frames are returned." }, "format": { "$ref": "#/definitions/StackFrameFormat", "description": "Specifies details on how to format the stack frames.\nThe attribute is only honored by a debug adapter if the corresponding capability `supportsValueFormattingOptions` is true." } }, "required": [ "threadId" ] }, "StackTraceResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `stackTrace` request.", "properties": { "body": { "type": "object", "properties": { "stackFrames": { "type": "array", "items": { "$ref": "#/definitions/StackFrame" }, "description": "The frames of the stack frame. If the array has length zero, there are no stack frames available.\nThis means that there is no location information available." }, "totalFrames": { "type": "integer", "description": "The total number of frames available in the stack. If omitted or if `totalFrames` is larger than the available frames, a client is expected to request frames until a request returns less frames than requested (which indicates the end of the stack). Returning monotonically increasing `totalFrames` values for subsequent requests can be used to enforce paging in the client." } }, "required": [ "stackFrames" ] } }, "required": [ "body" ] }] }, "ScopesRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request returns the variable scopes for a given stack frame ID.", "properties": { "command": { "type": "string", "enum": [ "scopes" ] }, "arguments": { "$ref": "#/definitions/ScopesArguments" } }, "required": [ "command", "arguments" ] }] }, "ScopesArguments": { "type": "object", "description": "Arguments for `scopes` request.", "properties": { "frameId": { "type": "integer", "description": "Retrieve the scopes for the stack frame identified by `frameId`. The `frameId` must have been obtained in the current suspended state. See 'Lifetime of Object References' in the Overview section for details." } }, "required": [ "frameId" ] }, "ScopesResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `scopes` request.", "properties": { "body": { "type": "object", "properties": { "scopes": { "type": "array", "items": { "$ref": "#/definitions/Scope" }, "description": "The scopes of the stack frame. If the array has length zero, there are no scopes available." } }, "required": [ "scopes" ] } }, "required": [ "body" ] }] }, "VariablesRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Retrieves all child variables for the given variable reference.\nA filter can be used to limit the fetched children to either named or indexed children.", "properties": { "command": { "type": "string", "enum": [ "variables" ] }, "arguments": { "$ref": "#/definitions/VariablesArguments" } }, "required": [ "command", "arguments" ] }] }, "VariablesArguments": { "type": "object", "description": "Arguments for `variables` request.", "properties": { "variablesReference": { "type": "integer", "description": "The variable for which to retrieve its children. The `variablesReference` must have been obtained in the current suspended state. See 'Lifetime of Object References' in the Overview section for details." }, "filter": { "type": "string", "enum": [ "indexed", "named" ], "description": "Filter to limit the child variables to either named or indexed. If omitted, both types are fetched." }, "start": { "type": "integer", "description": "The index of the first variable to return; if omitted children start at 0." }, "count": { "type": "integer", "description": "The number of variables to return. If count is missing or 0, all variables are returned." }, "format": { "$ref": "#/definitions/ValueFormat", "description": "Specifies details on how to format the Variable values.\nThe attribute is only honored by a debug adapter if the corresponding capability `supportsValueFormattingOptions` is true." } }, "required": [ "variablesReference" ] }, "VariablesResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `variables` request.", "properties": { "body": { "type": "object", "properties": { "variables": { "type": "array", "items": { "$ref": "#/definitions/Variable" }, "description": "All (or a range) of variables for the given variable reference." } }, "required": [ "variables" ] } }, "required": [ "body" ] }] }, "SetVariableRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Set the variable with the given name in the variable container to a new value. Clients should only call this request if the corresponding capability `supportsSetVariable` is true.\nIf a debug adapter implements both `setVariable` and `setExpression`, a client will only use `setExpression` if the variable has an `evaluateName` property.", "properties": { "command": { "type": "string", "enum": [ "setVariable" ] }, "arguments": { "$ref": "#/definitions/SetVariableArguments" } }, "required": [ "command", "arguments" ] }] }, "SetVariableArguments": { "type": "object", "description": "Arguments for `setVariable` request.", "properties": { "variablesReference": { "type": "integer", "description": "The reference of the variable container. The `variablesReference` must have been obtained in the current suspended state. See 'Lifetime of Object References' in the Overview section for details." }, "name": { "type": "string", "description": "The name of the variable in the container." }, "value": { "type": "string", "description": "The value of the variable." }, "format": { "$ref": "#/definitions/ValueFormat", "description": "Specifies details on how to format the response value." } }, "required": [ "variablesReference", "name", "value" ] }, "SetVariableResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `setVariable` request.", "properties": { "body": { "type": "object", "properties": { "value": { "type": "string", "description": "The new value of the variable." }, "type": { "type": "string", "description": "The type of the new value. Typically shown in the UI when hovering over the value." }, "variablesReference": { "type": "integer", "description": "If `variablesReference` is > 0, the new value is structured and its children can be retrieved by passing `variablesReference` to the `variables` request as long as execution remains suspended. See 'Lifetime of Object References' in the Overview section for details." }, "namedVariables": { "type": "integer", "description": "The number of named child variables.\nThe client can use this information to present the variables in a paged UI and fetch them in chunks.\nThe value should be less than or equal to 2147483647 (2^31-1)." }, "indexedVariables": { "type": "integer", "description": "The number of indexed child variables.\nThe client can use this information to present the variables in a paged UI and fetch them in chunks.\nThe value should be less than or equal to 2147483647 (2^31-1)." } }, "required": [ "value" ] } }, "required": [ "body" ] }] }, "SourceRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request retrieves the source code for a given source reference.", "properties": { "command": { "type": "string", "enum": [ "source" ] }, "arguments": { "$ref": "#/definitions/SourceArguments" } }, "required": [ "command", "arguments" ] }] }, "SourceArguments": { "type": "object", "description": "Arguments for `source` request.", "properties": { "source": { "$ref": "#/definitions/Source", "description": "Specifies the source content to load. Either `source.path` or `source.sourceReference` must be specified." }, "sourceReference": { "type": "integer", "description": "The reference to the source. This is the same as `source.sourceReference`.\nThis is provided for backward compatibility since old clients do not understand the `source` attribute." } }, "required": [ "sourceReference" ] }, "SourceResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `source` request.", "properties": { "body": { "type": "object", "properties": { "content": { "type": "string", "description": "Content of the source reference." }, "mimeType": { "type": "string", "description": "Content type (MIME type) of the source." } }, "required": [ "content" ] } }, "required": [ "body" ] }] }, "ThreadsRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request retrieves a list of all threads.", "properties": { "command": { "type": "string", "enum": [ "threads" ] } }, "required": [ "command" ] }] }, "ThreadsResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `threads` request.", "properties": { "body": { "type": "object", "properties": { "threads": { "type": "array", "items": { "$ref": "#/definitions/Thread" }, "description": "All threads." } }, "required": [ "threads" ] } }, "required": [ "body" ] }] }, "TerminateThreadsRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "The request terminates the threads with the given ids.\nClients should only call this request if the corresponding capability `supportsTerminateThreadsRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "terminateThreads" ] }, "arguments": { "$ref": "#/definitions/TerminateThreadsArguments" } }, "required": [ "command", "arguments" ] }] }, "TerminateThreadsArguments": { "type": "object", "description": "Arguments for `terminateThreads` request.", "properties": { "threadIds": { "type": "array", "items": { "type": "integer" }, "description": "Ids of threads to be terminated." } } }, "TerminateThreadsResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `terminateThreads` request. This is just an acknowledgement, no body field is required." }] }, "ModulesRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Modules can be retrieved from the debug adapter with this request which can either return all modules or a range of modules to support paging.\nClients should only call this request if the corresponding capability `supportsModulesRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "modules" ] }, "arguments": { "$ref": "#/definitions/ModulesArguments" } }, "required": [ "command", "arguments" ] }] }, "ModulesArguments": { "type": "object", "description": "Arguments for `modules` request.", "properties": { "startModule": { "type": "integer", "description": "The index of the first module to return; if omitted modules start at 0." }, "moduleCount": { "type": "integer", "description": "The number of modules to return. If `moduleCount` is not specified or 0, all modules are returned." } } }, "ModulesResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `modules` request.", "properties": { "body": { "type": "object", "properties": { "modules": { "type": "array", "items": { "$ref": "#/definitions/Module" }, "description": "All modules or range of modules." }, "totalModules": { "type": "integer", "description": "The total number of modules available." } }, "required": [ "modules" ] } }, "required": [ "body" ] }] }, "LoadedSourcesRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Retrieves the set of all sources currently loaded by the debugged process.\nClients should only call this request if the corresponding capability `supportsLoadedSourcesRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "loadedSources" ] }, "arguments": { "$ref": "#/definitions/LoadedSourcesArguments" } }, "required": [ "command" ] }] }, "LoadedSourcesArguments": { "type": "object", "description": "Arguments for `loadedSources` request." }, "LoadedSourcesResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `loadedSources` request.", "properties": { "body": { "type": "object", "properties": { "sources": { "type": "array", "items": { "$ref": "#/definitions/Source" }, "description": "Set of loaded sources." } }, "required": [ "sources" ] } }, "required": [ "body" ] }] }, "EvaluateRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Evaluates the given expression in the context of the topmost stack frame.\nThe expression has access to any variables and arguments that are in scope.", "properties": { "command": { "type": "string", "enum": [ "evaluate" ] }, "arguments": { "$ref": "#/definitions/EvaluateArguments" } }, "required": [ "command", "arguments" ] }] }, "EvaluateArguments": { "type": "object", "description": "Arguments for `evaluate` request.", "properties": { "expression": { "type": "string", "description": "The expression to evaluate." }, "frameId": { "type": "integer", "description": "Evaluate the expression in the scope of this stack frame. If not specified, the expression is evaluated in the global scope." }, "context": { "type": "string", "_enum": [ "watch", "repl", "hover", "clipboard", "variables" ], "enumDescriptions": [ "evaluate is called from a watch view context.", "evaluate is called from a REPL context.", "evaluate is called to generate the debug hover contents.\nThis value should only be used if the corresponding capability `supportsEvaluateForHovers` is true.", "evaluate is called to generate clipboard contents.\nThis value should only be used if the corresponding capability `supportsClipboardContext` is true.", "evaluate is called from a variables view context." ], "description": "The context in which the evaluate request is used." }, "format": { "$ref": "#/definitions/ValueFormat", "description": "Specifies details on how to format the result.\nThe attribute is only honored by a debug adapter if the corresponding capability `supportsValueFormattingOptions` is true." } }, "required": [ "expression" ] }, "EvaluateResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `evaluate` request.", "properties": { "body": { "type": "object", "properties": { "result": { "type": "string", "description": "The result of the evaluate request." }, "type": { "type": "string", "description": "The type of the evaluate result.\nThis attribute should only be returned by a debug adapter if the corresponding capability `supportsVariableType` is true." }, "presentationHint": { "$ref": "#/definitions/VariablePresentationHint", "description": "Properties of an evaluate result that can be used to determine how to render the result in the UI." }, "variablesReference": { "type": "integer", "description": "If `variablesReference` is > 0, the evaluate result is structured and its children can be retrieved by passing `variablesReference` to the `variables` request as long as execution remains suspended. See 'Lifetime of Object References' in the Overview section for details." }, "namedVariables": { "type": "integer", "description": "The number of named child variables.\nThe client can use this information to present the variables in a paged UI and fetch them in chunks.\nThe value should be less than or equal to 2147483647 (2^31-1)." }, "indexedVariables": { "type": "integer", "description": "The number of indexed child variables.\nThe client can use this information to present the variables in a paged UI and fetch them in chunks.\nThe value should be less than or equal to 2147483647 (2^31-1)." }, "memoryReference": { "type": "string", "description": "A memory reference to a location appropriate for this result.\nFor pointer type eval results, this is generally a reference to the memory address contained in the pointer.\nThis attribute should be returned by a debug adapter if corresponding capability `supportsMemoryReferences` is true." } }, "required": [ "result", "variablesReference" ] } }, "required": [ "body" ] }] }, "SetExpressionRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Evaluates the given `value` expression and assigns it to the `expression` which must be a modifiable l-value.\nThe expressions have access to any variables and arguments that are in scope of the specified frame.\nClients should only call this request if the corresponding capability `supportsSetExpression` is true.\nIf a debug adapter implements both `setExpression` and `setVariable`, a client uses `setExpression` if the variable has an `evaluateName` property.", "properties": { "command": { "type": "string", "enum": [ "setExpression" ] }, "arguments": { "$ref": "#/definitions/SetExpressionArguments" } }, "required": [ "command", "arguments" ] }] }, "SetExpressionArguments": { "type": "object", "description": "Arguments for `setExpression` request.", "properties": { "expression": { "type": "string", "description": "The l-value expression to assign to." }, "value": { "type": "string", "description": "The value expression to assign to the l-value expression." }, "frameId": { "type": "integer", "description": "Evaluate the expressions in the scope of this stack frame. If not specified, the expressions are evaluated in the global scope." }, "format": { "$ref": "#/definitions/ValueFormat", "description": "Specifies how the resulting value should be formatted." } }, "required": [ "expression", "value" ] }, "SetExpressionResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `setExpression` request.", "properties": { "body": { "type": "object", "properties": { "value": { "type": "string", "description": "The new value of the expression." }, "type": { "type": "string", "description": "The type of the value.\nThis attribute should only be returned by a debug adapter if the corresponding capability `supportsVariableType` is true." }, "presentationHint": { "$ref": "#/definitions/VariablePresentationHint", "description": "Properties of a value that can be used to determine how to render the result in the UI." }, "variablesReference": { "type": "integer", "description": "If `variablesReference` is > 0, the evaluate result is structured and its children can be retrieved by passing `variablesReference` to the `variables` request as long as execution remains suspended. See 'Lifetime of Object References' in the Overview section for details." }, "namedVariables": { "type": "integer", "description": "The number of named child variables.\nThe client can use this information to present the variables in a paged UI and fetch them in chunks.\nThe value should be less than or equal to 2147483647 (2^31-1)." }, "indexedVariables": { "type": "integer", "description": "The number of indexed child variables.\nThe client can use this information to present the variables in a paged UI and fetch them in chunks.\nThe value should be less than or equal to 2147483647 (2^31-1)." } }, "required": [ "value" ] } }, "required": [ "body" ] }] }, "StepInTargetsRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "This request retrieves the possible step-in targets for the specified stack frame.\nThese targets can be used in the `stepIn` request.\nClients should only call this request if the corresponding capability `supportsStepInTargetsRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "stepInTargets" ] }, "arguments": { "$ref": "#/definitions/StepInTargetsArguments" } }, "required": [ "command", "arguments" ] }] }, "StepInTargetsArguments": { "type": "object", "description": "Arguments for `stepInTargets` request.", "properties": { "frameId": { "type": "integer", "description": "The stack frame for which to retrieve the possible step-in targets." } }, "required": [ "frameId" ] }, "StepInTargetsResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `stepInTargets` request.", "properties": { "body": { "type": "object", "properties": { "targets": { "type": "array", "items": { "$ref": "#/definitions/StepInTarget" }, "description": "The possible step-in targets of the specified source location." } }, "required": [ "targets" ] } }, "required": [ "body" ] }] }, "GotoTargetsRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "This request retrieves the possible goto targets for the specified source location.\nThese targets can be used in the `goto` request.\nClients should only call this request if the corresponding capability `supportsGotoTargetsRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "gotoTargets" ] }, "arguments": { "$ref": "#/definitions/GotoTargetsArguments" } }, "required": [ "command", "arguments" ] }] }, "GotoTargetsArguments": { "type": "object", "description": "Arguments for `gotoTargets` request.", "properties": { "source": { "$ref": "#/definitions/Source", "description": "The source location for which the goto targets are determined." }, "line": { "type": "integer", "description": "The line location for which the goto targets are determined." }, "column": { "type": "integer", "description": "The position within `line` for which the goto targets are determined. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." } }, "required": [ "source", "line" ] }, "GotoTargetsResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `gotoTargets` request.", "properties": { "body": { "type": "object", "properties": { "targets": { "type": "array", "items": { "$ref": "#/definitions/GotoTarget" }, "description": "The possible goto targets of the specified location." } }, "required": [ "targets" ] } }, "required": [ "body" ] }] }, "CompletionsRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Returns a list of possible completions for a given caret position and text.\nClients should only call this request if the corresponding capability `supportsCompletionsRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "completions" ] }, "arguments": { "$ref": "#/definitions/CompletionsArguments" } }, "required": [ "command", "arguments" ] }] }, "CompletionsArguments": { "type": "object", "description": "Arguments for `completions` request.", "properties": { "frameId": { "type": "integer", "description": "Returns completions in the scope of this stack frame. If not specified, the completions are returned for the global scope." }, "text": { "type": "string", "description": "One or more source lines. Typically this is the text users have typed into the debug console before they asked for completion." }, "column": { "type": "integer", "description": "The position within `text` for which to determine the completion proposals. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." }, "line": { "type": "integer", "description": "A line for which to determine the completion proposals. If missing the first line of the text is assumed." } }, "required": [ "text", "column" ] }, "CompletionsResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `completions` request.", "properties": { "body": { "type": "object", "properties": { "targets": { "type": "array", "items": { "$ref": "#/definitions/CompletionItem" }, "description": "The possible completions for ." } }, "required": [ "targets" ] } }, "required": [ "body" ] }] }, "ExceptionInfoRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Retrieves the details of the exception that caused this event to be raised.\nClients should only call this request if the corresponding capability `supportsExceptionInfoRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "exceptionInfo" ] }, "arguments": { "$ref": "#/definitions/ExceptionInfoArguments" } }, "required": [ "command", "arguments" ] }] }, "ExceptionInfoArguments": { "type": "object", "description": "Arguments for `exceptionInfo` request.", "properties": { "threadId": { "type": "integer", "description": "Thread for which exception information should be retrieved." } }, "required": [ "threadId" ] }, "ExceptionInfoResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `exceptionInfo` request.", "properties": { "body": { "type": "object", "properties": { "exceptionId": { "type": "string", "description": "ID of the exception that was thrown." }, "description": { "type": "string", "description": "Descriptive text for the exception." }, "breakMode": { "$ref": "#/definitions/ExceptionBreakMode", "description": "Mode that caused the exception notification to be raised." }, "details": { "$ref": "#/definitions/ExceptionDetails", "description": "Detailed information about the exception." } }, "required": [ "exceptionId", "breakMode" ] } }, "required": [ "body" ] }] }, "ReadMemoryRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Reads bytes from memory at the provided location.\nClients should only call this request if the corresponding capability `supportsReadMemoryRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "readMemory" ] }, "arguments": { "$ref": "#/definitions/ReadMemoryArguments" } }, "required": [ "command", "arguments" ] }] }, "ReadMemoryArguments": { "type": "object", "description": "Arguments for `readMemory` request.", "properties": { "memoryReference": { "type": "string", "description": "Memory reference to the base location from which data should be read." }, "offset": { "type": "integer", "description": "Offset (in bytes) to be applied to the reference location before reading data. Can be negative." }, "count": { "type": "integer", "description": "Number of bytes to read at the specified location and offset." } }, "required": [ "memoryReference", "count" ] }, "ReadMemoryResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `readMemory` request.", "properties": { "body": { "type": "object", "properties": { "address": { "type": "string", "description": "The address of the first byte of data returned.\nTreated as a hex value if prefixed with `0x`, or as a decimal value otherwise." }, "unreadableBytes": { "type": "integer", "description": "The number of unreadable bytes encountered after the last successfully read byte.\nThis can be used to determine the number of bytes that should be skipped before a subsequent `readMemory` request succeeds." }, "data": { "type": "string", "description": "The bytes read from memory, encoded using base64. If the decoded length of `data` is less than the requested `count` in the original `readMemory` request, and `unreadableBytes` is zero or omitted, then the client should assume it's reached the end of readable memory." } }, "required": [ "address" ] } } }] }, "WriteMemoryRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Writes bytes to memory at the provided location.\nClients should only call this request if the corresponding capability `supportsWriteMemoryRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "writeMemory" ] }, "arguments": { "$ref": "#/definitions/WriteMemoryArguments" } }, "required": [ "command", "arguments" ] }] }, "WriteMemoryArguments": { "type": "object", "description": "Arguments for `writeMemory` request.", "properties": { "memoryReference": { "type": "string", "description": "Memory reference to the base location to which data should be written." }, "offset": { "type": "integer", "description": "Offset (in bytes) to be applied to the reference location before writing data. Can be negative." }, "allowPartial": { "type": "boolean", "description": "Property to control partial writes. If true, the debug adapter should attempt to write memory even if the entire memory region is not writable. In such a case the debug adapter should stop after hitting the first byte of memory that cannot be written and return the number of bytes written in the response via the `offset` and `bytesWritten` properties.\nIf false or missing, a debug adapter should attempt to verify the region is writable before writing, and fail the response if it is not." }, "data": { "type": "string", "description": "Bytes to write, encoded using base64." } }, "required": [ "memoryReference", "data" ] }, "WriteMemoryResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `writeMemory` request.", "properties": { "body": { "type": "object", "properties": { "offset": { "type": "integer", "description": "Property that should be returned when `allowPartial` is true to indicate the offset of the first byte of data successfully written. Can be negative." }, "bytesWritten": { "type": "integer", "description": "Property that should be returned when `allowPartial` is true to indicate the number of bytes starting from address that were successfully written." } } } } }] }, "DisassembleRequest": { "allOf": [ { "$ref": "#/definitions/Request" }, { "type": "object", "description": "Disassembles code stored at the provided location.\nClients should only call this request if the corresponding capability `supportsDisassembleRequest` is true.", "properties": { "command": { "type": "string", "enum": [ "disassemble" ] }, "arguments": { "$ref": "#/definitions/DisassembleArguments" } }, "required": [ "command", "arguments" ] }] }, "DisassembleArguments": { "type": "object", "description": "Arguments for `disassemble` request.", "properties": { "memoryReference": { "type": "string", "description": "Memory reference to the base location containing the instructions to disassemble." }, "offset": { "type": "integer", "description": "Offset (in bytes) to be applied to the reference location before disassembling. Can be negative." }, "instructionOffset": { "type": "integer", "description": "Offset (in instructions) to be applied after the byte offset (if any) before disassembling. Can be negative." }, "instructionCount": { "type": "integer", "description": "Number of instructions to disassemble starting at the specified location and offset.\nAn adapter must return exactly this number of instructions - any unavailable instructions should be replaced with an implementation-defined 'invalid instruction' value." }, "resolveSymbols": { "type": "boolean", "description": "If true, the adapter should attempt to resolve memory addresses and other values to symbolic names." } }, "required": [ "memoryReference", "instructionCount" ] }, "DisassembleResponse": { "allOf": [ { "$ref": "#/definitions/Response" }, { "type": "object", "description": "Response to `disassemble` request.", "properties": { "body": { "type": "object", "properties": { "instructions": { "type": "array", "items": { "$ref": "#/definitions/DisassembledInstruction" }, "description": "The list of disassembled instructions." } }, "required": [ "instructions" ] } } }] }, "Capabilities": { "type": "object", "title": "Types", "description": "Information about the capabilities of a debug adapter.", "properties": { "supportsConfigurationDoneRequest": { "type": "boolean", "description": "The debug adapter supports the `configurationDone` request." }, "supportsFunctionBreakpoints": { "type": "boolean", "description": "The debug adapter supports function breakpoints." }, "supportsConditionalBreakpoints": { "type": "boolean", "description": "The debug adapter supports conditional breakpoints." }, "supportsHitConditionalBreakpoints": { "type": "boolean", "description": "The debug adapter supports breakpoints that break execution after a specified number of hits." }, "supportsEvaluateForHovers": { "type": "boolean", "description": "The debug adapter supports a (side effect free) `evaluate` request for data hovers." }, "exceptionBreakpointFilters": { "type": "array", "items": { "$ref": "#/definitions/ExceptionBreakpointsFilter" }, "description": "Available exception filter options for the `setExceptionBreakpoints` request." }, "supportsStepBack": { "type": "boolean", "description": "The debug adapter supports stepping back via the `stepBack` and `reverseContinue` requests." }, "supportsSetVariable": { "type": "boolean", "description": "The debug adapter supports setting a variable to a value." }, "supportsRestartFrame": { "type": "boolean", "description": "The debug adapter supports restarting a frame." }, "supportsGotoTargetsRequest": { "type": "boolean", "description": "The debug adapter supports the `gotoTargets` request." }, "supportsStepInTargetsRequest": { "type": "boolean", "description": "The debug adapter supports the `stepInTargets` request." }, "supportsCompletionsRequest": { "type": "boolean", "description": "The debug adapter supports the `completions` request." }, "completionTriggerCharacters": { "type": "array", "items": { "type": "string" }, "description": "The set of characters that should trigger completion in a REPL. If not specified, the UI should assume the `.` character." }, "supportsModulesRequest": { "type": "boolean", "description": "The debug adapter supports the `modules` request." }, "additionalModuleColumns": { "type": "array", "items": { "$ref": "#/definitions/ColumnDescriptor" }, "description": "The set of additional module information exposed by the debug adapter." }, "supportedChecksumAlgorithms": { "type": "array", "items": { "$ref": "#/definitions/ChecksumAlgorithm" }, "description": "Checksum algorithms supported by the debug adapter." }, "supportsRestartRequest": { "type": "boolean", "description": "The debug adapter supports the `restart` request. In this case a client should not implement `restart` by terminating and relaunching the adapter but by calling the `restart` request." }, "supportsExceptionOptions": { "type": "boolean", "description": "The debug adapter supports `exceptionOptions` on the `setExceptionBreakpoints` request." }, "supportsValueFormattingOptions": { "type": "boolean", "description": "The debug adapter supports a `format` attribute on the `stackTrace`, `variables`, and `evaluate` requests." }, "supportsExceptionInfoRequest": { "type": "boolean", "description": "The debug adapter supports the `exceptionInfo` request." }, "supportTerminateDebuggee": { "type": "boolean", "description": "The debug adapter supports the `terminateDebuggee` attribute on the `disconnect` request." }, "supportSuspendDebuggee": { "type": "boolean", "description": "The debug adapter supports the `suspendDebuggee` attribute on the `disconnect` request." }, "supportsDelayedStackTraceLoading": { "type": "boolean", "description": "The debug adapter supports the delayed loading of parts of the stack, which requires that both the `startFrame` and `levels` arguments and the `totalFrames` result of the `stackTrace` request are supported." }, "supportsLoadedSourcesRequest": { "type": "boolean", "description": "The debug adapter supports the `loadedSources` request." }, "supportsLogPoints": { "type": "boolean", "description": "The debug adapter supports log points by interpreting the `logMessage` attribute of the `SourceBreakpoint`." }, "supportsTerminateThreadsRequest": { "type": "boolean", "description": "The debug adapter supports the `terminateThreads` request." }, "supportsSetExpression": { "type": "boolean", "description": "The debug adapter supports the `setExpression` request." }, "supportsTerminateRequest": { "type": "boolean", "description": "The debug adapter supports the `terminate` request." }, "supportsDataBreakpoints": { "type": "boolean", "description": "The debug adapter supports data breakpoints." }, "supportsReadMemoryRequest": { "type": "boolean", "description": "The debug adapter supports the `readMemory` request." }, "supportsWriteMemoryRequest": { "type": "boolean", "description": "The debug adapter supports the `writeMemory` request." }, "supportsDisassembleRequest": { "type": "boolean", "description": "The debug adapter supports the `disassemble` request." }, "supportsCancelRequest": { "type": "boolean", "description": "The debug adapter supports the `cancel` request." }, "supportsBreakpointLocationsRequest": { "type": "boolean", "description": "The debug adapter supports the `breakpointLocations` request." }, "supportsClipboardContext": { "type": "boolean", "description": "The debug adapter supports the `clipboard` context value in the `evaluate` request." }, "supportsSteppingGranularity": { "type": "boolean", "description": "The debug adapter supports stepping granularities (argument `granularity`) for the stepping requests." }, "supportsInstructionBreakpoints": { "type": "boolean", "description": "The debug adapter supports adding breakpoints based on instruction references." }, "supportsExceptionFilterOptions": { "type": "boolean", "description": "The debug adapter supports `filterOptions` as an argument on the `setExceptionBreakpoints` request." }, "supportsSingleThreadExecutionRequests": { "type": "boolean", "description": "The debug adapter supports the `singleThread` property on the execution requests (`continue`, `next`, `stepIn`, `stepOut`, `reverseContinue`, `stepBack`)." } } }, "ExceptionBreakpointsFilter": { "type": "object", "description": "An `ExceptionBreakpointsFilter` is shown in the UI as an filter option for configuring how exceptions are dealt with.", "properties": { "filter": { "type": "string", "description": "The internal ID of the filter option. This value is passed to the `setExceptionBreakpoints` request." }, "label": { "type": "string", "description": "The name of the filter option. This is shown in the UI." }, "description": { "type": "string", "description": "A help text providing additional information about the exception filter. This string is typically shown as a hover and can be translated." }, "default": { "type": "boolean", "description": "Initial value of the filter option. If not specified a value false is assumed." }, "supportsCondition": { "type": "boolean", "description": "Controls whether a condition can be specified for this filter option. If false or missing, a condition can not be set." }, "conditionDescription": { "type": "string", "description": "A help text providing information about the condition. This string is shown as the placeholder text for a text box and can be translated." } }, "required": [ "filter", "label" ] }, "Message": { "type": "object", "description": "A structured message object. Used to return errors from requests.", "properties": { "id": { "type": "integer", "description": "Unique (within a debug adapter implementation) identifier for the message. The purpose of these error IDs is to help extension authors that have the requirement that every user visible error message needs a corresponding error number, so that users or customer support can find information about the specific error more easily." }, "format": { "type": "string", "description": "A format string for the message. Embedded variables have the form `{name}`.\nIf variable name starts with an underscore character, the variable does not contain user data (PII) and can be safely used for telemetry purposes." }, "variables": { "type": "object", "description": "An object used as a dictionary for looking up the variables in the format string.", "additionalProperties": { "type": "string", "description": "All dictionary values must be strings." } }, "sendTelemetry": { "type": "boolean", "description": "If true send to telemetry." }, "showUser": { "type": "boolean", "description": "If true show user." }, "url": { "type": "string", "description": "A url where additional information about this message can be found." }, "urlLabel": { "type": "string", "description": "A label that is presented to the user as the UI for opening the url." } }, "required": [ "id", "format" ] }, "Module": { "type": "object", "description": "A Module object represents a row in the modules view.\nThe `id` attribute identifies a module in the modules view and is used in a `module` event for identifying a module for adding, updating or deleting.\nThe `name` attribute is used to minimally render the module in the UI.\n\nAdditional attributes can be added to the module. They show up in the module view if they have a corresponding `ColumnDescriptor`.\n\nTo avoid an unnecessary proliferation of additional attributes with similar semantics but different names, we recommend to re-use attributes from the 'recommended' list below first, and only introduce new attributes if nothing appropriate could be found.", "properties": { "id": { "type": ["integer", "string"], "description": "Unique identifier for the module." }, "name": { "type": "string", "description": "A name of the module." }, "path": { "type": "string", "description": "Logical full path to the module. The exact definition is implementation defined, but usually this would be a full path to the on-disk file for the module." }, "isOptimized": { "type": "boolean", "description": "True if the module is optimized." }, "isUserCode": { "type": "boolean", "description": "True if the module is considered 'user code' by a debugger that supports 'Just My Code'." }, "version": { "type": "string", "description": "Version of Module." }, "symbolStatus": { "type": "string", "description": "User-understandable description of if symbols were found for the module (ex: 'Symbols Loaded', 'Symbols not found', etc.)" }, "symbolFilePath": { "type": "string", "description": "Logical full path to the symbol file. The exact definition is implementation defined." }, "dateTimeStamp": { "type": "string", "description": "Module created or modified, encoded as a RFC 3339 timestamp." }, "addressRange": { "type": "string", "description": "Address range covered by this module." } }, "required": [ "id", "name" ] }, "ColumnDescriptor": { "type": "object", "description": "A `ColumnDescriptor` specifies what module attribute to show in a column of the modules view, how to format it,\nand what the column's label should be.\nIt is only used if the underlying UI actually supports this level of customization.", "properties": { "attributeName": { "type": "string", "description": "Name of the attribute rendered in this column." }, "label": { "type": "string", "description": "Header UI label of column." }, "format": { "type": "string", "description": "Format to use for the rendered values in this column. TBD how the format strings looks like." }, "type": { "type": "string", "enum": [ "string", "number", "boolean", "unixTimestampUTC" ], "description": "Datatype of values in this column. Defaults to `string` if not specified." }, "width": { "type": "integer", "description": "Width of this column in characters (hint only)." } }, "required": [ "attributeName", "label"] }, "ModulesViewDescriptor": { "type": "object", "description": "The ModulesViewDescriptor is the container for all declarative configuration options of a module view.\nFor now it only specifies the columns to be shown in the modules view.", "properties": { "columns": { "type": "array", "items": { "$ref": "#/definitions/ColumnDescriptor" } } }, "required": [ "columns" ] }, "Thread": { "type": "object", "description": "A Thread", "properties": { "id": { "type": "integer", "description": "Unique identifier for the thread." }, "name": { "type": "string", "description": "The name of the thread." } }, "required": [ "id", "name" ] }, "Source": { "type": "object", "description": "A `Source` is a descriptor for source code.\nIt is returned from the debug adapter as part of a `StackFrame` and it is used by clients when specifying breakpoints.", "properties": { "name": { "type": "string", "description": "The short name of the source. Every source returned from the debug adapter has a name.\nWhen sending a source to the debug adapter this name is optional." }, "path": { "type": "string", "description": "The path of the source to be shown in the UI.\nIt is only used to locate and load the content of the source if no `sourceReference` is specified (or its value is 0)." }, "sourceReference": { "type": "integer", "description": "If the value > 0 the contents of the source must be retrieved through the `source` request (even if a path is specified).\nSince a `sourceReference` is only valid for a session, it can not be used to persist a source.\nThe value should be less than or equal to 2147483647 (2^31-1)." }, "presentationHint": { "type": "string", "description": "A hint for how to present the source in the UI.\nA value of `deemphasize` can be used to indicate that the source is not available or that it is skipped on stepping.", "enum": [ "normal", "emphasize", "deemphasize" ] }, "origin": { "type": "string", "description": "The origin of this source. For example, 'internal module', 'inlined content from source map', etc." }, "sources": { "type": "array", "items": { "$ref": "#/definitions/Source" }, "description": "A list of sources that are related to this source. These may be the source that generated this source." }, "adapterData": { "type": [ "array", "boolean", "integer", "null", "number", "object", "string" ], "description": "Additional data that a debug adapter might want to loop through the client.\nThe client should leave the data intact and persist it across sessions. The client should not interpret the data." }, "checksums": { "type": "array", "items": { "$ref": "#/definitions/Checksum" }, "description": "The checksums associated with this file." } } }, "StackFrame": { "type": "object", "description": "A Stackframe contains the source location.", "properties": { "id": { "type": "integer", "description": "An identifier for the stack frame. It must be unique across all threads.\nThis id can be used to retrieve the scopes of the frame with the `scopes` request or to restart the execution of a stack frame." }, "name": { "type": "string", "description": "The name of the stack frame, typically a method name." }, "source": { "$ref": "#/definitions/Source", "description": "The source of the frame." }, "line": { "type": "integer", "description": "The line within the source of the frame. If the source attribute is missing or doesn't exist, `line` is 0 and should be ignored by the client." }, "column": { "type": "integer", "description": "Start position of the range covered by the stack frame. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based. If attribute `source` is missing or doesn't exist, `column` is 0 and should be ignored by the client." }, "endLine": { "type": "integer", "description": "The end line of the range covered by the stack frame." }, "endColumn": { "type": "integer", "description": "End position of the range covered by the stack frame. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." }, "canRestart": { "type": "boolean", "description": "Indicates whether this frame can be restarted with the `restart` request. Clients should only use this if the debug adapter supports the `restart` request and the corresponding capability `supportsRestartRequest` is true. If a debug adapter has this capability, then `canRestart` defaults to `true` if the property is absent." }, "instructionPointerReference": { "type": "string", "description": "A memory reference for the current instruction pointer in this frame." }, "moduleId": { "type": ["integer", "string"], "description": "The module associated with this frame, if any." }, "presentationHint": { "type": "string", "enum": [ "normal", "label", "subtle" ], "description": "A hint for how to present this frame in the UI.\nA value of `label` can be used to indicate that the frame is an artificial frame that is used as a visual label or separator. A value of `subtle` can be used to change the appearance of a frame in a 'subtle' way." } }, "required": [ "id", "name", "line", "column" ] }, "Scope": { "type": "object", "description": "A `Scope` is a named container for variables. Optionally a scope can map to a source or a range within a source.", "properties": { "name": { "type": "string", "description": "Name of the scope such as 'Arguments', 'Locals', or 'Registers'. This string is shown in the UI as is and can be translated." }, "presentationHint": { "type": "string", "description": "A hint for how to present this scope in the UI. If this attribute is missing, the scope is shown with a generic UI.", "_enum": [ "arguments", "locals", "registers" ], "enumDescriptions": [ "Scope contains method arguments.", "Scope contains local variables.", "Scope contains registers. Only a single `registers` scope should be returned from a `scopes` request." ] }, "variablesReference": { "type": "integer", "description": "The variables of this scope can be retrieved by passing the value of `variablesReference` to the `variables` request as long as execution remains suspended. See 'Lifetime of Object References' in the Overview section for details." }, "namedVariables": { "type": "integer", "description": "The number of named variables in this scope.\nThe client can use this information to present the variables in a paged UI and fetch them in chunks." }, "indexedVariables": { "type": "integer", "description": "The number of indexed variables in this scope.\nThe client can use this information to present the variables in a paged UI and fetch them in chunks." }, "expensive": { "type": "boolean", "description": "If true, the number of variables in this scope is large or expensive to retrieve." }, "source": { "$ref": "#/definitions/Source", "description": "The source for this scope." }, "line": { "type": "integer", "description": "The start line of the range covered by this scope." }, "column": { "type": "integer", "description": "Start position of the range covered by the scope. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." }, "endLine": { "type": "integer", "description": "The end line of the range covered by this scope." }, "endColumn": { "type": "integer", "description": "End position of the range covered by the scope. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." } }, "required": [ "name", "variablesReference", "expensive" ] }, "Variable": { "type": "object", "description": "A Variable is a name/value pair.\nThe `type` attribute is shown if space permits or when hovering over the variable's name.\nThe `kind` attribute is used to render additional properties of the variable, e.g. different icons can be used to indicate that a variable is public or private.\nIf the value is structured (has children), a handle is provided to retrieve the children with the `variables` request.\nIf the number of named or indexed children is large, the numbers should be returned via the `namedVariables` and `indexedVariables` attributes.\nThe client can use this information to present the children in a paged UI and fetch them in chunks.", "properties": { "name": { "type": "string", "description": "The variable's name." }, "value": { "type": "string", "description": "The variable's value.\nThis can be a multi-line text, e.g. for a function the body of a function.\nFor structured variables (which do not have a simple value), it is recommended to provide a one-line representation of the structured object. This helps to identify the structured object in the collapsed state when its children are not yet visible.\nAn empty string can be used if no value should be shown in the UI." }, "type": { "type": "string", "description": "The type of the variable's value. Typically shown in the UI when hovering over the value.\nThis attribute should only be returned by a debug adapter if the corresponding capability `supportsVariableType` is true." }, "presentationHint": { "$ref": "#/definitions/VariablePresentationHint", "description": "Properties of a variable that can be used to determine how to render the variable in the UI." }, "evaluateName": { "type": "string", "description": "The evaluatable name of this variable which can be passed to the `evaluate` request to fetch the variable's value." }, "variablesReference": { "type": "integer", "description": "If `variablesReference` is > 0, the variable is structured and its children can be retrieved by passing `variablesReference` to the `variables` request as long as execution remains suspended. See 'Lifetime of Object References' in the Overview section for details." }, "namedVariables": { "type": "integer", "description": "The number of named child variables.\nThe client can use this information to present the children in a paged UI and fetch them in chunks." }, "indexedVariables": { "type": "integer", "description": "The number of indexed child variables.\nThe client can use this information to present the children in a paged UI and fetch them in chunks." }, "memoryReference": { "type": "string", "description": "The memory reference for the variable if the variable represents executable code, such as a function pointer.\nThis attribute is only required if the corresponding capability `supportsMemoryReferences` is true." } }, "required": [ "name", "value", "variablesReference" ] }, "VariablePresentationHint": { "type": "object", "description": "Properties of a variable that can be used to determine how to render the variable in the UI.", "properties": { "kind": { "description": "The kind of variable. Before introducing additional values, try to use the listed values.", "type": "string", "_enum": [ "property", "method", "class", "data", "event", "baseClass", "innerClass", "interface", "mostDerivedClass", "virtual", "dataBreakpoint" ], "enumDescriptions": [ "Indicates that the object is a property.", "Indicates that the object is a method.", "Indicates that the object is a class.", "Indicates that the object is data.", "Indicates that the object is an event.", "Indicates that the object is a base class.", "Indicates that the object is an inner class.", "Indicates that the object is an interface.", "Indicates that the object is the most derived class.", "Indicates that the object is virtual, that means it is a synthetic object introduced by the adapter for rendering purposes, e.g. an index range for large arrays.", "Deprecated: Indicates that a data breakpoint is registered for the object. The `hasDataBreakpoint` attribute should generally be used instead." ] }, "attributes": { "description": "Set of attributes represented as an array of strings. Before introducing additional values, try to use the listed values.", "type": "array", "items": { "type": "string", "_enum": [ "static", "constant", "readOnly", "rawString", "hasObjectId", "canHaveObjectId", "hasSideEffects", "hasDataBreakpoint" ], "enumDescriptions": [ "Indicates that the object is static.", "Indicates that the object is a constant.", "Indicates that the object is read only.", "Indicates that the object is a raw string.", "Indicates that the object can have an Object ID created for it.", "Indicates that the object has an Object ID associated with it.", "Indicates that the evaluation had side effects.", "Indicates that the object has its value tracked by a data breakpoint." ] } }, "visibility": { "description": "Visibility of variable. Before introducing additional values, try to use the listed values.", "type": "string", "_enum": [ "public", "private", "protected", "internal", "final" ] }, "lazy": { "description": "If true, clients can present the variable with a UI that supports a specific gesture to trigger its evaluation.\nThis mechanism can be used for properties that require executing code when retrieving their value and where the code execution can be expensive and/or produce side-effects. A typical example are properties based on a getter function.\nPlease note that in addition to the `lazy` flag, the variable's `variablesReference` is expected to refer to a variable that will provide the value through another `variable` request.", "type": "boolean" } } }, "BreakpointLocation": { "type": "object", "description": "Properties of a breakpoint location returned from the `breakpointLocations` request.", "properties": { "line": { "type": "integer", "description": "Start line of breakpoint location." }, "column": { "type": "integer", "description": "The start position of a breakpoint location. Position is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." }, "endLine": { "type": "integer", "description": "The end line of breakpoint location if the location covers a range." }, "endColumn": { "type": "integer", "description": "The end position of a breakpoint location (if the location covers a range). Position is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." } }, "required": [ "line" ] }, "SourceBreakpoint": { "type": "object", "description": "Properties of a breakpoint or logpoint passed to the `setBreakpoints` request.", "properties": { "line": { "type": "integer", "description": "The source line of the breakpoint or logpoint." }, "column": { "type": "integer", "description": "Start position within source line of the breakpoint or logpoint. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." }, "condition": { "type": "string", "description": "The expression for conditional breakpoints.\nIt is only honored by a debug adapter if the corresponding capability `supportsConditionalBreakpoints` is true." }, "hitCondition": { "type": "string", "description": "The expression that controls how many hits of the breakpoint are ignored.\nThe debug adapter is expected to interpret the expression as needed.\nThe attribute is only honored by a debug adapter if the corresponding capability `supportsHitConditionalBreakpoints` is true.\nIf both this property and `condition` are specified, `hitCondition` should be evaluated only if the `condition` is met, and the debug adapter should stop only if both conditions are met." }, "logMessage": { "type": "string", "description": "If this attribute exists and is non-empty, the debug adapter must not 'break' (stop)\nbut log the message instead. Expressions within `{}` are interpolated.\nThe attribute is only honored by a debug adapter if the corresponding capability `supportsLogPoints` is true.\nIf either `hitCondition` or `condition` is specified, then the message should only be logged if those conditions are met." } }, "required": [ "line" ] }, "FunctionBreakpoint": { "type": "object", "description": "Properties of a breakpoint passed to the `setFunctionBreakpoints` request.", "properties": { "name": { "type": "string", "description": "The name of the function." }, "condition": { "type": "string", "description": "An expression for conditional breakpoints.\nIt is only honored by a debug adapter if the corresponding capability `supportsConditionalBreakpoints` is true." }, "hitCondition": { "type": "string", "description": "An expression that controls how many hits of the breakpoint are ignored.\nThe debug adapter is expected to interpret the expression as needed.\nThe attribute is only honored by a debug adapter if the corresponding capability `supportsHitConditionalBreakpoints` is true." } }, "required": [ "name" ] }, "DataBreakpointAccessType": { "type": "string", "description": "This enumeration defines all possible access types for data breakpoints.", "enum": [ "read", "write", "readWrite" ] }, "DataBreakpoint": { "type": "object", "description": "Properties of a data breakpoint passed to the `setDataBreakpoints` request.", "properties": { "dataId": { "type": "string", "description": "An id representing the data. This id is returned from the `dataBreakpointInfo` request." }, "accessType": { "$ref": "#/definitions/DataBreakpointAccessType", "description": "The access type of the data." }, "condition": { "type": "string", "description": "An expression for conditional breakpoints." }, "hitCondition": { "type": "string", "description": "An expression that controls how many hits of the breakpoint are ignored.\nThe debug adapter is expected to interpret the expression as needed." } }, "required": [ "dataId" ] }, "InstructionBreakpoint": { "type": "object", "description": "Properties of a breakpoint passed to the `setInstructionBreakpoints` request", "properties": { "instructionReference": { "type": "string", "description": "The instruction reference of the breakpoint.\nThis should be a memory or instruction pointer reference from an `EvaluateResponse`, `Variable`, `StackFrame`, `GotoTarget`, or `Breakpoint`." }, "offset": { "type": "integer", "description": "The offset from the instruction reference.\nThis can be negative." }, "condition": { "type": "string", "description": "An expression for conditional breakpoints.\nIt is only honored by a debug adapter if the corresponding capability `supportsConditionalBreakpoints` is true." }, "hitCondition": { "type": "string", "description": "An expression that controls how many hits of the breakpoint are ignored.\nThe debug adapter is expected to interpret the expression as needed.\nThe attribute is only honored by a debug adapter if the corresponding capability `supportsHitConditionalBreakpoints` is true." } }, "required": [ "instructionReference" ] }, "Breakpoint": { "type": "object", "description": "Information about a breakpoint created in `setBreakpoints`, `setFunctionBreakpoints`, `setInstructionBreakpoints`, or `setDataBreakpoints` requests.", "properties": { "id": { "type": "integer", "description": "The identifier for the breakpoint. It is needed if breakpoint events are used to update or remove breakpoints." }, "verified": { "type": "boolean", "description": "If true, the breakpoint could be set (but not necessarily at the desired location)." }, "message": { "type": "string", "description": "A message about the state of the breakpoint.\nThis is shown to the user and can be used to explain why a breakpoint could not be verified." }, "source": { "$ref": "#/definitions/Source", "description": "The source where the breakpoint is located." }, "line": { "type": "integer", "description": "The start line of the actual range covered by the breakpoint." }, "column": { "type": "integer", "description": "Start position of the source range covered by the breakpoint. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." }, "endLine": { "type": "integer", "description": "The end line of the actual range covered by the breakpoint." }, "endColumn": { "type": "integer", "description": "End position of the source range covered by the breakpoint. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based.\nIf no end line is given, then the end column is assumed to be in the start line." }, "instructionReference": { "type": "string", "description": "A memory reference to where the breakpoint is set." }, "offset": { "type": "integer", "description": "The offset from the instruction reference.\nThis can be negative." } }, "required": [ "verified" ] }, "SteppingGranularity": { "type": "string", "description": "The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`.", "enum": [ "statement", "line", "instruction" ], "enumDescriptions": [ "The step should allow the program to run until the current statement has finished executing.\nThe meaning of a statement is determined by the adapter and it may be considered equivalent to a line.\nFor example 'for(int i = 0; i < 10; i++)' could be considered to have 3 statements 'int i = 0', 'i < 10', and 'i++'.", "The step should allow the program to run until the current source line has executed.", "The step should allow one instruction to execute (e.g. one x86 instruction)." ] }, "StepInTarget": { "type": "object", "description": "A `StepInTarget` can be used in the `stepIn` request and determines into which single target the `stepIn` request should step.", "properties": { "id": { "type": "integer", "description": "Unique identifier for a step-in target." }, "label": { "type": "string", "description": "The name of the step-in target (shown in the UI)." }, "line": { "type": "integer", "description": "The line of the step-in target." }, "column": { "type": "integer", "description": "Start position of the range covered by the step in target. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." }, "endLine": { "type": "integer", "description": "The end line of the range covered by the step-in target." }, "endColumn": { "type": "integer", "description": "End position of the range covered by the step in target. It is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based." } }, "required": [ "id", "label" ] }, "GotoTarget": { "type": "object", "description": "A `GotoTarget` describes a code location that can be used as a target in the `goto` request.\nThe possible goto targets can be determined via the `gotoTargets` request.", "properties": { "id": { "type": "integer", "description": "Unique identifier for a goto target. This is used in the `goto` request." }, "label": { "type": "string", "description": "The name of the goto target (shown in the UI)." }, "line": { "type": "integer", "description": "The line of the goto target." }, "column": { "type": "integer", "description": "The column of the goto target." }, "endLine": { "type": "integer", "description": "The end line of the range covered by the goto target." }, "endColumn": { "type": "integer", "description": "The end column of the range covered by the goto target." }, "instructionPointerReference": { "type": "string", "description": "A memory reference for the instruction pointer value represented by this target." } }, "required": [ "id", "label", "line" ] }, "CompletionItem": { "type": "object", "description": "`CompletionItems` are the suggestions returned from the `completions` request.", "properties": { "label": { "type": "string", "description": "The label of this completion item. By default this is also the text that is inserted when selecting this completion." }, "text": { "type": "string", "description": "If text is returned and not an empty string, then it is inserted instead of the label." }, "sortText": { "type": "string", "description": "A string that should be used when comparing this item with other items. If not returned or an empty string, the `label` is used instead." }, "detail": { "type": "string", "description": "A human-readable string with additional information about this item, like type or symbol information." }, "type": { "$ref": "#/definitions/CompletionItemType", "description": "The item's type. Typically the client uses this information to render the item in the UI with an icon." }, "start": { "type": "integer", "description": "Start position (within the `text` attribute of the `completions` request) where the completion text is added. The position is measured in UTF-16 code units and the client capability `columnsStartAt1` determines whether it is 0- or 1-based. If the start position is omitted the text is added at the location specified by the `column` attribute of the `completions` request." }, "length": { "type": "integer", "description": "Length determines how many characters are overwritten by the completion text and it is measured in UTF-16 code units. If missing the value 0 is assumed which results in the completion text being inserted." }, "selectionStart": { "type": "integer", "description": "Determines the start of the new selection after the text has been inserted (or replaced). `selectionStart` is measured in UTF-16 code units and must be in the range 0 and length of the completion text. If omitted the selection starts at the end of the completion text." }, "selectionLength": { "type": "integer", "description": "Determines the length of the new selection after the text has been inserted (or replaced) and it is measured in UTF-16 code units. The selection can not extend beyond the bounds of the completion text. If omitted the length is assumed to be 0." } }, "required": [ "label" ] }, "CompletionItemType": { "type": "string", "description": "Some predefined types for the CompletionItem. Please note that not all clients have specific icons for all of them.", "enum": [ "method", "function", "constructor", "field", "variable", "class", "interface", "module", "property", "unit", "value", "enum", "keyword", "snippet", "text", "color", "file", "reference", "customcolor" ] }, "ChecksumAlgorithm": { "type": "string", "description": "Names of checksum algorithms that may be supported by a debug adapter.", "enum": [ "MD5", "SHA1", "SHA256", "timestamp" ] }, "Checksum": { "type": "object", "description": "The checksum of an item calculated by the specified algorithm.", "properties": { "algorithm": { "$ref": "#/definitions/ChecksumAlgorithm", "description": "The algorithm used to calculate this checksum." }, "checksum": { "type": "string", "description": "Value of the checksum, encoded as a hexadecimal value." } }, "required": [ "algorithm", "checksum" ] }, "ValueFormat": { "type": "object", "description": "Provides formatting information for a value.", "properties": { "hex": { "type": "boolean", "description": "Display the value in hex." } } }, "StackFrameFormat": { "allOf": [ { "$ref": "#/definitions/ValueFormat" }, { "type": "object", "description": "Provides formatting information for a stack frame.", "properties": { "parameters": { "type": "boolean", "description": "Displays parameters for the stack frame." }, "parameterTypes": { "type": "boolean", "description": "Displays the types of parameters for the stack frame." }, "parameterNames": { "type": "boolean", "description": "Displays the names of parameters for the stack frame." }, "parameterValues": { "type": "boolean", "description": "Displays the values of parameters for the stack frame." }, "line": { "type": "boolean", "description": "Displays the line number of the stack frame." }, "module": { "type": "boolean", "description": "Displays the module of the stack frame." }, "includeAll": { "type": "boolean", "description": "Includes all stack frames, including those the debug adapter might otherwise hide." } } }] }, "ExceptionFilterOptions": { "type": "object", "description": "An `ExceptionFilterOptions` is used to specify an exception filter together with a condition for the `setExceptionBreakpoints` request.", "properties": { "filterId": { "type": "string", "description": "ID of an exception filter returned by the `exceptionBreakpointFilters` capability." }, "condition": { "type": "string", "description": "An expression for conditional exceptions.\nThe exception breaks into the debugger if the result of the condition is true." } }, "required": [ "filterId" ] }, "ExceptionOptions": { "type": "object", "description": "An `ExceptionOptions` assigns configuration options to a set of exceptions.", "properties": { "path": { "type": "array", "items": { "$ref": "#/definitions/ExceptionPathSegment" }, "description": "A path that selects a single or multiple exceptions in a tree. If `path` is missing, the whole tree is selected.\nBy convention the first segment of the path is a category that is used to group exceptions in the UI." }, "breakMode": { "$ref": "#/definitions/ExceptionBreakMode", "description": "Condition when a thrown exception should result in a break." } }, "required": [ "breakMode" ] }, "ExceptionBreakMode": { "type": "string", "description": "This enumeration defines all possible conditions when a thrown exception should result in a break.\nnever: never breaks,\nalways: always breaks,\nunhandled: breaks when exception unhandled,\nuserUnhandled: breaks if the exception is not handled by user code.", "enum": [ "never", "always", "unhandled", "userUnhandled" ] }, "ExceptionPathSegment": { "type": "object", "description": "An `ExceptionPathSegment` represents a segment in a path that is used to match leafs or nodes in a tree of exceptions.\nIf a segment consists of more than one name, it matches the names provided if `negate` is false or missing, or it matches anything except the names provided if `negate` is true.", "properties": { "negate": { "type": "boolean", "description": "If false or missing this segment matches the names provided, otherwise it matches anything except the names provided." }, "names": { "type": "array", "items": { "type": "string" }, "description": "Depending on the value of `negate` the names that should match or not match." } }, "required": [ "names" ] }, "ExceptionDetails": { "type": "object", "description": "Detailed information about an exception that has occurred.", "properties": { "message": { "type": "string", "description": "Message contained in the exception." }, "typeName": { "type": "string", "description": "Short type name of the exception object." }, "fullTypeName": { "type": "string", "description": "Fully-qualified type name of the exception object." }, "evaluateName": { "type": "string", "description": "An expression that can be evaluated in the current scope to obtain the exception object." }, "stackTrace": { "type": "string", "description": "Stack trace at the time the exception was thrown." }, "innerException": { "type": "array", "items": { "$ref": "#/definitions/ExceptionDetails" }, "description": "Details of the exception contained by this exception, if any." } } }, "DisassembledInstruction": { "type": "object", "description": "Represents a single disassembled instruction.", "properties": { "address": { "type": "string", "description": "The address of the instruction. Treated as a hex value if prefixed with `0x`, or as a decimal value otherwise." }, "instructionBytes": { "type": "string", "description": "Raw bytes representing the instruction and its operands, in an implementation-defined format." }, "instruction": { "type": "string", "description": "Text representing the instruction and its operands, in an implementation-defined format." }, "symbol": { "type": "string", "description": "Name of the symbol that corresponds with the location of this instruction, if any." }, "location": { "$ref": "#/definitions/Source", "description": "Source location that corresponds to this instruction, if any.\nShould always be set (if available) on the first instruction returned,\nbut can be omitted afterwards if this instruction maps to the same source file as the previous instruction." }, "line": { "type": "integer", "description": "The line within the source location that corresponds to this instruction, if any." }, "column": { "type": "integer", "description": "The column within the line that corresponds to this instruction, if any." }, "endLine": { "type": "integer", "description": "The end line of the range that corresponds to this instruction, if any." }, "endColumn": { "type": "integer", "description": "The end column of the range that corresponds to this instruction, if any." } }, "required": [ "address", "instruction" ] }, "InvalidatedAreas": { "type": "string", "description": "Logical areas that can be invalidated by the `invalidated` event.", "_enum": [ "all", "stacks", "threads", "variables" ], "enumDescriptions": [ "All previously fetched data has become invalid and needs to be refetched.", "Previously fetched stack related data has become invalid and needs to be refetched.", "Previously fetched thread related data has become invalid and needs to be refetched.", "Previously fetched variable data has become invalid and needs to be refetched." ] } } } golang-github-google-go-dap-0.10.0/cmd/gentypes/gentypes.go000066400000000000000000000505031446076322400235370ustar00rootroot00000000000000// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // gentypes generates Go types from debugProtocol.json // // Usage: // // $ gentypes package main import ( "bytes" "encoding/json" "errors" "flag" "fmt" "go/format" "io/ioutil" "log" "net/http" "os" "strings" "unicode" ) var ( uFlag = flag.Bool("u", false, "updates the debugProtocol.json file before generating the code") oFlag = flag.String("o", "", "specifies the output file name. If unspecified, outputs to stdout") ) // parseRef parses the value of a "$ref" key. // For example "#definitions/ProtocolMessage" => "ProtocolMessage". func parseRef(refValue interface{}) string { refContents := refValue.(string) if !strings.HasPrefix(refContents, "#/definitions/") { log.Fatal("want ref to start with '#/definitions/', got ", refValue) } return replaceGoTypename(refContents[14:]) } // goFieldName converts a property name from its JSON representation to an // exported Go field name. // For example "__some_property_name" => "SomePropertyName". func goFieldName(jsonPropName string) string { clean := strings.ReplaceAll(jsonPropName, "_", " ") titled := strings.Title(clean) return strings.ReplaceAll(titled, " ", "") } // parsePropertyType takes the JSON value of a property field and extracts // the Go type of the property. For example, given this map: // // { // "type": "string", // "description": "The command to execute." // }, // // It will emit "string". func parsePropertyType(propValue map[string]interface{}) string { if ref, ok := propValue["$ref"]; ok { return parseRef(ref) } if _, ok := propValue["oneOf"]; ok { return "interface{}" } propType, ok := propValue["type"] if !ok { log.Fatal("property with no type or ref:", propValue) } switch propType.(type) { case string: switch propType { case "string": return "string" case "number": return "int" case "integer": return "int" case "boolean": return "bool" case "array": propItems, ok := propValue["items"] if !ok { log.Fatal("missing items type for property of array type:", propValue) } propItemsMap := propItems.(map[string]interface{}) return "[]" + parsePropertyType(propItemsMap) case "object": // When the type of a property is "object", we'll emit a map with a string // key and a value type that depends on the type of the // additionalProperties field. additionalProps, ok := propValue["additionalProperties"] if !ok { log.Fatal("missing additionalProperties field when type=object:", propValue) } var valueType string switch actual := additionalProps.(type) { case bool: valueType = "interface{}" case map[string]interface{}: valueType = parsePropertyType(actual) default: log.Fatal("unexpected additionalProperties value:", additionalProps) } return fmt.Sprintf("map[string]%v", valueType) case "interface{}": return "interface{}" default: log.Fatalf("unknown property type value %v in %v", propType, propValue) } case []interface{}: return "interface{}" default: log.Fatal("unknown property type", propType) } panic("unreachable") } // maybeParseInheritance helps parse types that inherit from other types. // A type description can have an "allOf" key, which means it inherits from // another type description. Returns the name of the base type specified in // allOf, and the description of the inheriting type. // // Example: // // "allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, // {... type description ...} ] // // Returns base type ProtocolMessage and a map representing type description. // If there is no "allOf", returns an empty baseTypeName and descMap itself. func maybeParseInheritance(descMap map[string]json.RawMessage) (baseTypeName string, typeDescJson map[string]json.RawMessage) { allOfListJson, ok := descMap["allOf"] if !ok { return "", descMap } var allOfSliceOfJson []json.RawMessage if err := json.Unmarshal(allOfListJson, &allOfSliceOfJson); err != nil { log.Fatal(err) } if len(allOfSliceOfJson) != 2 { log.Fatal("want 2 elements in allOf list, got", allOfSliceOfJson) } var baseTypeRef map[string]interface{} if err := json.Unmarshal(allOfSliceOfJson[0], &baseTypeRef); err != nil { log.Fatal(err) } if err := json.Unmarshal(allOfSliceOfJson[1], &typeDescJson); err != nil { log.Fatal(err) } return parseRef(baseTypeRef["$ref"]), typeDescJson } // emitToplevelType emits a single type into a string. It takes the type name // and a serialized json object representing the type. The json representation // will have fields: "type", "properties" etc. func emitToplevelType(typeName string, descJson json.RawMessage, goTypeIsStruct map[string]bool) string { var b strings.Builder var baseType string // We don't parse the description all the way to map[string]interface{} // because we have to retain the original JSON-order of properties (in this // type as well as any nested types like "body"). var descMap map[string]json.RawMessage if err := json.Unmarshal(descJson, &descMap); err != nil { log.Fatal(err) } baseType, descMap = maybeParseInheritance(descMap) typeJson, ok := descMap["type"] if !ok { log.Fatal("want description to have 'type', got ", descMap) } var descTypeString string if err := json.Unmarshal(typeJson, &descTypeString); err != nil { log.Fatal(err) } var comment string descriptionJson, ok := descMap["description"] if ok { if err := json.Unmarshal(descriptionJson, &comment); err != nil { log.Fatal(err) } } if len(comment) > 0 { comment = commentOutEachLine(fmt.Sprintf("%s: %s", typeName, comment)) fmt.Fprint(&b, comment) } if descTypeString == "string" { fmt.Fprintf(&b, "type %s string\n", typeName) return b.String() } else if descTypeString == "object" { fmt.Fprintf(&b, "type %s struct {\n", typeName) if len(baseType) > 0 { fmt.Fprintf(&b, "\t%s\n\n", baseType) } } else { log.Fatal("want description type to be object or string, got ", descTypeString) } var propsMapOfJson map[string]json.RawMessage if propsJson, ok := descMap["properties"]; ok { if err := json.Unmarshal(propsJson, &propsMapOfJson); err != nil { log.Fatal(err) } } else { b.WriteString("}\n") return b.String() } propsNamesInOrder, err := keysInOrder(descMap["properties"]) if err != nil { log.Fatal(err) } // Stores the properties that are required. requiredMap := make(map[string]bool) if requiredJson, ok := descMap["required"]; ok { var required []interface{} if err := json.Unmarshal(requiredJson, &required); err != nil { log.Fatal(err) } for _, r := range required { requiredMap[r.(string)] = true } } // Some types will have a "body" which should be emitted as a separate type. // Since we can't emit a whole new Go type while in the middle of emitting // another type, we save it for later and emit it after the current type is // done. bodyType := "" for _, propName := range propsNamesInOrder { // The JSON schema is designed for the TypeScript type system, where a // subclass can redefine a field in a superclass with a refined type (such // as specific values for a field). To ensure we emit Go structs that can // be unmarshaled from JSON messages properly, we must limit each field // to appear only once in hierarchical types. if propName == "type" && (typeName == "Request" || typeName == "Response" || typeName == "Event") { continue } if propName == "command" && typeName != "Request" && typeName != "Response" { continue } if propName == "event" && typeName != "Event" { continue } if propName == "arguments" && typeName == "Request" { continue } var propDesc map[string]interface{} if err := json.Unmarshal(propsMapOfJson[propName], &propDesc); err != nil { log.Fatal(err) } if propName == "body" { if typeName == "Response" || typeName == "Event" { continue } var bodyTypeName string if ref, ok := propDesc["$ref"]; ok { bodyTypeName = parseRef(ref) } else { bodyTypeName = typeName + "Body" bodyType = emitToplevelType(bodyTypeName, propsMapOfJson["body"], goTypeIsStruct) } if requiredMap["body"] { fmt.Fprintf(&b, "\t%s %s `json:\"body\"`\n", "Body", bodyTypeName) } else { fmt.Fprintf(&b, "\t%s %s `json:\"body,omitempty\"`\n", "Body", bodyTypeName) } } else if propName == "arguments" && (typeName == "LaunchRequest" || typeName == "AttachRequest") { // Special case for LaunchRequest or AttachRequest arguments, which are implementation // defined and don't have pre-set field names in the specification. fmt.Fprintln(&b, "\tArguments json.RawMessage `json:\"arguments\"`") } else { // Go type of this property. goType := parsePropertyType(propDesc) jsonTag := fmt.Sprintf("`json:\"%s", propName) if requiredMap[propName] { jsonTag += "\"`" } else if typeName == "ContinueResponseBody" && propName == "allThreadsContinued" { // This one special field must not have the omitempty tag, despite being // optional. If this attribute is missing the client will (according to // the specification) assume a value of 'true' for backward // compatibility. See: https://github.com/google/go-dap/issues/39 jsonTag += "\"`" } else if typeName == "InitializeRequestArguments" && (propName == "linesStartAt1" || propName == "columnsStartAt1") { // These two special fields must not have the omitempty tag, despite being // optional. If this attribute is missing the server will (according to // the specification) assume a value of 'true'. jsonTag += "\"`" } else if typeName == "ErrorMessage" && propName == "showUser" { // For launch/attach errors, vscode will treat omitted values the same way as true, // so to suppress visible reporting, we must report false explicitly. jsonTag += "\"`" } else { jsonTag += ",omitempty\"`" // If the field should be omitted when empty and is a struct type in Go, make it a pointer, // because non-pointer structs get initialized with default values in Go (and not nil), and // are then indistinguishable from structs with values actually set to zero when serializing // to JSON. Making them a pointer makes them initialize to nil, which is then indeed omitted // during serialization. if _, ok := propDesc["$ref"]; ok { // If we have a ref, then goType is the parsed ref if goTypeIsStruct[goType] { goType = "*" + goType } } } fmt.Fprintf(&b, "\t%s %s %s\n", goFieldName(propName), goType, jsonTag) } } b.WriteString("}\n") if len(bodyType) > 0 { b.WriteString("\n") b.WriteString(bodyType) } return b.String() } // keysInOrder returns the keys in json object in b, in their original order. // Based on https://github.com/golang/go/issues/27179#issuecomment-415559968 func keysInOrder(b []byte) ([]string, error) { d := json.NewDecoder(bytes.NewReader(b)) t, err := d.Token() if err != nil { return nil, err } if t != json.Delim('{') { return nil, errors.New("expected start of object") } var keys []string for { t, err := d.Token() if err != nil { return nil, err } if t == json.Delim('}') { return keys, nil } keys = append(keys, t.(string)) if err := skipValue(d); err != nil { return nil, err } } } // replaceGoTypename replaces conflicting type names in the JSON schema with // proper Go type names. func replaceGoTypename(typeName string) string { // Since we have a top-level interface named Message, we replace the DAP // message type Message with ErrorMessage. if typeName == "Message" { return "ErrorMessage" } return typeName } var errEnd = errors.New("invalid end of array or object") func skipValue(d *json.Decoder) error { t, err := d.Token() if err != nil { return err } switch t { case json.Delim('['), json.Delim('{'): for { if err := skipValue(d); err != nil { if err == errEnd { break } return err } } case json.Delim(']'), json.Delim('}'): return errEnd } return nil } // commentOutEachLine returns s such that a Go comment marker ("//") is // prepended to each line. func commentOutEachLine(s string) string { parts := strings.Split(s, "\n") var sb strings.Builder for _, p := range parts { fmt.Fprintf(&sb, "// %s\n", p) } return sb.String() } // emitMethodsForType may emit methods for typeName into sb. func emitMethodsForType(sb *strings.Builder, typeName string) { if typeName == "ProtocolMessage" { fmt.Fprintf(sb, "func (m *%s) GetSeq() int {return m.Seq}\n", typeName) } if strings.HasSuffix(typeName, "Request") && typeName != "Request" { fmt.Fprintf(sb, "func (r *%s) GetRequest() *Request {return &r.Request}\n", typeName) } if strings.HasSuffix(typeName, "Response") && typeName != "Response" { fmt.Fprintf(sb, "func (r *%s) GetResponse() *Response {return &r.Response}\n", typeName) } if strings.HasSuffix(typeName, "Event") && typeName != "Event" { fmt.Fprintf(sb, "func (e *%s) GetEvent() *Event {return &e.Event}\n", typeName) } if typeName == "LaunchRequest" || typeName == "AttachRequest" { fmt.Fprintf(sb, "func (r *%s) GetArguments() json.RawMessage { return r.Arguments }\n", typeName) } } func emitCtor(sb *strings.Builder, reqs, resps, events []string) { fmt.Fprint(sb, ` // Mapping of request commands and corresponding struct constructors that // can be passed to json.Unmarshal. var requestCtor = map[string]messageCtor{`) for _, r := range reqs { req := strings.TrimSuffix(firstToLower(r), "Request") var msg string if req == "initialize" { msg = ` Arguments: InitializeRequestArguments{ // Set the default values specified here: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Initialize. LinesStartAt1: true, ColumnsStartAt1: true, PathFormat: "path", }, ` } fmt.Fprintf(sb, "\n\t\"%s\":\tfunc() Message { return &%s{%s} },", req, r, msg) } fmt.Fprint(sb, "\n}") fmt.Fprint(sb, ` // Mapping of response commands and corresponding struct constructors that // can be passed to json.Unmarshal. var responseCtor = map[string]messageCtor{`) for _, r := range resps { resp := strings.TrimSuffix(firstToLower(r), "Response") fmt.Fprintf(sb, "\n\t\"%s\":\tfunc() Message { return &%s{} },", resp, r) } fmt.Fprint(sb, "\n}") fmt.Fprint(sb, ` // Mapping of event ids and corresponding struct constructors that // can be passed to json.Unmarshal. var eventCtor = map[string]messageCtor{`) for _, e := range events { ev := strings.TrimSuffix(firstToLower(e), "Event") fmt.Fprintf(sb, "\n\t\"%s\":\tfunc() Message { return &%s{} },", ev, e) } fmt.Fprint(sb, "\n}\n") } func firstToLower(s string) string { r := []rune(s) return string(unicode.ToLower(r[0])) + string(r[1:]) } const preamble = `// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Code generated by "cmd/gentypes/gentypes.go"; DO NOT EDIT. // DAP spec: https://microsoft.github.io/debug-adapter-protocol/specification // See cmd/gentypes/README.md for additional details. package dap import "encoding/json" // Message is an interface that all DAP message types implement with pointer // receivers. It's not part of the protocol but is used to enforce static // typing in Go code and provide some common accessors. // // Note: the DAP type "Message" (which is used in the body of ErrorResponse) // is renamed to ErrorMessage to avoid collision with this interface. type Message interface { GetSeq() int } // RequestMessage is an interface implemented by all Request-types. type RequestMessage interface { Message // GetRequest provides access to the embedded Request. GetRequest() *Request } // ResponseMessage is an interface implemented by all Response-types. type ResponseMessage interface { Message // GetResponse provides access to the embedded Response. GetResponse() *Response } // EventMessage is an interface implemented by all Event-types. type EventMessage interface { Message // GetEvent provides access to the embedded Event. GetEvent() *Event } // LaunchAttachRequest is an interface implemented by // LaunchRequest and AttachRequest as they contain shared // implementation specific arguments that are not part of // the specification. type LaunchAttachRequest interface { RequestMessage // GetArguments provides access to the Arguments map. GetArguments() json.RawMessage } ` // typesExcludeList is an exclude list of type names we don't want to emit. var typesExcludeList = map[string]bool{ // LaunchRequest and AttachRequest arguments can be arbitrary maps. // Therefore, this type is not used anywhere. "LaunchRequestArguments": true, "AttachRequestArguments": true, } func main() { flag.Parse() log.SetFlags(log.LstdFlags | log.Lshortfile) if flag.NArg() != 1 { fmt.Fprintln(os.Stderr, "Path to the DAP specification json file is required.") fmt.Fprintln(os.Stderr, "gentypes ") os.Exit(1) } inputFilename := flag.Arg(0) if *uFlag { if err := updateInput(inputFilename); err != nil { log.Fatalf("Failed to update the input file: %v", err) } } inputData, err := ioutil.ReadFile(inputFilename) if err != nil { log.Fatal(err) } var m map[string]json.RawMessage if err := json.Unmarshal(inputData, &m); err != nil { log.Fatal(err) } var typeMap map[string]json.RawMessage if err := json.Unmarshal(m["definitions"], &typeMap); err != nil { log.Fatal(err) } goTypesIsStruct := make(map[string]bool) for typeName, descJson := range typeMap { var descMap map[string]json.RawMessage if err := json.Unmarshal(descJson, &descMap); err != nil { log.Fatal(err) } _, descMap = maybeParseInheritance(descMap) typeJson, ok := descMap["type"] if !ok { log.Fatal("want description to have 'type', got ", descMap) } var descTypeString string if err := json.Unmarshal(typeJson, &descTypeString); err != nil { log.Fatal(err) } goTypesIsStruct[replaceGoTypename(typeName)] = descTypeString == "object" } var b strings.Builder b.WriteString(preamble) typeNames, err := keysInOrder(m["definitions"]) if err != nil { log.Fatal(err) } var requests, responses, events []string for _, typeName := range typeNames { if _, ok := typesExcludeList[typeName]; !ok { b.WriteString(emitToplevelType(replaceGoTypename(typeName), typeMap[typeName], goTypesIsStruct)) b.WriteString("\n") } emitMethodsForType(&b, replaceGoTypename(typeName)) // Add the typename to the appropriate list. if strings.HasSuffix(typeName, "Request") && typeName != "Request" { requests = append(requests, typeName) } if strings.HasSuffix(typeName, "Response") && typeName != "Response" && typeName != "ErrorResponse" { responses = append(responses, typeName) } if strings.HasSuffix(typeName, "Event") && typeName != "Event" { events = append(events, typeName) } } // Emit the maps from id to response and event types. emitCtor(&b, requests, responses, events) wholeFile := []byte(b.String()) formatted, err := format.Source(wholeFile) if err != nil { log.Fatal(err) } if *oFlag == "" { fmt.Print(string(formatted)) } else { if err := ioutil.WriteFile(*oFlag, formatted, 0644); err != nil { log.Fatalf("Failed to write the generated file: %v", err) } } } func updateInput(inputFilename string) error { resp, err := http.Get("https://raw.githubusercontent.com/microsoft/vscode-debugadapter-node/main/debugProtocol.json") if err != nil { return err } defer resp.Body.Close() data, err := ioutil.ReadAll(resp.Body) if err != nil { return err } return ioutil.WriteFile(inputFilename, data, 0644) } golang-github-google-go-dap-0.10.0/cmd/mockserver/000077500000000000000000000000001446076322400216715ustar00rootroot00000000000000golang-github-google-go-dap-0.10.0/cmd/mockserver/main.go000066400000000000000000000016501446076322400231460ustar00rootroot00000000000000// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // This starts a mock DAP server that runs indefinitely, accepts DAP // requests and responds with dummy or error responses. package main import ( "flag" "log" ) func main() { port := flag.String("port", "54321", "TCP port to listen on") flag.Parse() err := server(*port) if err != nil { log.Fatal("Could not start server: ", err) } } golang-github-google-go-dap-0.10.0/cmd/mockserver/server.go000066400000000000000000000520531446076322400235330ustar00rootroot00000000000000// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // This file defines helpers and request handlers for a dummy server // that accepts DAP requests and responds with dummy or error responses. // Fake-supported requests: // - initialize // - launch // - setBreakpoints // - setExceptionBreakpoints // - configurationDone // - threads // - stackTrace // - scopes // - variables // - continue // - disconnect // All other requests result in ErrorResponse's. // // The server uses the following goroutines: // - "main" goroutine accepts client connections one by one and // handles them serially by reading and decoding incoming requests // and dispatching each one to a new goroutine for further // processing. // - per-request goroutines process each request as if // letting fake debugger take over. They send events and responses // via the sender goroutine. // - sender goroutine listens for messages to send and // writes them to the client connection. // package main import ( "bufio" "io" "log" "net" "sync" "time" "github.com/google/go-dap" ) // server starts a server that listens on a specified port // and blocks indefinitely. This server can accept multiple // client connections at the same time. func server(port string) error { listener, err := net.Listen("tcp", ":"+port) if err != nil { return err } defer listener.Close() log.Println("Started server at", listener.Addr()) for { conn, err := listener.Accept() if err != nil { log.Println("Connection failed:", err) continue } log.Println("Accepted connection from", conn.RemoteAddr()) // Handle multiple client connections concurrently go handleConnection(conn) } } // handleConnection handles a connection from a single client. // It reads and decodes the incoming data and dispatches it // to per-request processing goroutines. It also launches the // sender goroutine to send resulting messages over the connection // back to the client. func handleConnection(conn net.Conn) { debugSession := fakeDebugSession{ rw: bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn)), sendQueue: make(chan dap.Message), stopDebug: make(chan struct{}), } go debugSession.sendFromQueue() for { err := debugSession.handleRequest() // TODO(polina): check for connection vs decoding error? if err != nil { if err == io.EOF { log.Println("No more data to read:", err) break } // There maybe more messages to process, but // we will start with the strict behavior of only accepting // expected inputs. log.Fatal("Server error: ", err) } } log.Println("Closing connection from", conn.RemoteAddr()) close(debugSession.stopDebug) debugSession.sendWg.Wait() close(debugSession.sendQueue) conn.Close() } func (ds *fakeDebugSession) handleRequest() error { log.Println("Reading request...") request, err := dap.ReadProtocolMessage(ds.rw.Reader) if err != nil { return err } log.Printf("Received request\n\t%#v\n", request) ds.sendWg.Add(1) go func() { ds.dispatchRequest(request) ds.sendWg.Done() }() return nil } // dispatchRequest launches a new goroutine to process each request // and send back events and responses. func (ds *fakeDebugSession) dispatchRequest(request dap.Message) { switch request := request.(type) { case *dap.InitializeRequest: ds.onInitializeRequest(request) case *dap.LaunchRequest: ds.onLaunchRequest(request) case *dap.AttachRequest: ds.onAttachRequest(request) case *dap.DisconnectRequest: ds.onDisconnectRequest(request) case *dap.TerminateRequest: ds.onTerminateRequest(request) case *dap.RestartRequest: ds.onRestartRequest(request) case *dap.SetBreakpointsRequest: ds.onSetBreakpointsRequest(request) case *dap.SetFunctionBreakpointsRequest: ds.onSetFunctionBreakpointsRequest(request) case *dap.SetExceptionBreakpointsRequest: ds.onSetExceptionBreakpointsRequest(request) case *dap.ConfigurationDoneRequest: ds.onConfigurationDoneRequest(request) case *dap.ContinueRequest: ds.onContinueRequest(request) case *dap.NextRequest: ds.onNextRequest(request) case *dap.StepInRequest: ds.onStepInRequest(request) case *dap.StepOutRequest: ds.onStepOutRequest(request) case *dap.StepBackRequest: ds.onStepBackRequest(request) case *dap.ReverseContinueRequest: ds.onReverseContinueRequest(request) case *dap.RestartFrameRequest: ds.onRestartFrameRequest(request) case *dap.GotoRequest: ds.onGotoRequest(request) case *dap.PauseRequest: ds.onPauseRequest(request) case *dap.StackTraceRequest: ds.onStackTraceRequest(request) case *dap.ScopesRequest: ds.onScopesRequest(request) case *dap.VariablesRequest: ds.onVariablesRequest(request) case *dap.SetVariableRequest: ds.onSetVariableRequest(request) case *dap.SetExpressionRequest: ds.onSetExpressionRequest(request) case *dap.SourceRequest: ds.onSourceRequest(request) case *dap.ThreadsRequest: ds.onThreadsRequest(request) case *dap.TerminateThreadsRequest: ds.onTerminateThreadsRequest(request) case *dap.EvaluateRequest: ds.onEvaluateRequest(request) case *dap.StepInTargetsRequest: ds.onStepInTargetsRequest(request) case *dap.GotoTargetsRequest: ds.onGotoTargetsRequest(request) case *dap.CompletionsRequest: ds.onCompletionsRequest(request) case *dap.ExceptionInfoRequest: ds.onExceptionInfoRequest(request) case *dap.LoadedSourcesRequest: ds.onLoadedSourcesRequest(request) case *dap.DataBreakpointInfoRequest: ds.onDataBreakpointInfoRequest(request) case *dap.SetDataBreakpointsRequest: ds.onSetDataBreakpointsRequest(request) case *dap.ReadMemoryRequest: ds.onReadMemoryRequest(request) case *dap.DisassembleRequest: ds.onDisassembleRequest(request) case *dap.CancelRequest: ds.onCancelRequest(request) case *dap.BreakpointLocationsRequest: ds.onBreakpointLocationsRequest(request) default: log.Fatalf("Unable to process %#v", request) } } // send lets the sender goroutine know via a channel that there is // a message to be sent to client. This is called by per-request // goroutines to send events and responses for each request and // to notify of events triggered by the fake debugger. func (ds *fakeDebugSession) send(message dap.Message) { ds.sendQueue <- message } // sendFromQueue is to be run in a separate goroutine to listen on a // channel for messages to send back to the client. It will // return once the channel is closed. func (ds *fakeDebugSession) sendFromQueue() { for message := range ds.sendQueue { dap.WriteProtocolMessage(ds.rw.Writer, message) log.Printf("Message sent\n\t%#v\n", message) ds.rw.Flush() } } // ----------------------------------------------------------------------- // Very Fake Debugger // // The debugging session will keep track of how many breakpoints // have been set. Once start-up is done (i.e. configurationDone // request is processed), it will "stop" at each breakpoint one by // one, and once there are no more, it will trigger a terminated event. type fakeDebugSession struct { // rw is used to read requests and write events/responses rw *bufio.ReadWriter // sendQueue is used to capture messages from multiple request // processing goroutines while writing them to the client connection // from a single goroutine via sendFromQueue. We must keep track of // the multiple channel senders with a wait group to make sure we do // not close this channel prematurely. Closing this channel will signal // the sendFromQueue goroutine that it can exit. sendQueue chan dap.Message sendWg sync.WaitGroup // stopDebug is used to notify long-running handlers to stop processing. stopDebug chan struct{} // bpSet is a counter of the remaining breakpoints that the debug // session is yet to stop at before the program terminates. bpSet int bpSetMux sync.Mutex } // doContinue allows fake program execution to continue when the program // is started or unpaused. It simulates events from the debug session // by "stopping" on a breakpoint or terminating if there are no more // breakpoints. Safe to use concurrently. func (ds *fakeDebugSession) doContinue() { var e dap.Message ds.bpSetMux.Lock() if ds.bpSet == 0 { // Pretend that the program is running. // The delay will allow for all in-flight responses // to be sent before termination. time.Sleep(1000 * time.Millisecond) e = &dap.TerminatedEvent{ Event: *newEvent("terminated"), } } else { e = &dap.StoppedEvent{ Event: *newEvent("stopped"), Body: dap.StoppedEventBody{Reason: "breakpoint", ThreadId: 1, AllThreadsStopped: true}, } ds.bpSet-- } ds.bpSetMux.Unlock() ds.send(e) } // ----------------------------------------------------------------------- // Request Handlers // // Below is a dummy implementation of the request handlers. // They take no action, but just return dummy responses. // A real debug adaptor would call the debugger methods here // and use their results to populate each response. func (ds *fakeDebugSession) onInitializeRequest(request *dap.InitializeRequest) { response := &dap.InitializeResponse{} response.Response = *newResponse(request.Seq, request.Command) response.Body.SupportsConfigurationDoneRequest = true response.Body.SupportsFunctionBreakpoints = false response.Body.SupportsConditionalBreakpoints = false response.Body.SupportsHitConditionalBreakpoints = false response.Body.SupportsEvaluateForHovers = false response.Body.ExceptionBreakpointFilters = []dap.ExceptionBreakpointsFilter{} response.Body.SupportsStepBack = false response.Body.SupportsSetVariable = false response.Body.SupportsRestartFrame = false response.Body.SupportsGotoTargetsRequest = false response.Body.SupportsStepInTargetsRequest = false response.Body.SupportsCompletionsRequest = false response.Body.CompletionTriggerCharacters = []string{} response.Body.SupportsModulesRequest = false response.Body.AdditionalModuleColumns = []dap.ColumnDescriptor{} response.Body.SupportedChecksumAlgorithms = []dap.ChecksumAlgorithm{} response.Body.SupportsRestartRequest = false response.Body.SupportsExceptionOptions = false response.Body.SupportsValueFormattingOptions = false response.Body.SupportsExceptionInfoRequest = false response.Body.SupportTerminateDebuggee = false response.Body.SupportsDelayedStackTraceLoading = false response.Body.SupportsLoadedSourcesRequest = false response.Body.SupportsLogPoints = false response.Body.SupportsTerminateThreadsRequest = false response.Body.SupportsSetExpression = false response.Body.SupportsTerminateRequest = false response.Body.SupportsDataBreakpoints = false response.Body.SupportsReadMemoryRequest = false response.Body.SupportsDisassembleRequest = false response.Body.SupportsCancelRequest = false response.Body.SupportsBreakpointLocationsRequest = false // This is a fake set up, so we can start "accepting" configuration // requests for setting breakpoints, etc from the client at any time. // Notify the client with an 'initialized' event. The client will end // the configuration sequence with 'configurationDone' request. e := &dap.InitializedEvent{Event: *newEvent("initialized")} ds.send(e) ds.send(response) } func (ds *fakeDebugSession) onLaunchRequest(request *dap.LaunchRequest) { // This is where a real debug adaptor would check the soundness of the // arguments (e.g. program from launch.json) and then use them to launch the // debugger and attach to the program. response := &dap.LaunchResponse{} response.Response = *newResponse(request.Seq, request.Command) ds.send(response) } func (ds *fakeDebugSession) onAttachRequest(request *dap.AttachRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "AttachRequest is not yet supported")) } func (ds *fakeDebugSession) onDisconnectRequest(request *dap.DisconnectRequest) { response := &dap.DisconnectResponse{} response.Response = *newResponse(request.Seq, request.Command) ds.send(response) } func (ds *fakeDebugSession) onTerminateRequest(request *dap.TerminateRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "TerminateRequest is not yet supported")) } func (ds *fakeDebugSession) onRestartRequest(request *dap.RestartRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "RestartRequest is not yet supported")) } func (ds *fakeDebugSession) onSetBreakpointsRequest(request *dap.SetBreakpointsRequest) { response := &dap.SetBreakpointsResponse{} response.Response = *newResponse(request.Seq, request.Command) response.Body.Breakpoints = make([]dap.Breakpoint, len(request.Arguments.Breakpoints)) for i, b := range request.Arguments.Breakpoints { response.Body.Breakpoints[i].Line = b.Line response.Body.Breakpoints[i].Verified = true ds.bpSetMux.Lock() ds.bpSet++ ds.bpSetMux.Unlock() } ds.send(response) } func (ds *fakeDebugSession) onSetFunctionBreakpointsRequest(request *dap.SetFunctionBreakpointsRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "SetFunctionBreakpointsRequest is not yet supported")) } func (ds *fakeDebugSession) onSetExceptionBreakpointsRequest(request *dap.SetExceptionBreakpointsRequest) { response := &dap.SetExceptionBreakpointsResponse{} response.Response = *newResponse(request.Seq, request.Command) ds.send(response) } func (ds *fakeDebugSession) onConfigurationDoneRequest(request *dap.ConfigurationDoneRequest) { // This would be the place to check if the session was configured to // stop on entry and if that is the case, to issue a // stopped-on-breakpoint event. This being a mock implementation, // we "let" the program continue after sending a successful response. e := &dap.ThreadEvent{Event: *newEvent("thread"), Body: dap.ThreadEventBody{Reason: "started", ThreadId: 1}} ds.send(e) response := &dap.ConfigurationDoneResponse{} response.Response = *newResponse(request.Seq, request.Command) ds.send(response) ds.doContinue() } func (ds *fakeDebugSession) onContinueRequest(request *dap.ContinueRequest) { response := &dap.ContinueResponse{} response.Response = *newResponse(request.Seq, request.Command) ds.send(response) ds.doContinue() } func (ds *fakeDebugSession) onNextRequest(request *dap.NextRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "NextRequest is not yet supported")) } func (ds *fakeDebugSession) onStepInRequest(request *dap.StepInRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "StepInRequest is not yet supported")) } func (ds *fakeDebugSession) onStepOutRequest(request *dap.StepOutRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "StepOutRequest is not yet supported")) } func (ds *fakeDebugSession) onStepBackRequest(request *dap.StepBackRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "StepBackRequest is not yet supported")) } func (ds *fakeDebugSession) onReverseContinueRequest(request *dap.ReverseContinueRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "ReverseContinueRequest is not yet supported")) } func (ds *fakeDebugSession) onRestartFrameRequest(request *dap.RestartFrameRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "RestartFrameRequest is not yet supported")) } func (ds *fakeDebugSession) onGotoRequest(request *dap.GotoRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "GotoRequest is not yet supported")) } func (ds *fakeDebugSession) onPauseRequest(request *dap.PauseRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "PauseRequest is not yet supported")) } func (ds *fakeDebugSession) onStackTraceRequest(request *dap.StackTraceRequest) { response := &dap.StackTraceResponse{} response.Response = *newResponse(request.Seq, request.Command) response.Body = dap.StackTraceResponseBody{ StackFrames: []dap.StackFrame{ { Id: 1000, Source: &dap.Source{Name: "hello.go", Path: "/Users/foo/go/src/hello/hello.go", SourceReference: 0}, Line: 5, Column: 0, Name: "main.main", }, }, TotalFrames: 1, } ds.send(response) } func (ds *fakeDebugSession) onScopesRequest(request *dap.ScopesRequest) { response := &dap.ScopesResponse{} response.Response = *newResponse(request.Seq, request.Command) response.Body = dap.ScopesResponseBody{ Scopes: []dap.Scope{ {Name: "Local", VariablesReference: 1000, Expensive: false}, {Name: "Global", VariablesReference: 1001, Expensive: true}, }, } ds.send(response) } func (ds *fakeDebugSession) onVariablesRequest(request *dap.VariablesRequest) { select { case <-ds.stopDebug: return // simulate long-running processing to make this handler // respond to this request after the next request is received case <-time.After(100 * time.Millisecond): response := &dap.VariablesResponse{} response.Response = *newResponse(request.Seq, request.Command) response.Body = dap.VariablesResponseBody{ Variables: []dap.Variable{{Name: "i", Value: "18434528", EvaluateName: "i", VariablesReference: 0}}, } ds.send(response) } } func (ds *fakeDebugSession) onSetVariableRequest(request *dap.SetVariableRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "setVariableRequest is not yet supported")) } func (ds *fakeDebugSession) onSetExpressionRequest(request *dap.SetExpressionRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "SetExpressionRequest is not yet supported")) } func (ds *fakeDebugSession) onSourceRequest(request *dap.SourceRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "SourceRequest is not yet supported")) } func (ds *fakeDebugSession) onThreadsRequest(request *dap.ThreadsRequest) { response := &dap.ThreadsResponse{} response.Response = *newResponse(request.Seq, request.Command) response.Body = dap.ThreadsResponseBody{Threads: []dap.Thread{{Id: 1, Name: "main"}}} ds.send(response) } func (ds *fakeDebugSession) onTerminateThreadsRequest(request *dap.TerminateThreadsRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "TerminateRequest is not yet supported")) } func (ds *fakeDebugSession) onEvaluateRequest(request *dap.EvaluateRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "EvaluateRequest is not yet supported")) } func (ds *fakeDebugSession) onStepInTargetsRequest(request *dap.StepInTargetsRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "StepInTargetRequest is not yet supported")) } func (ds *fakeDebugSession) onGotoTargetsRequest(request *dap.GotoTargetsRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "GotoTargetRequest is not yet supported")) } func (ds *fakeDebugSession) onCompletionsRequest(request *dap.CompletionsRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "CompletionRequest is not yet supported")) } func (ds *fakeDebugSession) onExceptionInfoRequest(request *dap.ExceptionInfoRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "ExceptionRequest is not yet supported")) } func (ds *fakeDebugSession) onLoadedSourcesRequest(request *dap.LoadedSourcesRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "LoadedRequest is not yet supported")) } func (ds *fakeDebugSession) onDataBreakpointInfoRequest(request *dap.DataBreakpointInfoRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "DataBreakpointInfoRequest is not yet supported")) } func (ds *fakeDebugSession) onSetDataBreakpointsRequest(request *dap.SetDataBreakpointsRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "SetDataBreakpointsRequest is not yet supported")) } func (ds *fakeDebugSession) onReadMemoryRequest(request *dap.ReadMemoryRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "ReadMemoryRequest is not yet supported")) } func (ds *fakeDebugSession) onDisassembleRequest(request *dap.DisassembleRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "DisassembleRequest is not yet supported")) } func (ds *fakeDebugSession) onCancelRequest(request *dap.CancelRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "CancelRequest is not yet supported")) } func (ds *fakeDebugSession) onBreakpointLocationsRequest(request *dap.BreakpointLocationsRequest) { ds.send(newErrorResponse(request.Seq, request.Command, "BreakpointLocationsRequest is not yet supported")) } func newEvent(event string) *dap.Event { return &dap.Event{ ProtocolMessage: dap.ProtocolMessage{ Seq: 0, Type: "event", }, Event: event, } } func newResponse(requestSeq int, command string) *dap.Response { return &dap.Response{ ProtocolMessage: dap.ProtocolMessage{ Seq: 0, Type: "response", }, Command: command, RequestSeq: requestSeq, Success: true, } } func newErrorResponse(requestSeq int, command string, message string) *dap.ErrorResponse { er := &dap.ErrorResponse{} er.Response = *newResponse(requestSeq, command) er.Success = false er.Message = "unsupported" er.Body.Error.Format = message er.Body.Error.Id = 12345 return er } golang-github-google-go-dap-0.10.0/cmd/mockserver/server_test.go000066400000000000000000000161631446076322400245740ustar00rootroot00000000000000// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package main import ( "bufio" "bytes" "io/ioutil" "log" "net" "sync" "testing" "time" "github.com/google/go-dap" ) var initializeRequest = []byte(`{"seq":1,"type":"request","command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"go","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"}}`) var initializedEvent = []byte(`{"seq":0,"type":"event","event":"initialized"}`) var initializeResponse = []byte(`{"seq":0,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsConfigurationDoneRequest":true}}`) var launchRequest = []byte(`{"seq":2,"type":"request","command":"launch","arguments":{"noDebug": true,"name":"Launch","type":"go","request":"launch","mode":"debug","program":"/Users/foo/go/src/hello","__sessionId":"4c88179f-1202-4f75-9e67-5bf535cde30a","args":["somearg"],"env":{"GOPATH":"/Users/foo/go","HOME":"/Users/foo","SHELL":"/bin/bash"}}}`) var launchResponse = []byte(`{"seq":0,"type":"response","request_seq":2,"success":true,"command":"launch"}`) var setBreakpointsRequest = []byte(`{"seq":3,"type":"request","command":"setBreakpoints","arguments":{"source":{"name":"hello.go","path":"/Users/foo/go/src/hello/hello.go"},"lines":[7],"breakpoints":[{"line":7}],"sourceModified":false}}`) var setBreakpointsResponse = []byte(`{"seq":0,"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"verified":true,"line":7}]}}`) var setExceptionBreakpointsRequest = []byte(`{"seq":4,"type":"request","command":"setExceptionBreakpoints","arguments":{"filters":[]}}`) var setExceptionBreakpointsResponse = []byte(`{"seq":0,"type":"response","request_seq":4,"success":true,"command":"setExceptionBreakpoints","body":{}}`) var configurationDoneRequest = []byte(`{"seq":5,"type":"request","command":"configurationDone"}`) var threadEvent = []byte(`{"seq":0,"type":"event","event":"thread","body":{"reason":"started","threadId":1}}`) var configurationDoneResponse = []byte(`{"seq":0,"type":"response","request_seq":5,"success":true,"command":"configurationDone"}`) var stoppedEvent = []byte(`{"seq":0,"type":"event","event":"stopped","body":{"reason":"breakpoint","threadId":1,"allThreadsStopped":true}}`) var threadsRequest = []byte(`{"seq":6,"type":"request","command":"threads"}`) var threadsResponse = []byte(`{"seq":0,"type":"response","request_seq":6,"success":true,"command":"threads","body":{"threads":[{"id":1,"name":"main"}]}}`) var stackTraceRequest = []byte(`{"seq":7,"type":"request","command":"stackTrace","arguments":{"threadId":1,"startFrame":0,"levels":20}}`) var stackTraceResponse = []byte(`{"seq":0,"type":"response","request_seq":7,"success":true,"command":"stackTrace","body":{"stackFrames":[{"id":1000,"name":"main.main","source":{"name":"hello.go","path":"/Users/foo/go/src/hello/hello.go"},"line":5,"column":0}],"totalFrames":1}}`) var scopesRequest = []byte(`{"seq":8,"type":"request","command":"scopes","arguments":{"frameId":1000}}`) var scopesResponse = []byte(`{"seq":0,"type":"response","request_seq":8,"success":true,"command":"scopes","body":{"scopes":[{"name":"Local","variablesReference":1000,"expensive":false},{"name":"Global","variablesReference":1001,"expensive":true}]}}`) var variablesRequest = []byte(`{"seq":9,"type":"request","command":"variables","arguments":{"variablesReference":1000}}`) var variablesResponse = []byte(`{"seq":0,"type":"response","request_seq":9,"success":true,"command":"variables","body":{"variables":[{"name":"i","value":"18434528","evaluateName":"i","variablesReference":0}]}}`) var continueRequest = []byte(`{"seq":10,"type":"request","command":"continue","arguments":{"threadId":1}}`) var continueResponse = []byte(`{"seq":0,"type":"response","request_seq":10,"success":true,"command":"continue","body":{"allThreadsContinued":false}}`) var terminatedEvent = []byte(`{"seq":0,"type":"event","event":"terminated","body":{}}`) var disconnectRequest = []byte(`{"seq":11,"type":"request","command":"disconnect","arguments":{"restart":false}}`) var disconnectResponse = []byte(`{"seq":0,"type":"response","request_seq":11,"success":true,"command":"disconnect"}`) func expectMessage(t *testing.T, r *bufio.Reader, want []byte) { got, err := dap.ReadBaseMessage(r) if err != nil { t.Error(err) } if !bytes.Equal(got, want) { t.Errorf("\ngot %q\nwant %q", got, want) } } func TestServer(t *testing.T) { log.SetOutput(ioutil.Discard) port := "54321" go func() { err := server(port) if err != nil { log.Fatal("Could not start server:", err) } }() // Give server time to start listening before clients connect time.Sleep(100 * time.Millisecond) var wg sync.WaitGroup wg.Add(2) go client(t, port, &wg) go client(t, port, &wg) wg.Wait() } func client(t *testing.T, port string, wg *sync.WaitGroup) { defer wg.Done() conn, err := net.Dial("tcp", ":"+port) if err != nil { log.Fatal("Could not connect to server:", err) } defer func() { t.Log("Closing connection to server at", conn.RemoteAddr()) conn.Close() }() t.Log("Connected to server at", conn.RemoteAddr()) r := bufio.NewReader(conn) // Start up dap.WriteBaseMessage(conn, initializeRequest) expectMessage(t, r, initializedEvent) expectMessage(t, r, initializeResponse) dap.WriteBaseMessage(conn, launchRequest) expectMessage(t, r, launchResponse) dap.WriteBaseMessage(conn, setBreakpointsRequest) expectMessage(t, r, setBreakpointsResponse) dap.WriteBaseMessage(conn, setExceptionBreakpointsRequest) expectMessage(t, r, setExceptionBreakpointsResponse) dap.WriteBaseMessage(conn, configurationDoneRequest) expectMessage(t, r, threadEvent) expectMessage(t, r, configurationDoneResponse) // Stop on preconfigured breakpoint & Continue expectMessage(t, r, stoppedEvent) dap.WriteBaseMessage(conn, threadsRequest) expectMessage(t, r, threadsResponse) dap.WriteBaseMessage(conn, stackTraceRequest) expectMessage(t, r, stackTraceResponse) dap.WriteBaseMessage(conn, scopesRequest) expectMessage(t, r, scopesResponse) // Processing of this request will be slow due to a fake delay. // Send the next request right away and confirm that processing // happens concurrently and the two responses are received // out of order. dap.WriteBaseMessage(conn, variablesRequest) dap.WriteBaseMessage(conn, continueRequest) expectMessage(t, r, continueResponse) expectMessage(t, r, variablesResponse) // Shut down expectMessage(t, r, terminatedEvent) dap.WriteBaseMessage(conn, disconnectRequest) expectMessage(t, r, disconnectResponse) } golang-github-google-go-dap-0.10.0/codec.go000066400000000000000000000145041446076322400203560ustar00rootroot00000000000000// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // This file contains utilities for decoding JSON-encoded bytes into DAP message. package dap import ( "encoding/json" "fmt" ) // DecodeProtocolMessageFieldError describes which JSON attribute // has an unsupported value that the decoding cannot handle. type DecodeProtocolMessageFieldError struct { Seq int SubType string FieldName string FieldValue string } func (e *DecodeProtocolMessageFieldError) Error() string { return fmt.Sprintf("%s %s '%s' is not supported (seq: %d)", e.SubType, e.FieldName, e.FieldValue, e.Seq) } // defaultCodec is used to decode vanilla DAP messages. var defaultCodec = NewCodec() // Codec is responsible for turning byte blobs into DAP messages. type Codec struct { eventCtor map[string]messageCtor requestCtor map[string]messageCtor responseCtor map[string]messageCtor } // NewCodec constructs a new codec that extends the vanilla DAP protocol. // Unless you need to register custom DAP messages, use // DecodeProtocolMessage instead. func NewCodec() *Codec { ret := &Codec{ eventCtor: make(map[string]messageCtor), requestCtor: make(map[string]messageCtor), responseCtor: make(map[string]messageCtor), } for k, v := range eventCtor { ret.eventCtor[k] = v } for k, v := range requestCtor { ret.requestCtor[k] = v } for k, v := range responseCtor { ret.responseCtor[k] = v } return ret } // RegisterRequest registers a new custom DAP command, so that it can be // unmarshalled by DecodeMessage. Returns an error when the command already // exists. // // The ctor functions need to return a new instance of the underlying DAP // message type. A typical usage looks like this: // // reqCtor := func() Message { return &LaunchRequest{} } // respCtor := func() Message { return &LaunchResponse{} } // codec.RegisterRequest("launch", reqCtor, respCtor) func (c *Codec) RegisterRequest(command string, requestCtor, responseCtor func() Message) error { _, hasReqCtor := c.requestCtor[command] _, hasRespCtor := c.responseCtor[command] if hasReqCtor || hasRespCtor { return fmt.Errorf("command %q is already registered", command) } c.requestCtor[command] = requestCtor c.responseCtor[command] = responseCtor return nil } // RegisterEvent registers a new custom DAP event, so that it can be // unmarshalled by DecodeMessage. Returns an error when the event already // exists. // // The ctor function needs to return a new instance of the underlying DAP // message type. A typical usage looks like this: // // ctor := func() Message { return &StoppedEvent{} } // codec.RegisterEvent("stopped", ctor) func (c *Codec) RegisterEvent(event string, ctor func() Message) error { if _, hasEventCtor := c.eventCtor[event]; hasEventCtor { return fmt.Errorf("event %q is already registered", event) } c.eventCtor[event] = ctor return nil } // DecodeMessage parses the JSON-encoded data and returns the result of // the appropriate type within the ProtocolMessage hierarchy. If message type, // command, etc cannot be cast, returns DecodeProtocolMessageFieldError. // See also godoc for json.Unmarshal, which is used for underlying decoding. func (c *Codec) DecodeMessage(data []byte) (Message, error) { // This struct is the union of the ResponseMessage, RequestMessage, and // EventMessage types. It is an optimization that saves an additional // json.Unmarshal call. var m struct { ProtocolMessage Command string `json:"command"` Event string `json:"event"` Success bool `json:"success"` } if err := json.Unmarshal(data, &m); err != nil { return nil, err } switch m.Type { case "request": return c.decodeRequest(m.Command, m.Seq, data) case "response": return c.decodeResponse(m.Command, m.Seq, m.Success, data) case "event": return c.decodeEvent(m.Event, m.Seq, data) default: return nil, &DecodeProtocolMessageFieldError{m.Seq, "ProtocolMessage", "type", m.Type} } } // decodeRequest determines what request type in the ProtocolMessage hierarchy // data corresponds to and uses json.Unmarshal to populate the corresponding // struct to be returned. func (c *Codec) decodeRequest(command string, seq int, data []byte) (Message, error) { ctor, ok := c.requestCtor[command] if !ok { return nil, &DecodeProtocolMessageFieldError{seq, "Request", "command", command} } requestPtr := ctor() err := json.Unmarshal(data, requestPtr) return requestPtr, err } // decodeResponse determines what response type in the ProtocolMessage hierarchy // data corresponds to and uses json.Unmarshal to populate the corresponding // struct to be returned. func (c *Codec) decodeResponse(command string, seq int, success bool, data []byte) (Message, error) { if !success { var er ErrorResponse err := json.Unmarshal(data, &er) return &er, err } ctor, ok := c.responseCtor[command] if !ok { return nil, &DecodeProtocolMessageFieldError{seq, "Response", "command", command} } responsePtr := ctor() err := json.Unmarshal(data, responsePtr) return responsePtr, err } // decodeEvent determines what event type in the ProtocolMessage hierarchy // data corresponds to and uses json.Unmarshal to populate the corresponding // struct to be returned. func (c *Codec) decodeEvent(event string, seq int, data []byte) (Message, error) { ctor, ok := c.eventCtor[event] if !ok { return nil, &DecodeProtocolMessageFieldError{seq, "Event", "event", event} } eventPtr := ctor() err := json.Unmarshal(data, eventPtr) return eventPtr, err } // DecodeProtocolMessage parses the JSON-encoded ProtocolMessage and returns // the message embedded in it. If message type, command, etc cannot be cast, // returns DecodeProtocolMessageFieldError. See also godoc for json.Unmarshal, // which is used for underlying decoding. func DecodeProtocolMessage(data []byte) (Message, error) { return defaultCodec.DecodeMessage(data) } type messageCtor func() Message golang-github-google-go-dap-0.10.0/codec_test.go000066400000000000000000001303541446076322400214170ustar00rootroot00000000000000// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package dap import ( "encoding/json" "reflect" "testing" ) // -------- Responses & Requests -------- var errorResponseString = `{"seq":11,"type":"response","request_seq":9,"command":"stackTrace","success":false,"message":"Unable to produce stack trace: \"{e}\"","body":{"error":{"id":2004,"format":"Unable to produce stack trace: \"{e}\"","variables":{"e":"Unknown goroutine 1"},"showUser":true}}}` var errorResponseStruct = ErrorResponse{ Response: Response{ ProtocolMessage: ProtocolMessage{ Seq: 11, Type: "response", }, Command: "stackTrace", RequestSeq: 9, Success: false, Message: "Unable to produce stack trace: \"{e}\"", }, Body: ErrorResponseBody{ Error: &ErrorMessage{ Id: 2004, Format: "Unable to produce stack trace: \"{e}\"", Variables: map[string]string{"e": "Unknown goroutine 1"}, ShowUser: true, }, }, } // -------- CancelRequest var cancelRequestString = `{"seq":25,"type":"request","command":"cancel","arguments":{"requestId":24}}` var cancelRequestStruct = CancelRequest{ Request: *newRequest(25, "cancel"), Arguments: &CancelArguments{RequestId: 24}, } var cancelResponseString = `{"seq":25,"type":"response","request_seq":26,"command":"cancel","success":true}` var cancelResponseStruct = CancelResponse{Response: *newResponse(25, 26, "cancel", true)} // -------- RunInTerminalRequest var runInTerminalRequestString = `{"seq":45,"type":"request","command":"runInTerminal","arguments":{"kind":"integrated","title":"Some Title","cwd":"/working/dir","args":["mycommand","arg1","arg2"]}}` var runInTerminalRequestStruct = RunInTerminalRequest{ Request: *newRequest(45, "runInTerminal"), Arguments: RunInTerminalRequestArguments{ Kind: "integrated", Title: "Some Title", Cwd: "/working/dir", Args: []string{"mycommand", "arg1", "arg2"}, }, } var runInTerminalResponseString = `{"seq":45,"type":"response","request_seq":46,"command":"runInTerminal","success":true,"body":{"processId":123456}}` var runInTerminalResponseStruct = RunInTerminalResponse{ Response: *newResponse(45, 46, "runInTerminal", true), Body: RunInTerminalResponseBody{ProcessId: 123456}, } // -------- Initialize var initializeRequestString = `{"seq":1,"type":"request","command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"go","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"}}` var initializeRequestOmitDefaultsString = `{"seq":1,"type":"request","command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"go","supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"}}` var initializeRequestStruct = InitializeRequest{ Request: *newRequest(1, "initialize"), Arguments: InitializeRequestArguments{ ClientID: "vscode", ClientName: "Visual Studio Code", AdapterID: "go", PathFormat: "path", LinesStartAt1: true, ColumnsStartAt1: true, SupportsVariableType: true, SupportsVariablePaging: true, SupportsRunInTerminalRequest: true, Locale: "en-us", }, } var initializeRequestNotDefaultsString = `{"seq":1,"type":"request","command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"go","pathFormat":"url","linesStartAt1":false,"columnsStartAt1":false,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"}}` var initializeRequestNotDefaultsStruct = InitializeRequest{ Request: *newRequest(1, "initialize"), Arguments: InitializeRequestArguments{ ClientID: "vscode", ClientName: "Visual Studio Code", AdapterID: "go", PathFormat: "url", LinesStartAt1: false, ColumnsStartAt1: false, SupportsVariableType: true, SupportsVariablePaging: true, SupportsRunInTerminalRequest: true, Locale: "en-us", }, } var initializeResponseString = `{"seq":1,"type":"response","request_seq":2,"command":"initialize","success":true,"body":{"supportsConfigurationDoneRequest":true,"supportsSetVariable":true}}` var initializeResponseStruct = InitializeResponse{ Response: *newResponse(1, 2, "initialize", true), Body: Capabilities{ SupportsConfigurationDoneRequest: true, SupportsSetVariable: true, }, } // -------- ConfigurationDone var configurationDoneRequestString = `{"seq":2,"type":"request","command":"configurationDone"}` var configurationDoneRequestStruct = ConfigurationDoneRequest{ Request: *newRequest(2, "configurationDone"), Arguments: nil, } var configurationDoneResponseString = `{"seq":2,"type":"response","request_seq":3,"command":"configurationDone","success":true}` var configurationDoneResponseStruct = ConfigurationDoneResponse{Response: *newResponse(2, 3, "configurationDone", true)} // -------- Launch var launchRequestString = `{"seq":3,"type":"request","command":"launch","arguments":{"noDebug":true,"name":"Launch"}}` var launchRequestStruct = LaunchRequest{ Request: *newRequest(3, "launch"), Arguments: json.RawMessage(`{"noDebug":true,"name":"Launch"}`), } var launchResponseString = `{"seq":3,"type":"response","request_seq":4,"command":"launch","success":true}` var launchResponseStruct = LaunchResponse{Response: *newResponse(3, 4, "launch", true)} // -------- Attach var attachRequestString = `{"seq":4,"type":"request","command":"attach","arguments":{}}` var attachRequestStruct = AttachRequest{ Request: *newRequest(4, "attach"), Arguments: json.RawMessage(`{}`), } var attachResponseString = `{"seq":4,"type":"response","request_seq":5,"command":"attach","success":true}` var attachResponseStruct = AttachResponse{Response: *newResponse(4, 5, "attach", true)} // -------- Restart var restartRequestString = `{"seq":5,"type":"request","command":"restart"}` var restartRequestStruct = RestartRequest{ Request: *newRequest(5, "restart"), Arguments: nil, } var restartResponseString = `{"seq":5,"type":"response","request_seq":6,"command":"restart","success":true}` var restartResponseStruct = RestartResponse{Response: *newResponse(5, 6, "restart", true)} // -------- Disconnect var disconnectRequestString = `{"seq":6,"type":"request","command":"disconnect","arguments":{"restart":true}}` var disconnectRequestStruct = DisconnectRequest{ Request: *newRequest(6, "disconnect"), Arguments: &DisconnectArguments{Restart: true}, } var disconnectResponseString = `{"seq":6,"type":"response","request_seq":7,"command":"disconnect","success":true}` var disconnectResponseStruct = DisconnectResponse{Response: *newResponse(6, 7, "disconnect", true)} // -------- Terminate var terminateRequestString = `{"seq":7,"type":"request","command":"terminate","arguments":{"restart":true}}` var terminateRequestStruct = TerminateRequest{ Request: *newRequest(7, "terminate"), Arguments: &TerminateArguments{Restart: true}, } var terminateResponseString = `{"seq":7,"type":"response","request_seq":8,"command":"terminate","success":true}` var terminateResponseStruct = TerminateResponse{Response: *newResponse(7, 8, "terminate", true)} // -------- BreakpointLocations var breakpointLocationsRequestString = `{"seq":8,"type":"request","command":"breakpointLocations","arguments":{"source":{"name":"hello.go","path":"/Users/foo/go/src/hello/hello.go"},"line":10}}` var breakpointLocationsRequestStruct = BreakpointLocationsRequest{ Request: *newRequest(8, "breakpointLocations"), Arguments: &BreakpointLocationsArguments{ Source: Source{Name: "hello.go", Path: "/Users/foo/go/src/hello/hello.go"}, Line: 10, }, } var breakpointLocationsResponseString = `{"seq":8,"type":"response","request_seq":9,"command":"breakpointLocations","success":true,"body":{"breakpoints":[{"line":14}]}}` var breakpointLocationsResponseStruct = BreakpointLocationsResponse{ Response: *newResponse(8, 9, "breakpointLocations", true), Body: BreakpointLocationsResponseBody{ Breakpoints: []BreakpointLocation{{Line: 14}}, }, } // -------- SetBreakpoints var setBreakpointsRequestString = `{"seq":9,"type":"request","command":"setBreakpoints","arguments":{"source":{"name":"hello.go","path":"/Users/foo/go/src/hello/hello.go"},"lines":[14],"breakpoints":[{"line":14}],"sourceModified":false}}` var setBreakpointsRequestStruct = SetBreakpointsRequest{ Request: *newRequest(9, "setBreakpoints"), Arguments: SetBreakpointsArguments{ Source: Source{Name: "hello.go", Path: "/Users/foo/go/src/hello/hello.go"}, Breakpoints: []SourceBreakpoint{{Line: 14}}, Lines: []int{14}, SourceModified: false, }, } var setBreakpointsResponseString = `{"seq":9,"type":"response","request_seq":10,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"verified":true,"line":14}]}}` var setBreakpointsResponseStruct = SetBreakpointsResponse{ Response: *newResponse(9, 10, "setBreakpoints", true), Body: SetBreakpointsResponseBody{ Breakpoints: []Breakpoint{{Verified: true, Line: 14}}, }, } // -------- SetFunctionBreakpoints var setFunctionBreakpointsRequestString = `{"seq":10,"type":"request","command":"setFunctionBreakpoints","arguments":{"breakpoints":[{"name":"blah"}]}}` var setFunctionBreakpointsRequestStruct = SetFunctionBreakpointsRequest{ Request: *newRequest(10, "setFunctionBreakpoints"), Arguments: SetFunctionBreakpointsArguments{ Breakpoints: []FunctionBreakpoint{{Name: "blah"}}, }, } var setFunctionBreakpointsResponseString = `{"seq":10,"type":"response","request_seq":11,"command":"setFunctionBreakpoints","success":true, "body":{"breakpoints":[{"verified":true,"line":20}]}}` var setFunctionBreakpointsResponseStruct = SetFunctionBreakpointsResponse{ Response: *newResponse(10, 11, "setFunctionBreakpoints", true), Body: SetFunctionBreakpointsResponseBody{ Breakpoints: []Breakpoint{{Verified: true, Line: 20}}, }, } // -------- SetExceptionBreakpoints var setExceptionBreakpointsRequestString = `{"seq":11,"type":"request","command":"setExceptionBreakpoints","arguments":{"filters":[]}}` var setExceptionBreakpointsRequestStruct = SetExceptionBreakpointsRequest{ Request: *newRequest(11, "setExceptionBreakpoints"), Arguments: SetExceptionBreakpointsArguments{Filters: []string{}}, } var setExceptionBreakpointsResponseString = `{"seq":11,"type":"response","request_seq":12,"command":"setExceptionBreakpoints","success":true}` var setExceptionBreakpointsResponseStruct = SetExceptionBreakpointsResponse{Response: *newResponse(11, 12, "setExceptionBreakpoints", true)} // -------- DataBreakpointInfo var dataBreakpointInfoRequestString = `{"seq":12,"type":"request","command":"dataBreakpointInfo","arguments":{"name":"fuzzybunny"}}` var dataBreakpointInfoRequestStruct = DataBreakpointInfoRequest{ Request: *newRequest(12, "dataBreakpointInfo"), Arguments: DataBreakpointInfoArguments{Name: "fuzzybunny"}, } var dataBreakpointInfoResponseString = `{"seq":12,"type":"response","request_seq":13,"command":"dataBreakpointInfo","success":true, "body":{"dataId":null,"description":"some description"}}` var dataBreakpointInfoResponseStruct = DataBreakpointInfoResponse{ Response: *newResponse(12, 13, "dataBreakpointInfo", true), Body: DataBreakpointInfoResponseBody{ DataId: nil, Description: "some description", }, } // -------- SetDataBreakpoints var setDataBreakpointsRequestString = `{"seq":13,"type":"request","command":"setDataBreakpoints","arguments":{"breakpoints":[{"dataId":"dataid"}]}}` var setDataBreakpointsRequestStruct = SetDataBreakpointsRequest{ Request: *newRequest(13, "setDataBreakpoints"), Arguments: SetDataBreakpointsArguments{ Breakpoints: []DataBreakpoint{{DataId: "dataid"}}, }, } var setDataBreakpointsResponseString = `{"seq":13,"type":"response","request_seq":14,"command":"setDataBreakpoints","success":true, "body":{"breakpoints":[{"verified":true,"line":100}]}}` var setDataBreakpointsResponseStruct = SetDataBreakpointsResponse{ Response: *newResponse(13, 14, "setDataBreakpoints", true), Body: SetDataBreakpointsResponseBody{ Breakpoints: []Breakpoint{{Verified: true, Line: 100}}, }, } // -------- Continue var continueRequestString = `{"seq":14,"type":"request","command":"continue","arguments":{"threadId":1}}` var continueRequestStruct = ContinueRequest{ Request: *newRequest(14, "continue"), Arguments: ContinueArguments{ThreadId: 1}, } var continueResponseString = `{"seq":14,"type":"response","request_seq":15,"command":"continue","success":true, "body":{"allThreadsContinued": true}}` var continueResponseStruct = ContinueResponse{ Response: *newResponse(14, 15, "continue", true), Body: ContinueResponseBody{AllThreadsContinued: true}, } // -------- Next var nextRequestString = `{"seq":15,"type":"request","command":"next","arguments":{"threadId":1}}` var nextRequestStruct = NextRequest{ Request: *newRequest(15, "next"), Arguments: NextArguments{ThreadId: 1}, } var nextResponseString = `{"seq":15,"type":"response","request_seq":16,"command":"next","success":true}` var nextResponseStruct = NextResponse{Response: *newResponse(15, 16, "next", true)} // -------- StepIn var stepInRequestString = `{"seq":16,"type":"request","command":"stepIn","arguments":{"threadId":1}}` var stepInRequestStruct = StepInRequest{ Request: *newRequest(16, "stepIn"), Arguments: StepInArguments{ThreadId: 1}, } var stepInResponseString = `{"seq":16,"type":"response","request_seq":17,"command":"stepIn","success":true}` var stepInResponseStruct = StepInResponse{Response: *newResponse(16, 17, "stepIn", true)} // -------- StepOut var stepOutRequestString = `{"seq":17,"type":"request","command":"stepOut","arguments":{"threadId":1}}` var stepOutRequestStruct = StepOutRequest{ Request: *newRequest(17, "stepOut"), Arguments: StepOutArguments{ThreadId: 1}, } var stepOutResponseString = `{"seq":17,"type":"response","request_seq":18,"command":"stepOut","success":true}` var stepOutResponseStruct = StepOutResponse{Response: *newResponse(17, 18, "stepOut", true)} // -------- StepBack var stepBackRequestString = `{"seq":18,"type":"request","command":"stepBack","arguments":{"threadId":1}}` var stepBackRequestStruct = StepBackRequest{ Request: *newRequest(18, "stepBack"), Arguments: StepBackArguments{ThreadId: 1}, } var stepBackResponseString = `{"seq":18,"type":"response","request_seq":19,"command":"stepBack","success":true}` var stepBackResponseStruct = StepBackResponse{Response: *newResponse(18, 19, "stepBack", true)} // -------- ReverseContinue var reverseContinueRequestString = `{"seq":19,"type":"request","command":"reverseContinue","arguments":{"threadId":1}}` var reverseContinueRequestStruct = ReverseContinueRequest{ Request: *newRequest(19, "reverseContinue"), Arguments: ReverseContinueArguments{ThreadId: 1}, } var reverseContinueResponseString = `{"seq":19,"type":"response","request_seq":20,"command":"reverseContinue","success":true}` var reverseContinueResponseStruct = ReverseContinueResponse{Response: *newResponse(19, 20, "reverseContinue", true)} // -------- RestartFrame var restartFrameRequestString = `{"seq":20,"type":"request","command":"restartFrame","arguments":{"frameId":5}}` var restartFrameRequestStruct = RestartFrameRequest{ Request: *newRequest(20, "restartFrame"), Arguments: RestartFrameArguments{FrameId: 5}, } var restartFrameResponseString = `{"seq":20,"type":"response","request_seq":21,"command":"restartFrame","success":true}` var restartFrameResponseStruct = RestartFrameResponse{Response: *newResponse(20, 21, "restartFrame", true)} // -------- Goto var gotoRequestString = `{"seq":21,"type":"request","command":"goto","arguments":{"threadId":1,"targetId":2}}` var gotoRequestStruct = GotoRequest{ Request: *newRequest(21, "goto"), Arguments: GotoArguments{ThreadId: 1, TargetId: 2}, } var gotoResponseString = `{"seq":21,"type":"response","request_seq":22,"command":"goto","success":true}` var gotoResponseStruct = GotoResponse{Response: *newResponse(21, 22, "goto", true)} // -------- Pause var pauseRequestString = `{"seq":22,"type":"request","command":"pause","arguments":{"threadId":1}}` var pauseRequestStruct = PauseRequest{ Request: *newRequest(22, "pause"), Arguments: PauseArguments{ThreadId: 1}, } var pauseResponseString = `{"seq":22,"type":"response","request_seq":23,"command":"pause","success":true}` var pauseResponseStruct = PauseResponse{Response: *newResponse(22, 23, "pause", true)} // -------- StackTrace var stackTraceRequestString = `{"seq":23,"type":"request","command":"stackTrace","arguments":{"threadId":1,"startFrame":0,"levels":20}}` var stackTraceRequestStruct = StackTraceRequest{ Request: *newRequest(23, "stackTrace"), Arguments: StackTraceArguments{ ThreadId: 1, StartFrame: 0, Levels: 20, }, } var stackTraceResponseString = `{"seq":23,"type":"response","request_seq":24,"command":"stackTrace","success":true,"body":{"stackFrames":[{"id":1000,"source":{"name":"hello.go","path":"/Users/foo/go/src/hello/hello.go","sourceReference":0},"line":6,"column":0,"name":"main.main"},{"id":1001,"source":{"name":"proc.go","path":"/usr/local/go/src/runtime/proc.go","sourceReference":0},"line":203,"column":0,"name":"runtime.main"},{"id":1002,"source":{"name":"asm_amd64.s","path":"/usr/local/go/src/runtime/asm_amd64.s","sourceReference":0},"line":1357,"column":0,"name":"runtime.goexit"}],"totalFrames":3}}` var stackTraceResponseStruct = StackTraceResponse{ Response: *newResponse(23, 24, "stackTrace", true), Body: StackTraceResponseBody{ StackFrames: []StackFrame{ { Id: 1000, Source: &Source{ Name: "hello.go", Path: "/Users/foo/go/src/hello/hello.go", SourceReference: 0, }, Line: 6, Column: 0, Name: "main.main", }, { Id: 1001, Source: &Source{ Name: "proc.go", Path: "/usr/local/go/src/runtime/proc.go", SourceReference: 0, }, Line: 203, Column: 0, Name: "runtime.main", }, { Id: 1002, Source: &Source{ Name: "asm_amd64.s", Path: "/usr/local/go/src/runtime/asm_amd64.s", SourceReference: 0, }, Line: 1357, Column: 0, Name: "runtime.goexit", }, }, TotalFrames: 3, }, } // -------- Scopes var scopesRequestString = `{"seq":24,"type":"request","command":"scopes","arguments":{"frameId":1000}}` var scopesRequestStruct = ScopesRequest{ Request: *newRequest(24, "scopes"), Arguments: ScopesArguments{FrameId: 1000}, } var scopesResponseString = `{"seq":24,"type":"response","request_seq":25,"command":"scopes","success":true,"body":{"scopes":[{"name":"Local","variablesReference":1000,"expensive":false},{"name":"Global","variablesReference":1001,"expensive":false}]}}` var scopesResponseStruct = ScopesResponse{ Response: *newResponse(24, 25, "scopes", true), Body: ScopesResponseBody{ Scopes: []Scope{ { Name: "Local", VariablesReference: 1000, Expensive: false, }, { Name: "Global", VariablesReference: 1001, Expensive: false, }, }, }, } // -------- Variables var variablesRequestString = `{"seq":25,"type":"request","command":"variables","arguments":{"variablesReference":1001}}` var variablesRequestStruct = VariablesRequest{ Request: *newRequest(25, "variables"), Arguments: VariablesArguments{VariablesReference: 1001}, } var variablesResponseString = `{"seq":25,"type":"response","request_seq":26,"command":"variables","success":true,"body":{"variables":[{"name":"x","value":"824634220368","evaluateName":"x","variablesReference":0}]}}` var variablesResponseStruct = VariablesResponse{ Response: *newResponse(25, 26, "variables", true), Body: VariablesResponseBody{ Variables: []Variable{ { Name: "x", Value: "824634220368", EvaluateName: "x", VariablesReference: 0, }, }, }, } // -------- SetVariable var setVariableRequestString = `{"seq":26,"type":"request","command":"setVariable","arguments":{"variablesReference":1008,"name":"x","value":"55"}}` var setVariableRequestStruct = SetVariableRequest{ Request: *newRequest(26, "setVariable"), Arguments: SetVariableArguments{ VariablesReference: 1008, Name: "x", Value: "55", }, } var setVariableResponseString = `{"seq":26,"type":"response","request_seq":27,"command":"setVariable","success":true,"body":{"value":"55"}}` var setVariableResponseStruct = SetVariableResponse{ Response: *newResponse(26, 27, "setVariable", true), Body: SetVariableResponseBody{Value: "55"}, } // -------- Source var sourceRequestString = `{"seq":27,"type":"request","command":"source","arguments":{"sourceReference":123}}` var sourceRequestStruct = SourceRequest{ Request: *newRequest(27, "source"), Arguments: SourceArguments{SourceReference: 123}, } var sourceResponseString = `{"seq":27,"type":"response","request_seq":28,"command":"source","success":true,"body":{"content":"somecontent"}}` var sourceResponseStruct = SourceResponse{ Response: *newResponse(27, 28, "source", true), Body: SourceResponseBody{Content: "somecontent"}, } // -------- Threads var threadsRequestString = `{"seq":28,"type":"request","command":"threads","arguments":{}}` var threadsRequestStruct = ThreadsRequest{Request: *newRequest(28, "threads")} var threadsResponseString = `{"seq":28,"type":"response","request_seq":29,"command":"threads","success":true,"body":{"threads":[{"id":1,"name":"Dummy"}]}}` var threadsResponseStruct = ThreadsResponse{ Response: *newResponse(28, 29, "threads", true), Body: ThreadsResponseBody{Threads: []Thread{{Id: 1, Name: "Dummy"}}}, } // -------- TerminateThreads var terminateThreadsRequestString = `{"seq":29,"type":"request","command":"terminateThreads","arguments":{"threadIds":[1]}}` var terminateThreadsRequestStruct = TerminateThreadsRequest{ Request: *newRequest(29, "terminateThreads"), Arguments: TerminateThreadsArguments{ThreadIds: []int{1}}, } var terminateThreadsResponseString = `{"seq":29,"type":"response","request_seq":30,"command":"terminateThreads","success":true}` var terminateThreadsResponseStruct = TerminateThreadsResponse{Response: *newResponse(29, 30, "terminateThreads", true)} // -------- Modules var modulesRequestString = `{"seq":30,"type":"request","command":"modules","arguments":{"startModule":1,"moduleCount":3}}` var modulesRequestStruct = ModulesRequest{ Request: *newRequest(30, "modules"), Arguments: ModulesArguments{ StartModule: 1, ModuleCount: 3, }, } var modulesResponseString = `{"seq":30,"type":"response","request_seq":31,"command":"modules","success":true,"body":{"totalModules":2,"modules":[{"id":1,"name":"one"}]}}` var modulesResponseStruct = ModulesResponse{ Response: *newResponse(30, 31, "modules", true), Body: ModulesResponseBody{ TotalModules: 2, Modules: []Module{{Id: 1.0, Name: "one"}}, }, } // -------- LoadedSources var loadedSourcesRequestString = `{"seq":31,"type":"request","command":"loadedSources"}` var loadedSourcesRequestStruct = LoadedSourcesRequest{ Request: *newRequest(31, "loadedSources"), Arguments: nil, } var loadedSourcesResponseString = `{"seq":31,"type":"response","request_seq":32,"command":"loadedSources","success":true,"body":{"sources":[{"name":"hello.go","path":"/Users/foo/go/src/hello/hello.go"}]}}` var loadedSourcesResponseStruct = LoadedSourcesResponse{ Response: *newResponse(31, 32, "loadedSources", true), Body: LoadedSourcesResponseBody{ Sources: []Source{ { Name: "hello.go", Path: "/Users/foo/go/src/hello/hello.go", }, }, }, } // -------- Evaluate var evaluateRequestString = `{"seq":32,"type":"request","command":"evaluate","arguments":{"expression":"x==1","frameId":1000,"context":"repl"}}` var evaluateRequestStruct = EvaluateRequest{ Request: *newRequest(32, "evaluate"), Arguments: EvaluateArguments{ Expression: "x==1", FrameId: 1000, Context: "repl", }, } var evaluateResponseString = `{"seq":32,"type":"response","request_seq":33,"command":"evaluate","success":true,"body":{"result":"false","variablesReference":1}}` var evaluateResponseStruct = EvaluateResponse{ Response: *newResponse(32, 33, "evaluate", true), Body: EvaluateResponseBody{ Result: "false", VariablesReference: 1, }, } // -------- SetExpression var setExpressionRequestString = `{"seq":33,"type":"request","command":"setExpression","arguments":{"expression":"x==1","value":"true"}}` var setExpressionRequestStruct = SetExpressionRequest{ Request: *newRequest(33, "setExpression"), Arguments: SetExpressionArguments{ Expression: "x==1", Value: "true", }, } var setExpressionResponseString = `{"seq":33,"type":"response","request_seq":34,"command":"setExpression","success":true,"body":{"value":"true"}}` var setExpressionResponseStruct = SetExpressionResponse{ Response: *newResponse(33, 34, "setExpression", true), Body: SetExpressionResponseBody{Value: "true"}, } // -------- StepInTargets var stepInTargetsRequestString = `{"seq":34,"type":"request","command":"stepInTargets","arguments":{"frameId":1000}}` var stepInTargetsRequestStruct = StepInTargetsRequest{ Request: *newRequest(34, "stepInTargets"), Arguments: StepInTargetsArguments{ FrameId: 1000, }, } var stepInTargetsResponseString = `{"seq":34,"type":"response","request_seq":35,"command":"stepInTargets","success":true,"body":{"targets":[{"id":123,"label":"somelabel"}]}}` var stepInTargetsResponseStruct = StepInTargetsResponse{ Response: *newResponse(34, 35, "stepInTargets", true), Body: StepInTargetsResponseBody{ Targets: []StepInTarget{ {Id: 123, Label: "somelabel"}, }, }, } // -------- GotoTargets var gotoTargetsRequestString = `{"seq":35,"type":"request","command":"gotoTargets","arguments":{"source":{"name":"hello.go","path":"/Users/foo/go/src/hello/hello.go"},"line":10}}` var gotoTargetsRequestStruct = GotoTargetsRequest{ Request: *newRequest(35, "gotoTargets"), Arguments: GotoTargetsArguments{ Source: Source{Name: "hello.go", Path: "/Users/foo/go/src/hello/hello.go"}, Line: 10, }, } var gotoTargetsResponseString = `{"seq":35,"type":"response","request_seq":36,"command":"gotoTargets","success":true,"body":{"targets":[{"id":123,"label":"somelabel","line":10}]}}` var gotoTargetsResponseStruct = GotoTargetsResponse{ Response: *newResponse(35, 36, "gotoTargets", true), Body: GotoTargetsResponseBody{ Targets: []GotoTarget{ {Id: 123, Label: "somelabel", Line: 10}, }, }, } // -------- Completions var completionsRequestString = `{"seq": 36,"type":"request","command":"completions","arguments":{"text":"sometext","column":123}}` var completionsRequestStruct = CompletionsRequest{ Request: *newRequest(36, "completions"), Arguments: CompletionsArguments{Text: "sometext", Column: 123}, } var completionsResponseString = `{"seq":36,"type":"response","request_seq":37,"command":"completions","success":true,"body":{"targets":[{"label":"somelabel"}]}}` var completionsResponseStruct = CompletionsResponse{ Response: *newResponse(36, 37, "completions", true), Body: CompletionsResponseBody{ Targets: []CompletionItem{ {Label: "somelabel"}, }, }, } // -------- ExceptionInfo var exceptionInfoRequestString = `{"seq":36,"type":"request","command":"exceptionInfo","arguments":{"threadId":1}}` var exceptionInfoRequestStruct = ExceptionInfoRequest{ Request: *newRequest(36, "exceptionInfo"), Arguments: ExceptionInfoArguments{ThreadId: 1}, } var exceptionInfoResponseString = `{"seq":36,"type":"response","request_seq":37,"command":"exceptionInfo","success":true,"body":{"exceptionId":"someid","breakMode":"somebreakmode"}}` var exceptionInfoResponseStruct = ExceptionInfoResponse{ Response: *newResponse(36, 37, "exceptionInfo", true), Body: ExceptionInfoResponseBody{ ExceptionId: "someid", BreakMode: "somebreakmode", }, } // -------- ReadMemory var readMemoryRequestString = `{"seq":37,"type":"request","command":"readMemory","arguments":{"memoryReference":"someref","count":123}}` var readMemoryRequestStruct = ReadMemoryRequest{ Request: *newRequest(37, "readMemory"), Arguments: ReadMemoryArguments{ MemoryReference: "someref", Count: 123, }, } var readMemoryResponseString = `{"seq":37,"type":"response","request_seq":38,"command":"readMemory","success":true,"body":{"address":"someaddr"}}` var readMemoryResponseStruct = ReadMemoryResponse{ Response: *newResponse(37, 38, "readMemory", true), Body: ReadMemoryResponseBody{Address: "someaddr"}, } // -------- Disassemble var disassembleRequestString = `{"seq":38,"type":"request","command":"disassemble","arguments":{"memoryReference":"someref","instructionCount":123}}` var disassembleRequestStruct = DisassembleRequest{ Request: *newRequest(38, "disassemble"), Arguments: DisassembleArguments{ MemoryReference: "someref", InstructionCount: 123, }, } var disassembleResponseString = `{"seq":38,"type":"response","request_seq":39,"command":"disassemble","success":true,"body":{"instructions":[{"address":"someaddr","instruction":"someinstr"}]}}` var disassembleResponseStruct = DisassembleResponse{ Response: *newResponse(38, 39, "disassemble", true), Body: DisassembleResponseBody{ Instructions: []DisassembledInstruction{ { Address: "someaddr", Instruction: "someinstr", }, }, }, } // -------- StartDebugging var startDebuggingRequestString = `{"seq":39,"type":"request","command":"startDebugging","arguments":{"request":"launch","configuration":{"any":true}}}` var startDebuggingRequestStruct = StartDebuggingRequest{ Request: *newRequest(39, "startDebugging"), Arguments: StartDebuggingRequestArguments{ Request: "launch", Configuration: map[string]interface{}{"any": true}, }, } var startDebuggingResponseString = `{"seq":39,"type":"response","request_seq":40,"command":"startDebugging","success":true}` var startDebuggingResponseStruct = StartDebuggingResponse{ Response: *newResponse(39, 40, "startDebugging", true), } // -------- Events -------- var initializedEventString = `{"seq":1,"type":"event","event":"initialized"}` var initializedEventStruct = InitializedEvent{ Event: *newEvent(1, "initialized"), } var stoppedEventString = `{"seq":2,"type":"event","event":"stopped","body":{"reason":"breakpoint","threadId":1,"allThreadsStopped":true}}` var stoppedEventStruct = StoppedEvent{ Event: *newEvent(2, "stopped"), Body: StoppedEventBody{Reason: "breakpoint", ThreadId: 1, AllThreadsStopped: true}, } var continuedEventString = `{"seq":3,"type":"event","event":"continued","body":{"threadId":123}}` var continuedEventStruct = ContinuedEvent{ Event: *newEvent(3, "continued"), Body: ContinuedEventBody{ThreadId: 123}, } var exitedEventString = `{"seq":4,"type":"event","event":"exited","body":{"exitCode":123}}` var exitedEventStruct = ExitedEvent{ Event: *newEvent(4, "exited"), Body: ExitedEventBody{ExitCode: 123}, } var terminatedEventString = `{"seq":5,"type":"event","event":"terminated","body":{"restart":true}}` var terminatedEventStruct = TerminatedEvent{ Event: *newEvent(5, "terminated"), Body: TerminatedEventBody{Restart: true}, } var threadEventString = `{"seq":6,"type":"event","event":"thread","body":{"reason":"started","threadId":18}}` var threadEventStruct = ThreadEvent{ Event: *newEvent(6, "thread"), Body: ThreadEventBody{Reason: "started", ThreadId: 18}, } var outputEventString = `{"seq":7,"type":"event","event":"output","body":{"category":"stdout","output":"something that got logged"}}` var outputEventStruct = OutputEvent{ Event: *newEvent(7, "output"), Body: OutputEventBody{Category: "stdout", Output: "something that got logged"}, } var breakpointEventString = `{"seq":8,"type":"event","event":"breakpoint","body":{"reason":"new","breakpoint":{"verified":true}}}` var breakpointEventStruct = BreakpointEvent{ Event: *newEvent(8, "breakpoint"), Body: BreakpointEventBody{Reason: "new", Breakpoint: Breakpoint{Verified: true}}, } var moduleEventString = `{"seq":9,"type":"event","event":"module","body":{"reason":"removed","module":{"id":"id"}}}` var moduleEventStruct = ModuleEvent{ Event: *newEvent(9, "module"), Body: ModuleEventBody{Reason: "removed", Module: Module{Id: "id"}}, } var loadedSourceEventString = `{"seq":10,"type":"event","event":"loadedSource","body":{"reason":"changed","source":{"name":"hello.go","path":"/Users/foo/go/src/hello/hello.go"}}}` var loadedSourceEventStruct = LoadedSourceEvent{ Event: *newEvent(10, "loadedSource"), Body: LoadedSourceEventBody{Reason: "changed", Source: Source{Name: "hello.go", Path: "/Users/foo/go/src/hello/hello.go"}}, } var processEventString = `{"seq":11,"type":"event","event":"process","body":{"name":"/home/example/myproj/program.js"}}` var processEventStruct = ProcessEvent{ Event: *newEvent(11, "process"), Body: ProcessEventBody{Name: "/home/example/myproj/program.js"}, } var capabilitiesEventString = `{"seq":12,"type":"event","event":"capabilities","body":{"capabilities":{"supportsFunctionBreakpoints":true}}}` var capabilitiesEventStruct = CapabilitiesEvent{ Event: *newEvent(12, "capabilities"), Body: CapabilitiesEventBody{Capabilities: Capabilities{SupportsFunctionBreakpoints: true}}, } func TestDecodeProtocolMessage(t *testing.T) { // Sometimes partial messages can be returned on error, but // the user should not rely on those and just check err itself. // Hence the test will not check those. var msgIgnoredOnError Message const noError = "" tests := []struct { data string wantMsg Message wantErr string }{ // ProtocolMessage {``, msgIgnoredOnError, "unexpected end of JSON input"}, {`,`, msgIgnoredOnError, "invalid character ',' looking for beginning of value"}, {`{}`, msgIgnoredOnError, "ProtocolMessage type '' is not supported (seq: 0)"}, {`{"a": 1}`, msgIgnoredOnError, "ProtocolMessage type '' is not supported (seq: 0)"}, {`{"type":"foo", "seq": 2}`, msgIgnoredOnError, "ProtocolMessage type 'foo' is not supported (seq: 2)"}, // Request {`{"type":"request"}`, msgIgnoredOnError, "Request command '' is not supported (seq: 0)"}, {cancelRequestString, &cancelRequestStruct, noError}, {runInTerminalRequestString, &runInTerminalRequestStruct, noError}, {initializeRequestString, &initializeRequestStruct, noError}, {initializeRequestOmitDefaultsString, &initializeRequestStruct, noError}, {initializeRequestNotDefaultsString, &initializeRequestNotDefaultsStruct, noError}, {configurationDoneRequestString, &configurationDoneRequestStruct, noError}, {launchRequestString, &launchRequestStruct, noError}, {attachRequestString, &attachRequestStruct, noError}, {restartRequestString, &restartRequestStruct, noError}, {disconnectRequestString, &disconnectRequestStruct, noError}, {terminateRequestString, &terminateRequestStruct, noError}, {breakpointLocationsRequestString, &breakpointLocationsRequestStruct, noError}, {setBreakpointsRequestString, &setBreakpointsRequestStruct, noError}, {setFunctionBreakpointsRequestString, &setFunctionBreakpointsRequestStruct, noError}, {setExceptionBreakpointsRequestString, &setExceptionBreakpointsRequestStruct, noError}, {dataBreakpointInfoRequestString, &dataBreakpointInfoRequestStruct, noError}, {setDataBreakpointsRequestString, &setDataBreakpointsRequestStruct, noError}, {continueRequestString, &continueRequestStruct, noError}, {nextRequestString, &nextRequestStruct, noError}, {stepInRequestString, &stepInRequestStruct, noError}, {stepOutRequestString, &stepOutRequestStruct, noError}, {stepBackRequestString, &stepBackRequestStruct, noError}, {reverseContinueRequestString, &reverseContinueRequestStruct, noError}, {restartFrameRequestString, &restartFrameRequestStruct, noError}, {gotoRequestString, &gotoRequestStruct, noError}, {pauseRequestString, &pauseRequestStruct, noError}, {stackTraceRequestString, &stackTraceRequestStruct, noError}, {scopesRequestString, &scopesRequestStruct, noError}, {variablesRequestString, &variablesRequestStruct, noError}, {setVariableRequestString, &setVariableRequestStruct, noError}, {sourceRequestString, &sourceRequestStruct, noError}, {threadsRequestString, &threadsRequestStruct, noError}, {terminateThreadsRequestString, &terminateThreadsRequestStruct, noError}, {modulesRequestString, &modulesRequestStruct, noError}, {loadedSourcesRequestString, &loadedSourcesRequestStruct, noError}, {evaluateRequestString, &evaluateRequestStruct, noError}, {setExpressionRequestString, &setExpressionRequestStruct, noError}, {stepInTargetsRequestString, &stepInTargetsRequestStruct, noError}, {gotoTargetsRequestString, &gotoTargetsRequestStruct, noError}, {completionsRequestString, &completionsRequestStruct, noError}, {exceptionInfoRequestString, &exceptionInfoRequestStruct, noError}, {readMemoryRequestString, &readMemoryRequestStruct, noError}, {disassembleRequestString, &disassembleRequestStruct, noError}, {startDebuggingRequestString, &startDebuggingRequestStruct, noError}, // Response {`{"type":"response","success":true, "seq": 77}`, msgIgnoredOnError, "Response command '' is not supported (seq: 77)"}, {errorResponseString, &errorResponseStruct, noError}, {cancelResponseString, &cancelResponseStruct, noError}, {runInTerminalResponseString, &runInTerminalResponseStruct, noError}, {initializeResponseString, &initializeResponseStruct, noError}, {configurationDoneResponseString, &configurationDoneResponseStruct, noError}, {launchResponseString, &launchResponseStruct, noError}, {attachResponseString, &attachResponseStruct, noError}, {restartResponseString, &restartResponseStruct, noError}, {disconnectResponseString, &disconnectResponseStruct, noError}, {terminateResponseString, &terminateResponseStruct, noError}, {breakpointLocationsResponseString, &breakpointLocationsResponseStruct, noError}, {setBreakpointsResponseString, &setBreakpointsResponseStruct, noError}, {setFunctionBreakpointsResponseString, &setFunctionBreakpointsResponseStruct, noError}, {setExceptionBreakpointsResponseString, &setExceptionBreakpointsResponseStruct, noError}, {dataBreakpointInfoResponseString, &dataBreakpointInfoResponseStruct, noError}, {setDataBreakpointsResponseString, &setDataBreakpointsResponseStruct, noError}, {continueResponseString, &continueResponseStruct, noError}, {nextResponseString, &nextResponseStruct, noError}, {stepInResponseString, &stepInResponseStruct, noError}, {stepOutResponseString, &stepOutResponseStruct, noError}, {stepBackResponseString, &stepBackResponseStruct, noError}, {reverseContinueResponseString, &reverseContinueResponseStruct, noError}, {restartFrameResponseString, &restartFrameResponseStruct, noError}, {gotoResponseString, &gotoResponseStruct, noError}, {pauseResponseString, &pauseResponseStruct, noError}, {stackTraceResponseString, &stackTraceResponseStruct, noError}, {scopesResponseString, &scopesResponseStruct, noError}, {variablesResponseString, &variablesResponseStruct, noError}, {setVariableResponseString, &setVariableResponseStruct, noError}, {sourceResponseString, &sourceResponseStruct, noError}, {threadsResponseString, &threadsResponseStruct, noError}, {terminateThreadsResponseString, &terminateThreadsResponseStruct, noError}, {modulesResponseString, &modulesResponseStruct, noError}, {loadedSourcesResponseString, &loadedSourcesResponseStruct, noError}, {evaluateResponseString, &evaluateResponseStruct, noError}, {setExpressionResponseString, &setExpressionResponseStruct, noError}, {stepInTargetsResponseString, &stepInTargetsResponseStruct, noError}, {gotoTargetsResponseString, &gotoTargetsResponseStruct, noError}, {completionsResponseString, &completionsResponseStruct, noError}, {exceptionInfoResponseString, &exceptionInfoResponseStruct, noError}, {readMemoryResponseString, &readMemoryResponseStruct, noError}, {disassembleResponseString, &disassembleResponseStruct, noError}, {startDebuggingResponseString, &startDebuggingResponseStruct, noError}, // Event {`{"type":"event", "seq": 8}`, msgIgnoredOnError, "Event event '' is not supported (seq: 8)"}, {initializedEventString, &initializedEventStruct, noError}, {stoppedEventString, &stoppedEventStruct, noError}, {continuedEventString, &continuedEventStruct, noError}, {exitedEventString, &exitedEventStruct, noError}, {terminatedEventString, &terminatedEventStruct, noError}, {threadEventString, &threadEventStruct, noError}, {outputEventString, &outputEventStruct, noError}, {breakpointEventString, &breakpointEventStruct, noError}, {moduleEventString, &moduleEventStruct, noError}, {loadedSourceEventString, &loadedSourceEventStruct, noError}, {processEventString, &processEventStruct, noError}, {capabilitiesEventString, &capabilitiesEventStruct, noError}, } for _, test := range tests { t.Run(test.data, func(t *testing.T) { msg, err := DecodeProtocolMessage([]byte(test.data)) if err != nil { // Decoding error if err.Error() != test.wantErr { // Was it the right error? t.Errorf("got error=%#v, want %q", err, test.wantErr) } } else { // No decoding error if test.wantErr != "" { // Did we expect one? t.Errorf("got error=nil, want %#q", test.wantErr) } got, _ := json.Marshal(msg) want, _ := json.Marshal(test.wantMsg) if !reflect.DeepEqual(msg, test.wantMsg) { // Check result t.Errorf("\ngot message\n%s\nwant\n%s", got, want) } } }) } } // -------- Custom Request/Response and Event -------- type customRequest struct { Request Body string `json:"body"` } func (r *customRequest) GetRequest() *Request { return &r.Request } type customResponse struct { Response Body string `json:"body"` } func (r *customResponse) GetResponse() *Response { return &r.Response } var customRequestString = `{"seq":40,"type":"request","command":"customReq","body":"242424"}` var customRequestStruct = customRequest{ Request: *newRequest(40, "customReq"), Body: "242424", } var customResponseString = `{"seq":40,"type":"response","request_seq":41,"command":"customReq","success":true,"body":"424242"}` var customResponseStruct = customResponse{ Response: *newResponse(40, 41, "customReq", true), Body: "424242", } type customEvent struct { Event Body int `json:"body"` } func (e *customEvent) GetEvent() *Event { return &e.Event } var customEventString = `{"seq":13,"type":"event","event":"customEvt","body":42}` var customEventStruct = customEvent{ Event: *newEvent(13, "customEvt"), Body: 42, } func TestDecodeProtocolMessage_Custom(t *testing.T) { tests := []struct { data string wantMsg Message }{ {customRequestString, &customRequestStruct}, {customResponseString, &customResponseStruct}, {customEventString, &customEventStruct}, } codec := NewCodec() codec.RegisterRequest("customReq", func() Message { return new(customRequest) }, func() Message { return new(customResponse) }) codec.RegisterEvent("customEvt", func() Message { return new(customEvent) }) for _, test := range tests { t.Run(test.data, func(t *testing.T) { msg, err := codec.DecodeMessage([]byte(test.data)) if err != nil { // Decoding error t.Fatalf("codec.DecodeMessage() failed with %v", err) } got, _ := json.Marshal(msg) want, _ := json.Marshal(test.wantMsg) if !reflect.DeepEqual(msg, test.wantMsg) { // Check result t.Errorf("\ngot message\n%s\nwant\n%s", got, want) } }) } } // newRequest builds a Request struct with the specified fields. func newRequest(seq int, command string) *Request { return &Request{ ProtocolMessage: ProtocolMessage{ Type: "request", Seq: seq, }, Command: command, } } // newEvent builds an Event struct with the specified fields. func newEvent(seq int, event string) *Event { return &Event{ ProtocolMessage: ProtocolMessage{ Seq: seq, Type: "event", }, Event: event, } } // newResponse builds a Response struct with the specified fields. func newResponse(seq int, requestSeq int, command string, success bool) *Response { return &Response{ ProtocolMessage: ProtocolMessage{ Seq: seq, Type: "response", }, Command: command, RequestSeq: requestSeq, Success: success, } } golang-github-google-go-dap-0.10.0/doc.go000066400000000000000000000015621446076322400200460ustar00rootroot00000000000000// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package dap contains data types and code for Debug Adapter Protocol (DAP) specification. // https://github.com/microsoft/vscode-debugadapter-node/blob/main/debugProtocol.json package dap //go:generate go run ./cmd/gentypes/gentypes.go -o schematypes.go -u cmd/gentypes/debugProtocol.json golang-github-google-go-dap-0.10.0/docs/000077500000000000000000000000001446076322400176765ustar00rootroot00000000000000golang-github-google-go-dap-0.10.0/docs/contributing.md000066400000000000000000000037101446076322400227300ustar00rootroot00000000000000# How to Contribute We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow. ## Contributor License Agreement Contributions to this project must be accompanied by a Contributor License Agreement. You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. Head over to to see your current agreements on file or to sign a new one. You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again. ## Code reviews All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more information on using pull requests. ## Source Code Headers Every file containing source code must include copyright and license information. This includes any JS/CSS files that you might be serving out to browsers. (This is to help well-intentioned people avoid accidental copying that doesn't comply with the license.) Apache header: Copyright 2020 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ## Community Guidelines This project follows [Google's Open Source Community Guidelines](https://opensource.google/conduct/). golang-github-google-go-dap-0.10.0/go.mod000066400000000000000000000000711446076322400200520ustar00rootroot00000000000000module github.com/google/go-dap go 1.13 retract v0.9.0 golang-github-google-go-dap-0.10.0/internal/000077500000000000000000000000001446076322400205625ustar00rootroot00000000000000golang-github-google-go-dap-0.10.0/internal/test.sh000077500000000000000000000013461446076322400221040ustar00rootroot00000000000000#!/bin/bash set -euo pipefail if [[ $# -gt 0 ]]; then echo "usage: runchecks.sh" 1>&2 exit 64 fi # ensure_go_binary verifies that a binary exists in $PATH corresponding to the # given go-gettable URI. If no such binary exists, it is fetched via `go install` # at latest. ensure_go_binary() { local binary=$(basename $1) if ! [ -x "$(command -v $binary)" ]; then echo "Installing: $1" # Run in a subshell for convenience, so that we don't have to worry about # our PWD. (set -x; cd && go install $1@latest) fi } echo "**** Running Go tests" go test -race -count=1 ./... echo "**** Running staticcheck" ensure_go_binary honnef.co/go/tools/cmd/staticcheck staticcheck ./... echo "**** Running go vet" go vet ./... golang-github-google-go-dap-0.10.0/io.go000066400000000000000000000105611446076322400177070ustar00rootroot00000000000000// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // This file contains utilities for DAP Base protocol I/O. // For additional information, see "Base protocol" section in // https://microsoft.github.io/debug-adapter-protocol/overview. package dap import ( "bufio" "encoding/json" "fmt" "io" "regexp" "strconv" "strings" ) // BaseProtocolError represents base protocol error, which occurs when the raw // message does not conform to the header+content format of the base protocol. type BaseProtocolError struct { Err string } func (bpe *BaseProtocolError) Error() string { return bpe.Err } var ( // ErrHeaderDelimiterNotCrLfCrLf is returned when only partial header // delimiter \r\n\r\n is encountered. ErrHeaderDelimiterNotCrLfCrLf = &BaseProtocolError{fmt.Sprintf("header delimiter is not %q", crLfcrLf)} // ErrHeaderNotContentLength is returned when the parsed header is // not of valid Content-Length format. ErrHeaderNotContentLength = &BaseProtocolError{fmt.Sprintf("header format is not %q", contentLengthHeaderRegex)} // ErrHeaderContentTooLong is returned when the content length specified in // the header is above contentMaxLength. ErrHeaderContentTooLong = &BaseProtocolError{fmt.Sprintf("content length over %v bytes", contentMaxLength)} ) const ( crLfcrLf = "\r\n\r\n" contentLengthHeaderFmt = "Content-Length: %d\r\n\r\n" contentMaxLength = 4 * 1024 * 1024 ) var ( contentLengthHeaderRegex = regexp.MustCompile("^Content-Length: ([0-9]+)$") ) // WriteBaseMessage formats content with Content-Length header and delimiters // as per the base protocol and writes the resulting message to w. func WriteBaseMessage(w io.Writer, content []byte) error { header := fmt.Sprintf(contentLengthHeaderFmt, len(content)) if _, err := w.Write([]byte(header)); err != nil { return err } _, err := w.Write(content) return err } // ReadBaseMessage reads one message from r consisting of a Content-Length // header and a content part. It parses the header to determine the size of // the content part and extracts and returns the actual content of the message. // Returns nil bytes on error, which can be one of the standard IO errors or // a BaseProtocolError defined in this package. func ReadBaseMessage(r *bufio.Reader) ([]byte, error) { contentLength, err := readContentLengthHeader(r) if err != nil { return nil, err } if contentLength > contentMaxLength { return nil, ErrHeaderContentTooLong } content := make([]byte, contentLength) if _, err = io.ReadFull(r, content); err != nil { return nil, err } return content, nil } // readContentLengthHeader looks for the only header field that is supported // and required: // Content-Length: [0-9]+\r\n\r\n // Extracts and returns the content length. func readContentLengthHeader(r *bufio.Reader) (contentLength int64, err error) { // Look for \r\n\r\n headerWithCr, err := r.ReadString('\r') if err != nil { return 0, err } nextThree := make([]byte, 3) if _, err = io.ReadFull(r, nextThree); err != nil { return 0, err } if string(nextThree) != "\n\r\n" { return 0, ErrHeaderDelimiterNotCrLfCrLf } // If header is in the right format, get the length header := strings.TrimSuffix(headerWithCr, "\r") headerAndLength := contentLengthHeaderRegex.FindStringSubmatch(header) if len(headerAndLength) < 2 { return 0, ErrHeaderNotContentLength } return strconv.ParseInt(headerAndLength[1], 10, 64) } // WriteProtocolMessage encodes message and writes it to w. func WriteProtocolMessage(w io.Writer, message Message) error { b, err := json.Marshal(message) if err != nil { return err } return WriteBaseMessage(w, b) } // ReadProtocolMessage reads a message from r, decodes and returns it. func ReadProtocolMessage(r *bufio.Reader) (Message, error) { content, err := ReadBaseMessage(r) if err != nil { return nil, err } return DecodeProtocolMessage(content) } golang-github-google-go-dap-0.10.0/io_test.go000066400000000000000000000233721446076322400207520ustar00rootroot00000000000000// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package dap import ( "bufio" "bytes" "encoding/json" "io" "io/ioutil" "reflect" "strings" "testing" "time" ) func Test_WriteBaseMessage(t *testing.T) { tests := []struct { input string wantWritten string wantErr error }{ {``, "Content-Length: 0\r\n\r\n", nil}, {`a`, "Content-Length: 1\r\n\r\na", nil}, {`{}`, "Content-Length: 2\r\n\r\n{}", nil}, {`{"a":0 "b":"blah"}`, "Content-Length: 18\r\n\r\n{\"a\":0 \"b\":\"blah\"}", nil}, } for _, test := range tests { t.Run(test.input, func(t *testing.T) { var buf bytes.Buffer gotErr := WriteBaseMessage(&buf, []byte(test.input)) gotWritten := buf.String() if gotErr != test.wantErr { t.Errorf("got err=%#v, want %#v", gotErr, test.wantErr) } if gotErr == nil && gotWritten != test.wantWritten { t.Errorf("got written=%q, want %q", gotWritten, test.wantWritten) } }) } } func Test_ReadBaseMessage(t *testing.T) { tests := []struct { input string wantBytesRead []byte wantBytesLeft []byte wantErr error }{ {"", nil, []byte(""), io.EOF}, {"random stuff\r\nabc", nil, []byte("c"), ErrHeaderDelimiterNotCrLfCrLf}, {"Cache-Control: no-cache\r\n\r\n", nil, []byte(""), ErrHeaderNotContentLength}, {"Content-Length 1\r\n\r\nabc", nil, []byte("abc"), ErrHeaderNotContentLength}, {"Content-Length: 10\r\n\r\nabc", nil, []byte(""), io.ErrUnexpectedEOF}, {"Content-Length: 3\r\n\r\nabc", []byte("abc"), []byte(""), nil}, {"Content-Length: 4194305\r\n\r\nabc", nil, []byte("abc"), ErrHeaderContentTooLong}, {"Content-Length: 6506440440440\r\n\r\nabc", nil, []byte("abc"), ErrHeaderContentTooLong}, } for _, test := range tests { t.Run(test.input, func(t *testing.T) { reader := bufio.NewReader(strings.NewReader(test.input)) gotBytes, gotErr := ReadBaseMessage(reader) if gotErr != test.wantErr { t.Errorf("got err=%#v, want %#v", gotErr, test.wantErr) } if gotErr == nil && !bytes.Equal(gotBytes, test.wantBytesRead) { t.Errorf("got bytes=%q, want %q", gotBytes, test.wantBytesRead) } bytesLeft, _ := ioutil.ReadAll(reader) if !bytes.Equal(bytesLeft, test.wantBytesLeft) { t.Errorf("got bytesLeft=%q, want %q", bytesLeft, test.wantBytesLeft) } }) } } func Test_readContentLengthHeader(t *testing.T) { tests := []struct { input string wantBytesLeft string // Bytes left in the reader after header reading wantLen int64 // Extracted content length value wantErr error }{ {"", "", 0, io.EOF}, {"Cache-Control: no-cache", "", 0, io.EOF}, {"Cache-Control: no-cache\r", "", 0, io.EOF}, {"Cache-Control: no-cache\rabc", "", 0, ErrHeaderDelimiterNotCrLfCrLf}, {"Cache-Control: no-cache\r\n", "", 0, io.ErrUnexpectedEOF}, {"Cache-Control: no-cache\r\n\r", "", 0, io.ErrUnexpectedEOF}, {"Cache-Control: no-cache\r\n\r\n", "", 0, ErrHeaderNotContentLength}, {"Cache-Control: no-cache\r\n\r\nabc", "abc", 0, ErrHeaderNotContentLength}, {"Content-Length: 3 abc", "", 0, io.EOF}, {"Content-Length: 3\nabc", "", 0, io.EOF}, {"Content-Length: 3\rabc", "", 0, ErrHeaderDelimiterNotCrLfCrLf}, {"Content-Length: 3\r\nabc", "c", 0, ErrHeaderDelimiterNotCrLfCrLf}, {"Content-Length: 3\r\n\rabc", "bc", 0, ErrHeaderDelimiterNotCrLfCrLf}, {"Content-Length: 3\r \n\r\nabc", "\nabc", 0, ErrHeaderDelimiterNotCrLfCrLf}, {"Content-Length: 3\r\n \r\nabc", "\nabc", 0, ErrHeaderDelimiterNotCrLfCrLf}, {"Content-Length: 3\r\n\r \nabc", "\nabc", 0, ErrHeaderDelimiterNotCrLfCrLf}, {"Content-Length 3\r\n\r\nabc", "abc", 0, ErrHeaderNotContentLength}, {"_Content-Length: 3\r\n\r\nabc", "abc", 0, ErrHeaderNotContentLength}, {"Content-Length: 3_\r\n\r\nabc", "abc", 0, ErrHeaderNotContentLength}, {"Content-Length: x\r\n\r\nabc", "abc", 0, ErrHeaderNotContentLength}, {"Content-Length: 3.0\r\n\r\nabc", "abc", 0, ErrHeaderNotContentLength}, {"Content-Length: -3\r\n\r\nabc", "abc", 0, ErrHeaderNotContentLength}, {"Content-Length: 0\r\n\r\nabc", "abc", 0, nil}, {"Content-Length: 3\r\n\r\nabc", "abc", 3, nil}, {"Content-Length: 9223372036854775807\r\n\r\nabc", "abc", 9223372036854775807, nil}, } for _, test := range tests { t.Run(test.input, func(t *testing.T) { reader := bufio.NewReader(strings.NewReader(test.input)) gotLen, gotErr := readContentLengthHeader(reader) if gotErr != test.wantErr { t.Errorf("got err=%#v, want %#v", gotErr, test.wantErr) } if gotErr == nil && gotLen != test.wantLen { t.Errorf("got len=%d, want %d", gotLen, test.wantLen) } bytesLeft, _ := ioutil.ReadAll(reader) if string(bytesLeft) != test.wantBytesLeft { t.Errorf("got bytesLeft=%q, want %q", bytesLeft, test.wantBytesLeft) } }) } } func TestWriteRead(t *testing.T) { writeContent := [][]byte{ []byte("this is"), []byte("a read write"), []byte("test"), } var buf bytes.Buffer for _, wc := range writeContent { if err := WriteBaseMessage(&buf, wc); err != nil { t.Fatal(err) } } reader := bufio.NewReader(&buf) for _, wc := range writeContent { rc, err := ReadBaseMessage(reader) if err != nil { t.Fatal(err) } if !bytes.Equal(rc, wc) { t.Fatalf("got %q, want %q", rc, wc) } } } // readMessagesAndNotify reads messages one by one until EOF. // Notifies of a read via messagesRead channel. func readMessagesAndNotify(t *testing.T, r io.Reader, messagesRead chan<- []byte) { reader := bufio.NewReader(r) for { msg, err := ReadBaseMessage(reader) if err == io.EOF { close(messagesRead) break } // On error, this will send "" as the content read messagesRead <- msg } } func writeOrFail(t *testing.T, w io.Writer, data string) { if n, err := w.Write([]byte(data)); err != nil || n < len(data) { t.Fatal(err) } } func TestReadMessageInParts(t *testing.T) { // This test uses separate goroutines to write and read messages // and relies on blocking channel operations between them to ensure that // the expected number of messages is read for what is written. // Otherwise, the test will time out. messagesRead := make(chan []byte) r, w := io.Pipe() header := "Content-Length: 11" baddelim := "\r\r\r\r" content1 := "message one" content2 := "message two" nocontent := "" // This will keep blocking to read a full message or EOF. go readMessagesAndNotify(t, r, messagesRead) checkNoMessageRead := func() { time.Sleep(100 * time.Millisecond) // Let read goroutine run select { case msg := <-messagesRead: t.Errorf("got %q, want none", msg) default: } } checkOneMessageRead := func(want []byte) { got := <-messagesRead if !bytes.Equal(got, want) { t.Errorf("got %q, want %q", got, want) } } // Good message written in full writeOrFail(t, w, header+crLfcrLf+content1) checkOneMessageRead([]byte(content1)) // Good message written in parts writeOrFail(t, w, header) checkNoMessageRead() writeOrFail(t, w, crLfcrLf) checkNoMessageRead() writeOrFail(t, w, content2) checkOneMessageRead([]byte(content2)) // Bad message written in full writeOrFail(t, w, header+baddelim) checkOneMessageRead([]byte(nocontent)) // Bad meassage written in parts writeOrFail(t, w, header) checkNoMessageRead() writeOrFail(t, w, baddelim) checkOneMessageRead([]byte(nocontent)) w.Close() // "sends" EOF } func TestReadWriteWithCodec(t *testing.T) { // Tests end-to-end write and read from a buffer using the DAP codec. req := InitializeRequest{ Request: Request{ ProtocolMessage: ProtocolMessage{ Type: "request", Seq: 121, }, Command: "initialize", }, Arguments: InitializeRequestArguments{ ClientID: "vscode", ClientName: "Visual Studio Code", AdapterID: "go", PathFormat: "path", LinesStartAt1: true, ColumnsStartAt1: false, SupportsVariableType: true, SupportsVariablePaging: true, SupportsRunInTerminalRequest: false, Locale: "en-us", }, } baseReq, err := json.Marshal(req) if err != nil { t.Error(err) } buf := new(bytes.Buffer) err = WriteBaseMessage(buf, baseReq) if err != nil { t.Error(err) } reader := bufio.NewReader(buf) msg, err := ReadBaseMessage(reader) if err != nil { t.Error(err) } readReqPtr, err := DecodeProtocolMessage(msg) if err != nil { t.Error(err) } if !reflect.DeepEqual(readReqPtr, &req) { t.Errorf("got req=%#v, want %#v", readReqPtr, req) } } const cancelReqString = "Content-Length: 75\r\n\r\n{\"seq\":25,\"type\":\"request\",\"command\":\"cancel\",\"arguments\":{\"requestId\":24}}" var cancelReqStruct = CancelRequest{ Request: Request{ ProtocolMessage: ProtocolMessage{ Type: "request", Seq: 25, }, Command: "cancel", }, Arguments: &CancelArguments{RequestId: 24}, } func TestWriteProtocolMessage(t *testing.T) { buf := new(bytes.Buffer) err := WriteProtocolMessage(buf, &cancelReqStruct) if err != nil { t.Error(err) } if buf.String() != cancelReqString { t.Errorf("got %#v, want %#v", buf.String(), cancelReqString) } } func TestReadProtocolMessage(t *testing.T) { reader := bufio.NewReader(strings.NewReader(cancelReqString)) msg, err := ReadProtocolMessage(reader) if err != nil { t.Error(err) } if !reflect.DeepEqual(msg, &cancelReqStruct) { t.Errorf("got req=%#v, want %#v", msg, &cancelReqStruct) } } golang-github-google-go-dap-0.10.0/schematypes.go000066400000000000000000002705551446076322400216400ustar00rootroot00000000000000// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Code generated by "cmd/gentypes/gentypes.go"; DO NOT EDIT. // DAP spec: https://microsoft.github.io/debug-adapter-protocol/specification // See cmd/gentypes/README.md for additional details. package dap import "encoding/json" // Message is an interface that all DAP message types implement with pointer // receivers. It's not part of the protocol but is used to enforce static // typing in Go code and provide some common accessors. // // Note: the DAP type "Message" (which is used in the body of ErrorResponse) // is renamed to ErrorMessage to avoid collision with this interface. type Message interface { GetSeq() int } // RequestMessage is an interface implemented by all Request-types. type RequestMessage interface { Message // GetRequest provides access to the embedded Request. GetRequest() *Request } // ResponseMessage is an interface implemented by all Response-types. type ResponseMessage interface { Message // GetResponse provides access to the embedded Response. GetResponse() *Response } // EventMessage is an interface implemented by all Event-types. type EventMessage interface { Message // GetEvent provides access to the embedded Event. GetEvent() *Event } // LaunchAttachRequest is an interface implemented by // LaunchRequest and AttachRequest as they contain shared // implementation specific arguments that are not part of // the specification. type LaunchAttachRequest interface { RequestMessage // GetArguments provides access to the Arguments map. GetArguments() json.RawMessage } // ProtocolMessage: Base class of requests, responses, and events. type ProtocolMessage struct { Seq int `json:"seq"` Type string `json:"type"` } func (m *ProtocolMessage) GetSeq() int { return m.Seq } // Request: A client or debug adapter initiated request. type Request struct { ProtocolMessage Command string `json:"command"` } // Event: A debug adapter initiated event. type Event struct { ProtocolMessage Event string `json:"event"` } // Response: Response for a request. type Response struct { ProtocolMessage RequestSeq int `json:"request_seq"` Success bool `json:"success"` Command string `json:"command"` Message string `json:"message,omitempty"` } // ErrorResponse: On error (whenever `success` is false), the body can provide more details. type ErrorResponse struct { Response Body ErrorResponseBody `json:"body"` } type ErrorResponseBody struct { Error *ErrorMessage `json:"error,omitempty"` } func (r *ErrorResponse) GetResponse() *Response { return &r.Response } // CancelRequest: The `cancel` request is used by the client in two situations: // - to indicate that it is no longer interested in the result produced by a specific request issued earlier // - to cancel a progress sequence. Clients should only call this request if the corresponding capability `supportsCancelRequest` is true. // This request has a hint characteristic: a debug adapter can only be expected to make a 'best effort' in honoring this request but there are no guarantees. // The `cancel` request may return an error if it could not cancel an operation but a client should refrain from presenting this error to end users. // The request that got cancelled still needs to send a response back. This can either be a normal result (`success` attribute true) or an error response (`success` attribute false and the `message` set to `cancelled`). // Returning partial results from a cancelled request is possible but please note that a client has no generic way for detecting that a response is partial or not. // The progress that got cancelled still needs to send a `progressEnd` event back. // // A client should not assume that progress just got cancelled after sending the `cancel` request. type CancelRequest struct { Request Arguments *CancelArguments `json:"arguments,omitempty"` } func (r *CancelRequest) GetRequest() *Request { return &r.Request } // CancelArguments: Arguments for `cancel` request. type CancelArguments struct { RequestId int `json:"requestId,omitempty"` ProgressId string `json:"progressId,omitempty"` } // CancelResponse: Response to `cancel` request. This is just an acknowledgement, so no body field is required. type CancelResponse struct { Response } func (r *CancelResponse) GetResponse() *Response { return &r.Response } // InitializedEvent: This event indicates that the debug adapter is ready to accept configuration requests (e.g. `setBreakpoints`, `setExceptionBreakpoints`). // A debug adapter is expected to send this event when it is ready to accept configuration requests (but not before the `initialize` request has finished). // The sequence of events/requests is as follows: // - adapters sends `initialized` event (after the `initialize` request has returned) // - client sends zero or more `setBreakpoints` requests // - client sends one `setFunctionBreakpoints` request (if corresponding capability `supportsFunctionBreakpoints` is true) // - client sends a `setExceptionBreakpoints` request if one or more `exceptionBreakpointFilters` have been defined (or if `supportsConfigurationDoneRequest` is not true) // - client sends other future configuration requests // - client sends one `configurationDone` request to indicate the end of the configuration. type InitializedEvent struct { Event } func (e *InitializedEvent) GetEvent() *Event { return &e.Event } // StoppedEvent: The event indicates that the execution of the debuggee has stopped due to some condition. // This can be caused by a breakpoint previously set, a stepping request has completed, by executing a debugger statement etc. type StoppedEvent struct { Event Body StoppedEventBody `json:"body"` } type StoppedEventBody struct { Reason string `json:"reason"` Description string `json:"description,omitempty"` ThreadId int `json:"threadId,omitempty"` PreserveFocusHint bool `json:"preserveFocusHint,omitempty"` Text string `json:"text,omitempty"` AllThreadsStopped bool `json:"allThreadsStopped,omitempty"` HitBreakpointIds []int `json:"hitBreakpointIds,omitempty"` } func (e *StoppedEvent) GetEvent() *Event { return &e.Event } // ContinuedEvent: The event indicates that the execution of the debuggee has continued. // Please note: a debug adapter is not expected to send this event in response to a request that implies that execution continues, e.g. `launch` or `continue`. // It is only necessary to send a `continued` event if there was no previous request that implied this. type ContinuedEvent struct { Event Body ContinuedEventBody `json:"body"` } type ContinuedEventBody struct { ThreadId int `json:"threadId"` AllThreadsContinued bool `json:"allThreadsContinued,omitempty"` } func (e *ContinuedEvent) GetEvent() *Event { return &e.Event } // ExitedEvent: The event indicates that the debuggee has exited and returns its exit code. type ExitedEvent struct { Event Body ExitedEventBody `json:"body"` } type ExitedEventBody struct { ExitCode int `json:"exitCode"` } func (e *ExitedEvent) GetEvent() *Event { return &e.Event } // TerminatedEvent: The event indicates that debugging of the debuggee has terminated. This does **not** mean that the debuggee itself has exited. type TerminatedEvent struct { Event Body TerminatedEventBody `json:"body,omitempty"` } type TerminatedEventBody struct { Restart interface{} `json:"restart,omitempty"` } func (e *TerminatedEvent) GetEvent() *Event { return &e.Event } // ThreadEvent: The event indicates that a thread has started or exited. type ThreadEvent struct { Event Body ThreadEventBody `json:"body"` } type ThreadEventBody struct { Reason string `json:"reason"` ThreadId int `json:"threadId"` } func (e *ThreadEvent) GetEvent() *Event { return &e.Event } // OutputEvent: The event indicates that the target has produced some output. type OutputEvent struct { Event Body OutputEventBody `json:"body"` } type OutputEventBody struct { Category string `json:"category,omitempty"` Output string `json:"output"` Group string `json:"group,omitempty"` VariablesReference int `json:"variablesReference,omitempty"` Source *Source `json:"source,omitempty"` Line int `json:"line,omitempty"` Column int `json:"column,omitempty"` Data interface{} `json:"data,omitempty"` } func (e *OutputEvent) GetEvent() *Event { return &e.Event } // BreakpointEvent: The event indicates that some information about a breakpoint has changed. type BreakpointEvent struct { Event Body BreakpointEventBody `json:"body"` } type BreakpointEventBody struct { Reason string `json:"reason"` Breakpoint Breakpoint `json:"breakpoint"` } func (e *BreakpointEvent) GetEvent() *Event { return &e.Event } // ModuleEvent: The event indicates that some information about a module has changed. type ModuleEvent struct { Event Body ModuleEventBody `json:"body"` } type ModuleEventBody struct { Reason string `json:"reason"` Module Module `json:"module"` } func (e *ModuleEvent) GetEvent() *Event { return &e.Event } // LoadedSourceEvent: The event indicates that some source has been added, changed, or removed from the set of all loaded sources. type LoadedSourceEvent struct { Event Body LoadedSourceEventBody `json:"body"` } type LoadedSourceEventBody struct { Reason string `json:"reason"` Source Source `json:"source"` } func (e *LoadedSourceEvent) GetEvent() *Event { return &e.Event } // ProcessEvent: The event indicates that the debugger has begun debugging a new process. Either one that it has launched, or one that it has attached to. type ProcessEvent struct { Event Body ProcessEventBody `json:"body"` } type ProcessEventBody struct { Name string `json:"name"` SystemProcessId int `json:"systemProcessId,omitempty"` IsLocalProcess bool `json:"isLocalProcess,omitempty"` StartMethod string `json:"startMethod,omitempty"` PointerSize int `json:"pointerSize,omitempty"` } func (e *ProcessEvent) GetEvent() *Event { return &e.Event } // CapabilitiesEvent: The event indicates that one or more capabilities have changed. // Since the capabilities are dependent on the client and its UI, it might not be possible to change that at random times (or too late). // Consequently this event has a hint characteristic: a client can only be expected to make a 'best effort' in honoring individual capabilities but there are no guarantees. // Only changed capabilities need to be included, all other capabilities keep their values. type CapabilitiesEvent struct { Event Body CapabilitiesEventBody `json:"body"` } type CapabilitiesEventBody struct { Capabilities Capabilities `json:"capabilities"` } func (e *CapabilitiesEvent) GetEvent() *Event { return &e.Event } // ProgressStartEvent: The event signals that a long running operation is about to start and provides additional information for the client to set up a corresponding progress and cancellation UI. // The client is free to delay the showing of the UI in order to reduce flicker. // This event should only be sent if the corresponding capability `supportsProgressReporting` is true. type ProgressStartEvent struct { Event Body ProgressStartEventBody `json:"body"` } type ProgressStartEventBody struct { ProgressId string `json:"progressId"` Title string `json:"title"` RequestId int `json:"requestId,omitempty"` Cancellable bool `json:"cancellable,omitempty"` Message string `json:"message,omitempty"` Percentage int `json:"percentage,omitempty"` } func (e *ProgressStartEvent) GetEvent() *Event { return &e.Event } // ProgressUpdateEvent: The event signals that the progress reporting needs to be updated with a new message and/or percentage. // The client does not have to update the UI immediately, but the clients needs to keep track of the message and/or percentage values. // This event should only be sent if the corresponding capability `supportsProgressReporting` is true. type ProgressUpdateEvent struct { Event Body ProgressUpdateEventBody `json:"body"` } type ProgressUpdateEventBody struct { ProgressId string `json:"progressId"` Message string `json:"message,omitempty"` Percentage int `json:"percentage,omitempty"` } func (e *ProgressUpdateEvent) GetEvent() *Event { return &e.Event } // ProgressEndEvent: The event signals the end of the progress reporting with a final message. // This event should only be sent if the corresponding capability `supportsProgressReporting` is true. type ProgressEndEvent struct { Event Body ProgressEndEventBody `json:"body"` } type ProgressEndEventBody struct { ProgressId string `json:"progressId"` Message string `json:"message,omitempty"` } func (e *ProgressEndEvent) GetEvent() *Event { return &e.Event } // InvalidatedEvent: This event signals that some state in the debug adapter has changed and requires that the client needs to re-render the data snapshot previously requested. // Debug adapters do not have to emit this event for runtime changes like stopped or thread events because in that case the client refetches the new state anyway. But the event can be used for example to refresh the UI after rendering formatting has changed in the debug adapter. // This event should only be sent if the corresponding capability `supportsInvalidatedEvent` is true. type InvalidatedEvent struct { Event Body InvalidatedEventBody `json:"body"` } type InvalidatedEventBody struct { Areas []InvalidatedAreas `json:"areas,omitempty"` ThreadId int `json:"threadId,omitempty"` StackFrameId int `json:"stackFrameId,omitempty"` } func (e *InvalidatedEvent) GetEvent() *Event { return &e.Event } // MemoryEvent: This event indicates that some memory range has been updated. It should only be sent if the corresponding capability `supportsMemoryEvent` is true. // Clients typically react to the event by re-issuing a `readMemory` request if they show the memory identified by the `memoryReference` and if the updated memory range overlaps the displayed range. Clients should not make assumptions how individual memory references relate to each other, so they should not assume that they are part of a single continuous address range and might overlap. // Debug adapters can use this event to indicate that the contents of a memory range has changed due to some other request like `setVariable` or `setExpression`. Debug adapters are not expected to emit this event for each and every memory change of a running program, because that information is typically not available from debuggers and it would flood clients with too many events. type MemoryEvent struct { Event Body MemoryEventBody `json:"body"` } type MemoryEventBody struct { MemoryReference string `json:"memoryReference"` Offset int `json:"offset"` Count int `json:"count"` } func (e *MemoryEvent) GetEvent() *Event { return &e.Event } // RunInTerminalRequest: This request is sent from the debug adapter to the client to run a command in a terminal. // This is typically used to launch the debuggee in a terminal provided by the client. // This request should only be called if the corresponding client capability `supportsRunInTerminalRequest` is true. // Client implementations of `runInTerminal` are free to run the command however they choose including issuing the command to a command line interpreter (aka 'shell'). Argument strings passed to the `runInTerminal` request must arrive verbatim in the command to be run. As a consequence, clients which use a shell are responsible for escaping any special shell characters in the argument strings to prevent them from being interpreted (and modified) by the shell. // Some users may wish to take advantage of shell processing in the argument strings. For clients which implement `runInTerminal` using an intermediary shell, the `argsCanBeInterpretedByShell` property can be set to true. In this case the client is requested not to escape any special shell characters in the argument strings. type RunInTerminalRequest struct { Request Arguments RunInTerminalRequestArguments `json:"arguments"` } func (r *RunInTerminalRequest) GetRequest() *Request { return &r.Request } // RunInTerminalRequestArguments: Arguments for `runInTerminal` request. type RunInTerminalRequestArguments struct { Kind string `json:"kind,omitempty"` Title string `json:"title,omitempty"` Cwd string `json:"cwd"` Args []string `json:"args"` Env map[string]interface{} `json:"env,omitempty"` ArgsCanBeInterpretedByShell bool `json:"argsCanBeInterpretedByShell,omitempty"` } // RunInTerminalResponse: Response to `runInTerminal` request. type RunInTerminalResponse struct { Response Body RunInTerminalResponseBody `json:"body"` } type RunInTerminalResponseBody struct { ProcessId int `json:"processId,omitempty"` ShellProcessId int `json:"shellProcessId,omitempty"` } func (r *RunInTerminalResponse) GetResponse() *Response { return &r.Response } // StartDebuggingRequest: This request is sent from the debug adapter to the client to start a new debug session of the same type as the caller. // This request should only be sent if the corresponding client capability `supportsStartDebuggingRequest` is true. // A client implementation of `startDebugging` should start a new debug session (of the same type as the caller) in the same way that the caller's session was started. If the client supports hierarchical debug sessions, the newly created session can be treated as a child of the caller session. type StartDebuggingRequest struct { Request Arguments StartDebuggingRequestArguments `json:"arguments"` } func (r *StartDebuggingRequest) GetRequest() *Request { return &r.Request } // StartDebuggingRequestArguments: Arguments for `startDebugging` request. type StartDebuggingRequestArguments struct { Configuration map[string]interface{} `json:"configuration"` Request string `json:"request"` } // StartDebuggingResponse: Response to `startDebugging` request. This is just an acknowledgement, so no body field is required. type StartDebuggingResponse struct { Response } func (r *StartDebuggingResponse) GetResponse() *Response { return &r.Response } // InitializeRequest: The `initialize` request is sent as the first request from the client to the debug adapter in order to configure it with client capabilities and to retrieve capabilities from the debug adapter. // Until the debug adapter has responded with an `initialize` response, the client must not send any additional requests or events to the debug adapter. // In addition the debug adapter is not allowed to send any requests or events to the client until it has responded with an `initialize` response. // The `initialize` request may only be sent once. type InitializeRequest struct { Request Arguments InitializeRequestArguments `json:"arguments"` } func (r *InitializeRequest) GetRequest() *Request { return &r.Request } // InitializeRequestArguments: Arguments for `initialize` request. type InitializeRequestArguments struct { ClientID string `json:"clientID,omitempty"` ClientName string `json:"clientName,omitempty"` AdapterID string `json:"adapterID"` Locale string `json:"locale,omitempty"` LinesStartAt1 bool `json:"linesStartAt1"` ColumnsStartAt1 bool `json:"columnsStartAt1"` PathFormat string `json:"pathFormat,omitempty"` SupportsVariableType bool `json:"supportsVariableType,omitempty"` SupportsVariablePaging bool `json:"supportsVariablePaging,omitempty"` SupportsRunInTerminalRequest bool `json:"supportsRunInTerminalRequest,omitempty"` SupportsMemoryReferences bool `json:"supportsMemoryReferences,omitempty"` SupportsProgressReporting bool `json:"supportsProgressReporting,omitempty"` SupportsInvalidatedEvent bool `json:"supportsInvalidatedEvent,omitempty"` SupportsMemoryEvent bool `json:"supportsMemoryEvent,omitempty"` SupportsArgsCanBeInterpretedByShell bool `json:"supportsArgsCanBeInterpretedByShell,omitempty"` SupportsStartDebuggingRequest bool `json:"supportsStartDebuggingRequest,omitempty"` } // InitializeResponse: Response to `initialize` request. type InitializeResponse struct { Response Body Capabilities `json:"body,omitempty"` } func (r *InitializeResponse) GetResponse() *Response { return &r.Response } // ConfigurationDoneRequest: This request indicates that the client has finished initialization of the debug adapter. // So it is the last request in the sequence of configuration requests (which was started by the `initialized` event). // Clients should only call this request if the corresponding capability `supportsConfigurationDoneRequest` is true. type ConfigurationDoneRequest struct { Request Arguments *ConfigurationDoneArguments `json:"arguments,omitempty"` } func (r *ConfigurationDoneRequest) GetRequest() *Request { return &r.Request } // ConfigurationDoneArguments: Arguments for `configurationDone` request. type ConfigurationDoneArguments struct { } // ConfigurationDoneResponse: Response to `configurationDone` request. This is just an acknowledgement, so no body field is required. type ConfigurationDoneResponse struct { Response } func (r *ConfigurationDoneResponse) GetResponse() *Response { return &r.Response } // LaunchRequest: This launch request is sent from the client to the debug adapter to start the debuggee with or without debugging (if `noDebug` is true). // Since launching is debugger/runtime specific, the arguments for this request are not part of this specification. type LaunchRequest struct { Request Arguments json.RawMessage `json:"arguments"` } func (r *LaunchRequest) GetRequest() *Request { return &r.Request } func (r *LaunchRequest) GetArguments() json.RawMessage { return r.Arguments } // LaunchResponse: Response to `launch` request. This is just an acknowledgement, so no body field is required. type LaunchResponse struct { Response } func (r *LaunchResponse) GetResponse() *Response { return &r.Response } // AttachRequest: The `attach` request is sent from the client to the debug adapter to attach to a debuggee that is already running. // Since attaching is debugger/runtime specific, the arguments for this request are not part of this specification. type AttachRequest struct { Request Arguments json.RawMessage `json:"arguments"` } func (r *AttachRequest) GetRequest() *Request { return &r.Request } func (r *AttachRequest) GetArguments() json.RawMessage { return r.Arguments } // AttachResponse: Response to `attach` request. This is just an acknowledgement, so no body field is required. type AttachResponse struct { Response } func (r *AttachResponse) GetResponse() *Response { return &r.Response } // RestartRequest: Restarts a debug session. Clients should only call this request if the corresponding capability `supportsRestartRequest` is true. // If the capability is missing or has the value false, a typical client emulates `restart` by terminating the debug adapter first and then launching it anew. type RestartRequest struct { Request Arguments *RestartArguments `json:"arguments,omitempty"` } func (r *RestartRequest) GetRequest() *Request { return &r.Request } // RestartArguments: Arguments for `restart` request. type RestartArguments struct { Arguments interface{} `json:"arguments,omitempty"` } // RestartResponse: Response to `restart` request. This is just an acknowledgement, so no body field is required. type RestartResponse struct { Response } func (r *RestartResponse) GetResponse() *Response { return &r.Response } // DisconnectRequest: The `disconnect` request asks the debug adapter to disconnect from the debuggee (thus ending the debug session) and then to shut down itself (the debug adapter). // In addition, the debug adapter must terminate the debuggee if it was started with the `launch` request. If an `attach` request was used to connect to the debuggee, then the debug adapter must not terminate the debuggee. // This implicit behavior of when to terminate the debuggee can be overridden with the `terminateDebuggee` argument (which is only supported by a debug adapter if the corresponding capability `supportTerminateDebuggee` is true). type DisconnectRequest struct { Request Arguments *DisconnectArguments `json:"arguments,omitempty"` } func (r *DisconnectRequest) GetRequest() *Request { return &r.Request } // DisconnectArguments: Arguments for `disconnect` request. type DisconnectArguments struct { Restart bool `json:"restart,omitempty"` TerminateDebuggee bool `json:"terminateDebuggee,omitempty"` SuspendDebuggee bool `json:"suspendDebuggee,omitempty"` } // DisconnectResponse: Response to `disconnect` request. This is just an acknowledgement, so no body field is required. type DisconnectResponse struct { Response } func (r *DisconnectResponse) GetResponse() *Response { return &r.Response } // TerminateRequest: The `terminate` request is sent from the client to the debug adapter in order to shut down the debuggee gracefully. Clients should only call this request if the capability `supportsTerminateRequest` is true. // Typically a debug adapter implements `terminate` by sending a software signal which the debuggee intercepts in order to clean things up properly before terminating itself. // Please note that this request does not directly affect the state of the debug session: if the debuggee decides to veto the graceful shutdown for any reason by not terminating itself, then the debug session just continues. // Clients can surface the `terminate` request as an explicit command or they can integrate it into a two stage Stop command that first sends `terminate` to request a graceful shutdown, and if that fails uses `disconnect` for a forceful shutdown. type TerminateRequest struct { Request Arguments *TerminateArguments `json:"arguments,omitempty"` } func (r *TerminateRequest) GetRequest() *Request { return &r.Request } // TerminateArguments: Arguments for `terminate` request. type TerminateArguments struct { Restart bool `json:"restart,omitempty"` } // TerminateResponse: Response to `terminate` request. This is just an acknowledgement, so no body field is required. type TerminateResponse struct { Response } func (r *TerminateResponse) GetResponse() *Response { return &r.Response } // BreakpointLocationsRequest: The `breakpointLocations` request returns all possible locations for source breakpoints in a given range. // Clients should only call this request if the corresponding capability `supportsBreakpointLocationsRequest` is true. type BreakpointLocationsRequest struct { Request Arguments *BreakpointLocationsArguments `json:"arguments,omitempty"` } func (r *BreakpointLocationsRequest) GetRequest() *Request { return &r.Request } // BreakpointLocationsArguments: Arguments for `breakpointLocations` request. type BreakpointLocationsArguments struct { Source Source `json:"source"` Line int `json:"line"` Column int `json:"column,omitempty"` EndLine int `json:"endLine,omitempty"` EndColumn int `json:"endColumn,omitempty"` } // BreakpointLocationsResponse: Response to `breakpointLocations` request. // Contains possible locations for source breakpoints. type BreakpointLocationsResponse struct { Response Body BreakpointLocationsResponseBody `json:"body"` } type BreakpointLocationsResponseBody struct { Breakpoints []BreakpointLocation `json:"breakpoints"` } func (r *BreakpointLocationsResponse) GetResponse() *Response { return &r.Response } // SetBreakpointsRequest: Sets multiple breakpoints for a single source and clears all previous breakpoints in that source. // To clear all breakpoint for a source, specify an empty array. // When a breakpoint is hit, a `stopped` event (with reason `breakpoint`) is generated. type SetBreakpointsRequest struct { Request Arguments SetBreakpointsArguments `json:"arguments"` } func (r *SetBreakpointsRequest) GetRequest() *Request { return &r.Request } // SetBreakpointsArguments: Arguments for `setBreakpoints` request. type SetBreakpointsArguments struct { Source Source `json:"source"` Breakpoints []SourceBreakpoint `json:"breakpoints,omitempty"` Lines []int `json:"lines,omitempty"` SourceModified bool `json:"sourceModified,omitempty"` } // SetBreakpointsResponse: Response to `setBreakpoints` request. // Returned is information about each breakpoint created by this request. // This includes the actual code location and whether the breakpoint could be verified. // The breakpoints returned are in the same order as the elements of the `breakpoints` // (or the deprecated `lines`) array in the arguments. type SetBreakpointsResponse struct { Response Body SetBreakpointsResponseBody `json:"body"` } type SetBreakpointsResponseBody struct { Breakpoints []Breakpoint `json:"breakpoints"` } func (r *SetBreakpointsResponse) GetResponse() *Response { return &r.Response } // SetFunctionBreakpointsRequest: Replaces all existing function breakpoints with new function breakpoints. // To clear all function breakpoints, specify an empty array. // When a function breakpoint is hit, a `stopped` event (with reason `function breakpoint`) is generated. // Clients should only call this request if the corresponding capability `supportsFunctionBreakpoints` is true. type SetFunctionBreakpointsRequest struct { Request Arguments SetFunctionBreakpointsArguments `json:"arguments"` } func (r *SetFunctionBreakpointsRequest) GetRequest() *Request { return &r.Request } // SetFunctionBreakpointsArguments: Arguments for `setFunctionBreakpoints` request. type SetFunctionBreakpointsArguments struct { Breakpoints []FunctionBreakpoint `json:"breakpoints"` } // SetFunctionBreakpointsResponse: Response to `setFunctionBreakpoints` request. // Returned is information about each breakpoint created by this request. type SetFunctionBreakpointsResponse struct { Response Body SetFunctionBreakpointsResponseBody `json:"body"` } type SetFunctionBreakpointsResponseBody struct { Breakpoints []Breakpoint `json:"breakpoints"` } func (r *SetFunctionBreakpointsResponse) GetResponse() *Response { return &r.Response } // SetExceptionBreakpointsRequest: The request configures the debugger's response to thrown exceptions. // If an exception is configured to break, a `stopped` event is fired (with reason `exception`). // Clients should only call this request if the corresponding capability `exceptionBreakpointFilters` returns one or more filters. type SetExceptionBreakpointsRequest struct { Request Arguments SetExceptionBreakpointsArguments `json:"arguments"` } func (r *SetExceptionBreakpointsRequest) GetRequest() *Request { return &r.Request } // SetExceptionBreakpointsArguments: Arguments for `setExceptionBreakpoints` request. type SetExceptionBreakpointsArguments struct { Filters []string `json:"filters"` FilterOptions []ExceptionFilterOptions `json:"filterOptions,omitempty"` ExceptionOptions []ExceptionOptions `json:"exceptionOptions,omitempty"` } // SetExceptionBreakpointsResponse: Response to `setExceptionBreakpoints` request. // The response contains an array of `Breakpoint` objects with information about each exception breakpoint or filter. The `Breakpoint` objects are in the same order as the elements of the `filters`, `filterOptions`, `exceptionOptions` arrays given as arguments. If both `filters` and `filterOptions` are given, the returned array must start with `filters` information first, followed by `filterOptions` information. // The `verified` property of a `Breakpoint` object signals whether the exception breakpoint or filter could be successfully created and whether the condition or hit count expressions are valid. In case of an error the `message` property explains the problem. The `id` property can be used to introduce a unique ID for the exception breakpoint or filter so that it can be updated subsequently by sending breakpoint events. // For backward compatibility both the `breakpoints` array and the enclosing `body` are optional. If these elements are missing a client is not able to show problems for individual exception breakpoints or filters. type SetExceptionBreakpointsResponse struct { Response Body SetExceptionBreakpointsResponseBody `json:"body,omitempty"` } type SetExceptionBreakpointsResponseBody struct { Breakpoints []Breakpoint `json:"breakpoints,omitempty"` } func (r *SetExceptionBreakpointsResponse) GetResponse() *Response { return &r.Response } // DataBreakpointInfoRequest: Obtains information on a possible data breakpoint that could be set on an expression or variable. // Clients should only call this request if the corresponding capability `supportsDataBreakpoints` is true. type DataBreakpointInfoRequest struct { Request Arguments DataBreakpointInfoArguments `json:"arguments"` } func (r *DataBreakpointInfoRequest) GetRequest() *Request { return &r.Request } // DataBreakpointInfoArguments: Arguments for `dataBreakpointInfo` request. type DataBreakpointInfoArguments struct { VariablesReference int `json:"variablesReference,omitempty"` Name string `json:"name"` FrameId int `json:"frameId,omitempty"` } // DataBreakpointInfoResponse: Response to `dataBreakpointInfo` request. type DataBreakpointInfoResponse struct { Response Body DataBreakpointInfoResponseBody `json:"body"` } type DataBreakpointInfoResponseBody struct { DataId interface{} `json:"dataId"` Description string `json:"description"` AccessTypes []DataBreakpointAccessType `json:"accessTypes,omitempty"` CanPersist bool `json:"canPersist,omitempty"` } func (r *DataBreakpointInfoResponse) GetResponse() *Response { return &r.Response } // SetDataBreakpointsRequest: Replaces all existing data breakpoints with new data breakpoints. // To clear all data breakpoints, specify an empty array. // When a data breakpoint is hit, a `stopped` event (with reason `data breakpoint`) is generated. // Clients should only call this request if the corresponding capability `supportsDataBreakpoints` is true. type SetDataBreakpointsRequest struct { Request Arguments SetDataBreakpointsArguments `json:"arguments"` } func (r *SetDataBreakpointsRequest) GetRequest() *Request { return &r.Request } // SetDataBreakpointsArguments: Arguments for `setDataBreakpoints` request. type SetDataBreakpointsArguments struct { Breakpoints []DataBreakpoint `json:"breakpoints"` } // SetDataBreakpointsResponse: Response to `setDataBreakpoints` request. // Returned is information about each breakpoint created by this request. type SetDataBreakpointsResponse struct { Response Body SetDataBreakpointsResponseBody `json:"body"` } type SetDataBreakpointsResponseBody struct { Breakpoints []Breakpoint `json:"breakpoints"` } func (r *SetDataBreakpointsResponse) GetResponse() *Response { return &r.Response } // SetInstructionBreakpointsRequest: Replaces all existing instruction breakpoints. Typically, instruction breakpoints would be set from a disassembly window. // To clear all instruction breakpoints, specify an empty array. // When an instruction breakpoint is hit, a `stopped` event (with reason `instruction breakpoint`) is generated. // Clients should only call this request if the corresponding capability `supportsInstructionBreakpoints` is true. type SetInstructionBreakpointsRequest struct { Request Arguments SetInstructionBreakpointsArguments `json:"arguments"` } func (r *SetInstructionBreakpointsRequest) GetRequest() *Request { return &r.Request } // SetInstructionBreakpointsArguments: Arguments for `setInstructionBreakpoints` request type SetInstructionBreakpointsArguments struct { Breakpoints []InstructionBreakpoint `json:"breakpoints"` } // SetInstructionBreakpointsResponse: Response to `setInstructionBreakpoints` request type SetInstructionBreakpointsResponse struct { Response Body SetInstructionBreakpointsResponseBody `json:"body"` } type SetInstructionBreakpointsResponseBody struct { Breakpoints []Breakpoint `json:"breakpoints"` } func (r *SetInstructionBreakpointsResponse) GetResponse() *Response { return &r.Response } // ContinueRequest: The request resumes execution of all threads. If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true resumes only the specified thread. If not all threads were resumed, the `allThreadsContinued` attribute of the response should be set to false. type ContinueRequest struct { Request Arguments ContinueArguments `json:"arguments"` } func (r *ContinueRequest) GetRequest() *Request { return &r.Request } // ContinueArguments: Arguments for `continue` request. type ContinueArguments struct { ThreadId int `json:"threadId"` SingleThread bool `json:"singleThread,omitempty"` } // ContinueResponse: Response to `continue` request. type ContinueResponse struct { Response Body ContinueResponseBody `json:"body"` } type ContinueResponseBody struct { AllThreadsContinued bool `json:"allThreadsContinued"` } func (r *ContinueResponse) GetResponse() *Response { return &r.Response } // NextRequest: The request executes one step (in the given granularity) for the specified thread and allows all other threads to run freely by resuming them. // If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true prevents other suspended threads from resuming. // The debug adapter first sends the response and then a `stopped` event (with reason `step`) after the step has completed. type NextRequest struct { Request Arguments NextArguments `json:"arguments"` } func (r *NextRequest) GetRequest() *Request { return &r.Request } // NextArguments: Arguments for `next` request. type NextArguments struct { ThreadId int `json:"threadId"` SingleThread bool `json:"singleThread,omitempty"` Granularity SteppingGranularity `json:"granularity,omitempty"` } // NextResponse: Response to `next` request. This is just an acknowledgement, so no body field is required. type NextResponse struct { Response } func (r *NextResponse) GetResponse() *Response { return &r.Response } // StepInRequest: The request resumes the given thread to step into a function/method and allows all other threads to run freely by resuming them. // If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true prevents other suspended threads from resuming. // If the request cannot step into a target, `stepIn` behaves like the `next` request. // The debug adapter first sends the response and then a `stopped` event (with reason `step`) after the step has completed. // If there are multiple function/method calls (or other targets) on the source line, // the argument `targetId` can be used to control into which target the `stepIn` should occur. // The list of possible targets for a given source line can be retrieved via the `stepInTargets` request. type StepInRequest struct { Request Arguments StepInArguments `json:"arguments"` } func (r *StepInRequest) GetRequest() *Request { return &r.Request } // StepInArguments: Arguments for `stepIn` request. type StepInArguments struct { ThreadId int `json:"threadId"` SingleThread bool `json:"singleThread,omitempty"` TargetId int `json:"targetId,omitempty"` Granularity SteppingGranularity `json:"granularity,omitempty"` } // StepInResponse: Response to `stepIn` request. This is just an acknowledgement, so no body field is required. type StepInResponse struct { Response } func (r *StepInResponse) GetResponse() *Response { return &r.Response } // StepOutRequest: The request resumes the given thread to step out (return) from a function/method and allows all other threads to run freely by resuming them. // If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true prevents other suspended threads from resuming. // The debug adapter first sends the response and then a `stopped` event (with reason `step`) after the step has completed. type StepOutRequest struct { Request Arguments StepOutArguments `json:"arguments"` } func (r *StepOutRequest) GetRequest() *Request { return &r.Request } // StepOutArguments: Arguments for `stepOut` request. type StepOutArguments struct { ThreadId int `json:"threadId"` SingleThread bool `json:"singleThread,omitempty"` Granularity SteppingGranularity `json:"granularity,omitempty"` } // StepOutResponse: Response to `stepOut` request. This is just an acknowledgement, so no body field is required. type StepOutResponse struct { Response } func (r *StepOutResponse) GetResponse() *Response { return &r.Response } // StepBackRequest: The request executes one backward step (in the given granularity) for the specified thread and allows all other threads to run backward freely by resuming them. // If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true prevents other suspended threads from resuming. // The debug adapter first sends the response and then a `stopped` event (with reason `step`) after the step has completed. // Clients should only call this request if the corresponding capability `supportsStepBack` is true. type StepBackRequest struct { Request Arguments StepBackArguments `json:"arguments"` } func (r *StepBackRequest) GetRequest() *Request { return &r.Request } // StepBackArguments: Arguments for `stepBack` request. type StepBackArguments struct { ThreadId int `json:"threadId"` SingleThread bool `json:"singleThread,omitempty"` Granularity SteppingGranularity `json:"granularity,omitempty"` } // StepBackResponse: Response to `stepBack` request. This is just an acknowledgement, so no body field is required. type StepBackResponse struct { Response } func (r *StepBackResponse) GetResponse() *Response { return &r.Response } // ReverseContinueRequest: The request resumes backward execution of all threads. If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument to true resumes only the specified thread. If not all threads were resumed, the `allThreadsContinued` attribute of the response should be set to false. // Clients should only call this request if the corresponding capability `supportsStepBack` is true. type ReverseContinueRequest struct { Request Arguments ReverseContinueArguments `json:"arguments"` } func (r *ReverseContinueRequest) GetRequest() *Request { return &r.Request } // ReverseContinueArguments: Arguments for `reverseContinue` request. type ReverseContinueArguments struct { ThreadId int `json:"threadId"` SingleThread bool `json:"singleThread,omitempty"` } // ReverseContinueResponse: Response to `reverseContinue` request. This is just an acknowledgement, so no body field is required. type ReverseContinueResponse struct { Response } func (r *ReverseContinueResponse) GetResponse() *Response { return &r.Response } // RestartFrameRequest: The request restarts execution of the specified stack frame. // The debug adapter first sends the response and then a `stopped` event (with reason `restart`) after the restart has completed. // Clients should only call this request if the corresponding capability `supportsRestartFrame` is true. type RestartFrameRequest struct { Request Arguments RestartFrameArguments `json:"arguments"` } func (r *RestartFrameRequest) GetRequest() *Request { return &r.Request } // RestartFrameArguments: Arguments for `restartFrame` request. type RestartFrameArguments struct { FrameId int `json:"frameId"` } // RestartFrameResponse: Response to `restartFrame` request. This is just an acknowledgement, so no body field is required. type RestartFrameResponse struct { Response } func (r *RestartFrameResponse) GetResponse() *Response { return &r.Response } // GotoRequest: The request sets the location where the debuggee will continue to run. // This makes it possible to skip the execution of code or to execute code again. // The code between the current location and the goto target is not executed but skipped. // The debug adapter first sends the response and then a `stopped` event with reason `goto`. // Clients should only call this request if the corresponding capability `supportsGotoTargetsRequest` is true (because only then goto targets exist that can be passed as arguments). type GotoRequest struct { Request Arguments GotoArguments `json:"arguments"` } func (r *GotoRequest) GetRequest() *Request { return &r.Request } // GotoArguments: Arguments for `goto` request. type GotoArguments struct { ThreadId int `json:"threadId"` TargetId int `json:"targetId"` } // GotoResponse: Response to `goto` request. This is just an acknowledgement, so no body field is required. type GotoResponse struct { Response } func (r *GotoResponse) GetResponse() *Response { return &r.Response } // PauseRequest: The request suspends the debuggee. // The debug adapter first sends the response and then a `stopped` event (with reason `pause`) after the thread has been paused successfully. type PauseRequest struct { Request Arguments PauseArguments `json:"arguments"` } func (r *PauseRequest) GetRequest() *Request { return &r.Request } // PauseArguments: Arguments for `pause` request. type PauseArguments struct { ThreadId int `json:"threadId"` } // PauseResponse: Response to `pause` request. This is just an acknowledgement, so no body field is required. type PauseResponse struct { Response } func (r *PauseResponse) GetResponse() *Response { return &r.Response } // StackTraceRequest: The request returns a stacktrace from the current execution state of a given thread. // A client can request all stack frames by omitting the startFrame and levels arguments. For performance-conscious clients and if the corresponding capability `supportsDelayedStackTraceLoading` is true, stack frames can be retrieved in a piecemeal way with the `startFrame` and `levels` arguments. The response of the `stackTrace` request may contain a `totalFrames` property that hints at the total number of frames in the stack. If a client needs this total number upfront, it can issue a request for a single (first) frame and depending on the value of `totalFrames` decide how to proceed. In any case a client should be prepared to receive fewer frames than requested, which is an indication that the end of the stack has been reached. type StackTraceRequest struct { Request Arguments StackTraceArguments `json:"arguments"` } func (r *StackTraceRequest) GetRequest() *Request { return &r.Request } // StackTraceArguments: Arguments for `stackTrace` request. type StackTraceArguments struct { ThreadId int `json:"threadId"` StartFrame int `json:"startFrame,omitempty"` Levels int `json:"levels,omitempty"` Format *StackFrameFormat `json:"format,omitempty"` } // StackTraceResponse: Response to `stackTrace` request. type StackTraceResponse struct { Response Body StackTraceResponseBody `json:"body"` } type StackTraceResponseBody struct { StackFrames []StackFrame `json:"stackFrames"` TotalFrames int `json:"totalFrames,omitempty"` } func (r *StackTraceResponse) GetResponse() *Response { return &r.Response } // ScopesRequest: The request returns the variable scopes for a given stack frame ID. type ScopesRequest struct { Request Arguments ScopesArguments `json:"arguments"` } func (r *ScopesRequest) GetRequest() *Request { return &r.Request } // ScopesArguments: Arguments for `scopes` request. type ScopesArguments struct { FrameId int `json:"frameId"` } // ScopesResponse: Response to `scopes` request. type ScopesResponse struct { Response Body ScopesResponseBody `json:"body"` } type ScopesResponseBody struct { Scopes []Scope `json:"scopes"` } func (r *ScopesResponse) GetResponse() *Response { return &r.Response } // VariablesRequest: Retrieves all child variables for the given variable reference. // A filter can be used to limit the fetched children to either named or indexed children. type VariablesRequest struct { Request Arguments VariablesArguments `json:"arguments"` } func (r *VariablesRequest) GetRequest() *Request { return &r.Request } // VariablesArguments: Arguments for `variables` request. type VariablesArguments struct { VariablesReference int `json:"variablesReference"` Filter string `json:"filter,omitempty"` Start int `json:"start,omitempty"` Count int `json:"count,omitempty"` Format *ValueFormat `json:"format,omitempty"` } // VariablesResponse: Response to `variables` request. type VariablesResponse struct { Response Body VariablesResponseBody `json:"body"` } type VariablesResponseBody struct { Variables []Variable `json:"variables"` } func (r *VariablesResponse) GetResponse() *Response { return &r.Response } // SetVariableRequest: Set the variable with the given name in the variable container to a new value. Clients should only call this request if the corresponding capability `supportsSetVariable` is true. // If a debug adapter implements both `setVariable` and `setExpression`, a client will only use `setExpression` if the variable has an `evaluateName` property. type SetVariableRequest struct { Request Arguments SetVariableArguments `json:"arguments"` } func (r *SetVariableRequest) GetRequest() *Request { return &r.Request } // SetVariableArguments: Arguments for `setVariable` request. type SetVariableArguments struct { VariablesReference int `json:"variablesReference"` Name string `json:"name"` Value string `json:"value"` Format *ValueFormat `json:"format,omitempty"` } // SetVariableResponse: Response to `setVariable` request. type SetVariableResponse struct { Response Body SetVariableResponseBody `json:"body"` } type SetVariableResponseBody struct { Value string `json:"value"` Type string `json:"type,omitempty"` VariablesReference int `json:"variablesReference,omitempty"` NamedVariables int `json:"namedVariables,omitempty"` IndexedVariables int `json:"indexedVariables,omitempty"` } func (r *SetVariableResponse) GetResponse() *Response { return &r.Response } // SourceRequest: The request retrieves the source code for a given source reference. type SourceRequest struct { Request Arguments SourceArguments `json:"arguments"` } func (r *SourceRequest) GetRequest() *Request { return &r.Request } // SourceArguments: Arguments for `source` request. type SourceArguments struct { Source *Source `json:"source,omitempty"` SourceReference int `json:"sourceReference"` } // SourceResponse: Response to `source` request. type SourceResponse struct { Response Body SourceResponseBody `json:"body"` } type SourceResponseBody struct { Content string `json:"content"` MimeType string `json:"mimeType,omitempty"` } func (r *SourceResponse) GetResponse() *Response { return &r.Response } // ThreadsRequest: The request retrieves a list of all threads. type ThreadsRequest struct { Request } func (r *ThreadsRequest) GetRequest() *Request { return &r.Request } // ThreadsResponse: Response to `threads` request. type ThreadsResponse struct { Response Body ThreadsResponseBody `json:"body"` } type ThreadsResponseBody struct { Threads []Thread `json:"threads"` } func (r *ThreadsResponse) GetResponse() *Response { return &r.Response } // TerminateThreadsRequest: The request terminates the threads with the given ids. // Clients should only call this request if the corresponding capability `supportsTerminateThreadsRequest` is true. type TerminateThreadsRequest struct { Request Arguments TerminateThreadsArguments `json:"arguments"` } func (r *TerminateThreadsRequest) GetRequest() *Request { return &r.Request } // TerminateThreadsArguments: Arguments for `terminateThreads` request. type TerminateThreadsArguments struct { ThreadIds []int `json:"threadIds,omitempty"` } // TerminateThreadsResponse: Response to `terminateThreads` request. This is just an acknowledgement, no body field is required. type TerminateThreadsResponse struct { Response } func (r *TerminateThreadsResponse) GetResponse() *Response { return &r.Response } // ModulesRequest: Modules can be retrieved from the debug adapter with this request which can either return all modules or a range of modules to support paging. // Clients should only call this request if the corresponding capability `supportsModulesRequest` is true. type ModulesRequest struct { Request Arguments ModulesArguments `json:"arguments"` } func (r *ModulesRequest) GetRequest() *Request { return &r.Request } // ModulesArguments: Arguments for `modules` request. type ModulesArguments struct { StartModule int `json:"startModule,omitempty"` ModuleCount int `json:"moduleCount,omitempty"` } // ModulesResponse: Response to `modules` request. type ModulesResponse struct { Response Body ModulesResponseBody `json:"body"` } type ModulesResponseBody struct { Modules []Module `json:"modules"` TotalModules int `json:"totalModules,omitempty"` } func (r *ModulesResponse) GetResponse() *Response { return &r.Response } // LoadedSourcesRequest: Retrieves the set of all sources currently loaded by the debugged process. // Clients should only call this request if the corresponding capability `supportsLoadedSourcesRequest` is true. type LoadedSourcesRequest struct { Request Arguments *LoadedSourcesArguments `json:"arguments,omitempty"` } func (r *LoadedSourcesRequest) GetRequest() *Request { return &r.Request } // LoadedSourcesArguments: Arguments for `loadedSources` request. type LoadedSourcesArguments struct { } // LoadedSourcesResponse: Response to `loadedSources` request. type LoadedSourcesResponse struct { Response Body LoadedSourcesResponseBody `json:"body"` } type LoadedSourcesResponseBody struct { Sources []Source `json:"sources"` } func (r *LoadedSourcesResponse) GetResponse() *Response { return &r.Response } // EvaluateRequest: Evaluates the given expression in the context of the topmost stack frame. // The expression has access to any variables and arguments that are in scope. type EvaluateRequest struct { Request Arguments EvaluateArguments `json:"arguments"` } func (r *EvaluateRequest) GetRequest() *Request { return &r.Request } // EvaluateArguments: Arguments for `evaluate` request. type EvaluateArguments struct { Expression string `json:"expression"` FrameId int `json:"frameId,omitempty"` Context string `json:"context,omitempty"` Format *ValueFormat `json:"format,omitempty"` } // EvaluateResponse: Response to `evaluate` request. type EvaluateResponse struct { Response Body EvaluateResponseBody `json:"body"` } type EvaluateResponseBody struct { Result string `json:"result"` Type string `json:"type,omitempty"` PresentationHint *VariablePresentationHint `json:"presentationHint,omitempty"` VariablesReference int `json:"variablesReference"` NamedVariables int `json:"namedVariables,omitempty"` IndexedVariables int `json:"indexedVariables,omitempty"` MemoryReference string `json:"memoryReference,omitempty"` } func (r *EvaluateResponse) GetResponse() *Response { return &r.Response } // SetExpressionRequest: Evaluates the given `value` expression and assigns it to the `expression` which must be a modifiable l-value. // The expressions have access to any variables and arguments that are in scope of the specified frame. // Clients should only call this request if the corresponding capability `supportsSetExpression` is true. // If a debug adapter implements both `setExpression` and `setVariable`, a client uses `setExpression` if the variable has an `evaluateName` property. type SetExpressionRequest struct { Request Arguments SetExpressionArguments `json:"arguments"` } func (r *SetExpressionRequest) GetRequest() *Request { return &r.Request } // SetExpressionArguments: Arguments for `setExpression` request. type SetExpressionArguments struct { Expression string `json:"expression"` Value string `json:"value"` FrameId int `json:"frameId,omitempty"` Format *ValueFormat `json:"format,omitempty"` } // SetExpressionResponse: Response to `setExpression` request. type SetExpressionResponse struct { Response Body SetExpressionResponseBody `json:"body"` } type SetExpressionResponseBody struct { Value string `json:"value"` Type string `json:"type,omitempty"` PresentationHint *VariablePresentationHint `json:"presentationHint,omitempty"` VariablesReference int `json:"variablesReference,omitempty"` NamedVariables int `json:"namedVariables,omitempty"` IndexedVariables int `json:"indexedVariables,omitempty"` } func (r *SetExpressionResponse) GetResponse() *Response { return &r.Response } // StepInTargetsRequest: This request retrieves the possible step-in targets for the specified stack frame. // These targets can be used in the `stepIn` request. // Clients should only call this request if the corresponding capability `supportsStepInTargetsRequest` is true. type StepInTargetsRequest struct { Request Arguments StepInTargetsArguments `json:"arguments"` } func (r *StepInTargetsRequest) GetRequest() *Request { return &r.Request } // StepInTargetsArguments: Arguments for `stepInTargets` request. type StepInTargetsArguments struct { FrameId int `json:"frameId"` } // StepInTargetsResponse: Response to `stepInTargets` request. type StepInTargetsResponse struct { Response Body StepInTargetsResponseBody `json:"body"` } type StepInTargetsResponseBody struct { Targets []StepInTarget `json:"targets"` } func (r *StepInTargetsResponse) GetResponse() *Response { return &r.Response } // GotoTargetsRequest: This request retrieves the possible goto targets for the specified source location. // These targets can be used in the `goto` request. // Clients should only call this request if the corresponding capability `supportsGotoTargetsRequest` is true. type GotoTargetsRequest struct { Request Arguments GotoTargetsArguments `json:"arguments"` } func (r *GotoTargetsRequest) GetRequest() *Request { return &r.Request } // GotoTargetsArguments: Arguments for `gotoTargets` request. type GotoTargetsArguments struct { Source Source `json:"source"` Line int `json:"line"` Column int `json:"column,omitempty"` } // GotoTargetsResponse: Response to `gotoTargets` request. type GotoTargetsResponse struct { Response Body GotoTargetsResponseBody `json:"body"` } type GotoTargetsResponseBody struct { Targets []GotoTarget `json:"targets"` } func (r *GotoTargetsResponse) GetResponse() *Response { return &r.Response } // CompletionsRequest: Returns a list of possible completions for a given caret position and text. // Clients should only call this request if the corresponding capability `supportsCompletionsRequest` is true. type CompletionsRequest struct { Request Arguments CompletionsArguments `json:"arguments"` } func (r *CompletionsRequest) GetRequest() *Request { return &r.Request } // CompletionsArguments: Arguments for `completions` request. type CompletionsArguments struct { FrameId int `json:"frameId,omitempty"` Text string `json:"text"` Column int `json:"column"` Line int `json:"line,omitempty"` } // CompletionsResponse: Response to `completions` request. type CompletionsResponse struct { Response Body CompletionsResponseBody `json:"body"` } type CompletionsResponseBody struct { Targets []CompletionItem `json:"targets"` } func (r *CompletionsResponse) GetResponse() *Response { return &r.Response } // ExceptionInfoRequest: Retrieves the details of the exception that caused this event to be raised. // Clients should only call this request if the corresponding capability `supportsExceptionInfoRequest` is true. type ExceptionInfoRequest struct { Request Arguments ExceptionInfoArguments `json:"arguments"` } func (r *ExceptionInfoRequest) GetRequest() *Request { return &r.Request } // ExceptionInfoArguments: Arguments for `exceptionInfo` request. type ExceptionInfoArguments struct { ThreadId int `json:"threadId"` } // ExceptionInfoResponse: Response to `exceptionInfo` request. type ExceptionInfoResponse struct { Response Body ExceptionInfoResponseBody `json:"body"` } type ExceptionInfoResponseBody struct { ExceptionId string `json:"exceptionId"` Description string `json:"description,omitempty"` BreakMode ExceptionBreakMode `json:"breakMode"` Details *ExceptionDetails `json:"details,omitempty"` } func (r *ExceptionInfoResponse) GetResponse() *Response { return &r.Response } // ReadMemoryRequest: Reads bytes from memory at the provided location. // Clients should only call this request if the corresponding capability `supportsReadMemoryRequest` is true. type ReadMemoryRequest struct { Request Arguments ReadMemoryArguments `json:"arguments"` } func (r *ReadMemoryRequest) GetRequest() *Request { return &r.Request } // ReadMemoryArguments: Arguments for `readMemory` request. type ReadMemoryArguments struct { MemoryReference string `json:"memoryReference"` Offset int `json:"offset,omitempty"` Count int `json:"count"` } // ReadMemoryResponse: Response to `readMemory` request. type ReadMemoryResponse struct { Response Body ReadMemoryResponseBody `json:"body,omitempty"` } type ReadMemoryResponseBody struct { Address string `json:"address"` UnreadableBytes int `json:"unreadableBytes,omitempty"` Data string `json:"data,omitempty"` } func (r *ReadMemoryResponse) GetResponse() *Response { return &r.Response } // WriteMemoryRequest: Writes bytes to memory at the provided location. // Clients should only call this request if the corresponding capability `supportsWriteMemoryRequest` is true. type WriteMemoryRequest struct { Request Arguments WriteMemoryArguments `json:"arguments"` } func (r *WriteMemoryRequest) GetRequest() *Request { return &r.Request } // WriteMemoryArguments: Arguments for `writeMemory` request. type WriteMemoryArguments struct { MemoryReference string `json:"memoryReference"` Offset int `json:"offset,omitempty"` AllowPartial bool `json:"allowPartial,omitempty"` Data string `json:"data"` } // WriteMemoryResponse: Response to `writeMemory` request. type WriteMemoryResponse struct { Response Body WriteMemoryResponseBody `json:"body,omitempty"` } type WriteMemoryResponseBody struct { Offset int `json:"offset,omitempty"` BytesWritten int `json:"bytesWritten,omitempty"` } func (r *WriteMemoryResponse) GetResponse() *Response { return &r.Response } // DisassembleRequest: Disassembles code stored at the provided location. // Clients should only call this request if the corresponding capability `supportsDisassembleRequest` is true. type DisassembleRequest struct { Request Arguments DisassembleArguments `json:"arguments"` } func (r *DisassembleRequest) GetRequest() *Request { return &r.Request } // DisassembleArguments: Arguments for `disassemble` request. type DisassembleArguments struct { MemoryReference string `json:"memoryReference"` Offset int `json:"offset,omitempty"` InstructionOffset int `json:"instructionOffset,omitempty"` InstructionCount int `json:"instructionCount"` ResolveSymbols bool `json:"resolveSymbols,omitempty"` } // DisassembleResponse: Response to `disassemble` request. type DisassembleResponse struct { Response Body DisassembleResponseBody `json:"body,omitempty"` } type DisassembleResponseBody struct { Instructions []DisassembledInstruction `json:"instructions"` } func (r *DisassembleResponse) GetResponse() *Response { return &r.Response } // Capabilities: Information about the capabilities of a debug adapter. type Capabilities struct { SupportsConfigurationDoneRequest bool `json:"supportsConfigurationDoneRequest,omitempty"` SupportsFunctionBreakpoints bool `json:"supportsFunctionBreakpoints,omitempty"` SupportsConditionalBreakpoints bool `json:"supportsConditionalBreakpoints,omitempty"` SupportsHitConditionalBreakpoints bool `json:"supportsHitConditionalBreakpoints,omitempty"` SupportsEvaluateForHovers bool `json:"supportsEvaluateForHovers,omitempty"` ExceptionBreakpointFilters []ExceptionBreakpointsFilter `json:"exceptionBreakpointFilters,omitempty"` SupportsStepBack bool `json:"supportsStepBack,omitempty"` SupportsSetVariable bool `json:"supportsSetVariable,omitempty"` SupportsRestartFrame bool `json:"supportsRestartFrame,omitempty"` SupportsGotoTargetsRequest bool `json:"supportsGotoTargetsRequest,omitempty"` SupportsStepInTargetsRequest bool `json:"supportsStepInTargetsRequest,omitempty"` SupportsCompletionsRequest bool `json:"supportsCompletionsRequest,omitempty"` CompletionTriggerCharacters []string `json:"completionTriggerCharacters,omitempty"` SupportsModulesRequest bool `json:"supportsModulesRequest,omitempty"` AdditionalModuleColumns []ColumnDescriptor `json:"additionalModuleColumns,omitempty"` SupportedChecksumAlgorithms []ChecksumAlgorithm `json:"supportedChecksumAlgorithms,omitempty"` SupportsRestartRequest bool `json:"supportsRestartRequest,omitempty"` SupportsExceptionOptions bool `json:"supportsExceptionOptions,omitempty"` SupportsValueFormattingOptions bool `json:"supportsValueFormattingOptions,omitempty"` SupportsExceptionInfoRequest bool `json:"supportsExceptionInfoRequest,omitempty"` SupportTerminateDebuggee bool `json:"supportTerminateDebuggee,omitempty"` SupportSuspendDebuggee bool `json:"supportSuspendDebuggee,omitempty"` SupportsDelayedStackTraceLoading bool `json:"supportsDelayedStackTraceLoading,omitempty"` SupportsLoadedSourcesRequest bool `json:"supportsLoadedSourcesRequest,omitempty"` SupportsLogPoints bool `json:"supportsLogPoints,omitempty"` SupportsTerminateThreadsRequest bool `json:"supportsTerminateThreadsRequest,omitempty"` SupportsSetExpression bool `json:"supportsSetExpression,omitempty"` SupportsTerminateRequest bool `json:"supportsTerminateRequest,omitempty"` SupportsDataBreakpoints bool `json:"supportsDataBreakpoints,omitempty"` SupportsReadMemoryRequest bool `json:"supportsReadMemoryRequest,omitempty"` SupportsWriteMemoryRequest bool `json:"supportsWriteMemoryRequest,omitempty"` SupportsDisassembleRequest bool `json:"supportsDisassembleRequest,omitempty"` SupportsCancelRequest bool `json:"supportsCancelRequest,omitempty"` SupportsBreakpointLocationsRequest bool `json:"supportsBreakpointLocationsRequest,omitempty"` SupportsClipboardContext bool `json:"supportsClipboardContext,omitempty"` SupportsSteppingGranularity bool `json:"supportsSteppingGranularity,omitempty"` SupportsInstructionBreakpoints bool `json:"supportsInstructionBreakpoints,omitempty"` SupportsExceptionFilterOptions bool `json:"supportsExceptionFilterOptions,omitempty"` SupportsSingleThreadExecutionRequests bool `json:"supportsSingleThreadExecutionRequests,omitempty"` } // ExceptionBreakpointsFilter: An `ExceptionBreakpointsFilter` is shown in the UI as an filter option for configuring how exceptions are dealt with. type ExceptionBreakpointsFilter struct { Filter string `json:"filter"` Label string `json:"label"` Description string `json:"description,omitempty"` Default bool `json:"default,omitempty"` SupportsCondition bool `json:"supportsCondition,omitempty"` ConditionDescription string `json:"conditionDescription,omitempty"` } // ErrorMessage: A structured message object. Used to return errors from requests. type ErrorMessage struct { Id int `json:"id"` Format string `json:"format"` Variables map[string]string `json:"variables,omitempty"` SendTelemetry bool `json:"sendTelemetry,omitempty"` ShowUser bool `json:"showUser"` Url string `json:"url,omitempty"` UrlLabel string `json:"urlLabel,omitempty"` } // Module: A Module object represents a row in the modules view. // The `id` attribute identifies a module in the modules view and is used in a `module` event for identifying a module for adding, updating or deleting. // The `name` attribute is used to minimally render the module in the UI. // // Additional attributes can be added to the module. They show up in the module view if they have a corresponding `ColumnDescriptor`. // // To avoid an unnecessary proliferation of additional attributes with similar semantics but different names, we recommend to re-use attributes from the 'recommended' list below first, and only introduce new attributes if nothing appropriate could be found. type Module struct { Id interface{} `json:"id"` Name string `json:"name"` Path string `json:"path,omitempty"` IsOptimized bool `json:"isOptimized,omitempty"` IsUserCode bool `json:"isUserCode,omitempty"` Version string `json:"version,omitempty"` SymbolStatus string `json:"symbolStatus,omitempty"` SymbolFilePath string `json:"symbolFilePath,omitempty"` DateTimeStamp string `json:"dateTimeStamp,omitempty"` AddressRange string `json:"addressRange,omitempty"` } // ColumnDescriptor: A `ColumnDescriptor` specifies what module attribute to show in a column of the modules view, how to format it, // and what the column's label should be. // It is only used if the underlying UI actually supports this level of customization. type ColumnDescriptor struct { AttributeName string `json:"attributeName"` Label string `json:"label"` Format string `json:"format,omitempty"` Type string `json:"type,omitempty"` Width int `json:"width,omitempty"` } // ModulesViewDescriptor: The ModulesViewDescriptor is the container for all declarative configuration options of a module view. // For now it only specifies the columns to be shown in the modules view. type ModulesViewDescriptor struct { Columns []ColumnDescriptor `json:"columns"` } // Thread: A Thread type Thread struct { Id int `json:"id"` Name string `json:"name"` } // Source: A `Source` is a descriptor for source code. // It is returned from the debug adapter as part of a `StackFrame` and it is used by clients when specifying breakpoints. type Source struct { Name string `json:"name,omitempty"` Path string `json:"path,omitempty"` SourceReference int `json:"sourceReference,omitempty"` PresentationHint string `json:"presentationHint,omitempty"` Origin string `json:"origin,omitempty"` Sources []Source `json:"sources,omitempty"` AdapterData interface{} `json:"adapterData,omitempty"` Checksums []Checksum `json:"checksums,omitempty"` } // StackFrame: A Stackframe contains the source location. type StackFrame struct { Id int `json:"id"` Name string `json:"name"` Source *Source `json:"source,omitempty"` Line int `json:"line"` Column int `json:"column"` EndLine int `json:"endLine,omitempty"` EndColumn int `json:"endColumn,omitempty"` CanRestart bool `json:"canRestart,omitempty"` InstructionPointerReference string `json:"instructionPointerReference,omitempty"` ModuleId interface{} `json:"moduleId,omitempty"` PresentationHint string `json:"presentationHint,omitempty"` } // Scope: A `Scope` is a named container for variables. Optionally a scope can map to a source or a range within a source. type Scope struct { Name string `json:"name"` PresentationHint string `json:"presentationHint,omitempty"` VariablesReference int `json:"variablesReference"` NamedVariables int `json:"namedVariables,omitempty"` IndexedVariables int `json:"indexedVariables,omitempty"` Expensive bool `json:"expensive"` Source *Source `json:"source,omitempty"` Line int `json:"line,omitempty"` Column int `json:"column,omitempty"` EndLine int `json:"endLine,omitempty"` EndColumn int `json:"endColumn,omitempty"` } // Variable: A Variable is a name/value pair. // The `type` attribute is shown if space permits or when hovering over the variable's name. // The `kind` attribute is used to render additional properties of the variable, e.g. different icons can be used to indicate that a variable is public or private. // If the value is structured (has children), a handle is provided to retrieve the children with the `variables` request. // If the number of named or indexed children is large, the numbers should be returned via the `namedVariables` and `indexedVariables` attributes. // The client can use this information to present the children in a paged UI and fetch them in chunks. type Variable struct { Name string `json:"name"` Value string `json:"value"` Type string `json:"type,omitempty"` PresentationHint *VariablePresentationHint `json:"presentationHint,omitempty"` EvaluateName string `json:"evaluateName,omitempty"` VariablesReference int `json:"variablesReference"` NamedVariables int `json:"namedVariables,omitempty"` IndexedVariables int `json:"indexedVariables,omitempty"` MemoryReference string `json:"memoryReference,omitempty"` } // VariablePresentationHint: Properties of a variable that can be used to determine how to render the variable in the UI. type VariablePresentationHint struct { Kind string `json:"kind,omitempty"` Attributes []string `json:"attributes,omitempty"` Visibility string `json:"visibility,omitempty"` Lazy bool `json:"lazy,omitempty"` } // BreakpointLocation: Properties of a breakpoint location returned from the `breakpointLocations` request. type BreakpointLocation struct { Line int `json:"line"` Column int `json:"column,omitempty"` EndLine int `json:"endLine,omitempty"` EndColumn int `json:"endColumn,omitempty"` } // SourceBreakpoint: Properties of a breakpoint or logpoint passed to the `setBreakpoints` request. type SourceBreakpoint struct { Line int `json:"line"` Column int `json:"column,omitempty"` Condition string `json:"condition,omitempty"` HitCondition string `json:"hitCondition,omitempty"` LogMessage string `json:"logMessage,omitempty"` } // FunctionBreakpoint: Properties of a breakpoint passed to the `setFunctionBreakpoints` request. type FunctionBreakpoint struct { Name string `json:"name"` Condition string `json:"condition,omitempty"` HitCondition string `json:"hitCondition,omitempty"` } // DataBreakpointAccessType: This enumeration defines all possible access types for data breakpoints. type DataBreakpointAccessType string // DataBreakpoint: Properties of a data breakpoint passed to the `setDataBreakpoints` request. type DataBreakpoint struct { DataId string `json:"dataId"` AccessType DataBreakpointAccessType `json:"accessType,omitempty"` Condition string `json:"condition,omitempty"` HitCondition string `json:"hitCondition,omitempty"` } // InstructionBreakpoint: Properties of a breakpoint passed to the `setInstructionBreakpoints` request type InstructionBreakpoint struct { InstructionReference string `json:"instructionReference"` Offset int `json:"offset,omitempty"` Condition string `json:"condition,omitempty"` HitCondition string `json:"hitCondition,omitempty"` } // Breakpoint: Information about a breakpoint created in `setBreakpoints`, `setFunctionBreakpoints`, `setInstructionBreakpoints`, or `setDataBreakpoints` requests. type Breakpoint struct { Id int `json:"id,omitempty"` Verified bool `json:"verified"` Message string `json:"message,omitempty"` Source *Source `json:"source,omitempty"` Line int `json:"line,omitempty"` Column int `json:"column,omitempty"` EndLine int `json:"endLine,omitempty"` EndColumn int `json:"endColumn,omitempty"` InstructionReference string `json:"instructionReference,omitempty"` Offset int `json:"offset,omitempty"` } // SteppingGranularity: The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`. type SteppingGranularity string // StepInTarget: A `StepInTarget` can be used in the `stepIn` request and determines into which single target the `stepIn` request should step. type StepInTarget struct { Id int `json:"id"` Label string `json:"label"` Line int `json:"line,omitempty"` Column int `json:"column,omitempty"` EndLine int `json:"endLine,omitempty"` EndColumn int `json:"endColumn,omitempty"` } // GotoTarget: A `GotoTarget` describes a code location that can be used as a target in the `goto` request. // The possible goto targets can be determined via the `gotoTargets` request. type GotoTarget struct { Id int `json:"id"` Label string `json:"label"` Line int `json:"line"` Column int `json:"column,omitempty"` EndLine int `json:"endLine,omitempty"` EndColumn int `json:"endColumn,omitempty"` InstructionPointerReference string `json:"instructionPointerReference,omitempty"` } // CompletionItem: `CompletionItems` are the suggestions returned from the `completions` request. type CompletionItem struct { Label string `json:"label"` Text string `json:"text,omitempty"` SortText string `json:"sortText,omitempty"` Detail string `json:"detail,omitempty"` Type CompletionItemType `json:"type,omitempty"` Start int `json:"start,omitempty"` Length int `json:"length,omitempty"` SelectionStart int `json:"selectionStart,omitempty"` SelectionLength int `json:"selectionLength,omitempty"` } // CompletionItemType: Some predefined types for the CompletionItem. Please note that not all clients have specific icons for all of them. type CompletionItemType string // ChecksumAlgorithm: Names of checksum algorithms that may be supported by a debug adapter. type ChecksumAlgorithm string // Checksum: The checksum of an item calculated by the specified algorithm. type Checksum struct { Algorithm ChecksumAlgorithm `json:"algorithm"` Checksum string `json:"checksum"` } // ValueFormat: Provides formatting information for a value. type ValueFormat struct { Hex bool `json:"hex,omitempty"` } // StackFrameFormat: Provides formatting information for a stack frame. type StackFrameFormat struct { ValueFormat Parameters bool `json:"parameters,omitempty"` ParameterTypes bool `json:"parameterTypes,omitempty"` ParameterNames bool `json:"parameterNames,omitempty"` ParameterValues bool `json:"parameterValues,omitempty"` Line bool `json:"line,omitempty"` Module bool `json:"module,omitempty"` IncludeAll bool `json:"includeAll,omitempty"` } // ExceptionFilterOptions: An `ExceptionFilterOptions` is used to specify an exception filter together with a condition for the `setExceptionBreakpoints` request. type ExceptionFilterOptions struct { FilterId string `json:"filterId"` Condition string `json:"condition,omitempty"` } // ExceptionOptions: An `ExceptionOptions` assigns configuration options to a set of exceptions. type ExceptionOptions struct { Path []ExceptionPathSegment `json:"path,omitempty"` BreakMode ExceptionBreakMode `json:"breakMode"` } // ExceptionBreakMode: This enumeration defines all possible conditions when a thrown exception should result in a break. // never: never breaks, // always: always breaks, // unhandled: breaks when exception unhandled, // userUnhandled: breaks if the exception is not handled by user code. type ExceptionBreakMode string // ExceptionPathSegment: An `ExceptionPathSegment` represents a segment in a path that is used to match leafs or nodes in a tree of exceptions. // If a segment consists of more than one name, it matches the names provided if `negate` is false or missing, or it matches anything except the names provided if `negate` is true. type ExceptionPathSegment struct { Negate bool `json:"negate,omitempty"` Names []string `json:"names"` } // ExceptionDetails: Detailed information about an exception that has occurred. type ExceptionDetails struct { Message string `json:"message,omitempty"` TypeName string `json:"typeName,omitempty"` FullTypeName string `json:"fullTypeName,omitempty"` EvaluateName string `json:"evaluateName,omitempty"` StackTrace string `json:"stackTrace,omitempty"` InnerException []ExceptionDetails `json:"innerException,omitempty"` } // DisassembledInstruction: Represents a single disassembled instruction. type DisassembledInstruction struct { Address string `json:"address"` InstructionBytes string `json:"instructionBytes,omitempty"` Instruction string `json:"instruction"` Symbol string `json:"symbol,omitempty"` Location *Source `json:"location,omitempty"` Line int `json:"line,omitempty"` Column int `json:"column,omitempty"` EndLine int `json:"endLine,omitempty"` EndColumn int `json:"endColumn,omitempty"` } // InvalidatedAreas: Logical areas that can be invalidated by the `invalidated` event. type InvalidatedAreas string // Mapping of request commands and corresponding struct constructors that // can be passed to json.Unmarshal. var requestCtor = map[string]messageCtor{ "cancel": func() Message { return &CancelRequest{} }, "runInTerminal": func() Message { return &RunInTerminalRequest{} }, "startDebugging": func() Message { return &StartDebuggingRequest{} }, "initialize": func() Message { return &InitializeRequest{ Arguments: InitializeRequestArguments{ // Set the default values specified here: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Initialize. LinesStartAt1: true, ColumnsStartAt1: true, PathFormat: "path", }, } }, "configurationDone": func() Message { return &ConfigurationDoneRequest{} }, "launch": func() Message { return &LaunchRequest{} }, "attach": func() Message { return &AttachRequest{} }, "restart": func() Message { return &RestartRequest{} }, "disconnect": func() Message { return &DisconnectRequest{} }, "terminate": func() Message { return &TerminateRequest{} }, "breakpointLocations": func() Message { return &BreakpointLocationsRequest{} }, "setBreakpoints": func() Message { return &SetBreakpointsRequest{} }, "setFunctionBreakpoints": func() Message { return &SetFunctionBreakpointsRequest{} }, "setExceptionBreakpoints": func() Message { return &SetExceptionBreakpointsRequest{} }, "dataBreakpointInfo": func() Message { return &DataBreakpointInfoRequest{} }, "setDataBreakpoints": func() Message { return &SetDataBreakpointsRequest{} }, "setInstructionBreakpoints": func() Message { return &SetInstructionBreakpointsRequest{} }, "continue": func() Message { return &ContinueRequest{} }, "next": func() Message { return &NextRequest{} }, "stepIn": func() Message { return &StepInRequest{} }, "stepOut": func() Message { return &StepOutRequest{} }, "stepBack": func() Message { return &StepBackRequest{} }, "reverseContinue": func() Message { return &ReverseContinueRequest{} }, "restartFrame": func() Message { return &RestartFrameRequest{} }, "goto": func() Message { return &GotoRequest{} }, "pause": func() Message { return &PauseRequest{} }, "stackTrace": func() Message { return &StackTraceRequest{} }, "scopes": func() Message { return &ScopesRequest{} }, "variables": func() Message { return &VariablesRequest{} }, "setVariable": func() Message { return &SetVariableRequest{} }, "source": func() Message { return &SourceRequest{} }, "threads": func() Message { return &ThreadsRequest{} }, "terminateThreads": func() Message { return &TerminateThreadsRequest{} }, "modules": func() Message { return &ModulesRequest{} }, "loadedSources": func() Message { return &LoadedSourcesRequest{} }, "evaluate": func() Message { return &EvaluateRequest{} }, "setExpression": func() Message { return &SetExpressionRequest{} }, "stepInTargets": func() Message { return &StepInTargetsRequest{} }, "gotoTargets": func() Message { return &GotoTargetsRequest{} }, "completions": func() Message { return &CompletionsRequest{} }, "exceptionInfo": func() Message { return &ExceptionInfoRequest{} }, "readMemory": func() Message { return &ReadMemoryRequest{} }, "writeMemory": func() Message { return &WriteMemoryRequest{} }, "disassemble": func() Message { return &DisassembleRequest{} }, } // Mapping of response commands and corresponding struct constructors that // can be passed to json.Unmarshal. var responseCtor = map[string]messageCtor{ "cancel": func() Message { return &CancelResponse{} }, "runInTerminal": func() Message { return &RunInTerminalResponse{} }, "startDebugging": func() Message { return &StartDebuggingResponse{} }, "initialize": func() Message { return &InitializeResponse{} }, "configurationDone": func() Message { return &ConfigurationDoneResponse{} }, "launch": func() Message { return &LaunchResponse{} }, "attach": func() Message { return &AttachResponse{} }, "restart": func() Message { return &RestartResponse{} }, "disconnect": func() Message { return &DisconnectResponse{} }, "terminate": func() Message { return &TerminateResponse{} }, "breakpointLocations": func() Message { return &BreakpointLocationsResponse{} }, "setBreakpoints": func() Message { return &SetBreakpointsResponse{} }, "setFunctionBreakpoints": func() Message { return &SetFunctionBreakpointsResponse{} }, "setExceptionBreakpoints": func() Message { return &SetExceptionBreakpointsResponse{} }, "dataBreakpointInfo": func() Message { return &DataBreakpointInfoResponse{} }, "setDataBreakpoints": func() Message { return &SetDataBreakpointsResponse{} }, "setInstructionBreakpoints": func() Message { return &SetInstructionBreakpointsResponse{} }, "continue": func() Message { return &ContinueResponse{} }, "next": func() Message { return &NextResponse{} }, "stepIn": func() Message { return &StepInResponse{} }, "stepOut": func() Message { return &StepOutResponse{} }, "stepBack": func() Message { return &StepBackResponse{} }, "reverseContinue": func() Message { return &ReverseContinueResponse{} }, "restartFrame": func() Message { return &RestartFrameResponse{} }, "goto": func() Message { return &GotoResponse{} }, "pause": func() Message { return &PauseResponse{} }, "stackTrace": func() Message { return &StackTraceResponse{} }, "scopes": func() Message { return &ScopesResponse{} }, "variables": func() Message { return &VariablesResponse{} }, "setVariable": func() Message { return &SetVariableResponse{} }, "source": func() Message { return &SourceResponse{} }, "threads": func() Message { return &ThreadsResponse{} }, "terminateThreads": func() Message { return &TerminateThreadsResponse{} }, "modules": func() Message { return &ModulesResponse{} }, "loadedSources": func() Message { return &LoadedSourcesResponse{} }, "evaluate": func() Message { return &EvaluateResponse{} }, "setExpression": func() Message { return &SetExpressionResponse{} }, "stepInTargets": func() Message { return &StepInTargetsResponse{} }, "gotoTargets": func() Message { return &GotoTargetsResponse{} }, "completions": func() Message { return &CompletionsResponse{} }, "exceptionInfo": func() Message { return &ExceptionInfoResponse{} }, "readMemory": func() Message { return &ReadMemoryResponse{} }, "writeMemory": func() Message { return &WriteMemoryResponse{} }, "disassemble": func() Message { return &DisassembleResponse{} }, } // Mapping of event ids and corresponding struct constructors that // can be passed to json.Unmarshal. var eventCtor = map[string]messageCtor{ "initialized": func() Message { return &InitializedEvent{} }, "stopped": func() Message { return &StoppedEvent{} }, "continued": func() Message { return &ContinuedEvent{} }, "exited": func() Message { return &ExitedEvent{} }, "terminated": func() Message { return &TerminatedEvent{} }, "thread": func() Message { return &ThreadEvent{} }, "output": func() Message { return &OutputEvent{} }, "breakpoint": func() Message { return &BreakpointEvent{} }, "module": func() Message { return &ModuleEvent{} }, "loadedSource": func() Message { return &LoadedSourceEvent{} }, "process": func() Message { return &ProcessEvent{} }, "capabilities": func() Message { return &CapabilitiesEvent{} }, "progressStart": func() Message { return &ProgressStartEvent{} }, "progressUpdate": func() Message { return &ProgressUpdateEvent{} }, "progressEnd": func() Message { return &ProgressEndEvent{} }, "invalidated": func() Message { return &InvalidatedEvent{} }, "memory": func() Message { return &MemoryEvent{} }, } golang-github-google-go-dap-0.10.0/schematypes_test.go000066400000000000000000000056061446076322400226700ustar00rootroot00000000000000// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package dap import ( "bytes" "encoding/json" "testing" ) // makeErrorResponse creates a pre-populated ErrorResponse for testing. func makeErrorResponse() *ErrorResponse { return &ErrorResponse{ Response: Response{ ProtocolMessage: ProtocolMessage{ Seq: 199, Type: "response", }, Command: "stackTrace", RequestSeq: 9, Success: false, Message: "Unable to produce stack trace: \"{e}\"", }, Body: ErrorResponseBody{ Error: &ErrorMessage{ Id: 2004, Format: "Unable to produce stack trace: \"{e}\"", Variables: map[string]string{"e": "Unknown goroutine 1"}, ShowUser: true, }, }, } } func TestMessageInterface(t *testing.T) { resp := makeErrorResponse() f := func(m Message) int { return m.GetSeq() } // Test adherence to the Message interface. seq := f(resp) if seq != 199 { t.Errorf("got seq=%d, want 199", seq) } } func TestReponseMessageInterface(t *testing.T) { resp := makeErrorResponse() f := func(rm ResponseMessage) (int, int) { return rm.GetSeq(), rm.GetResponse().RequestSeq } // Test adherence to the ResponseMessage interface. seq, rseq := f(resp) if seq != 199 { t.Errorf("got seq=%d, want 199", seq) } if rseq != 9 { t.Errorf("got ResponseSeq=%d, want 9", rseq) } } func TestLaunchAttachRequestInterface(t *testing.T) { lr := &LaunchRequest{ Request: Request{ ProtocolMessage: ProtocolMessage{ Seq: 19, Type: "request", }, Command: "launch", }, Arguments: json.RawMessage("foobar"), } ar := &AttachRequest{ Request: Request{ ProtocolMessage: ProtocolMessage{ Seq: 19, Type: "request", }, Command: "attach", }, Arguments: json.RawMessage(`{"foo":"bar"}`), } f := func(r LaunchAttachRequest) (int, string, json.RawMessage) { return r.GetSeq(), r.GetRequest().Command, r.GetArguments() } // Test adherence to the LaunchAttachRequest interface. lseq, lcmd, lfoo := f(lr) aseq, acmd, afoo := f(ar) if lseq != 19 || aseq != 19 { t.Errorf("got lseq=%d aseq=%d, want 19", lseq, aseq) } if lcmd != "launch" || acmd != "attach" { t.Errorf("got lcmd=%s acmd=%s, want (\"launch\", \"attach\")", lcmd, acmd) } if !bytes.Equal(lfoo, []byte("foobar")) || !bytes.Equal(afoo, []byte(`{"foo":"bar"}`)) { t.Errorf(`got lfoo=%v afoo=%v, want "foobar", {"foo":"bar"}`, lfoo, afoo) } }