Author: John Harrison Date: 2024-10-15T12:19:21-07:00 New Revision: 224f62de9e34d537b1fd282b47b773b04bea34f1
URL: https://github.com/llvm/llvm-project/commit/224f62de9e34d537b1fd282b47b773b04bea34f1 DIFF: https://github.com/llvm/llvm-project/commit/224f62de9e34d537b1fd282b47b773b04bea34f1.diff LOG: [lldb-dap] Improving the naming consistency of startDebugging reverse request. (#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. Added: Modified: lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py lldb/tools/lldb-dap/DAP.cpp lldb/tools/lldb-dap/README.md lldb/tools/lldb-dap/lldb-dap.cpp Removed: ################################################################################ diff --git a/lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py b/lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py index fd48e69cae5e25..fd452d91e472bd 100644 --- a/lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py +++ b/lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py @@ -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 @@ -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() diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index 5e75d84cf8243e..119779d7bfecba 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -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; } diff --git a/lldb/tools/lldb-dap/README.md b/lldb/tools/lldb-dap/README.md index 3a7d82e887cca3..11086eb222d2eb 100644 --- a/lldb/tools/lldb-dap/README.md +++ b/lldb/tools/lldb-dap/README.md @@ -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 @@ -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. @@ -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\"}'" ] } ``` diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp index a167088c8901ca..5e351ab11ab6ca 100644 --- a/lldb/tools/lldb-dap/lldb-dap.cpp +++ b/lldb/tools/lldb-dap/lldb-dap.cpp @@ -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."); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits