1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-10 06:01:52 +00:00

creport: Further skeleton the CrashReport object.

This commit is contained in:
Michael Scire 2018-06-25 00:42:26 -06:00
parent af4485d533
commit 6ffc9bd8e0
3 changed files with 47 additions and 4 deletions

View file

@ -0,0 +1,10 @@
#include <switch.h>
#include "creport_crash_report.hpp"
void CrashReport::BuildReport(u64 pid, bool has_extra_info) {
this->has_extra_info = has_extra_info;
if (OpenProcess(pid)) {
/* TODO: Actually generate report... */
Close();
}
}

View file

@ -0,0 +1,30 @@
#pragma once
#include <switch.h>
class CrashReport {
private:
Handle debug_handle;
bool has_extra_info;
Result result;
public:
CrashReport() : debug_handle(INVALID_HANDLE), result(0x4A2) { }
void BuildReport(u64 pid, bool has_extra_info);
Result GetResult() {
return this->result;
}
bool OpenProcess(u64 pid) {
return R_SUCCEEDED(svcDebugActiveProcess(&debug_handle, pid));
}
void Close() {
if (debug_handle != INVALID_HANDLE) {
svcCloseHandle(debug_handle);
debug_handle = INVALID_HANDLE;
}
}
};

View file

@ -6,6 +6,8 @@
#include <switch.h>
#include "creport_crash_report.hpp"
extern "C" {
extern u32 __start__;
@ -74,6 +76,8 @@ static u64 creport_parse_u64(char *s) {
return out_val;
}
static CrashReport g_Creport;
int main(int argc, char **argv) {
/* Validate arguments. */
if (argc < 2) {
@ -85,12 +89,11 @@ int main(int argc, char **argv) {
}
}
/* Parse arguments. */
/* Parse crashed PID. */
u64 crashed_pid = creport_parse_u64(argv[0]);
bool has_extra_info = argv[1][0] == '1';
/* TODO: Generate report. */
(void)(has_extra_info);
/* Try to debug the crashed process. */
g_Creport.BuildReport(crashed_pid, argv[1][0] == '1');
if (R_SUCCEEDED(nsdevInitialize())) {
nsdevTerminateProcess(crashed_pid);