reporter.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2019 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <array>
  6. #include <optional>
  7. #include <string>
  8. #include <vector>
  9. #include "common/common_types.h"
  10. union ResultCode;
  11. namespace Kernel {
  12. class HLERequestContext;
  13. } // namespace Kernel
  14. namespace Service::FileSystem {
  15. enum class LogMode : u32;
  16. }
  17. namespace Service::LM {
  18. struct LogMessage;
  19. } // namespace Service::LM
  20. namespace Core {
  21. class System;
  22. class Reporter {
  23. public:
  24. explicit Reporter(System& system);
  25. ~Reporter();
  26. // Used by fatal services
  27. void SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u64 entry_point, u64 sp,
  28. u64 pc, u64 pstate, u64 afsr0, u64 afsr1, u64 esr, u64 far,
  29. const std::array<u64, 31>& registers, const std::array<u64, 32>& backtrace,
  30. u32 backtrace_size, const std::string& arch, u32 unk10) const;
  31. // Used by syscall svcBreak
  32. void SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64 info2,
  33. std::optional<std::vector<u8>> resolved_buffer = {}) const;
  34. // Used by HLE service handler
  35. void SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u32 command_id,
  36. const std::string& name,
  37. const std::string& service_name) const;
  38. // Used by stub applet implementation
  39. void SaveUnimplementedAppletReport(u32 applet_id, u32 common_args_version, u32 library_version,
  40. u32 theme_color, bool startup_sound, u64 system_tick,
  41. std::vector<std::vector<u8>> normal_channel,
  42. std::vector<std::vector<u8>> interactive_channel) const;
  43. enum class PlayReportType {
  44. Old,
  45. New,
  46. System,
  47. };
  48. void SavePlayReport(PlayReportType type, u64 title_id, std::vector<std::vector<u8>> data,
  49. std::optional<u64> process_id = {}, std::optional<u128> user_id = {}) const;
  50. // Used by error applet
  51. void SaveErrorReport(u64 title_id, ResultCode result,
  52. std::optional<std::string> custom_text_main = {},
  53. std::optional<std::string> custom_text_detail = {}) const;
  54. void SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode,
  55. std::string log_message) const;
  56. // Used by lm services
  57. void SaveLogReport(u32 destination, std::vector<Service::LM::LogMessage> messages) const;
  58. // Can be used anywhere to generate a backtrace and general info report at any point during
  59. // execution. Not intended to be used for anything other than debugging or testing.
  60. void SaveUserReport() const;
  61. private:
  62. bool IsReportingEnabled() const;
  63. System& system;
  64. };
  65. } // namespace Core