summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/reporter.cpp42
-rw-r--r--src/core/reporter.h8
2 files changed, 35 insertions, 15 deletions
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp
index 774022569..6ea26fda7 100644
--- a/src/core/reporter.cpp
+++ b/src/core/reporter.cpp
@@ -2,8 +2,13 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <ctime>
5#include <fstream> 6#include <fstream>
7
8#include <fmt/format.h>
9#include <fmt/time.h>
6#include <json.hpp> 10#include <json.hpp>
11
7#include "common/file_util.h" 12#include "common/file_util.h"
8#include "common/hex_util.h" 13#include "common/hex_util.h"
9#include "common/scm_rev.h" 14#include "common/scm_rev.h"
@@ -14,7 +19,6 @@
14#include "core/hle/result.h" 19#include "core/hle/result.h"
15#include "core/reporter.h" 20#include "core/reporter.h"
16#include "core/settings.h" 21#include "core/settings.h"
17#include "fmt/time.h"
18 22
19namespace { 23namespace {
20 24
@@ -30,9 +34,11 @@ std::string GetTimestamp() {
30 34
31using namespace nlohmann; 35using namespace nlohmann;
32 36
33void SaveToFile(const json& json, const std::string& filename) { 37void SaveToFile(json json, const std::string& filename) {
34 if (!FileUtil::CreateFullPath(filename)) 38 if (!FileUtil::CreateFullPath(filename)) {
35 LOG_ERROR(Core, "Failed to create path for '{}' to save report!", filename); 39 LOG_ERROR(Core, "Failed to create path for '{}' to save report!", filename);
40 return;
41 }
36 42
37 std::ofstream file( 43 std::ofstream file(
38 FileUtil::SanitizePath(filename, FileUtil::DirectorySeparator::PlatformDefault)); 44 FileUtil::SanitizePath(filename, FileUtil::DirectorySeparator::PlatformDefault));
@@ -61,8 +67,11 @@ json GetReportCommonData(u64 title_id, ResultCode result, const std::string& tim
61 {"result_description", fmt::format("{:08X}", result.description.Value())}, 67 {"result_description", fmt::format("{:08X}", result.description.Value())},
62 {"timestamp", timestamp}, 68 {"timestamp", timestamp},
63 }; 69 };
64 if (user_id.has_value()) 70
71 if (user_id.has_value()) {
65 out["user_id"] = fmt::format("{:016X}{:016X}", (*user_id)[1], (*user_id)[0]); 72 out["user_id"] = fmt::format("{:016X}{:016X}", (*user_id)[1], (*user_id)[0]);
73 }
74
66 return out; 75 return out;
67} 76}
68 77
@@ -171,14 +180,14 @@ json GetHLERequestContextData(Kernel::HLERequestContext& ctx) {
171 out["buffer_descriptor_c"] = GetHLEBufferDescriptorData<false>(ctx.BufferDescriptorC()); 180 out["buffer_descriptor_c"] = GetHLEBufferDescriptorData<false>(ctx.BufferDescriptorC());
172 out["buffer_descriptor_x"] = GetHLEBufferDescriptorData<true>(ctx.BufferDescriptorX()); 181 out["buffer_descriptor_x"] = GetHLEBufferDescriptorData<true>(ctx.BufferDescriptorX());
173 182
174 return std::move(out); 183 return out;
175} 184}
176 185
177} // Anonymous namespace 186} // Anonymous namespace
178 187
179namespace Core { 188namespace Core {
180 189
181Reporter::Reporter(Core::System& system) : system(system) {} 190Reporter::Reporter(System& system) : system(system) {}
182 191
183Reporter::~Reporter() = default; 192Reporter::~Reporter() = default;
184 193
@@ -187,8 +196,9 @@ void Reporter::SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u
187 const std::array<u64, 31>& registers, 196 const std::array<u64, 31>& registers,
188 const std::array<u64, 32>& backtrace, u32 backtrace_size, 197 const std::array<u64, 32>& backtrace, u32 backtrace_size,
189 const std::string& arch, u32 unk10) const { 198 const std::string& arch, u32 unk10) const {
190 if (!IsReportingEnabled()) 199 if (!IsReportingEnabled()) {
191 return; 200 return;
201 }
192 202
193 const auto timestamp = GetTimestamp(); 203 const auto timestamp = GetTimestamp();
194 json out; 204 json out;
@@ -212,8 +222,9 @@ void Reporter::SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u
212 222
213void Reporter::SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64 info2, 223void Reporter::SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64 info2,
214 std::optional<std::vector<u8>> resolved_buffer) const { 224 std::optional<std::vector<u8>> resolved_buffer) const {
215 if (!IsReportingEnabled()) 225 if (!IsReportingEnabled()) {
216 return; 226 return;
227 }
217 228
218 const auto timestamp = GetTimestamp(); 229 const auto timestamp = GetTimestamp();
219 const auto title_id = system.CurrentProcess()->GetTitleID(); 230 const auto title_id = system.CurrentProcess()->GetTitleID();
@@ -238,8 +249,9 @@ void Reporter::SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64
238void Reporter::SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u32 command_id, 249void Reporter::SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u32 command_id,
239 const std::string& name, 250 const std::string& name,
240 const std::string& service_name) const { 251 const std::string& service_name) const {
241 if (!IsReportingEnabled()) 252 if (!IsReportingEnabled()) {
242 return; 253 return;
254 }
243 255
244 const auto timestamp = GetTimestamp(); 256 const auto timestamp = GetTimestamp();
245 const auto title_id = system.CurrentProcess()->GetTitleID(); 257 const auto title_id = system.CurrentProcess()->GetTitleID();
@@ -259,8 +271,9 @@ void Reporter::SaveUnimplementedAppletReport(
259 u32 applet_id, u32 common_args_version, u32 library_version, u32 theme_color, 271 u32 applet_id, u32 common_args_version, u32 library_version, u32 theme_color,
260 bool startup_sound, u64 system_tick, std::vector<std::vector<u8>> normal_channel, 272 bool startup_sound, u64 system_tick, std::vector<std::vector<u8>> normal_channel,
261 std::vector<std::vector<u8>> interactive_channel) const { 273 std::vector<std::vector<u8>> interactive_channel) const {
262 if (!IsReportingEnabled()) 274 if (!IsReportingEnabled()) {
263 return; 275 return;
276 }
264 277
265 const auto timestamp = GetTimestamp(); 278 const auto timestamp = GetTimestamp();
266 const auto title_id = system.CurrentProcess()->GetTitleID(); 279 const auto title_id = system.CurrentProcess()->GetTitleID();
@@ -293,8 +306,9 @@ void Reporter::SaveUnimplementedAppletReport(
293 306
294void Reporter::SavePlayReport(u64 title_id, u64 process_id, std::vector<std::vector<u8>> data, 307void Reporter::SavePlayReport(u64 title_id, u64 process_id, std::vector<std::vector<u8>> data,
295 std::optional<u128> user_id) const { 308 std::optional<u128> user_id) const {
296 if (!IsReportingEnabled()) 309 if (!IsReportingEnabled()) {
297 return; 310 return;
311 }
298 312
299 const auto timestamp = GetTimestamp(); 313 const auto timestamp = GetTimestamp();
300 json out; 314 json out;
@@ -316,8 +330,9 @@ void Reporter::SavePlayReport(u64 title_id, u64 process_id, std::vector<std::vec
316void Reporter::SaveErrorReport(u64 title_id, ResultCode result, 330void Reporter::SaveErrorReport(u64 title_id, ResultCode result,
317 std::optional<std::string> custom_text_main, 331 std::optional<std::string> custom_text_main,
318 std::optional<std::string> custom_text_detail) const { 332 std::optional<std::string> custom_text_detail) const {
319 if (!IsReportingEnabled()) 333 if (!IsReportingEnabled()) {
320 return; 334 return;
335 }
321 336
322 const auto timestamp = GetTimestamp(); 337 const auto timestamp = GetTimestamp();
323 json out; 338 json out;
@@ -336,8 +351,9 @@ void Reporter::SaveErrorReport(u64 title_id, ResultCode result,
336} 351}
337 352
338void Reporter::SaveUserReport() const { 353void Reporter::SaveUserReport() const {
339 if (!IsReportingEnabled()) 354 if (!IsReportingEnabled()) {
340 return; 355 return;
356 }
341 357
342 const auto timestamp = GetTimestamp(); 358 const auto timestamp = GetTimestamp();
343 const auto title_id = system.CurrentProcess()->GetTitleID(); 359 const auto title_id = system.CurrentProcess()->GetTitleID();
diff --git a/src/core/reporter.h b/src/core/reporter.h
index 3de19c0f7..4266ca550 100644
--- a/src/core/reporter.h
+++ b/src/core/reporter.h
@@ -4,7 +4,9 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
7#include <optional> 8#include <optional>
9#include <string>
8#include <vector> 10#include <vector>
9#include "common/common_types.h" 11#include "common/common_types.h"
10 12
@@ -16,9 +18,11 @@ class HLERequestContext;
16 18
17namespace Core { 19namespace Core {
18 20
21class System;
22
19class Reporter { 23class Reporter {
20public: 24public:
21 explicit Reporter(Core::System& system); 25 explicit Reporter(System& system);
22 ~Reporter(); 26 ~Reporter();
23 27
24 void SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u64 entry_point, u64 sp, 28 void SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u64 entry_point, u64 sp,
@@ -50,7 +54,7 @@ public:
50private: 54private:
51 bool IsReportingEnabled() const; 55 bool IsReportingEnabled() const;
52 56
53 Core::System& system; 57 System& system;
54}; 58};
55 59
56} // namespace Core 60} // namespace Core