Skip to content

Commit 224f62d

Browse files
authored
[lldb-dap] Improving the naming consistency of startDebugging reverse request. (llvm#112396)
Adjusting the name from `lldb-dap startDebugging` to `lldb-dap start-debugging` to improve consistency with other names for commands in lldb/lldb-dap.
1 parent f7468a2 commit 224f62d

File tree

4 files changed

+15
-24
lines changed

4 files changed

+15
-24
lines changed

lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
"""
2-
Test lldb-dap startDebugging reverse request
2+
Test lldb-dap start-debugging reverse requests.
33
"""
44

55

6-
import dap_server
76
from lldbsuite.test.decorators import *
87
from lldbsuite.test.lldbtest import *
9-
from lldbsuite.test import lldbutil
108
import lldbdap_testcase
119

1210

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

3129
self.continue_to_exit()

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -866,42 +866,35 @@ int64_t Variables::InsertVariable(lldb::SBValue variable, bool is_permanent) {
866866
bool StartDebuggingRequestHandler::DoExecute(
867867
lldb::SBDebugger debugger, char **command,
868868
lldb::SBCommandReturnObject &result) {
869-
// Command format like: `startDebugging <launch|attach> <configuration>`
869+
// Command format like: `start-debugging <launch|attach> <configuration>`
870870
if (!command) {
871-
result.SetError("Invalid use of startDebugging");
872-
result.SetStatus(lldb::eReturnStatusFailed);
871+
result.SetError("Invalid use of start-debugging, expected format "
872+
"`start-debugging <launch|attach> <configuration>`.");
873873
return false;
874874
}
875875

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

882881
if (!command[1] || llvm::StringRef(command[1]).empty()) {
883-
result.SetError("configuration missing.");
884-
result.SetStatus(lldb::eReturnStatusFailed);
882+
result.SetError("start-debugging debug configuration missing.");
885883
return false;
886884
}
887885

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

891-
int i = 2;
892-
while (command[i]) {
893-
raw_configuration.append(" ").append(command[i]);
894-
}
895-
896889
llvm::Expected<llvm::json::Value> configuration =
897890
llvm::json::parse(raw_configuration);
898891

899892
if (!configuration) {
900893
llvm::Error err = configuration.takeError();
901-
std::string msg =
902-
"Failed to parse json configuration: " + llvm::toString(std::move(err));
894+
std::string msg = "Failed to parse json configuration: " +
895+
llvm::toString(std::move(err)) + "\n\n" +
896+
raw_configuration;
903897
result.SetError(msg.c_str());
904-
result.SetStatus(lldb::eReturnStatusFailed);
905898
return false;
906899
}
907900

lldb/tools/lldb-dap/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ The escape character can be adjusted via the `commandEscapePrefix` configuration
244244
The `lldb-dap` tool includes additional custom commands to support the Debug
245245
Adapter Protocol features.
246246

247-
#### `lldb-dap startDebugging`
247+
#### `lldb-dap start-debugging`
248248

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

257257
```
258-
lldb-dap startDebugging <launch|attach> <configuration>
258+
lldb-dap start-debugging <launch|attach> <configuration>
259259
```
260260

261261
This will launch a server and then request a child debug session for a client.
@@ -264,7 +264,7 @@ This will launch a server and then request a child debug session for a client.
264264
{
265265
"program": "server",
266266
"postRunCommand": [
267-
"lldb-dap startDebugging launch '{\"program\":\"client\"}'"
267+
"lldb-dap start-debugging launch '{\"program\":\"client\"}'"
268268
]
269269
}
270270
```

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ void request_initialize(const llvm::json::Object &request) {
18891889
"lldb-dap", "Commands for managing lldb-dap.");
18901890
if (GetBoolean(arguments, "supportsStartDebuggingRequest", false)) {
18911891
cmd.AddCommand(
1892-
"startDebugging", new StartDebuggingRequestHandler(),
1892+
"start-debugging", new StartDebuggingRequestHandler(),
18931893
"Sends a startDebugging request from the debug adapter to the client "
18941894
"to start a child debug session of the same type as the caller.");
18951895
}

0 commit comments

Comments
 (0)