添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
近视的春卷  ·  mongodb://10.79.12.56: ...·  1 年前    · 
傻傻的课本  ·  QT ...·  2 年前    · 
阳刚的数据线  ·  Oops!!! - 简书·  2 年前    · 

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

My application dumps useful information to stdout / stderr when I run it. When debugging, I'd like to be able to copy this to a file automatically, rather than need to use some wort of wrapper script that calls tee , copy-paste from the output console, or run separately to capture this. There may well be an existing workaround, but as this is quite a simple and I imagine commonly useful feature request, I think it would be nice to add support for it on its own.

I'd propose adding an option similar ot this to launch.json, most likely keeping it simple as it's a pretty trivial addition:

// ...
configurations: [{
    "name": "Foo",
    "type": "cppdbg",
    "request": "launch",
    "program": "${workspaceFolder}/main",
    // ...
    "log": {
        "stdout": "/path/to/file.out"
        "stderr": "/path/to/file.err"
        "stdin":  "/path/to/file.in" // Optional - capture anything typed into the run console.
    // ...
// ...

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@stellarpower in theory this feature request sounds simple to implement but in reality it is difficult.

The problem is that VS Code knows nothing about "stdout/stdin/stderr" of the debuggee because only the debug extension controls the debuggee and "knows" if it supports "stdout/stdin/stderr" and whether it is possible to redirect "stdout/stdin/stderr" to/from a file.

So in your case the C/C++ extension would be in a much better position to implement that feature. I suggest to file a feature against the C/C++ extension too.

Thanks for the fast response!

Afraid I'm not sure I understand, what do you mean by if the debuggee supports stdout/stdin/stderr? Every process forked ought to have at least these file descriptors opened I believe.

Presumably for any extenson being used to debug, if it outputs something to the integrated console as part of this it'd need to get access to the console in the same way as a different extension, wouldn't it?

@stellarpower VS Code does not know anything about "forked processes". It is the debug extension that might fork the debuggee. But when debugging Javascript running in a browser, or when attaching a debugger to an already running process, there is no need to "fork a process" and as a consequence there is nothing like "stdout/stdin/stderr".

If a debug extension starts a debuggee in the integrated (or external) terminal, then the debuggee's "stdout/stdin/stderr" are managed directly by the integrated terminal's shell. In this case not even the debug extension sees the input/output to/from "stdout/stdin/stderr". Only if the debuggee is launched in the debug console, has the debug extension a chance to see the stdout/stderr (but not even stdin, a missing piece currently discussed in microsoft/debug-adapter-protocol#216).