-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lldb-dap] Add stdio redirection #158609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb-dap] Add stdio redirection #158609
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,6 +177,31 @@ llvm::Error BaseRequestHandler::LaunchProcess( | |
launch_info.SetEnvironment(env, true); | ||
} | ||
|
||
if (!arguments.stdio.empty() && !arguments.disableSTDIO) { | ||
|
||
size_t n = std::max(arguments.stdio.size(), static_cast<size_t>(3)); | ||
for (size_t i = 0; i < n; i++) { | ||
std::optional<std::string> path; | ||
if (arguments.stdio.size() < i) | ||
path = arguments.stdio.back(); | ||
else | ||
path = arguments.stdio[i]; | ||
if (!path) | ||
continue; | ||
switch (i) { | ||
case 0: | ||
launch_info.AddOpenFileAction(i, path->c_str(), true, false); | ||
break; | ||
case 1: | ||
case 2: | ||
launch_info.AddOpenFileAction(i, path->c_str(), false, true); | ||
break; | ||
default: | ||
launch_info.AddOpenFileAction(i, path->c_str(), true, true); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
launch_info.SetDetachOnError(arguments.detachOnError); | ||
launch_info.SetShellExpandArguments(arguments.shellExpandArguments); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,6 +237,7 @@ contain the following key/value pairs: | |
| **stopOnEntry** | boolean | | Whether to stop program immediately after launching. | ||
| **runInTerminal** (deprecated) | boolean | | Launch the program inside an integrated terminal in the IDE. Useful for debugging interactive command line programs. | ||
| **console** | string | | Specify where to launch the program: internal console (`internalConsole`), integrated terminal (`integratedTerminal`) or external terminal (`externalTerminal`). Supported from lldb-dap 21.0 version. | ||
| **stdio** | [string] | | Destination for program stdio streams (0 - stdin, 1 - stdout, 2 - stderr, ...). Using `null` value means no redirection. Supported from lldb-dap 22.0 version. | ||
|
||
| **launchCommands** | [string] | | LLDB commands executed to launch the program. | ||
|
||
For JSON configurations of `"type": "attach"`, the JSON configuration can contain | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -615,6 +615,14 @@ | |
"description": "Specify where to launch the program: internal console, integrated terminal or external terminal.", | ||
"default": "internalConsole" | ||
}, | ||
"stdio": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"description": "Destination for program stdio streams (0 - stdin, 1 - stdout, 2 - stderr, ...). Using null value means no redirection.", | ||
|
||
"default": [] | ||
}, | ||
"timeout": { | ||
"type": "number", | ||
"description": "The time in seconds to wait for a program to stop at entry point when launching with \"launchCommands\". Defaults to 30 seconds." | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use this pattern
that way you don't need to unlink the file manually