Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 10 additions & 9 deletions Fleece/Support/Backtrace+signals-win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ namespace fleece {
bt = Backtrace::capture(skip, 32 + skip);
}

if ( sCrashStream ) {
sCrashStream << "\n\n******************** Process Crash: " << violation_type()
<< " ********************\n";
bt->writeTo(sCrashStream);
sCrashStream << "\n******************** Now terminating ********************\n";
if ( !sLogPath.empty() ) {
ofstream crashStream(sLogPath, ios::out | ios::trunc | ios::binary);
if ( crashStream ) {
crashStream << "\n\n******************** Process Crash: " << violation_type()
<< " ********************\n";
bt->writeTo(crashStream);
crashStream << "\n******************** Now terminating ********************\n";
}
}

cerr << "\n\n******************** Process Crash: " << violation_type() << " ********************\n";
Expand All @@ -110,11 +113,9 @@ namespace fleece {
};

// Awkwardly defined here to avoid FleeceBase getting its own copy since it also compiles Backtrace.cc
ofstream BacktraceSignalHandler::sCrashStream;
string BacktraceSignalHandler::sLogPath;

void BacktraceSignalHandler::setLogPath(const char* path) {
sCrashStream = ofstream(path, ios::out | ios::trunc | ios::binary);
}
void BacktraceSignalHandler::setLogPath(const char* path) { sLogPath = path; }
} // namespace fleece

static fleece::BacktraceSignalHandlerWin32 handler;
2 changes: 1 addition & 1 deletion Fleece/Support/Backtrace.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace fleece {

protected:
#ifdef _WIN32
static std::ofstream sCrashStream;
static std::string sLogPath;
#else
static volatile sig_atomic_t sLogFD;
#endif
Expand Down
Loading