================
@@ -285,6 +304,107 @@ static llvm::Error 
LaunchRunInTerminalTarget(llvm::opt::Arg &target_arg,
 #endif
 
   lldb_private::FileSystem::Initialize();
+
+#ifdef _WIN32
+  RunInTerminalLauncherCommChannel comm_channel(comm_file);
+
+  auto wcommandLineOrErr =
+      lldb_private::GetFlattenedWindowsCommandStringW(argv);
+  if (!wcommandLineOrErr)
+    return notifyError(comm_channel, "Failed to process arguments");
+
+  STARTUPINFOEXW startupinfoex = {};
+  startupinfoex.StartupInfo.cb = sizeof(STARTUPINFOEXW);
+  startupinfoex.StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
+
+  HANDLE stdin_handle = GetStdHandle(STD_INPUT_HANDLE);
+  HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
+  HANDLE stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
+
+  auto attributelist_or_err =
+      lldb_private::ProcThreadAttributeList::Create(startupinfoex);
+  if (!attributelist_or_err) {
+    return notifyError(comm_channel, "Could not open inherited handles",
+                       attributelist_or_err.getError());
+  }
+
+  if (!stdio.empty()) {
+    llvm::SmallVector<llvm::StringRef, 3> files;
+    stdio.split(files, ':');
----------------
charles-zablit wrote:

> We could split this up into 3 flags, like `--override-stdin`, 
> `--override-stdout` and `--override-stderr` so we don't have to split on any 
> specific characters.

I don't think that would work, if we want to match the existing behavior:
> | **stdio**                      | [string]               |     | The stdio 
> property specifies the redirection targets for the debuggee's stdio streams. 
> A null value redirects a stream to the default debug terminal. String can be 
> a path to file, named pipe or TTY device. If less than three values are 
> provided, the list will be padded with the last value. Specifying more than 
> three values will create additional file descriptors (4, 5, etc.). Supported 
> from lldb-dap 22.0 version. |

https://github.com/llvm/llvm-project/blob/3bf53844cfedf09f22d2786e57ef81d5d41fe249/lldb/docs/use/lldbdap.md?plain=1#L191

The `--override-*` would have to be sorted somehow, and we would need an 
`--override-extra` flag as well, which brings us back to the initial problem.

https://github.com/llvm/llvm-project/pull/174635
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to