From 8dcb07152ea9c58860ab27b8161489694edda8df Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 14 Dec 2020 19:15:49 -0800 Subject: [PATCH] creport: update for 11.0.0 behavior --- .../creport/source/creport_crash_report.cpp | 5 ++- .../creport/source/creport_crash_report.hpp | 2 +- stratosphere/creport/source/creport_main.cpp | 39 +++++++++++-------- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/stratosphere/creport/source/creport_crash_report.cpp b/stratosphere/creport/source/creport_crash_report.cpp index 9b1b93517..ef23aeca5 100644 --- a/stratosphere/creport/source/creport_crash_report.cpp +++ b/stratosphere/creport/source/creport_crash_report.cpp @@ -288,7 +288,7 @@ namespace ams::creport { svcReadDebugProcessMemory(this->dying_message, this->debug_handle, this->dying_message_address, this->dying_message_size); } - void CrashReport::SaveReport() { + void CrashReport::SaveReport(bool enable_screenshot) { /* Try to ensure path exists. */ TryCreateReportDirectories(); @@ -333,6 +333,9 @@ namespace ams::creport { this->dying_message = nullptr; /* Try to take a screenshot. */ + /* NOTE: Nintendo validates that enable_screenshot is true here, and validates that the application id is not in a blacklist. */ + /* Since we save reports only locally and do not send them via telemetry, we will skip this. */ + AMS_UNUSED(enable_screenshot); if (hos::GetVersion() >= hos::Version_9_0_0 && this->IsApplication()) { sm::ScopedServiceHolder capssc_holder; if (capssc_holder) { diff --git a/stratosphere/creport/source/creport_crash_report.hpp b/stratosphere/creport/source/creport_crash_report.hpp index 15858c02b..141b0b9ec 100644 --- a/stratosphere/creport/source/creport_crash_report.hpp +++ b/stratosphere/creport/source/creport_crash_report.hpp @@ -91,7 +91,7 @@ namespace ams::creport { void BuildReport(os::ProcessId process_id, bool has_extra_info); void GetFatalContext(::FatalCpuContext *out) const; - void SaveReport(); + void SaveReport(bool enable_screenshot); private: void ProcessExceptions(); void ProcessDyingMessage(); diff --git a/stratosphere/creport/source/creport_main.cpp b/stratosphere/creport/source/creport_main.cpp index fdd824efe..f016bc00e 100644 --- a/stratosphere/creport/source/creport_main.cpp +++ b/stratosphere/creport/source/creport_main.cpp @@ -100,33 +100,38 @@ int main(int argc, char **argv) { } } - /* Parse crashed PID. */ - os::ProcessId crashed_pid = creport::ParseProcessIdArgument(argv[0]); + /* Parse arguments. */ + const os::ProcessId crashed_pid = creport::ParseProcessIdArgument(argv[0]); + const bool has_extra_info = argv[1][0] == '1'; + const bool enable_screenshot = argc >= 3 && argv[2][0] == '1'; + const bool enable_jit_debug = argc >= 4 && argv[3][0] == '1'; /* Initialize the crash report. */ g_crash_report.Initialize(); /* Try to debug the crashed process. */ - g_crash_report.BuildReport(crashed_pid, argv[1][0] == '1'); + g_crash_report.BuildReport(crashed_pid, has_extra_info); if (!g_crash_report.IsComplete()) { return EXIT_FAILURE; } /* Save report to file. */ - g_crash_report.SaveReport(); + g_crash_report.SaveReport(enable_screenshot); - /* Try to terminate the process. */ - if (hos::GetVersion() >= hos::Version_10_0_0) { - /* On 10.0.0+, use pgl to terminate. */ - sm::ScopedServiceHolder pgl_holder; - if (pgl_holder) { - pgl::TerminateProcess(crashed_pid); - } - } else { - /* On < 10.0.0, use ns:dev to terminate. */ - sm::ScopedServiceHolder ns_holder; - if (ns_holder) { - nsdevTerminateProcess(static_cast(crashed_pid)); + /* If we should, try to terminate the process. */ + if (hos::GetVersion() < hos::Version_11_0_0 || !enable_jit_debug) { + if (hos::GetVersion() >= hos::Version_10_0_0) { + /* On 10.0.0+, use pgl to terminate. */ + sm::ScopedServiceHolder pgl_holder; + if (pgl_holder) { + pgl::TerminateProcess(crashed_pid); + } + } else { + /* On < 10.0.0, use ns:dev to terminate. */ + sm::ScopedServiceHolder ns_holder; + if (ns_holder) { + nsdevTerminateProcess(static_cast(crashed_pid)); + } } } @@ -135,7 +140,7 @@ int main(int argc, char **argv) { if (g_crash_report.IsApplication()) { return EXIT_SUCCESS; } - } else if (argv[1][0] == '1') { + } else if (has_extra_info) { return EXIT_SUCCESS; }