reporter.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 <span>
  7. #include <string>
  8. #include <vector>
  9. #include "common/common_types.h"
  10. union Result;
  11. namespace Service {
  12. class HLERequestContext;
  13. } // namespace Service
  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, Result 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. const std::optional<std::vector<u8>>& resolved_buffer = {}) const;
  31. // Used by HLE service handler
  32. void SaveUnimplementedFunctionReport(Service::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(
  37. u32 applet_id, u32 common_args_version, u32 library_version, u32 theme_color,
  38. bool startup_sound, u64 system_tick, const std::vector<std::vector<u8>>& normal_channel,
  39. const 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,
  47. const std::vector<std::span<const u8>>& data,
  48. std::optional<u64> process_id = {}, std::optional<u128> user_id = {}) const;
  49. // Used by error applet
  50. void SaveErrorReport(u64 title_id, Result result,
  51. const std::optional<std::string>& custom_text_main = {},
  52. const std::optional<std::string>& custom_text_detail = {}) const;
  53. void SaveFSAccessLog(std::string_view log_message) const;
  54. // Can be used anywhere to generate a backtrace and general info report at any point during
  55. // execution. Not intended to be used for anything other than debugging or testing.
  56. void SaveUserReport() const;
  57. private:
  58. void ClearFSAccessLog() const;
  59. bool IsReportingEnabled() const;
  60. System& system;
  61. };
  62. } // namespace Core