mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-04 23:55:08 +01:00
Attempt Flushing Logger
During Fatal Signals
Any signals that lead to exception handling being triggered now attempt to flush all logs given that the log mutex is unoccupied, this is to mostly help logs be more complete when exiting isn't graceful.
This commit is contained in:
parent
586bee2c59
commit
662935c35d
@ -12,10 +12,18 @@ namespace skyline {
|
||||
}
|
||||
|
||||
void Logger::LoggerContext::Finalize() {
|
||||
std::lock_guard lock(mutex);
|
||||
logFile.close();
|
||||
}
|
||||
|
||||
void Logger::LoggerContext::TryFlush() {
|
||||
std::unique_lock lock(mutex, std::try_to_lock);
|
||||
if (lock)
|
||||
logFile.flush();
|
||||
}
|
||||
|
||||
void Logger::LoggerContext::Flush() {
|
||||
std::lock_guard lock(mutex);
|
||||
logFile.flush();
|
||||
}
|
||||
|
||||
@ -60,4 +68,4 @@ namespace skyline {
|
||||
std::lock_guard guard(mutex);
|
||||
logFile << str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ namespace skyline {
|
||||
|
||||
void Finalize();
|
||||
|
||||
void TryFlush();
|
||||
|
||||
void Flush();
|
||||
|
||||
void Write(const std::string &str);
|
||||
|
@ -56,14 +56,17 @@ namespace skyline::signal {
|
||||
frame = SafeFrameRecurse(2, lookupFrame);
|
||||
hasAdvanced = true;
|
||||
} else {
|
||||
Logger::EmulationContext.TryFlush();
|
||||
terminateHandler(); // We presumably have no exception handlers left on the stack to consume the exception, it's time to quit
|
||||
}
|
||||
}
|
||||
lookupFrame = lookupFrame->next;
|
||||
}
|
||||
|
||||
if (!frame->next)
|
||||
if (!frame->next) {
|
||||
Logger::EmulationContext.TryFlush(); // We want to attempt to flush all logs before quitting
|
||||
terminateHandler(); // We don't know the frame's stack boundaries, the only option is to quit
|
||||
}
|
||||
|
||||
asm("MOV SP, %x0\n\t" // Stack frame is the first item on a function's stack, it's used to calculate calling function's stack pointer
|
||||
"MOV LR, %x1\n\t"
|
||||
@ -99,6 +102,8 @@ namespace skyline::signal {
|
||||
terminateHandler = handler;
|
||||
std::set_terminate(TerminateHandler);
|
||||
}
|
||||
|
||||
Logger::EmulationContext.TryFlush(); // We want to attempt to flush all logs in case exception handling fails and infloops
|
||||
}
|
||||
|
||||
template<typename Signature>
|
||||
|
Loading…
Reference in New Issue
Block a user