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
Rename to send() and change the logic
  • Loading branch information
alef committed Dec 31, 2024
commit d772dd6ea5b12834dd118c8e1bfd47dca4090115
19 changes: 14 additions & 5 deletions src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,16 @@ struct OutputDebugStreamA : public std::ostream {
virtual int overflow( int c ) override {
if( EOF != c ) {
int rc = buf->sputc( c );
output_string.push_back( c );
OutputDebugString( c );
if ( std::iscntrl(c) ) {
send();
} else {
output_string.push_back( c );
if (output_string.size() >= max) {
send();
}
}
} else {
send();
}
return c;
}
Expand All @@ -671,11 +679,12 @@ struct OutputDebugStreamA : public std::ostream {
return rc;
}
private:
// If `c` is not EOF then it must have been called by overflow
void OutputDebugString( int c = EOF ) {
if( output_string.size() >= max || c == '\n' || c == '\r' ) {
void send(const char *s = nullptr) {
if (s == nullptr) {
::OutputDebugStringA( output_string.c_str() );
output_string.clear();
} else {
::OutputDebugStringA( s );
}
}
static constexpr std::streamsize max = 4096;
Expand Down