diff options
| author | 2019-07-06 21:26:40 -0400 | |
|---|---|---|
| committer | 2019-07-06 21:26:40 -0400 | |
| commit | 9e689a81f8a6ea543ed56f2dbd90641c1b6502a9 (patch) | |
| tree | 34123048f2531d46d213a1e1c2ea78648be0fdf0 | |
| parent | Merge pull request #2677 from lioncash/assert (diff) | |
| parent | core/reporter: Allow moves into SaveToFile() (diff) | |
| download | yuzu-9e689a81f8a6ea543ed56f2dbd90641c1b6502a9.tar.gz yuzu-9e689a81f8a6ea543ed56f2dbd90641c1b6502a9.tar.xz yuzu-9e689a81f8a6ea543ed56f2dbd90641c1b6502a9.zip | |
Merge pull request #2674 from lioncash/reporter
core/reporter: Minor changes
| -rw-r--r-- | src/core/reporter.cpp | 42 | ||||
| -rw-r--r-- | src/core/reporter.h | 8 |
2 files changed, 35 insertions, 15 deletions
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index 774022569..6ea26fda7 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp | |||
| @@ -2,8 +2,13 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <ctime> | ||
| 5 | #include <fstream> | 6 | #include <fstream> |
| 7 | |||
| 8 | #include <fmt/format.h> | ||
| 9 | #include <fmt/time.h> | ||
| 6 | #include <json.hpp> | 10 | #include <json.hpp> |
| 11 | |||
| 7 | #include "common/file_util.h" | 12 | #include "common/file_util.h" |
| 8 | #include "common/hex_util.h" | 13 | #include "common/hex_util.h" |
| 9 | #include "common/scm_rev.h" | 14 | #include "common/scm_rev.h" |
| @@ -14,7 +19,6 @@ | |||
| 14 | #include "core/hle/result.h" | 19 | #include "core/hle/result.h" |
| 15 | #include "core/reporter.h" | 20 | #include "core/reporter.h" |
| 16 | #include "core/settings.h" | 21 | #include "core/settings.h" |
| 17 | #include "fmt/time.h" | ||
| 18 | 22 | ||
| 19 | namespace { | 23 | namespace { |
| 20 | 24 | ||
| @@ -30,9 +34,11 @@ std::string GetTimestamp() { | |||
| 30 | 34 | ||
| 31 | using namespace nlohmann; | 35 | using namespace nlohmann; |
| 32 | 36 | ||
| 33 | void SaveToFile(const json& json, const std::string& filename) { | 37 | void SaveToFile(json json, const std::string& filename) { |
| 34 | if (!FileUtil::CreateFullPath(filename)) | 38 | if (!FileUtil::CreateFullPath(filename)) { |
| 35 | LOG_ERROR(Core, "Failed to create path for '{}' to save report!", filename); | 39 | LOG_ERROR(Core, "Failed to create path for '{}' to save report!", filename); |
| 40 | return; | ||
| 41 | } | ||
| 36 | 42 | ||
| 37 | std::ofstream file( | 43 | std::ofstream file( |
| 38 | FileUtil::SanitizePath(filename, FileUtil::DirectorySeparator::PlatformDefault)); | 44 | FileUtil::SanitizePath(filename, FileUtil::DirectorySeparator::PlatformDefault)); |
| @@ -61,8 +67,11 @@ json GetReportCommonData(u64 title_id, ResultCode result, const std::string& tim | |||
| 61 | {"result_description", fmt::format("{:08X}", result.description.Value())}, | 67 | {"result_description", fmt::format("{:08X}", result.description.Value())}, |
| 62 | {"timestamp", timestamp}, | 68 | {"timestamp", timestamp}, |
| 63 | }; | 69 | }; |
| 64 | if (user_id.has_value()) | 70 | |
| 71 | if (user_id.has_value()) { | ||
| 65 | out["user_id"] = fmt::format("{:016X}{:016X}", (*user_id)[1], (*user_id)[0]); | 72 | out["user_id"] = fmt::format("{:016X}{:016X}", (*user_id)[1], (*user_id)[0]); |
| 73 | } | ||
| 74 | |||
| 66 | return out; | 75 | return out; |
| 67 | } | 76 | } |
| 68 | 77 | ||
| @@ -171,14 +180,14 @@ json GetHLERequestContextData(Kernel::HLERequestContext& ctx) { | |||
| 171 | out["buffer_descriptor_c"] = GetHLEBufferDescriptorData<false>(ctx.BufferDescriptorC()); | 180 | out["buffer_descriptor_c"] = GetHLEBufferDescriptorData<false>(ctx.BufferDescriptorC()); |
| 172 | out["buffer_descriptor_x"] = GetHLEBufferDescriptorData<true>(ctx.BufferDescriptorX()); | 181 | out["buffer_descriptor_x"] = GetHLEBufferDescriptorData<true>(ctx.BufferDescriptorX()); |
| 173 | 182 | ||
| 174 | return std::move(out); | 183 | return out; |
| 175 | } | 184 | } |
| 176 | 185 | ||
| 177 | } // Anonymous namespace | 186 | } // Anonymous namespace |
| 178 | 187 | ||
| 179 | namespace Core { | 188 | namespace Core { |
| 180 | 189 | ||
| 181 | Reporter::Reporter(Core::System& system) : system(system) {} | 190 | Reporter::Reporter(System& system) : system(system) {} |
| 182 | 191 | ||
| 183 | Reporter::~Reporter() = default; | 192 | Reporter::~Reporter() = default; |
| 184 | 193 | ||
| @@ -187,8 +196,9 @@ void Reporter::SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u | |||
| 187 | const std::array<u64, 31>& registers, | 196 | const std::array<u64, 31>& registers, |
| 188 | const std::array<u64, 32>& backtrace, u32 backtrace_size, | 197 | const std::array<u64, 32>& backtrace, u32 backtrace_size, |
| 189 | const std::string& arch, u32 unk10) const { | 198 | const std::string& arch, u32 unk10) const { |
| 190 | if (!IsReportingEnabled()) | 199 | if (!IsReportingEnabled()) { |
| 191 | return; | 200 | return; |
| 201 | } | ||
| 192 | 202 | ||
| 193 | const auto timestamp = GetTimestamp(); | 203 | const auto timestamp = GetTimestamp(); |
| 194 | json out; | 204 | json out; |
| @@ -212,8 +222,9 @@ void Reporter::SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u | |||
| 212 | 222 | ||
| 213 | void Reporter::SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64 info2, | 223 | void Reporter::SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64 info2, |
| 214 | std::optional<std::vector<u8>> resolved_buffer) const { | 224 | std::optional<std::vector<u8>> resolved_buffer) const { |
| 215 | if (!IsReportingEnabled()) | 225 | if (!IsReportingEnabled()) { |
| 216 | return; | 226 | return; |
| 227 | } | ||
| 217 | 228 | ||
| 218 | const auto timestamp = GetTimestamp(); | 229 | const auto timestamp = GetTimestamp(); |
| 219 | const auto title_id = system.CurrentProcess()->GetTitleID(); | 230 | const auto title_id = system.CurrentProcess()->GetTitleID(); |
| @@ -238,8 +249,9 @@ void Reporter::SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64 | |||
| 238 | void Reporter::SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u32 command_id, | 249 | void Reporter::SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u32 command_id, |
| 239 | const std::string& name, | 250 | const std::string& name, |
| 240 | const std::string& service_name) const { | 251 | const std::string& service_name) const { |
| 241 | if (!IsReportingEnabled()) | 252 | if (!IsReportingEnabled()) { |
| 242 | return; | 253 | return; |
| 254 | } | ||
| 243 | 255 | ||
| 244 | const auto timestamp = GetTimestamp(); | 256 | const auto timestamp = GetTimestamp(); |
| 245 | const auto title_id = system.CurrentProcess()->GetTitleID(); | 257 | const auto title_id = system.CurrentProcess()->GetTitleID(); |
| @@ -259,8 +271,9 @@ void Reporter::SaveUnimplementedAppletReport( | |||
| 259 | u32 applet_id, u32 common_args_version, u32 library_version, u32 theme_color, | 271 | u32 applet_id, u32 common_args_version, u32 library_version, u32 theme_color, |
| 260 | bool startup_sound, u64 system_tick, std::vector<std::vector<u8>> normal_channel, | 272 | bool startup_sound, u64 system_tick, std::vector<std::vector<u8>> normal_channel, |
| 261 | std::vector<std::vector<u8>> interactive_channel) const { | 273 | std::vector<std::vector<u8>> interactive_channel) const { |
| 262 | if (!IsReportingEnabled()) | 274 | if (!IsReportingEnabled()) { |
| 263 | return; | 275 | return; |
| 276 | } | ||
| 264 | 277 | ||
| 265 | const auto timestamp = GetTimestamp(); | 278 | const auto timestamp = GetTimestamp(); |
| 266 | const auto title_id = system.CurrentProcess()->GetTitleID(); | 279 | const auto title_id = system.CurrentProcess()->GetTitleID(); |
| @@ -293,8 +306,9 @@ void Reporter::SaveUnimplementedAppletReport( | |||
| 293 | 306 | ||
| 294 | void Reporter::SavePlayReport(u64 title_id, u64 process_id, std::vector<std::vector<u8>> data, | 307 | void Reporter::SavePlayReport(u64 title_id, u64 process_id, std::vector<std::vector<u8>> data, |
| 295 | std::optional<u128> user_id) const { | 308 | std::optional<u128> user_id) const { |
| 296 | if (!IsReportingEnabled()) | 309 | if (!IsReportingEnabled()) { |
| 297 | return; | 310 | return; |
| 311 | } | ||
| 298 | 312 | ||
| 299 | const auto timestamp = GetTimestamp(); | 313 | const auto timestamp = GetTimestamp(); |
| 300 | json out; | 314 | json out; |
| @@ -316,8 +330,9 @@ void Reporter::SavePlayReport(u64 title_id, u64 process_id, std::vector<std::vec | |||
| 316 | void Reporter::SaveErrorReport(u64 title_id, ResultCode result, | 330 | void Reporter::SaveErrorReport(u64 title_id, ResultCode result, |
| 317 | std::optional<std::string> custom_text_main, | 331 | std::optional<std::string> custom_text_main, |
| 318 | std::optional<std::string> custom_text_detail) const { | 332 | std::optional<std::string> custom_text_detail) const { |
| 319 | if (!IsReportingEnabled()) | 333 | if (!IsReportingEnabled()) { |
| 320 | return; | 334 | return; |
| 335 | } | ||
| 321 | 336 | ||
| 322 | const auto timestamp = GetTimestamp(); | 337 | const auto timestamp = GetTimestamp(); |
| 323 | json out; | 338 | json out; |
| @@ -336,8 +351,9 @@ void Reporter::SaveErrorReport(u64 title_id, ResultCode result, | |||
| 336 | } | 351 | } |
| 337 | 352 | ||
| 338 | void Reporter::SaveUserReport() const { | 353 | void Reporter::SaveUserReport() const { |
| 339 | if (!IsReportingEnabled()) | 354 | if (!IsReportingEnabled()) { |
| 340 | return; | 355 | return; |
| 356 | } | ||
| 341 | 357 | ||
| 342 | const auto timestamp = GetTimestamp(); | 358 | const auto timestamp = GetTimestamp(); |
| 343 | const auto title_id = system.CurrentProcess()->GetTitleID(); | 359 | const auto title_id = system.CurrentProcess()->GetTitleID(); |
diff --git a/src/core/reporter.h b/src/core/reporter.h index 3de19c0f7..4266ca550 100644 --- a/src/core/reporter.h +++ b/src/core/reporter.h | |||
| @@ -4,7 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 7 | #include <optional> | 8 | #include <optional> |
| 9 | #include <string> | ||
| 8 | #include <vector> | 10 | #include <vector> |
| 9 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 10 | 12 | ||
| @@ -16,9 +18,11 @@ class HLERequestContext; | |||
| 16 | 18 | ||
| 17 | namespace Core { | 19 | namespace Core { |
| 18 | 20 | ||
| 21 | class System; | ||
| 22 | |||
| 19 | class Reporter { | 23 | class Reporter { |
| 20 | public: | 24 | public: |
| 21 | explicit Reporter(Core::System& system); | 25 | explicit Reporter(System& system); |
| 22 | ~Reporter(); | 26 | ~Reporter(); |
| 23 | 27 | ||
| 24 | void SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u64 entry_point, u64 sp, | 28 | void SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u64 entry_point, u64 sp, |
| @@ -50,7 +54,7 @@ public: | |||
| 50 | private: | 54 | private: |
| 51 | bool IsReportingEnabled() const; | 55 | bool IsReportingEnabled() const; |
| 52 | 56 | ||
| 53 | Core::System& system; | 57 | System& system; |
| 54 | }; | 58 | }; |
| 55 | 59 | ||
| 56 | } // namespace Core | 60 | } // namespace Core |