creport: update for 11.0.0 behavior

This commit is contained in:
Michael Scire 2020-12-14 19:15:49 -08:00
parent 3b5dff0f83
commit 8dcb07152e
3 changed files with 27 additions and 19 deletions

View File

@ -288,7 +288,7 @@ namespace ams::creport {
svcReadDebugProcessMemory(this->dying_message, this->debug_handle, this->dying_message_address, this->dying_message_size); 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. */ /* Try to ensure path exists. */
TryCreateReportDirectories(); TryCreateReportDirectories();
@ -333,6 +333,9 @@ namespace ams::creport {
this->dying_message = nullptr; this->dying_message = nullptr;
/* Try to take a screenshot. */ /* 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()) { if (hos::GetVersion() >= hos::Version_9_0_0 && this->IsApplication()) {
sm::ScopedServiceHolder<capsrv::InitializeScreenShotControl, capsrv::FinalizeScreenShotControl> capssc_holder; sm::ScopedServiceHolder<capsrv::InitializeScreenShotControl, capsrv::FinalizeScreenShotControl> capssc_holder;
if (capssc_holder) { if (capssc_holder) {

View File

@ -91,7 +91,7 @@ namespace ams::creport {
void BuildReport(os::ProcessId process_id, bool has_extra_info); void BuildReport(os::ProcessId process_id, bool has_extra_info);
void GetFatalContext(::FatalCpuContext *out) const; void GetFatalContext(::FatalCpuContext *out) const;
void SaveReport(); void SaveReport(bool enable_screenshot);
private: private:
void ProcessExceptions(); void ProcessExceptions();
void ProcessDyingMessage(); void ProcessDyingMessage();

View File

@ -100,22 +100,26 @@ int main(int argc, char **argv) {
} }
} }
/* Parse crashed PID. */ /* Parse arguments. */
os::ProcessId crashed_pid = creport::ParseProcessIdArgument(argv[0]); 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. */ /* Initialize the crash report. */
g_crash_report.Initialize(); g_crash_report.Initialize();
/* Try to debug the crashed process. */ /* 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()) { if (!g_crash_report.IsComplete()) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
/* Save report to file. */ /* Save report to file. */
g_crash_report.SaveReport(); g_crash_report.SaveReport(enable_screenshot);
/* Try to terminate the process. */ /* 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) { if (hos::GetVersion() >= hos::Version_10_0_0) {
/* On 10.0.0+, use pgl to terminate. */ /* On 10.0.0+, use pgl to terminate. */
sm::ScopedServiceHolder<pgl::Initialize, pgl::Finalize> pgl_holder; sm::ScopedServiceHolder<pgl::Initialize, pgl::Finalize> pgl_holder;
@ -129,13 +133,14 @@ int main(int argc, char **argv) {
nsdevTerminateProcess(static_cast<u64>(crashed_pid)); nsdevTerminateProcess(static_cast<u64>(crashed_pid));
} }
} }
}
/* Don't fatal if we have extra info, or if we're 5.0.0+ and an application crashed. */ /* Don't fatal if we have extra info, or if we're 5.0.0+ and an application crashed. */
if (hos::GetVersion() >= hos::Version_5_0_0) { if (hos::GetVersion() >= hos::Version_5_0_0) {
if (g_crash_report.IsApplication()) { if (g_crash_report.IsApplication()) {
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
} else if (argv[1][0] == '1') { } else if (has_extra_info) {
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }