Skip to content

Commit 291a962

Browse files
ashgtiJDevlieghere
authored andcommitted
[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. (cherry picked from commit 224f62d)
1 parent 7d9e788 commit 291a962

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
@@ -868,42 +868,35 @@ int64_t Variables::InsertVariable(lldb::SBValue variable, bool is_permanent) {
868868
bool StartDebuggingRequestHandler::DoExecute(
869869
lldb::SBDebugger debugger, char **command,
870870
lldb::SBCommandReturnObject &result) {
871-
// Command format like: `startDebugging <launch|attach> <configuration>`
871+
// Command format like: `start-debugging <launch|attach> <configuration>`
872872
if (!command) {
873-
result.SetError("Invalid use of startDebugging");
874-
result.SetStatus(lldb::eReturnStatusFailed);
873+
result.SetError("Invalid use of start-debugging, expected format "
874+
"`start-debugging <launch|attach> <configuration>`.");
875875
return false;
876876
}
877877

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

884883
if (!command[1] || llvm::StringRef(command[1]).empty()) {
885-
result.SetError("configuration missing.");
886-
result.SetStatus(lldb::eReturnStatusFailed);
884+
result.SetError("start-debugging debug configuration missing.");
887885
return false;
888886
}
889887

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

893-
int i = 2;
894-
while (command[i]) {
895-
raw_configuration.append(" ").append(command[i]);
896-
}
897-
898891
llvm::Expected<llvm::json::Value> configuration =
899892
llvm::json::parse(raw_configuration);
900893

901894
if (!configuration) {
902895
llvm::Error err = configuration.takeError();
903-
std::string msg =
904-
"Failed to parse json configuration: " + llvm::toString(std::move(err));
896+
std::string msg = "Failed to parse json configuration: " +
897+
llvm::toString(std::move(err)) + "\n\n" +
898+
raw_configuration;
905899
result.SetError(msg.c_str());
906-
result.SetStatus(lldb::eReturnStatusFailed);
907900
return false;
908901
}
909902

lldb/tools/lldb-dap/README.md

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

244-
#### `lldb-dap startDebugging`
244+
#### `lldb-dap start-debugging`
245245

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

254254
```
255-
lldb-dap startDebugging <launch|attach> <configuration>
255+
lldb-dap start-debugging <launch|attach> <configuration>
256256
```
257257

258258
This will launch a server and then request a child debug session for a client.
@@ -261,7 +261,7 @@ This will launch a server and then request a child debug session for a client.
261261
{
262262
"program": "server",
263263
"postRunCommand": [
264-
"lldb-dap startDebugging launch '{\"program\":\"client\"}'"
264+
"lldb-dap start-debugging launch '{\"program\":\"client\"}'"
265265
]
266266
}
267267
```

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ void request_initialize(const llvm::json::Object &request) {
18821882
"lldb-dap", "Commands for managing lldb-dap.");
18831883
if (GetBoolean(arguments, "supportsStartDebuggingRequest", false)) {
18841884
cmd.AddCommand(
1885-
"startDebugging", new StartDebuggingRequestHandler(),
1885+
"start-debugging", new StartDebuggingRequestHandler(),
18861886
"Sends a startDebugging request from the debug adapter to the client "
18871887
"to start a child debug session of the same type as the caller.");
18881888
}

0 commit comments

Comments
 (0)