| 1 | //===-- ProtocolTypes.h ---------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file contains POD structs based on the DAP specification at |
| 10 | // https://microsoft.github.io/debug-adapter-protocol/specification |
| 11 | // |
| 12 | // This is not meant to be a complete implementation, new interfaces are added |
| 13 | // when they're needed. |
| 14 | // |
| 15 | // Each struct has a toJSON and fromJSON function, that converts between |
| 16 | // the struct and a JSON representation. (See JSON.h) |
| 17 | // |
| 18 | //===----------------------------------------------------------------------===// |
| 19 | |
| 20 | #ifndef LLDB_TOOLS_LLDB_DAP_PROTOCOL_PROTOCOL_REQUESTS_H |
| 21 | #define LLDB_TOOLS_LLDB_DAP_PROTOCOL_PROTOCOL_REQUESTS_H |
| 22 | |
| 23 | #include "Protocol/ProtocolBase.h" |
| 24 | #include "Protocol/ProtocolTypes.h" |
| 25 | #include "lldb/lldb-defines.h" |
| 26 | #include "lldb/lldb-types.h" |
| 27 | #include "llvm/ADT/DenseSet.h" |
| 28 | #include "llvm/ADT/StringMap.h" |
| 29 | #include "llvm/Support/JSON.h" |
| 30 | #include <chrono> |
| 31 | #include <cstdint> |
| 32 | #include <optional> |
| 33 | #include <string> |
| 34 | #include <vector> |
| 35 | |
| 36 | namespace lldb_dap::protocol { |
| 37 | |
| 38 | /// Arguments for `cancel` request. |
| 39 | struct CancelArguments { |
| 40 | /// The ID (attribute `seq`) of the request to cancel. If missing no request |
| 41 | /// is cancelled. |
| 42 | /// |
| 43 | /// Both a `requestId` and a `progressId` can be specified in one request. |
| 44 | std::optional<int64_t> requestId; |
| 45 | |
| 46 | /// The ID (attribute `progressId`) of the progress to cancel. If missing no |
| 47 | /// progress is cancelled. |
| 48 | /// |
| 49 | /// Both a `requestId` and a `progressId` can be specified in one request. |
| 50 | std::optional<int64_t> progressId; |
| 51 | }; |
| 52 | bool fromJSON(const llvm::json::Value &, CancelArguments &, llvm::json::Path); |
| 53 | |
| 54 | /// Response to `cancel` request. This is just an acknowledgement, so no body |
| 55 | /// field is required. |
| 56 | using CancelResponse = VoidResponse; |
| 57 | |
| 58 | /// Arguments for `disconnect` request. |
| 59 | struct DisconnectArguments { |
| 60 | /// A value of true indicates that this `disconnect` request is part of a |
| 61 | /// restart sequence. |
| 62 | std::optional<bool> restart; |
| 63 | |
| 64 | /// Indicates whether the debuggee should be terminated when the debugger is |
| 65 | /// disconnected. If unspecified, the debug adapter is free to do whatever it |
| 66 | /// thinks is best. The attribute is only honored by a debug adapter if the |
| 67 | /// corresponding capability `supportTerminateDebuggee` is true. |
| 68 | std::optional<bool> terminateDebuggee; |
| 69 | |
| 70 | /// Indicates whether the debuggee should stay suspended when the debugger is |
| 71 | /// disconnected. If unspecified, the debuggee should resume execution. The |
| 72 | /// attribute is only honored by a debug adapter if the corresponding |
| 73 | /// capability `supportSuspendDebuggee` is true. |
| 74 | std::optional<bool> suspendDebuggee; |
| 75 | }; |
| 76 | bool fromJSON(const llvm::json::Value &, DisconnectArguments &, |
| 77 | llvm::json::Path); |
| 78 | |
| 79 | /// Response to `disconnect` request. This is just an acknowledgement, so no |
| 80 | /// body field is required. |
| 81 | using DisconnectResponse = VoidResponse; |
| 82 | |
| 83 | /// Features supported by DAP clients. |
| 84 | enum ClientFeature : unsigned { |
| 85 | eClientFeatureVariableType, |
| 86 | eClientFeatureVariablePaging, |
| 87 | eClientFeatureRunInTerminalRequest, |
| 88 | eClientFeatureMemoryReferences, |
| 89 | eClientFeatureProgressReporting, |
| 90 | eClientFeatureInvalidatedEvent, |
| 91 | eClientFeatureMemoryEvent, |
| 92 | /// Client supports the `argsCanBeInterpretedByShell` attribute on the |
| 93 | /// `runInTerminal` request. |
| 94 | eClientFeatureArgsCanBeInterpretedByShell, |
| 95 | eClientFeatureStartDebuggingRequest, |
| 96 | /// The client will interpret ANSI escape sequences in the display of |
| 97 | /// `OutputEvent.output` and `Variable.value` fields when |
| 98 | /// `Capabilities.supportsANSIStyling` is also enabled. |
| 99 | eClientFeatureANSIStyling, |
| 100 | }; |
| 101 | |
| 102 | /// Format of paths reported by the debug adapter. |
| 103 | enum PathFormat : unsigned { ePatFormatPath, ePathFormatURI }; |
| 104 | |
| 105 | /// Arguments for `initialize` request. |
| 106 | struct InitializeRequestArguments { |
| 107 | /// The ID of the debug adapter. |
| 108 | std::string adapterID; |
| 109 | |
| 110 | /// The ID of the client using this adapter. |
| 111 | std::optional<std::string> clientID; |
| 112 | |
| 113 | /// The human-readable name of the client using this adapter. |
| 114 | std::optional<std::string> clientName; |
| 115 | |
| 116 | /// The ISO-639 locale of the client using this adapter, e.g. en-US or de-CH. |
| 117 | std::optional<std::string> locale; |
| 118 | |
| 119 | /// Determines in what format paths are specified. The default is `path`, |
| 120 | /// which is the native format. |
| 121 | PathFormat pathFormat = ePatFormatPath; |
| 122 | |
| 123 | /// If true all line numbers are 1-based (default). |
| 124 | std::optional<bool> linesStartAt1; |
| 125 | |
| 126 | /// If true all column numbers are 1-based (default). |
| 127 | std::optional<bool> columnsStartAt1; |
| 128 | |
| 129 | /// The set of supported features reported by the client. |
| 130 | llvm::DenseSet<ClientFeature> supportedFeatures; |
| 131 | |
| 132 | /// lldb-dap Extensions |
| 133 | /// @{ |
| 134 | |
| 135 | /// Source init files when initializing lldb::SBDebugger. |
| 136 | std::optional<bool> lldbExtSourceInitFile; |
| 137 | |
| 138 | /// @} |
| 139 | }; |
| 140 | bool fromJSON(const llvm::json::Value &, InitializeRequestArguments &, |
| 141 | llvm::json::Path); |
| 142 | |
| 143 | /// Response to `initialize` request. The capabilities of this debug adapter. |
| 144 | using InitializeResponse = std::optional<Capabilities>; |
| 145 | |
| 146 | /// DAP Launch and Attach common configurations. |
| 147 | /// |
| 148 | /// See package.json debuggers > configurationAttributes > launch or attach > |
| 149 | /// properties for common configurations. |
| 150 | struct Configuration { |
| 151 | /// Specify a working directory to use when launching `lldb-dap`. If the debug |
| 152 | /// information in your executable contains relative paths, this option can be |
| 153 | /// used so that `lldb-dap` can find source files and object files that have |
| 154 | /// relative paths. |
| 155 | std::string debuggerRoot; |
| 156 | |
| 157 | /// Enable auto generated summaries for variables when no summaries exist for |
| 158 | /// a given type. This feature can cause performance delays in large projects |
| 159 | /// when viewing variables. |
| 160 | bool enableAutoVariableSummaries = false; |
| 161 | |
| 162 | /// If a variable is displayed using a synthetic children, also display the |
| 163 | /// actual contents of the variable at the end under a [raw] entry. This is |
| 164 | /// useful when creating synthetic child plug-ins as it lets you see the |
| 165 | /// actual contents of the variable. |
| 166 | bool enableSyntheticChildDebugging = false; |
| 167 | |
| 168 | /// Enable language specific extended backtraces. |
| 169 | bool displayExtendedBacktrace = false; |
| 170 | |
| 171 | /// Stop at the entry point of the program when launching or attaching. |
| 172 | bool stopOnEntry = false; |
| 173 | |
| 174 | /// Optional timeout when waiting for the program to `runInTerminal` or |
| 175 | /// attach. |
| 176 | std::chrono::seconds timeout = std::chrono::seconds(30); |
| 177 | |
| 178 | /// The escape prefix to use for executing regular LLDB commands in the Debug |
| 179 | /// Console, instead of printing variables. Defaults to a backtick. If it's an |
| 180 | /// empty string, then all expression in the Debug Console are treated as |
| 181 | /// regular LLDB commands. |
| 182 | std::string commandEscapePrefix = "`" ; |
| 183 | |
| 184 | /// If non-empty, stack frames will have descriptions generated based on the |
| 185 | /// provided format. See https://lldb.llvm.org/use/formatting.html for an |
| 186 | /// explanation on format strings for frames. If the format string contains |
| 187 | /// errors, an error message will be displayed on the Debug Console and the |
| 188 | /// default frame names will be used. This might come with a performance cost |
| 189 | /// because debug information might need to be processed to generate the |
| 190 | /// description. |
| 191 | std::optional<std::string> customFrameFormat; |
| 192 | |
| 193 | /// Same as `customFrameFormat`, but for threads instead of stack frames. |
| 194 | std::optional<std::string> customThreadFormat; |
| 195 | |
| 196 | /// Specify a source path to remap "./" to allow full paths to be used when |
| 197 | /// setting breakpoints in binaries that have relative source paths. |
| 198 | std::string sourcePath; |
| 199 | |
| 200 | /// Specify an array of path re-mappings. Each element in the array must be a |
| 201 | /// two element array containing a source and destination pathname. Overrides |
| 202 | /// sourcePath. |
| 203 | std::vector<std::pair<std::string, std::string>> sourceMap; |
| 204 | |
| 205 | /// LLDB commands executed upon debugger startup prior to creating the LLDB |
| 206 | /// target. |
| 207 | std::vector<std::string> preInitCommands; |
| 208 | |
| 209 | /// LLDB commands executed upon debugger startup prior to creating the LLDB |
| 210 | /// target. |
| 211 | std::vector<std::string> initCommands; |
| 212 | |
| 213 | /// LLDB commands executed just before launching/attaching, after the LLDB |
| 214 | /// target has been created. |
| 215 | std::vector<std::string> preRunCommands; |
| 216 | |
| 217 | /// LLDB commands executed just after launching/attaching, after the LLDB |
| 218 | /// target has been created. |
| 219 | std::vector<std::string> postRunCommands; |
| 220 | |
| 221 | /// LLDB commands executed just after each stop. |
| 222 | std::vector<std::string> stopCommands; |
| 223 | |
| 224 | /// LLDB commands executed when the program exits. |
| 225 | std::vector<std::string> exitCommands; |
| 226 | |
| 227 | /// LLDB commands executed when the debugging session ends. |
| 228 | std::vector<std::string> terminateCommands; |
| 229 | |
| 230 | /// Path to the executable. |
| 231 | /// |
| 232 | /// *NOTE:* When launching, either `launchCommands` or `program` must be |
| 233 | /// configured. If both are configured then `launchCommands` takes priority. |
| 234 | std::string program; |
| 235 | |
| 236 | /// Target triple for the program (arch-vendor-os). If not set, inferred from |
| 237 | /// the binary. |
| 238 | std::string targetTriple; |
| 239 | |
| 240 | /// Specify name of the platform to use for this target, creating the platform |
| 241 | /// if necessary. |
| 242 | std::string platformName; |
| 243 | }; |
| 244 | |
| 245 | /// lldb-dap specific launch arguments. |
| 246 | struct LaunchRequestArguments { |
| 247 | /// Common lldb-dap configuration values for launching/attaching operations. |
| 248 | Configuration configuration; |
| 249 | |
| 250 | /// If true, the launch request should launch the program without enabling |
| 251 | /// debugging. |
| 252 | bool noDebug = false; |
| 253 | |
| 254 | /// Launch specific operations. |
| 255 | /// |
| 256 | /// See package.json debuggers > configurationAttributes > launch > |
| 257 | /// properties. |
| 258 | /// @{ |
| 259 | |
| 260 | /// LLDB commands executed to launch the program. |
| 261 | /// |
| 262 | /// *NOTE:* Either launchCommands or program must be configured. |
| 263 | /// |
| 264 | /// If set, takes priority over the 'program' when launching the target. |
| 265 | std::vector<std::string> launchCommands; |
| 266 | |
| 267 | /// The program working directory. |
| 268 | std::string cwd; |
| 269 | |
| 270 | /// An array of command line argument strings to be passed to the program |
| 271 | /// being launched. |
| 272 | std::vector<std::string> args; |
| 273 | |
| 274 | /// Environment variables to set when launching the program. The format of |
| 275 | /// each environment variable string is "VAR=VALUE" for environment variables |
| 276 | /// with values or just "VAR" for environment variables with no values. |
| 277 | llvm::StringMap<std::string> env; |
| 278 | |
| 279 | /// If set, then the client stub should detach rather than killing the |
| 280 | /// debuggee if it loses connection with lldb. |
| 281 | bool detachOnError = false; |
| 282 | |
| 283 | /// Disable ASLR (Address Space Layout Randomization) when launching the |
| 284 | /// process. |
| 285 | bool disableASLR = true; |
| 286 | |
| 287 | /// Do not set up for terminal I/O to go to running process. |
| 288 | bool disableSTDIO = false; |
| 289 | |
| 290 | /// Set whether to shell expand arguments to the process when launching. |
| 291 | bool shellExpandArguments = false; |
| 292 | |
| 293 | /// Launch the program inside an integrated terminal in the IDE. Useful for |
| 294 | /// debugging interactive command line programs. |
| 295 | bool runInTerminal = false; |
| 296 | |
| 297 | /// @} |
| 298 | }; |
| 299 | bool fromJSON(const llvm::json::Value &, LaunchRequestArguments &, |
| 300 | llvm::json::Path); |
| 301 | |
| 302 | /// Response to `launch` request. This is just an acknowledgement, so no body |
| 303 | /// field is required. |
| 304 | using LaunchResponse = VoidResponse; |
| 305 | |
| 306 | #define LLDB_DAP_INVALID_PORT -1 |
| 307 | |
| 308 | /// lldb-dap specific attach arguments. |
| 309 | struct AttachRequestArguments { |
| 310 | /// Common lldb-dap configuration values for launching/attaching operations. |
| 311 | Configuration configuration; |
| 312 | |
| 313 | /// Attach specific operations. |
| 314 | /// |
| 315 | /// See package.json debuggers > configurationAttributes > attach > |
| 316 | /// properties. |
| 317 | /// @{ |
| 318 | |
| 319 | /// Custom commands that are executed instead of attaching to a process ID or |
| 320 | /// to a process by name. These commands may optionally create a new target |
| 321 | /// and must perform an attach. A valid process must exist after these |
| 322 | /// commands complete or the `"attach"` will fail. |
| 323 | std::vector<std::string> attachCommands; |
| 324 | |
| 325 | /// System process ID to attach to. |
| 326 | lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; |
| 327 | |
| 328 | /// Wait for the process to launch. |
| 329 | bool waitFor = false; |
| 330 | |
| 331 | /// TCP/IP port to attach to a remote system. Specifying both pid and port is |
| 332 | /// an error. |
| 333 | int32_t gdbRemotePort = LLDB_DAP_INVALID_PORT; |
| 334 | |
| 335 | /// The hostname to connect to a remote system. The default hostname being |
| 336 | /// used `localhost`. |
| 337 | std::string gdbRemoteHostname = "localhost" ; |
| 338 | |
| 339 | /// Path to the core file to debug. |
| 340 | std::string coreFile; |
| 341 | |
| 342 | /// @} |
| 343 | }; |
| 344 | bool fromJSON(const llvm::json::Value &, AttachRequestArguments &, |
| 345 | llvm::json::Path); |
| 346 | |
| 347 | /// Response to `attach` request. This is just an acknowledgement, so no body |
| 348 | /// field is required. |
| 349 | using AttachResponse = VoidResponse; |
| 350 | |
| 351 | /// Arguments for `continue` request. |
| 352 | struct ContinueArguments { |
| 353 | /// Specifies the active thread. If the debug adapter supports single thread |
| 354 | /// execution (see `supportsSingleThreadExecutionRequests`) and the argument |
| 355 | /// `singleThread` is true, only the thread with this ID is resumed. |
| 356 | lldb::tid_t threadId = LLDB_INVALID_THREAD_ID; |
| 357 | |
| 358 | /// If this flag is true, execution is resumed only for the thread with given |
| 359 | /// `threadId`. |
| 360 | bool singleThread = false; |
| 361 | }; |
| 362 | bool fromJSON(const llvm::json::Value &, ContinueArguments &, llvm::json::Path); |
| 363 | |
| 364 | /// Response to `continue` request. |
| 365 | struct ContinueResponseBody { |
| 366 | // If omitted or set to `true`, this response signals to the client that all |
| 367 | // threads have been resumed. The value `false` indicates that not all threads |
| 368 | // were resumed. |
| 369 | bool allThreadsContinued = true; |
| 370 | }; |
| 371 | llvm::json::Value toJSON(const ContinueResponseBody &); |
| 372 | |
| 373 | /// Arguments for `configurationDone` request. |
| 374 | using ConfigurationDoneArguments = EmptyArguments; |
| 375 | |
| 376 | /// Response to `configurationDone` request. This is just an acknowledgement, so |
| 377 | /// no body field is required. |
| 378 | using ConfigurationDoneResponse = VoidResponse; |
| 379 | |
| 380 | /// Arguments for `setVariable` request. |
| 381 | struct SetVariableArguments { |
| 382 | /// The reference of the variable container. The `variablesReference` must |
| 383 | /// have been obtained in the current suspended state. See 'Lifetime of Object |
| 384 | /// References' in the Overview section for details. |
| 385 | uint64_t variablesReference = UINT64_MAX; |
| 386 | |
| 387 | /// The name of the variable in the container. |
| 388 | std::string name; |
| 389 | |
| 390 | /// The value of the variable. |
| 391 | std::string value; |
| 392 | |
| 393 | /// Specifies details on how to format the response value. |
| 394 | ValueFormat format; |
| 395 | }; |
| 396 | bool fromJSON(const llvm::json::Value &, SetVariableArguments &, |
| 397 | llvm::json::Path); |
| 398 | |
| 399 | /// Response to `setVariable` request. |
| 400 | struct SetVariableResponseBody { |
| 401 | |
| 402 | /// The new value of the variable. |
| 403 | std::string value; |
| 404 | |
| 405 | /// The type of the new value. Typically shown in the UI when hovering over |
| 406 | /// the value. |
| 407 | std::optional<std::string> type; |
| 408 | |
| 409 | /// If `variablesReference` is > 0, the new value is structured and its |
| 410 | /// children can be retrieved by passing `variablesReference` to the |
| 411 | /// `variables` request as long as execution remains suspended. See 'Lifetime |
| 412 | /// of Object References' in the Overview section for details. |
| 413 | /// |
| 414 | /// If this property is included in the response, any `variablesReference` |
| 415 | /// previously associated with the updated variable, and those of its |
| 416 | /// children, are no longer valid. |
| 417 | std::optional<uint64_t> variablesReference; |
| 418 | |
| 419 | /// The number of named child variables. |
| 420 | /// The client can use this information to present the variables in a paged |
| 421 | /// UI and fetch them in chunks. |
| 422 | /// The value should be less than or equal to 2147483647 (2^31-1). |
| 423 | std::optional<uint32_t> namedVariables; |
| 424 | |
| 425 | /// The number of indexed child variables. |
| 426 | /// The client can use this information to present the variables in a paged |
| 427 | /// UI and fetch them in chunks. |
| 428 | /// The value should be less than or equal to 2147483647 (2^31-1). |
| 429 | std::optional<uint32_t> indexedVariables; |
| 430 | |
| 431 | /// A memory reference to a location appropriate for this result. |
| 432 | /// For pointer type eval results, this is generally a reference to the |
| 433 | /// memory address contained in the pointer. |
| 434 | /// This attribute may be returned by a debug adapter if corresponding |
| 435 | /// capability `supportsMemoryReferences` is true. |
| 436 | std::optional<std::string> memoryReference; |
| 437 | |
| 438 | /// A reference that allows the client to request the location where the new |
| 439 | /// value is declared. For example, if the new value is function pointer, the |
| 440 | /// adapter may be able to look up the function's location. This should be |
| 441 | /// present only if the adapter is likely to be able to resolve the location. |
| 442 | /// |
| 443 | /// This reference shares the same lifetime as the `variablesReference`. See |
| 444 | /// 'Lifetime of Object References' in the Overview section for details. |
| 445 | std::optional<uint64_t> valueLocationReference; |
| 446 | }; |
| 447 | llvm::json::Value toJSON(const SetVariableResponseBody &); |
| 448 | |
| 449 | struct ScopesArguments { |
| 450 | /// Retrieve the scopes for the stack frame identified by `frameId`. The |
| 451 | /// `frameId` must have been obtained in the current suspended state. See |
| 452 | /// 'Lifetime of Object References' in the Overview section for details. |
| 453 | uint64_t frameId = LLDB_INVALID_FRAME_ID; |
| 454 | }; |
| 455 | bool fromJSON(const llvm::json::Value &, ScopesArguments &, llvm::json::Path); |
| 456 | |
| 457 | struct ScopesResponseBody { |
| 458 | std::vector<Scope> scopes; |
| 459 | }; |
| 460 | llvm::json::Value toJSON(const ScopesResponseBody &); |
| 461 | |
| 462 | /// Arguments for `source` request. |
| 463 | struct SourceArguments { |
| 464 | /// Specifies the source content to load. Either `source.path` or |
| 465 | /// `source.sourceReference` must be specified. |
| 466 | std::optional<Source> source; |
| 467 | |
| 468 | /// The reference to the source. This is the same as `source.sourceReference`. |
| 469 | /// This is provided for backward compatibility since old clients do not |
| 470 | /// understand the `source` attribute. |
| 471 | int64_t sourceReference; |
| 472 | }; |
| 473 | bool fromJSON(const llvm::json::Value &, SourceArguments &, llvm::json::Path); |
| 474 | |
| 475 | /// Response to `source` request. |
| 476 | struct SourceResponseBody { |
| 477 | /// Content of the source reference. |
| 478 | std::string content; |
| 479 | |
| 480 | /// Content type (MIME type) of the source. |
| 481 | std::optional<std::string> mimeType; |
| 482 | }; |
| 483 | llvm::json::Value toJSON(const SourceResponseBody &); |
| 484 | |
| 485 | /// Arguments for the `threads` request, no arguments. |
| 486 | using ThreadsArguments = EmptyArguments; |
| 487 | |
| 488 | /// Response to `threads` request. |
| 489 | struct ThreadsResponseBody { |
| 490 | /// All threads. |
| 491 | std::vector<Thread> threads; |
| 492 | }; |
| 493 | llvm::json::Value toJSON(const ThreadsResponseBody &); |
| 494 | |
| 495 | /// Arguments for `next` request. |
| 496 | struct NextArguments { |
| 497 | /// Specifies the thread for which to resume execution for one step (of the |
| 498 | /// given granularity). |
| 499 | lldb::tid_t threadId = LLDB_INVALID_THREAD_ID; |
| 500 | |
| 501 | /// If this flag is true, all other suspended threads are not resumed. |
| 502 | bool singleThread = false; |
| 503 | |
| 504 | /// Stepping granularity. If no granularity is specified, a granularity of |
| 505 | /// `statement` is assumed. |
| 506 | SteppingGranularity granularity = eSteppingGranularityStatement; |
| 507 | }; |
| 508 | bool fromJSON(const llvm::json::Value &, NextArguments &, llvm::json::Path); |
| 509 | |
| 510 | /// Response to `next` request. This is just an acknowledgement, so no |
| 511 | /// body field is required. |
| 512 | using NextResponse = VoidResponse; |
| 513 | |
| 514 | /// Arguments for `stepIn` request. |
| 515 | struct StepInArguments { |
| 516 | /// Specifies the thread for which to resume execution for one step-into (of |
| 517 | /// the given granularity). |
| 518 | lldb::tid_t threadId = LLDB_INVALID_THREAD_ID; |
| 519 | |
| 520 | /// If this flag is true, all other suspended threads are not resumed. |
| 521 | bool singleThread = false; |
| 522 | |
| 523 | /// Id of the target to step into. |
| 524 | std::optional<uint64_t> targetId; |
| 525 | |
| 526 | /// Stepping granularity. If no granularity is specified, a granularity of |
| 527 | /// `statement` is assumed. |
| 528 | SteppingGranularity granularity = eSteppingGranularityStatement; |
| 529 | }; |
| 530 | bool fromJSON(const llvm::json::Value &, StepInArguments &, llvm::json::Path); |
| 531 | |
| 532 | /// Response to `stepIn` request. This is just an acknowledgement, so no |
| 533 | /// body field is required. |
| 534 | using StepInResponse = VoidResponse; |
| 535 | |
| 536 | /// Arguments for `stepOut` request. |
| 537 | struct StepOutArguments { |
| 538 | /// Specifies the thread for which to resume execution for one step-out (of |
| 539 | /// the given granularity). |
| 540 | lldb::tid_t threadId = LLDB_INVALID_THREAD_ID; |
| 541 | |
| 542 | /// If this flag is true, all other suspended threads are not resumed. |
| 543 | std::optional<bool> singleThread; |
| 544 | |
| 545 | /// Stepping granularity. If no granularity is specified, a granularity of |
| 546 | /// `statement` is assumed. |
| 547 | SteppingGranularity granularity = eSteppingGranularityStatement; |
| 548 | }; |
| 549 | bool fromJSON(const llvm::json::Value &, StepOutArguments &, llvm::json::Path); |
| 550 | |
| 551 | /// Response to `stepOut` request. This is just an acknowledgement, so no |
| 552 | /// body field is required. |
| 553 | using StepOutResponse = VoidResponse; |
| 554 | |
| 555 | /// Arguments for `breakpointLocations` request. |
| 556 | struct BreakpointLocationsArguments { |
| 557 | /// The source location of the breakpoints; either `source.path` or |
| 558 | /// `source.sourceReference` must be specified. |
| 559 | Source source; |
| 560 | |
| 561 | /// Start line of range to search possible breakpoint locations in. If only |
| 562 | /// the line is specified, the request returns all possible locations in that |
| 563 | /// line. |
| 564 | uint32_t line; |
| 565 | |
| 566 | /// Start position within `line` to search possible breakpoint locations in. |
| 567 | /// It is measured in UTF-16 code units and the client capability |
| 568 | /// `columnsStartAt1` determines whether it is 0- or 1-based. If no column is |
| 569 | /// given, the first position in the start line is assumed. |
| 570 | std::optional<uint32_t> column; |
| 571 | |
| 572 | /// End line of range to search possible breakpoint locations in. If no end |
| 573 | /// line is given, then the end line is assumed to be the start line. |
| 574 | std::optional<uint32_t> endLine; |
| 575 | |
| 576 | /// End position within `endLine` to search possible breakpoint locations in. |
| 577 | /// It is measured in UTF-16 code units and the client capability |
| 578 | /// `columnsStartAt1` determines whether it is 0- or 1-based. If no end column |
| 579 | /// is given, the last position in the end line is assumed. |
| 580 | std::optional<uint32_t> endColumn; |
| 581 | }; |
| 582 | bool fromJSON(const llvm::json::Value &, BreakpointLocationsArguments &, |
| 583 | llvm::json::Path); |
| 584 | |
| 585 | /// Response to `breakpointLocations` request. |
| 586 | struct BreakpointLocationsResponseBody { |
| 587 | /// Content of the source reference. |
| 588 | std::vector<BreakpointLocation> breakpoints; |
| 589 | }; |
| 590 | llvm::json::Value toJSON(const BreakpointLocationsResponseBody &); |
| 591 | |
| 592 | /// Arguments for `setBreakpoints` request. |
| 593 | struct SetBreakpointsArguments { |
| 594 | /// The source location of the breakpoints; either `source.path` or |
| 595 | /// `source.sourceReference` must be specified. |
| 596 | Source source; |
| 597 | |
| 598 | /// The code locations of the breakpoints. |
| 599 | std::optional<std::vector<SourceBreakpoint>> breakpoints; |
| 600 | |
| 601 | /// Deprecated: The code locations of the breakpoints. |
| 602 | std::optional<std::vector<uint32_t>> lines; |
| 603 | |
| 604 | /// A value of true indicates that the underlying source has been modified |
| 605 | /// which results in new breakpoint locations. |
| 606 | std::optional<bool> sourceModified; |
| 607 | }; |
| 608 | bool fromJSON(const llvm::json::Value &, SetBreakpointsArguments &, |
| 609 | llvm::json::Path); |
| 610 | |
| 611 | /// Response to `setBreakpoints` request. |
| 612 | /// Returned is information about each breakpoint created by this request. |
| 613 | /// This includes the actual code location and whether the breakpoint could be |
| 614 | /// verified. The breakpoints returned are in the same order as the elements of |
| 615 | /// the breakpoints (or the deprecated lines) array in the arguments. |
| 616 | struct SetBreakpointsResponseBody { |
| 617 | /// Information about the breakpoints. |
| 618 | /// The array elements are in the same order as the elements of the |
| 619 | /// `breakpoints` (or the deprecated `lines`) array in the arguments. |
| 620 | std::vector<Breakpoint> breakpoints; |
| 621 | }; |
| 622 | llvm::json::Value toJSON(const SetBreakpointsResponseBody &); |
| 623 | |
| 624 | /// Arguments for `setFunctionBreakpoints` request. |
| 625 | struct SetFunctionBreakpointsArguments { |
| 626 | /// The function names of the breakpoints. |
| 627 | std::vector<FunctionBreakpoint> breakpoints; |
| 628 | }; |
| 629 | bool fromJSON(const llvm::json::Value &, SetFunctionBreakpointsArguments &, |
| 630 | llvm::json::Path); |
| 631 | |
| 632 | /// Response to `setFunctionBreakpoints` request. |
| 633 | /// Returned is information about each breakpoint created by this request. |
| 634 | struct SetFunctionBreakpointsResponseBody { |
| 635 | /// Information about the breakpoints. The array elements correspond to the |
| 636 | /// elements of the `breakpoints` array. |
| 637 | std::vector<Breakpoint> breakpoints; |
| 638 | }; |
| 639 | llvm::json::Value toJSON(const SetFunctionBreakpointsResponseBody &); |
| 640 | |
| 641 | /// Arguments for `setInstructionBreakpoints` request. |
| 642 | struct SetInstructionBreakpointsArguments { |
| 643 | /// The instruction references of the breakpoints. |
| 644 | std::vector<InstructionBreakpoint> breakpoints; |
| 645 | }; |
| 646 | bool fromJSON(const llvm::json::Value &, SetInstructionBreakpointsArguments &, |
| 647 | llvm::json::Path); |
| 648 | |
| 649 | /// Response to `setInstructionBreakpoints` request. |
| 650 | struct SetInstructionBreakpointsResponseBody { |
| 651 | /// Information about the breakpoints. The array elements correspond to the |
| 652 | /// elements of the `breakpoints` array. |
| 653 | std::vector<Breakpoint> breakpoints; |
| 654 | }; |
| 655 | llvm::json::Value toJSON(const SetInstructionBreakpointsResponseBody &); |
| 656 | |
| 657 | /// Arguments for `dataBreakpointInfo` request. |
| 658 | struct DataBreakpointInfoArguments { |
| 659 | /// Reference to the variable container if the data breakpoint is requested |
| 660 | /// for a child of the container. The `variablesReference` must have been |
| 661 | /// obtained in the current suspended state.See 'Lifetime of Object |
| 662 | /// References' in the Overview section for details. |
| 663 | std::optional<int64_t> variablesReference; |
| 664 | |
| 665 | /// The name of the variable's child to obtain data breakpoint information |
| 666 | /// for. If `variablesReference` isn't specified, this can be an expression, |
| 667 | /// or an address if `asAddress` is also true. |
| 668 | std::string name; |
| 669 | |
| 670 | /// When `name` is an expression, evaluate it in the scope of this stack |
| 671 | /// frame. If not specified, the expression is evaluated in the global scope. |
| 672 | /// When `asAddress` is true, the `frameId` is ignored. |
| 673 | std::optional<uint64_t> frameId; |
| 674 | |
| 675 | /// If specified, a debug adapter should return information for the range of |
| 676 | /// memory extending `bytes` number of bytes from the address or variable |
| 677 | /// specified by `name`. Breakpoints set using the resulting data ID should |
| 678 | /// pause on data access anywhere within that range. |
| 679 | /// Clients may set this property only if the `supportsDataBreakpointBytes` |
| 680 | /// capability is true. |
| 681 | std::optional<int64_t> bytes; |
| 682 | |
| 683 | /// If `true`, the `name` is a memory address and the debugger should |
| 684 | /// interpret it as a decimal value, or hex value if it is prefixed with `0x`. |
| 685 | /// Clients may set this property only if the `supportsDataBreakpointBytes` |
| 686 | /// capability is true. |
| 687 | std::optional<bool> asAddress; |
| 688 | |
| 689 | /// The mode of the desired breakpoint. If defined, this must be one of the |
| 690 | /// `breakpointModes` the debug adapter advertised in its `Capabilities`. |
| 691 | std::optional<std::string> mode; |
| 692 | }; |
| 693 | bool fromJSON(const llvm::json::Value &, DataBreakpointInfoArguments &, |
| 694 | llvm::json::Path); |
| 695 | |
| 696 | /// Response to `dataBreakpointInfo` request. |
| 697 | struct DataBreakpointInfoResponseBody { |
| 698 | /// An identifier for the data on which a data breakpoint can be registered |
| 699 | /// with the `setDataBreakpoints` request or null if no data breakpoint is |
| 700 | /// available. If a `variablesReference` or `frameId` is passed, the `dataId` |
| 701 | /// is valid in the current suspended state, otherwise it's valid |
| 702 | /// indefinitely. See 'Lifetime of Object References' in the Overview section |
| 703 | /// for details. Breakpoints set using the `dataId` in the |
| 704 | /// `setDataBreakpoints` request may outlive the lifetime of the associated |
| 705 | /// `dataId`. |
| 706 | std::optional<std::string> dataId; |
| 707 | |
| 708 | /// UI string that describes on what data the breakpoint is set on or why a |
| 709 | /// data breakpoint is not available. |
| 710 | std::string description; |
| 711 | |
| 712 | /// Attribute lists the available access types for a potential data |
| 713 | /// breakpoint. A UI client could surface this information. |
| 714 | std::optional<std::vector<DataBreakpointAccessType>> accessTypes; |
| 715 | |
| 716 | /// Attribute indicates that a potential data breakpoint could be persisted |
| 717 | /// across sessions. |
| 718 | std::optional<bool> canPersist; |
| 719 | }; |
| 720 | llvm::json::Value toJSON(const DataBreakpointInfoResponseBody &); |
| 721 | |
| 722 | /// Arguments for `setDataBreakpoints` request. |
| 723 | struct SetDataBreakpointsArguments { |
| 724 | /// The contents of this array replaces all existing data breakpoints. An |
| 725 | /// empty array clears all data breakpoints. |
| 726 | std::vector<DataBreakpoint> breakpoints; |
| 727 | }; |
| 728 | bool fromJSON(const llvm::json::Value &, SetDataBreakpointsArguments &, |
| 729 | llvm::json::Path); |
| 730 | |
| 731 | /// Response to `setDataBreakpoints` request. |
| 732 | struct SetDataBreakpointsResponseBody { |
| 733 | /// Information about the data breakpoints. The array elements correspond to |
| 734 | /// the elements of the input argument `breakpoints` array. |
| 735 | std::vector<Breakpoint> breakpoints; |
| 736 | }; |
| 737 | llvm::json::Value toJSON(const SetDataBreakpointsResponseBody &); |
| 738 | |
| 739 | /// Arguments to `disassemble` request. |
| 740 | struct DisassembleArguments { |
| 741 | /// Memory reference to the base location containing the instructions to |
| 742 | /// disassemble. |
| 743 | std::string memoryReference; |
| 744 | |
| 745 | /// Offset (in bytes) to be applied to the reference location before |
| 746 | /// disassembling. Can be negative. |
| 747 | std::optional<int64_t> offset; |
| 748 | |
| 749 | /// Offset (in instructions) to be applied after the byte offset (if any) |
| 750 | /// before disassembling. Can be negative. |
| 751 | std::optional<int64_t> instructionOffset; |
| 752 | |
| 753 | /// Number of instructions to disassemble starting at the specified location |
| 754 | /// and offset. |
| 755 | /// An adapter must return exactly this number of instructions - any |
| 756 | /// unavailable instructions should be replaced with an implementation-defined |
| 757 | /// 'invalid instruction' value. |
| 758 | uint32_t instructionCount; |
| 759 | |
| 760 | /// If true, the adapter should attempt to resolve memory addresses and other |
| 761 | /// values to symbolic names. |
| 762 | std::optional<bool> resolveSymbols; |
| 763 | }; |
| 764 | bool fromJSON(const llvm::json::Value &, DisassembleArguments &, |
| 765 | llvm::json::Path); |
| 766 | llvm::json::Value toJSON(const DisassembleArguments &); |
| 767 | |
| 768 | /// Response to `disassemble` request. |
| 769 | struct DisassembleResponseBody { |
| 770 | /// The list of disassembled instructions. |
| 771 | std::vector<DisassembledInstruction> instructions; |
| 772 | }; |
| 773 | bool fromJSON(const llvm::json::Value &, DisassembleResponseBody &, |
| 774 | llvm::json::Path); |
| 775 | llvm::json::Value toJSON(const DisassembleResponseBody &); |
| 776 | |
| 777 | } // namespace lldb_dap::protocol |
| 778 | |
| 779 | #endif |
| 780 | |