Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""
Test lldb-dap startDebugging reverse request
Test lldb-dap start-debugging reverse requests.
"""


import dap_server
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
import lldbdap_testcase


Expand All @@ -25,7 +23,7 @@ def test_startDebugging(self):
self.set_source_breakpoints(source, [breakpoint_line])
self.continue_to_next_stop()
self.dap_server.request_evaluate(
"`lldb-dap startDebugging attach '{\"pid\":321}'", context="repl"
"`lldb-dap start-debugging attach '{\"pid\":321}'", context="repl"
)

self.continue_to_exit()
Expand Down
23 changes: 8 additions & 15 deletions lldb/tools/lldb-dap/DAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,42 +866,35 @@ int64_t Variables::InsertVariable(lldb::SBValue variable, bool is_permanent) {
bool StartDebuggingRequestHandler::DoExecute(
lldb::SBDebugger debugger, char **command,
lldb::SBCommandReturnObject &result) {
// Command format like: `startDebugging <launch|attach> <configuration>`
// Command format like: `start-debugging <launch|attach> <configuration>`
if (!command) {
result.SetError("Invalid use of startDebugging");
result.SetStatus(lldb::eReturnStatusFailed);
result.SetError("Invalid use of start-debugging, expected format "
"`start-debugging <launch|attach> <configuration>`.");
return false;
}

if (!command[0] || llvm::StringRef(command[0]).empty()) {
result.SetError("startDebugging request type missing.");
result.SetStatus(lldb::eReturnStatusFailed);
result.SetError("start-debugging request type missing.");
return false;
}

if (!command[1] || llvm::StringRef(command[1]).empty()) {
result.SetError("configuration missing.");
result.SetStatus(lldb::eReturnStatusFailed);
result.SetError("start-debugging debug configuration missing.");
return false;
}

llvm::StringRef request{command[0]};
std::string raw_configuration{command[1]};

int i = 2;
while (command[i]) {
raw_configuration.append(" ").append(command[i]);
}

llvm::Expected<llvm::json::Value> configuration =
llvm::json::parse(raw_configuration);

if (!configuration) {
llvm::Error err = configuration.takeError();
std::string msg =
"Failed to parse json configuration: " + llvm::toString(std::move(err));
std::string msg = "Failed to parse json configuration: " +
llvm::toString(std::move(err)) + "\n\n" +
raw_configuration;
result.SetError(msg.c_str());
result.SetStatus(lldb::eReturnStatusFailed);
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions lldb/tools/lldb-dap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ The escape character can be adjusted via the `commandEscapePrefix` configuration
The `lldb-dap` tool includes additional custom commands to support the Debug
Adapter Protocol features.

#### `lldb-dap startDebugging`
#### `lldb-dap start-debugging`

Using the command `lldb-dap startDebugging` it is possible to trigger a
Using the command `lldb-dap start-debugging` it is possible to trigger a
reverse request to the client requesting a child debug session with the
specified configuration. For example, this can be used to attached to forked or
spawned processes. For more information see
Expand All @@ -255,7 +255,7 @@ spawned processes. For more information see
The custom command has the following format:

```
lldb-dap startDebugging <launch|attach> <configuration>
lldb-dap start-debugging <launch|attach> <configuration>
```

This will launch a server and then request a child debug session for a client.
Expand All @@ -264,7 +264,7 @@ This will launch a server and then request a child debug session for a client.
{
"program": "server",
"postRunCommand": [
"lldb-dap startDebugging launch '{\"program\":\"client\"}'"
"lldb-dap start-debugging launch '{\"program\":\"client\"}'"
]
}
```
Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/lldb-dap/lldb-dap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1889,7 +1889,7 @@ void request_initialize(const llvm::json::Object &request) {
"lldb-dap", "Commands for managing lldb-dap.");
if (GetBoolean(arguments, "supportsStartDebuggingRequest", false)) {
cmd.AddCommand(
"startDebugging", new StartDebuggingRequestHandler(),
"start-debugging", new StartDebuggingRequestHandler(),
"Sends a startDebugging request from the debug adapter to the client "
"to start a child debug session of the same type as the caller.");
}
Expand Down
Loading