reporter.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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::LM {
  15. struct LogMessage;
  16. } // namespace Service::LM
  17. namespace Core {
  18. class System;
  19. class Reporter {
  20. public:
  21. explicit Reporter(System& system_);
  22. ~Reporter();
  23. // Used by fatal services
  24. void SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u64 entry_point, u64 sp,
  25. u64 pc, u64 pstate, u64 afsr0, u64 afsr1, u64 esr, u64 far,
  26. const std::array<u64, 31>& registers, const std::array<u64, 32>& backtrace,
  27. u32 backtrace_size, const std::string& arch, u32 unk10) const;
  28. // Used by syscall svcBreak
  29. void SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64 info2,
  30. std::optional<std::vector<u8>> resolved_buffer = {}) const;
  31. // Used by HLE service handler
  32. void SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u32 command_id,
  33. const std::string& name,
  34. const std::string& service_name) const;
  35. // Used by stub applet implementation
  36. void SaveUnimplementedAppletReport(u32 applet_id, u32 common_args_version, u32 library_version,
  37. u32 theme_color, bool startup_sound, u64 system_tick,
  38. std::vector<std::vector<u8>> normal_channel,
  39. std::vector<std::vector<u8>> interactive_channel) const;
  40. enum class PlayReportType {
  41. Old,
  42. Old2,
  43. New,
  44. System,
  45. };
  46. void SavePlayReport(PlayReportType type, u64 title_id, std::vector<std::vector<u8>> data,
  47. std::optional<u64> process_id = {}, std::optional<u128> user_id = {}) const;
  48. // Used by error applet
  49. void SaveErrorReport(u64 title_id, ResultCode result,
  50. std::optional<std::string> custom_text_main = {},
  51. std::optional<std::string> custom_text_detail = {}) const;
  52. void SaveFSAccessLog(std::string_view log_message) const;
  53. // Can be used anywhere to generate a backtrace and general info report at any point during
  54. // execution. Not intended to be used for anything other than debugging or testing.
  55. void SaveUserReport() const;
  56. private:
  57. void ClearFSAccessLog() const;
  58. bool IsReportingEnabled() const;
  59. System& system;
  60. };
  61. } // namespace Core