Use a common function to abort for debugging purposes

This commit is contained in:
Cameron Gutman
2024-02-25 19:23:58 -06:00
parent 53b2217a34
commit 83e3ea5aa7
5 changed files with 18 additions and 4 deletions
+12
View File
@@ -166,6 +166,18 @@ namespace lifetime {
} }
} }
/**
* @brief Breaks into the debugger or terminates Sunshine if no debugger is attached.
*/
void
debug_trap() {
#ifdef _WIN32
DebugBreak();
#else
std::raise(SIGTRAP);
#endif
}
/** /**
* @brief Gets the argv array passed to main(). * @brief Gets the argv array passed to main().
*/ */
+2
View File
@@ -42,6 +42,8 @@ namespace lifetime {
extern std::atomic_int desired_exit_code; extern std::atomic_int desired_exit_code;
void void
exit_sunshine(int exit_code, bool async); exit_sunshine(int exit_code, bool async);
void
debug_trap();
char ** char **
get_argv(); get_argv();
} // namespace lifetime } // namespace lifetime
+2 -2
View File
@@ -318,7 +318,7 @@ main(int argc, char *argv[]) {
auto task = []() { auto task = []() {
BOOST_LOG(fatal) << "10 seconds passed, yet Sunshine's still running: Forcing shutdown"sv; BOOST_LOG(fatal) << "10 seconds passed, yet Sunshine's still running: Forcing shutdown"sv;
log_flush(); log_flush();
std::abort(); lifetime::debug_trap();
}; };
force_shutdown = task_pool.pushDelayed(task, 10s).task_id; force_shutdown = task_pool.pushDelayed(task, 10s).task_id;
@@ -331,7 +331,7 @@ main(int argc, char *argv[]) {
auto task = []() { auto task = []() {
BOOST_LOG(fatal) << "10 seconds passed, yet Sunshine's still running: Forcing shutdown"sv; BOOST_LOG(fatal) << "10 seconds passed, yet Sunshine's still running: Forcing shutdown"sv;
log_flush(); log_flush();
std::abort(); lifetime::debug_trap();
}; };
force_shutdown = task_pool.pushDelayed(task, 10s).task_id; force_shutdown = task_pool.pushDelayed(task, 10s).task_id;
+1 -1
View File
@@ -489,7 +489,7 @@ namespace platf {
auto winerror = GetLastError(); auto winerror = GetLastError();
// Log the failure of reverting to self and its error code // Log the failure of reverting to self and its error code
BOOST_LOG(fatal) << "Failed to revert to self after impersonation: "sv << winerror; BOOST_LOG(fatal) << "Failed to revert to self after impersonation: "sv << winerror;
std::abort(); DebugBreak();
} }
return ec; return ec;
+1 -1
View File
@@ -1815,7 +1815,7 @@ namespace stream {
auto task = []() { auto task = []() {
BOOST_LOG(fatal) << "Hang detected! Session failed to terminate in 10 seconds."sv; BOOST_LOG(fatal) << "Hang detected! Session failed to terminate in 10 seconds."sv;
log_flush(); log_flush();
std::abort(); lifetime::debug_trap();
}; };
auto force_kill = task_pool.pushDelayed(task, 10s).task_id; auto force_kill = task_pool.pushDelayed(task, 10s).task_id;
auto fg = util::fail_guard([&force_kill]() { auto fg = util::fail_guard([&force_kill]() {