diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/reporter.cpp | 52 | ||||
| -rw-r--r-- | src/core/reporter.h | 17 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index 9c657929e..a465d7421 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | 7 | ||
| 8 | #include <fmt/chrono.h> | 8 | #include <fmt/chrono.h> |
| 9 | #include <fmt/format.h> | 9 | #include <fmt/format.h> |
| 10 | #include <fmt/ostream.h> | ||
| 11 | #include <fmt/time.h> | ||
| 10 | #include <json.hpp> | 12 | #include <json.hpp> |
| 11 | 13 | ||
| 12 | #include "common/file_util.h" | 14 | #include "common/file_util.h" |
| @@ -17,6 +19,7 @@ | |||
| 17 | #include "core/hle/kernel/hle_ipc.h" | 19 | #include "core/hle/kernel/hle_ipc.h" |
| 18 | #include "core/hle/kernel/process.h" | 20 | #include "core/hle/kernel/process.h" |
| 19 | #include "core/hle/result.h" | 21 | #include "core/hle/result.h" |
| 22 | #include "core/hle/service/lm/manager.h" | ||
| 20 | #include "core/reporter.h" | 23 | #include "core/reporter.h" |
| 21 | #include "core/settings.h" | 24 | #include "core/settings.h" |
| 22 | 25 | ||
| @@ -354,6 +357,55 @@ void Reporter::SaveErrorReport(u64 title_id, ResultCode result, | |||
| 354 | SaveToFile(std::move(out), GetPath("error_report", title_id, timestamp)); | 357 | SaveToFile(std::move(out), GetPath("error_report", title_id, timestamp)); |
| 355 | } | 358 | } |
| 356 | 359 | ||
| 360 | void Reporter::SaveLogReport(u32 destination, std::vector<Service::LM::LogMessage> messages) const { | ||
| 361 | if (!IsReportingEnabled()) { | ||
| 362 | return; | ||
| 363 | } | ||
| 364 | |||
| 365 | const auto timestamp = GetTimestamp(); | ||
| 366 | json out; | ||
| 367 | |||
| 368 | out["yuzu_version"] = GetYuzuVersionData(); | ||
| 369 | out["report_common"] = | ||
| 370 | GetReportCommonData(system.CurrentProcess()->GetTitleID(), RESULT_SUCCESS, timestamp); | ||
| 371 | |||
| 372 | out["log_destination"] = | ||
| 373 | fmt::format("{}", static_cast<Service::LM::DestinationFlag>(destination)); | ||
| 374 | |||
| 375 | auto json_messages = json::array(); | ||
| 376 | std::transform(messages.begin(), messages.end(), std::back_inserter(json_messages), | ||
| 377 | [](const Service::LM::LogMessage& message) { | ||
| 378 | json out; | ||
| 379 | out["is_head"] = fmt::format("{}", message.header.IsHeadLog()); | ||
| 380 | out["is_tail"] = fmt::format("{}", message.header.IsTailLog()); | ||
| 381 | out["pid"] = fmt::format("{:016X}", message.header.pid); | ||
| 382 | out["thread_context"] = | ||
| 383 | fmt::format("{:016X}", message.header.thread_context); | ||
| 384 | out["payload_size"] = fmt::format("{:016X}", message.header.payload_size); | ||
| 385 | out["flags"] = fmt::format("{:04X}", message.header.flags.Value()); | ||
| 386 | out["severity"] = fmt::format("{}", message.header.severity.Value()); | ||
| 387 | out["verbosity"] = fmt::format("{:02X}", message.header.verbosity); | ||
| 388 | |||
| 389 | auto fields = json::array(); | ||
| 390 | std::transform(message.fields.begin(), message.fields.end(), | ||
| 391 | std::back_inserter(fields), [](const auto& kv) { | ||
| 392 | json out; | ||
| 393 | out["type"] = fmt::format("{}", kv.first); | ||
| 394 | out["data"] = | ||
| 395 | Service::LM::FormatField(kv.first, kv.second); | ||
| 396 | return std::move(out); | ||
| 397 | }); | ||
| 398 | |||
| 399 | out["fields"] = std::move(fields); | ||
| 400 | return std::move(out); | ||
| 401 | }); | ||
| 402 | |||
| 403 | out["log_messages"] = std::move(json_messages); | ||
| 404 | |||
| 405 | SaveToFile(std::move(out), | ||
| 406 | GetPath("log_report", system.CurrentProcess()->GetTitleID(), timestamp)); | ||
| 407 | } | ||
| 408 | |||
| 357 | void Reporter::SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode, | 409 | void Reporter::SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode, |
| 358 | std::string log_message) const { | 410 | std::string log_message) const { |
| 359 | if (!IsReportingEnabled()) | 411 | if (!IsReportingEnabled()) |
diff --git a/src/core/reporter.h b/src/core/reporter.h index f08aa11fb..6e51113fd 100644 --- a/src/core/reporter.h +++ b/src/core/reporter.h | |||
| @@ -20,6 +20,10 @@ namespace Service::FileSystem { | |||
| 20 | enum class LogMode : u32; | 20 | enum class LogMode : u32; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | namespace Service::LM { | ||
| 24 | struct LogMessage; | ||
| 25 | } // namespace Service::LM | ||
| 26 | |||
| 23 | namespace Core { | 27 | namespace Core { |
| 24 | 28 | ||
| 25 | class System; | 29 | class System; |
| @@ -29,18 +33,22 @@ public: | |||
| 29 | explicit Reporter(System& system); | 33 | explicit Reporter(System& system); |
| 30 | ~Reporter(); | 34 | ~Reporter(); |
| 31 | 35 | ||
| 36 | // Used by fatal services | ||
| 32 | void SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u64 entry_point, u64 sp, | 37 | void SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u64 entry_point, u64 sp, |
| 33 | u64 pc, u64 pstate, u64 afsr0, u64 afsr1, u64 esr, u64 far, | 38 | u64 pc, u64 pstate, u64 afsr0, u64 afsr1, u64 esr, u64 far, |
| 34 | const std::array<u64, 31>& registers, const std::array<u64, 32>& backtrace, | 39 | const std::array<u64, 31>& registers, const std::array<u64, 32>& backtrace, |
| 35 | u32 backtrace_size, const std::string& arch, u32 unk10) const; | 40 | u32 backtrace_size, const std::string& arch, u32 unk10) const; |
| 36 | 41 | ||
| 42 | // Used by syscall svcBreak | ||
| 37 | void SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64 info2, | 43 | void SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64 info2, |
| 38 | std::optional<std::vector<u8>> resolved_buffer = {}) const; | 44 | std::optional<std::vector<u8>> resolved_buffer = {}) const; |
| 39 | 45 | ||
| 46 | // Used by HLE service handler | ||
| 40 | void SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u32 command_id, | 47 | void SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u32 command_id, |
| 41 | const std::string& name, | 48 | const std::string& name, |
| 42 | const std::string& service_name) const; | 49 | const std::string& service_name) const; |
| 43 | 50 | ||
| 51 | // Used by stub applet implementation | ||
| 44 | void SaveUnimplementedAppletReport(u32 applet_id, u32 common_args_version, u32 library_version, | 52 | void SaveUnimplementedAppletReport(u32 applet_id, u32 common_args_version, u32 library_version, |
| 45 | u32 theme_color, bool startup_sound, u64 system_tick, | 53 | u32 theme_color, bool startup_sound, u64 system_tick, |
| 46 | std::vector<std::vector<u8>> normal_channel, | 54 | std::vector<std::vector<u8>> normal_channel, |
| @@ -51,10 +59,14 @@ public: | |||
| 51 | New, | 59 | New, |
| 52 | System, | 60 | System, |
| 53 | }; | 61 | }; |
| 62 | // Used by prepo services | ||
| 63 | void SavePlayReport(u64 title_id, u64 process_id, std::vector<std::vector<u8>> data, | ||
| 64 | std::optional<u128> user_id = {}) const; | ||
| 54 | 65 | ||
| 55 | void SavePlayReport(PlayReportType type, u64 title_id, std::vector<std::vector<u8>> data, | 66 | void SavePlayReport(PlayReportType type, u64 title_id, std::vector<std::vector<u8>> data, |
| 56 | std::optional<u64> process_id = {}, std::optional<u128> user_id = {}) const; | 67 | std::optional<u64> process_id = {}, std::optional<u128> user_id = {}) const; |
| 57 | 68 | ||
| 69 | // Used by error applet | ||
| 58 | void SaveErrorReport(u64 title_id, ResultCode result, | 70 | void SaveErrorReport(u64 title_id, ResultCode result, |
| 59 | std::optional<std::string> custom_text_main = {}, | 71 | std::optional<std::string> custom_text_main = {}, |
| 60 | std::optional<std::string> custom_text_detail = {}) const; | 72 | std::optional<std::string> custom_text_detail = {}) const; |
| @@ -62,6 +74,11 @@ public: | |||
| 62 | void SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode, | 74 | void SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode, |
| 63 | std::string log_message) const; | 75 | std::string log_message) const; |
| 64 | 76 | ||
| 77 | // Used by lm services | ||
| 78 | void SaveLogReport(u32 destination, std::vector<Service::LM::LogMessage> messages) const; | ||
| 79 | |||
| 80 | // Can be used anywhere to generate a backtrace and general info report at any point during | ||
| 81 | // execution. Not intended to be used for anything other than debugging or testing. | ||
| 65 | void SaveUserReport() const; | 82 | void SaveUserReport() const; |
| 66 | 83 | ||
| 67 | private: | 84 | private: |