creport: update for new-ipc

This commit is contained in:
Michael Scire
2019-10-17 19:48:28 -07:00
committed by SciresM
parent 799c158b86
commit 89c6fc6437
5 changed files with 29 additions and 27 deletions

View File

@@ -18,7 +18,6 @@
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <malloc.h>
#include <switch.h>
#include <stratosphere.hpp>
@@ -30,8 +29,9 @@ extern "C" {
extern u32 __start__;
u32 __nx_applet_type = AppletType_None;
u32 __nx_fs_num_sessions = 1;
#define INNER_HEAP_SIZE 0x100000
#define INNER_HEAP_SIZE 0x4000
size_t nx_inner_heap_size = INNER_HEAP_SIZE;
char nx_inner_heap[INNER_HEAP_SIZE];
@@ -65,8 +65,10 @@ void __libnx_initheap(void) {
fake_heap_end = (char*)addr + size;
}
using namespace sts;
void __appInit(void) {
SetFirmwareVersionForLibnx();
hos::SetVersionForLibnx();
DoWithSmSession([&]() {
R_ASSERT(fsInitialize());
@@ -81,7 +83,7 @@ void __appExit(void) {
fsExit();
}
static sts::creport::CrashReport g_Creport;
static creport::CrashReport g_crash_report;
int main(int argc, char **argv) {
/* Validate arguments. */
@@ -95,28 +97,28 @@ int main(int argc, char **argv) {
}
/* Parse crashed PID. */
u64 crashed_pid = sts::creport::ParseProcessIdArgument(argv[0]);
os::ProcessId crashed_pid = creport::ParseProcessIdArgument(argv[0]);
/* Try to debug the crashed process. */
g_Creport.BuildReport(crashed_pid, argv[1][0] == '1');
if (!g_Creport.IsComplete()) {
g_crash_report.BuildReport(crashed_pid, argv[1][0] == '1');
if (!g_crash_report.IsComplete()) {
return EXIT_FAILURE;
}
/* Save report to file. */
g_Creport.SaveReport();
g_crash_report.SaveReport();
/* Try to terminate the process. */
{
sts::sm::ScopedServiceHolder<nsdevInitialize, nsdevExit> ns_holder;
sm::ScopedServiceHolder<nsdevInitialize, nsdevExit> ns_holder;
if (ns_holder) {
nsdevTerminateProcess(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. */
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) {
if (g_Creport.IsApplication()) {
if (hos::GetVersion() >= hos::Version_500) {
if (g_crash_report.IsApplication()) {
return EXIT_SUCCESS;
}
} else if (argv[1][0] == '1') {
@@ -124,12 +126,12 @@ int main(int argc, char **argv) {
}
/* Also don't fatal if we're a user break. */
if (g_Creport.IsUserBreak()) {
if (g_crash_report.IsUserBreak()) {
return EXIT_SUCCESS;
}
/* Throw fatal error. */
FatalContext ctx;
g_Creport.GetFatalContext(&ctx);
fatalWithContext(g_Creport.GetResult(), FatalType_ErrorScreen, &ctx);
g_crash_report.GetFatalContext(&ctx);
fatalWithContext(g_crash_report.GetResult(), FatalType_ErrorScreen, &ctx);
}