The Run and Debug output windows seem to do some internal buffering, in effect delaying display of the output until the buffer threshold is reached. I'd like to be able to disable this behaviour. Or force a flush. I have a program that logs a lot of debug info to stdout and it's annoying to not be able to read it when I need it. So much, that I have to do such debugging outside of kdevelop.
For the record, relevant code is in kdevelop.git:kdevplatform/outputview/outputmodel.cpp. If you want to investigate the issue yourself, please have a look at further instructions at: https://www.kdevelop.org/contribute-kdevelop
@Jaka: Does your program log to stdout without printing a newline? I think if it *does* print a newline, then you shouldn't actually notice the internal buffering -- we're actually processing output at least every 50 ms (cf. BATCH_AGGREGATE_TIME_DELAY variable in code)
They are newline terminated, but maybe multiline strings (these dumps are long) end up treated differently. I'll take a look.
Perfect, if you have any questions, please join our IRC chat #kdevelop on Freenode.
Ok, finally took the time to investigate. Our logging does some string construction, but everything ends up being printed by fprintf. It's all in this file: https://github.com/gemrb/gemrb/blob/master/gemrb/core/System/Logger/Stdio.cpp Even if I cut out all the prettifying stuff, always explicitly print a newline in the fprintf call and print only a few characters of the passed message, there is still buffering in play. So basically no matter how trivial is what we try to print, kdevelop still buffers the output. It doesn't appear to be time-based at all either; with shorter messages I have to generate many more before they get dumped to the window.
*** Bug 427128 has been marked as a duplicate of this bug. ***
I would mark this bug as important instead of normal. It is quite a show stopper for using kdevelop for debugging, dont't you think. Note that I noticed just after submitting #427128 that it does not always occur: I was able to see the output of a debugged script with no delay while the same output was buffered when just run.
On my side, the problem appear when running python code. I just noticed that output of my python script is also buffered when running in a console like that: $ python tracenn.py 2>&1 | tee output.log Could it be a problem with the python interpreter itself?
(In reply to Gaël de Chalendar (aka Kleag) from comment #8) > On my side, the problem appear when running python code. I just noticed that > output of my python script is also buffered when running in a console like > that: > > $ python tracenn.py 2>&1 | tee output.log > > Could it be a problem with the python interpreter itself? Yes, it is: https://stackoverflow.com/questions/107705/disable-output-buffering When adding the -u flag to the script interpreter field of the launch configuration, the output is no more buffered. Should it be added by default? Or detected and the user warned? Well, with this new information, I'm not sure anymore that my bug #427128 is really a duplicate of the current one.
Doing that for the python debugger may be OK, but for C/C++ there's no such option. @Jaka Kranjc: Your code in StdioLogger::print is doing: fprintf(stdout, "%s", message); stdout is buffered, this is not KDevelop's fault. Dito for StdioLogger::LogInternal. If you want to have unbuffered output, flush the stdout stream after calling fprintf, or use an unbuffered channel like stderr.
That could explain it, but: - stdout is supposed to be line-buffered, not fully buffered - why doesn't it behave the same when ran from konsole directly? I can add a setvbuf call that will likely fix it, but I'd like to understand it first.