From bdc47693f154ffe41f16a452f65d9bd609a72683 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Fri, 17 May 2019 21:47:07 -0400 Subject: applets: Save report on stubbed applet This also reworks the applet data storage to be peekable. --- src/core/hle/service/am/applets/applets.cpp | 33 ++++++++++++++++------ src/core/hle/service/am/applets/applets.h | 16 ++++++++--- .../hle/service/am/applets/general_backend.cpp | 10 ++++++- src/core/hle/service/am/applets/general_backend.h | 5 +++- 4 files changed, 49 insertions(+), 15 deletions(-) (limited to 'src/core/hle/service/am') diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index e812c66e9..2a945bc7b 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -35,12 +35,27 @@ AppletDataBroker::AppletDataBroker() { AppletDataBroker::~AppletDataBroker() = default; +AppletDataBroker::RawChannelData AppletDataBroker::PeekDataToAppletForDebug() const { + std::vector> out_normal; + std::vector> out_interactive; + + for (const auto& storage : in_channel) { + out_normal.push_back(storage->GetData()); + } + + for (const auto& storage : in_interactive_channel) { + out_interactive.push_back(storage->GetData()); + } + + return {out_normal, out_interactive}; +} + std::unique_ptr AppletDataBroker::PopNormalDataToGame() { if (out_channel.empty()) return nullptr; auto out = std::move(out_channel.front()); - out_channel.pop(); + out_channel.pop_front(); return out; } @@ -49,7 +64,7 @@ std::unique_ptr AppletDataBroker::PopNormalDataToApplet() { return nullptr; auto out = std::move(in_channel.front()); - in_channel.pop(); + in_channel.pop_front(); return out; } @@ -58,7 +73,7 @@ std::unique_ptr AppletDataBroker::PopInteractiveDataToGame() { return nullptr; auto out = std::move(out_interactive_channel.front()); - out_interactive_channel.pop(); + out_interactive_channel.pop_front(); return out; } @@ -67,25 +82,25 @@ std::unique_ptr AppletDataBroker::PopInteractiveDataToApplet() { return nullptr; auto out = std::move(in_interactive_channel.front()); - in_interactive_channel.pop(); + in_interactive_channel.pop_front(); return out; } void AppletDataBroker::PushNormalDataFromGame(IStorage storage) { - in_channel.push(std::make_unique(storage)); + in_channel.push_back(std::make_unique(storage)); } void AppletDataBroker::PushNormalDataFromApplet(IStorage storage) { - out_channel.push(std::make_unique(storage)); + out_channel.push_back(std::make_unique(storage)); pop_out_data_event.writable->Signal(); } void AppletDataBroker::PushInteractiveDataFromGame(IStorage storage) { - in_interactive_channel.push(std::make_unique(storage)); + in_interactive_channel.push_back(std::make_unique(storage)); } void AppletDataBroker::PushInteractiveDataFromApplet(IStorage storage) { - out_interactive_channel.push(std::make_unique(storage)); + out_interactive_channel.push_back(std::make_unique(storage)); pop_interactive_out_data_event.writable->Signal(); } @@ -189,7 +204,7 @@ std::shared_ptr AppletManager::GetApplet(AppletId id) const { UNIMPLEMENTED_MSG( "No backend implementation exists for applet_id={:02X}! Falling back to stub applet.", static_cast(id)); - return std::make_shared(); + return std::make_shared(id); } } diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 7f932672c..8c2c15968 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h @@ -54,6 +54,14 @@ public: AppletDataBroker(); ~AppletDataBroker(); + struct RawChannelData { + std::vector> normal; + std::vector> interactive; + }; + + // Retrieves but does not pop the data sent to applet. + RawChannelData PeekDataToAppletForDebug() const; + std::unique_ptr PopNormalDataToGame(); std::unique_ptr PopNormalDataToApplet(); @@ -76,16 +84,16 @@ private: // Queues are named from applet's perspective // PopNormalDataToApplet and PushNormalDataFromGame - std::queue> in_channel; + std::deque> in_channel; // PopNormalDataToGame and PushNormalDataFromApplet - std::queue> out_channel; + std::deque> out_channel; // PopInteractiveDataToApplet and PushInteractiveDataFromGame - std::queue> in_interactive_channel; + std::deque> in_interactive_channel; // PopInteractiveDataToGame and PushInteractiveDataFromApplet - std::queue> out_interactive_channel; + std::deque> out_interactive_channel; Kernel::EventPair state_changed_event; diff --git a/src/core/hle/service/am/applets/general_backend.cpp b/src/core/hle/service/am/applets/general_backend.cpp index c591b9ac2..55865176c 100644 --- a/src/core/hle/service/am/applets/general_backend.cpp +++ b/src/core/hle/service/am/applets/general_backend.cpp @@ -13,6 +13,7 @@ #include "core/hle/result.h" #include "core/hle/service/am/am.h" #include "core/hle/service/am/applets/general_backend.h" +#include "core/reporter.h" namespace Service::AM::Applets { @@ -83,13 +84,20 @@ void PhotoViewer::ViewFinished() { broker.SignalStateChanged(); } -StubApplet::StubApplet() = default; +StubApplet::StubApplet(AppletId id) : id(id) {} StubApplet::~StubApplet() = default; void StubApplet::Initialize() { LOG_WARNING(Service_AM, "called (STUBBED)"); Applet::Initialize(); + + const auto data = broker.PeekDataToAppletForDebug(); + Core::System::GetInstance().GetReporter().SaveUnimplementedAppletReport( + static_cast(id), common_args.arguments_version, common_args.library_version, + common_args.theme_color, common_args.play_startup_sound, common_args.system_tick, + data.normal, data.interactive); + LogCurrentStorage(broker, "Initialize"); } diff --git a/src/core/hle/service/am/applets/general_backend.h b/src/core/hle/service/am/applets/general_backend.h index 2dd255d7c..bc919a8dd 100644 --- a/src/core/hle/service/am/applets/general_backend.h +++ b/src/core/hle/service/am/applets/general_backend.h @@ -34,7 +34,7 @@ private: class StubApplet final : public Applet { public: - StubApplet(); + StubApplet(AppletId id); ~StubApplet() override; void Initialize() override; @@ -43,6 +43,9 @@ public: ResultCode GetStatus() const override; void ExecuteInteractive() override; void Execute() override; + +private: + AppletId id; }; } // namespace Service::AM::Applets -- cgit v1.2.3 From 24392c8ec83b1b3f0b90bc80f37466c9a853f63d Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Fri, 17 May 2019 21:47:47 -0400 Subject: applets/error: Save report on error applet This matches official behavior with the erpt/eclct/eupld service chain. --- src/core/hle/service/am/applets/error.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/core/hle/service/am') diff --git a/src/core/hle/service/am/applets/error.cpp b/src/core/hle/service/am/applets/error.cpp index 04774bedc..af3a900f8 100644 --- a/src/core/hle/service/am/applets/error.cpp +++ b/src/core/hle/service/am/applets/error.cpp @@ -9,8 +9,10 @@ #include "common/string_util.h" #include "core/core.h" #include "core/frontend/applets/error.h" +#include "core/hle/kernel/process.h" #include "core/hle/service/am/am.h" #include "core/hle/service/am/applets/error.h" +#include "core/reporter.h" namespace Service::AM::Applets { @@ -143,9 +145,12 @@ void Error::Execute() { } const auto callback = [this] { DisplayCompleted(); }; + const auto title_id = Core::CurrentProcess()->GetTitleID(); + const auto& reporter{Core::System::GetInstance().GetReporter()}; switch (mode) { case ErrorAppletMode::ShowError: + reporter.SaveErrorReport(title_id, error_code); frontend.ShowError(error_code, callback); break; case ErrorAppletMode::ShowSystemError: @@ -156,14 +161,18 @@ void Error::Execute() { const auto& detail_text = system ? args->system_error.detail_text : args->application_error.detail_text; - frontend.ShowCustomErrorText( - error_code, - Common::StringFromFixedZeroTerminatedBuffer(main_text.data(), main_text.size()), - Common::StringFromFixedZeroTerminatedBuffer(detail_text.data(), detail_text.size()), - callback); + const auto main_text_string = + Common::StringFromFixedZeroTerminatedBuffer(main_text.data(), main_text.size()); + const auto detail_text_string = + Common::StringFromFixedZeroTerminatedBuffer(detail_text.data(), detail_text.size()); + + reporter.SaveErrorReport(title_id, error_code, main_text_string, detail_text_string); + frontend.ShowCustomErrorText(error_code, main_text_string, detail_text_string, callback); break; } case ErrorAppletMode::ShowErrorRecord: + reporter.SaveErrorReport(title_id, error_code, + fmt::format("{:016X}", args->error_record.posix_time)); frontend.ShowErrorWithTimestamp( error_code, std::chrono::seconds{args->error_record.posix_time}, callback); break; -- cgit v1.2.3 From b77fde7c5c1f63aad9d4f01ea625805661870f3e Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 26 May 2019 11:40:41 -0400 Subject: loader: Move NSO module tracking to AppLoader Also cleanup of general stuff --- src/core/hle/service/am/applets/applets.cpp | 5 +++-- src/core/hle/service/am/applets/general_backend.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/core/hle/service/am') diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index 2a945bc7b..d8ad0079a 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -37,17 +37,18 @@ AppletDataBroker::~AppletDataBroker() = default; AppletDataBroker::RawChannelData AppletDataBroker::PeekDataToAppletForDebug() const { std::vector> out_normal; - std::vector> out_interactive; for (const auto& storage : in_channel) { out_normal.push_back(storage->GetData()); } + std::vector> out_interactive; + for (const auto& storage : in_interactive_channel) { out_interactive.push_back(storage->GetData()); } - return {out_normal, out_interactive}; + return {std::move(out_normal), std::move(out_interactive)}; } std::unique_ptr AppletDataBroker::PopNormalDataToGame() { diff --git a/src/core/hle/service/am/applets/general_backend.h b/src/core/hle/service/am/applets/general_backend.h index bc919a8dd..fb68a2543 100644 --- a/src/core/hle/service/am/applets/general_backend.h +++ b/src/core/hle/service/am/applets/general_backend.h @@ -34,7 +34,7 @@ private: class StubApplet final : public Applet { public: - StubApplet(AppletId id); + explicit StubApplet(AppletId id); ~StubApplet() override; void Initialize() override; -- cgit v1.2.3