Open vedantk opened 4 years ago
We could add a check to see if we have gotten any input from our process and when the ProcessIOHandler is about to deactivate itself, it could print an extra newline if needed. The "(lldb) " prompt comes from editline and has ansi terminal codes that are used to get the start of the line and if the process prints stuff without a newline this will happen. The ProcessIOHandler gets pushed and popped each time the process starts and stops and it takes over the input and output in case you need to type anything into STDIN or print stuff from STDOUT/ERR. So it would be easy to maintain some state in the ProcessIOHandler and print an extra newline if needed. I believe the ProcessIOHandler gets pushed and popped during expression evaluation. Also editline has a bug where it doesn't colorize the prompt correctly, so it lets editline paint the normal prompt, and then there is LLDB code that will repaint the prompt with color, that is why we see two prompts in Raphael's example.
Sandwiching the 'dump' output between two newline characters totally solves the problem, it was just not intuitive to me that that's necessary.
But I suppose it makes sense. As the printf occurs during expression evaluation, lldb cannot know that it should print a newline. This might be ntbf / behaves correctly, then.
The other option is that Editline is maybe somehow rendering the prompt while the stderr output is being rendered, but I'm not sure how exactly that actually works under the hood.
This usually happens when there is a missing trailing newline in the output:
(lldb) p (void)fprintf(stderr, "fooddasdfasdf")
(lldb) dfasdf(lldb)
Did you check that this is not stripped by accident?
Extended Description
While debugging clang or llvm and calling 'dump' on various objects, lldb sometimes swallows part of the output. E.g.:
or
Why does that happen? These dump methods are writing to dbgs(), which should just be stderr.