mirror of
https://github.com/Vita3K/Vita3K.git
synced 2026-07-11 01:34:23 +02:00
mem&util/log: Bugfixes for log utils
- Avoid dereferencing the address of `si_addr` after converting it to `uint64 *`. - Prohibit to use initialization expressions when using `LOG_XXX_IF`. - Handle null exception pointer in terminate handler.
This commit is contained in:
@@ -583,7 +583,7 @@ static void signal_handler(int sig, siginfo_t *info, void *uct) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
LOG_CRITICAL("Unhandled access to {}", log_hex(*reinterpret_cast<uint64_t *>(&info->si_addr)));
|
||||
LOG_CRITICAL("Unhandled access to 0x{:X}", reinterpret_cast<uintptr_t>(info->si_addr));
|
||||
raise(SIGTRAP);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,11 +36,7 @@
|
||||
#define LOG_ERROR SPDLOG_ERROR
|
||||
#define LOG_CRITICAL SPDLOG_CRITICAL
|
||||
|
||||
#define LOG_IF(log_function, flag, ...) \
|
||||
do { \
|
||||
if (flag) \
|
||||
log_function(__VA_ARGS__); \
|
||||
} while (0)
|
||||
#define LOG_IF(log_function, flag, ...) ((flag) ? log_function(__VA_ARGS__) : static_cast<void>(0))
|
||||
|
||||
#define LOG_TRACE_IF(flag, ...) LOG_IF(LOG_TRACE, flag, __VA_ARGS__)
|
||||
#define LOG_DEBUG_IF(flag, ...) LOG_IF(LOG_DEBUG, flag, __VA_ARGS__)
|
||||
|
||||
@@ -78,7 +78,12 @@ ExitCode init(const Root &root_paths, bool use_stdout) {
|
||||
static std::terminate_handler old_terminate = nullptr;
|
||||
old_terminate = std::set_terminate([]() {
|
||||
try {
|
||||
std::rethrow_exception(std::current_exception());
|
||||
auto eptr = std::current_exception();
|
||||
if (eptr) {
|
||||
std::rethrow_exception(eptr);
|
||||
} else {
|
||||
LOG_CRITICAL("Unhandled 'std::terminate()' call");
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
LOG_CRITICAL("Unhandled C++ exception. {}", e.what());
|
||||
} catch (...) {
|
||||
|
||||
Reference in New Issue
Block a user