[Lldb-commits] [PATCH] D84974: Enable Launching the Debugee in VSCode Terminal

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 18 13:41:51 PDT 2020


clayborg added inline comments.


================
Comment at: lldb/tools/lldb-vscode/VSCode.cpp:410
+
+VSCode::PacketStatus VSCode::SendReverseRequest(llvm::json::Object &request,
+                                                llvm::json::Object &response) {
----------------
clayborg wrote:
> clayborg wrote:
> > add "const" to before "llvm::json::Object &request"
> I see we are modifying "request" below, so we can't make it "const". There are two ways to fix this:
> 1 - change it to be "llvm::json::Object request" and then use std::move() when calling SendReverseRequest. 
> 2 - just leave as a reference and modify the original object.
> 
> I think I prefer option #1.
Or we can leave this as "const" as originally suggested and add a function to VSCode:

```
llvm::json::Object VSCode::CreateReverseRequest(std::string command) {
  llvm::json::Object request;
  request.try_emplace("type", "request");
  request.try_emplace("command", command);
  request.try_emplace("seq", ++reverse_request_seq);
  return request;
}

```
And call that in request_runInTerminal when creating the reverse request packet. See other inline comment for details.


================
Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1453-1455
+  llvm::json::Object reverseRequest;
+  reverseRequest.try_emplace("type", "request");
+  reverseRequest.try_emplace("command", "runInTerminal");
----------------
This could become:

```
llvm::json::Object reverseRequest = g_vsc.CreateReverseRequest("runInTerminal");
```
And then we wouldn't need to add the "seq" key/value pair in SendReverseRequest


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84974/new/

https://reviews.llvm.org/D84974



More information about the lldb-commits mailing list