Skip to content
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

Send debug messages to Windows debugger #78838

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avoid sending newlines & co. to DebugView
DebugView will show newlines as additional empty lines,
while the vscode debugger output will print them correctly.
  • Loading branch information
alef committed Dec 31, 2024
commit 725cca86349952006bb5385120ba4e9271bb7592
23 changes: 20 additions & 3 deletions src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,26 @@ struct OutputDebugStreamA : public std::ostream {
return c;
}
virtual std::streamsize xsputn( const char *s, std::streamsize n ) override {
std::streamsize rc = buf->sputn( s, n );
output_string.append( s, n );
OutputDebugString();
std::streamsize rc = buf->sputn( s, n ), last = 0, i = 0;
for(; i < n; ++i) {
if( std::iscntrl(s[i]) ) {
if(i == last+1) { // Skip multiple empty lines
last = i;
continue;
}
const std::string sv(s + last, i - last);
last = i;
send(sv.c_str());
}
}
std::string append( s + last, n - last );
// Skip if only made of multiple newlines
if (none_of( append.begin(), append.end(), [](int c) { return std::iscntrl(c); })) {
output_string.append( s + last, n - last );
}
if (output_string.size() >= max) {
send();
}
return rc;
}
private:
Expand Down