diff --git a/stratosphere/ncm/source/impl/ncm_content_manager.cpp b/stratosphere/ncm/source/impl/ncm_content_manager.cpp index dcfe4326f..6d3d6af74 100644 --- a/stratosphere/ncm/source/impl/ncm_content_manager.cpp +++ b/stratosphere/ncm/source/impl/ncm_content_manager.cpp @@ -257,6 +257,8 @@ namespace sts::ncm::impl { } void FinalizeContentManager() { + debug::DebugLog("Finalizing content manager...\n"); + { std::scoped_lock lk(g_mutex); diff --git a/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp b/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp index 311fbc112..60a424a1f 100644 --- a/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp +++ b/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp @@ -66,6 +66,7 @@ namespace sts::ncm::impl { this->EnsureRecursively(placeholder_id); this->GetPlaceHolderPathUncached(placeholder_path, placeholder_id); + debug::DebugLog("Creating %s\n", placeholder_path); R_TRY_CATCH(fsdevCreateFile(placeholder_path, size, FS_CREATE_BIG_FILE)) { R_CATCH(ResultFsPathAlreadyExists) { return ResultNcmPlaceHolderAlreadyExists; @@ -80,6 +81,7 @@ namespace sts::ncm::impl { this->GetPlaceHolderPathUncached(placeholder_path, placeholder_id); + debug::DebugLog("Deleting %s\n", placeholder_path); if (std::remove(placeholder_path) != 0) { R_TRY_CATCH(fsdevGetLastResult()) { R_CATCH(ResultFsPathNotFound) { diff --git a/stratosphere/ncm/source/lr_addoncontentlocationresolver.cpp b/stratosphere/ncm/source/lr_addoncontentlocationresolver.cpp index a6051bdc9..4d4d5e1ef 100644 --- a/stratosphere/ncm/source/lr_addoncontentlocationresolver.cpp +++ b/stratosphere/ncm/source/lr_addoncontentlocationresolver.cpp @@ -17,6 +17,8 @@ #include "impl/ncm_content_manager.hpp" #include "lr_addoncontentlocationresolver.hpp" +#include "debug.hpp" + namespace sts::lr { AddOnContentLocationResolverInterface::AddOnContentLocationResolverInterface() { @@ -24,6 +26,7 @@ namespace sts::lr { } Result AddOnContentLocationResolverInterface::ResolveAddOnContentPath(OutPointerWithServerSize out, ncm::TitleId tid) { + R_DEBUG_START Path path; ncm::StorageId storage_id = ncm::StorageId::None; @@ -42,16 +45,21 @@ namespace sts::lr { *out.pointer = path; return ResultSuccess; + R_DEBUG_END } Result AddOnContentLocationResolverInterface::RegisterAddOnContentStorage(ncm::StorageId storage_id, ncm::TitleId tid) { + R_DEBUG_START R_TRY(this->redirector.SetRedirection(tid, storage_id)); return ResultSuccess; + R_DEBUG_END } Result AddOnContentLocationResolverInterface::UnregisterAllAddOnContentPath() { + R_DEBUG_START this->redirector.ClearRedirections(); return ResultSuccess; + R_DEBUG_END } } \ No newline at end of file diff --git a/stratosphere/ncm/source/lr_contentlocationresolver.cpp b/stratosphere/ncm/source/lr_contentlocationresolver.cpp index ddbffc45e..0c5321ab5 100644 --- a/stratosphere/ncm/source/lr_contentlocationresolver.cpp +++ b/stratosphere/ncm/source/lr_contentlocationresolver.cpp @@ -48,6 +48,7 @@ namespace sts::lr { R_ASSERT(this->content_storage->GetPath(&path, program_content_id)); *out.pointer = path; + debug::DebugLog("Resolved program path to %s\n", path.path); return ResultSuccess; R_DEBUG_END } @@ -107,6 +108,7 @@ namespace sts::lr { Result ContentLocationResolverInterface::RedirectApplicationHtmlDocumentPath(InPointer path, ncm::TitleId tid) { R_DEBUG_START this->html_docs_redirector.SetRedirection(tid, *path.pointer, impl::RedirectionFlags_Application); + debug::DebugLog("Redirected application html document path to %s\n", (*path.pointer).path); return ResultSuccess; R_DEBUG_END } diff --git a/stratosphere/ncm/source/lr_redirectonlylocationresolver.cpp b/stratosphere/ncm/source/lr_redirectonlylocationresolver.cpp index 8f626f3ce..0c6ca239d 100644 --- a/stratosphere/ncm/source/lr_redirectonlylocationresolver.cpp +++ b/stratosphere/ncm/source/lr_redirectonlylocationresolver.cpp @@ -152,21 +152,28 @@ namespace sts::lr { } Result RedirectOnlyLocationResolverInterface::EraseApplicationControlRedirection(ncm::TitleId tid) { + R_DEBUG_START this->app_control_redirector.EraseRedirection(tid); return ResultSuccess; + R_DEBUG_END } Result RedirectOnlyLocationResolverInterface::EraseApplicationHtmlDocumentRedirection(ncm::TitleId tid) { + R_DEBUG_START this->html_docs_redirector.EraseRedirection(tid); return ResultSuccess; + R_DEBUG_END } Result RedirectOnlyLocationResolverInterface::EraseApplicationLegalInformationRedirection(ncm::TitleId tid) { + R_DEBUG_START this->legal_info_redirector.EraseRedirection(tid); return ResultSuccess; + R_DEBUG_END } Result RedirectOnlyLocationResolverInterface::ResolveProgramPathForDebug(OutPointerWithServerSize out, ncm::TitleId tid) { + R_DEBUG_START Path path; if (this->debug_program_redirector.FindRedirection(&path, tid)) { @@ -182,21 +189,28 @@ namespace sts::lr { *out.pointer = path; return ResultSuccess; + R_DEBUG_END } Result RedirectOnlyLocationResolverInterface::RedirectProgramPathForDebug(InPointer path, ncm::TitleId tid) { + R_DEBUG_START this->debug_program_redirector.SetRedirection(tid, *path.pointer); return ResultSuccess; + R_DEBUG_END } Result RedirectOnlyLocationResolverInterface::RedirectApplicationProgramPathForDebug(InPointer path, ncm::TitleId tid) { + R_DEBUG_START this->debug_program_redirector.SetRedirection(tid, *path.pointer, impl::RedirectionFlags_Application); return ResultSuccess; + R_DEBUG_END } Result RedirectOnlyLocationResolverInterface::EraseProgramRedirectionForDebug(ncm::TitleId tid) { + R_DEBUG_START this->debug_program_redirector.EraseRedirection(tid); return ResultSuccess; + R_DEBUG_END } } \ No newline at end of file diff --git a/stratosphere/ncm/source/ncm_content_manager_service.cpp b/stratosphere/ncm/source/ncm_content_manager_service.cpp index 80f82ae13..abfc6564e 100644 --- a/stratosphere/ncm/source/ncm_content_manager_service.cpp +++ b/stratosphere/ncm/source/ncm_content_manager_service.cpp @@ -21,10 +21,6 @@ namespace sts::ncm { - ContentManagerService::~ContentManagerService() { - impl::FinalizeContentManager(); - } - Result ContentManagerService::CreateContentStorage(StorageId storage_id) { R_DEBUG_START return impl::CreateContentStorage(storage_id); diff --git a/stratosphere/ncm/source/ncm_content_manager_service.hpp b/stratosphere/ncm/source/ncm_content_manager_service.hpp index 32e014125..6b6813158 100644 --- a/stratosphere/ncm/source/ncm_content_manager_service.hpp +++ b/stratosphere/ncm/source/ncm_content_manager_service.hpp @@ -40,8 +40,6 @@ namespace sts::ncm { ActivateContentMetaDatabase = 11, InactivateContentMetaDatabase = 12, }; - public: - ~ContentManagerService(); public: virtual Result CreateContentStorage(StorageId storage_id); virtual Result CreateContentMetaDatabase(StorageId storage_id); diff --git a/stratosphere/ncm/source/ncm_contentmetadatabase.cpp b/stratosphere/ncm/source/ncm_contentmetadatabase.cpp index 47c8d3ce3..4aca8bac1 100644 --- a/stratosphere/ncm/source/ncm_contentmetadatabase.cpp +++ b/stratosphere/ncm/source/ncm_contentmetadatabase.cpp @@ -209,10 +209,12 @@ namespace sts::ncm { } Result ContentMetaDatabaseInterface::GetContentIdByType(Out out_content_id, ContentMetaKey key, ContentType type) { + R_DEBUG_START ContentId content_id; R_TRY(this->GetContentIdByTypeImpl(&content_id, key, type, std::nullopt)); out_content_id.SetValue(content_id); return ResultSuccess; + R_DEBUG_END } Result ContentMetaDatabaseInterface::ListContentInfo(Out out_count, OutBuffer out_info, ContentMetaKey key, u32 offset) { @@ -664,13 +666,16 @@ namespace sts::ncm { } Result OnMemoryContentMetaDatabaseInterface::LookupOrphanContent(OutBuffer out_orphaned, InBuffer content_ids) { + R_DEBUG_START return ResultNcmInvalidContentMetaDatabase; + R_DEBUG_END } Result OnMemoryContentMetaDatabaseInterface::Commit() { + R_DEBUG_START R_TRY(this->EnsureEnabled()); - return ResultSuccess; + R_DEBUG_END } } \ No newline at end of file diff --git a/stratosphere/ncm/source/ncm_main.cpp b/stratosphere/ncm/source/ncm_main.cpp index 787fb0988..2904a833c 100644 --- a/stratosphere/ncm/source/ncm_main.cpp +++ b/stratosphere/ncm/source/ncm_main.cpp @@ -22,6 +22,8 @@ #include "lr_manager_service.hpp" #include "ncm_content_manager_service.hpp" +#include "debug.hpp" + extern "C" { extern u32 __start__; @@ -160,6 +162,8 @@ int main(int argc, char **argv) s_content_manager_thread.Join(); s_location_resolver_thread.Join(); + + sts::ncm::impl::FinalizeContentManager(); return 0; } \ No newline at end of file