code-debug icon indicating copy to clipboard operation
code-debug copied to clipboard

Program output in debug console missing most of the content

Open konradsa opened this issue 5 years ago • 8 comments

  • [x] If you are using gdb
    • [x] gdb --version >= 7.7.1
    • [x] it works on the command line with gdb
    • [x] cwd and target are properly set
  • [ ] If you are using lldb
    • [ ] lldb --version >= 3.7.1
    • [ ] it works on the command line with lldb-mi
    • [ ] cwd and target are properly set

I am trying out native debug with Vscode running on Windows, but Remote SSH connection to Linux host. When launching a binary with Native debug, I can set breakpoints and step through the code, but my issue is that the debug console only shows part the output that my program writes to stdout and stderr. There is no excessive logging, and I can see some lines of the output, but most are missing, output spreading multiple lines seems to be truncated at the top. It works fine with the regular C++ extension's debug mode, as well as with plain GDB.

Any idea what could be causing this? Is there some sort of buffer that needs to be configured?

konradsa avatar Aug 24 '20 19:08 konradsa

can you enable "showDevDebugOutput": true, "printCalls": true and check if the output appears there? If it does, it's definitely a bug in my extension, if it doesn't then it might be something with gdb, the ssh connection or the extension. I could imagine the program acts like it's being piped (you might want to check this), so it buffers a lot as if writing to a file.

WebFreak001 avatar Aug 24 '20 19:08 WebFreak001

No difference with these flags enabled, my program output is still missing.

If you have some ideas what else I can check, let me know. Like I said, it works fine with regular GDB, and also when using the debugger that comes with the C++ extension. If I redirect the output to a file when launching native debug in launch.json, I can see all the output in the file.... so there is some disconnect there between the remote machine and the local Vscode instance. The weird thing is thought that I see a few lines of output in the console, but the vast majority appears to be missing.

konradsa avatar Aug 24 '20 21:08 konradsa

I am redirecting the output to a file for now to work around this issue, will update this thread if I find the cause or a solution. But besides that, great extension! Seems to work a lot faster than the C++ extension from Microsoft when it comes to debugging, don't know why that one is so slow, especially when it comes to stepping.

konradsa avatar Aug 25 '20 12:08 konradsa

I have the exact same scenario as well, but I don't get any output at all, just pure debugging.
Would love to see support for this, I love this extension!! ❤️

MrPointer avatar Aug 28 '20 13:08 MrPointer

I've run into this issue as well when working on a mixed C++/Lua project. I've confirmed it doesn't occur when using GDB 9.1 directly from the terminal and the expected output is logged to stdout and file correctly. In my testing, attempting to print an @ character anywhere in a string to stdout causes the entire string to be discarded; there's no content logged for these messages with "showDevDebugOutput" enabled except for multiple repeating lines of GDB -> App: {"outOfBandRecord":[]}. When I trim the string to directly after the @ character, the string shows back up in VSCode's Debug Console.

Further testing reveals that when I try to log test followed by @"test2" the string test2 is printed on console and the debug console output is as follows:

GDB -> App: {"outOfBandRecord":[]}
test
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"test2"}]}
test2

I'm thinking it's an issue with this extension's string parsing. Hopefully I've provided specific enough information to be able to reproduce it; I'd be happy to investigate further as needed! I've tried to ensure all elements of my codebase aren't interfering and can confirm GDB prints my program's output correctly.

sturnclaw avatar Oct 02 '20 06:10 sturnclaw

To add to this bug report, printing the same strings to stderr instead of stdout causes them to be passed through correctly without being eaten.

EDIT: and just to clarify, this is all happening in a local debug session on linux, no SSH or WSL involved.

sturnclaw avatar Nov 26 '20 00:11 sturnclaw

As this question was about SSH and console: is it possible to use a separate console also in this case? It seems that terminal: "" just applies to normal launches, but not to ssh? If it would be possible to have a decoupled terminal (either an external one or the terminal within vscode) then this issue would be solved. [note: with an older variant of this extension I have the issue that if the program waits for user input and I do anything (for example setting a breakpoint) then the program seems to get the GDB command as user-input...]

GitMensch avatar Mar 12 '21 17:03 GitMensch

To elaborate what Web-eWorks has suggested, append "1>&2" to the end of arguments in the launch configuration.

For example:

"arguments": "<arg1> <arg2> 1>&2"

konradsa avatar Nov 12 '21 21:11 konradsa