reporter.h 2.7 KB

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