From 2e7491f605e05b808e751e37ae034e2b52a02cb2 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 21 Feb 2023 13:51:56 -0700 Subject: [PATCH] kern: delete creation time field from KProcess --- .../libmesosphere/include/mesosphere/kern_build_config.hpp | 5 +++++ .../libmesosphere/include/mesosphere/kern_k_process.hpp | 2 ++ libraries/libmesosphere/source/kern_k_process.cpp | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/libmesosphere/include/mesosphere/kern_build_config.hpp b/libraries/libmesosphere/include/mesosphere/kern_build_config.hpp index 8dcee9a88..6ecd2291b 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_build_config.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_build_config.hpp @@ -42,6 +42,11 @@ #define MESOSPHERE_ENABLE_PANIC_REGISTER_DUMP #define MESOSPHERE_ENABLE_HARDWARE_SINGLE_STEP +/* NOTE: In 16.0.0, Nintendo deleted the creation time field for KProcess, */ +/* but this may be useful for some debugging applications, and so can be. */ +/* re-enabled by toggling this define. */ +//#define MESOSPHERE_ENABLE_PROCESS_CREATION_TIME + /* NOTE: This enables fast class token storage using a class member. */ /* This saves a virtual call when doing KAutoObject->DynCast<>(), */ /* at the cost of storing class tokens inside the class object. */ diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp index 9ff663f5f..33adfe097 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp @@ -84,7 +84,9 @@ namespace ams::kern { KCapabilities m_capabilities; ams::svc::ProgramId m_program_id; u64 m_process_id; + #if defined(MESOSPHERE_ENABLE_PROCESS_CREATION_TIME) s64 m_creation_time; + #endif KProcessAddress m_code_address; size_t m_code_size; size_t m_main_thread_stack_size; diff --git a/libraries/libmesosphere/source/kern_k_process.cpp b/libraries/libmesosphere/source/kern_k_process.cpp index 7768833d1..35c6959b3 100644 --- a/libraries/libmesosphere/source/kern_k_process.cpp +++ b/libraries/libmesosphere/source/kern_k_process.cpp @@ -198,7 +198,6 @@ namespace ams::kern { /* Set misc fields. */ m_state = State_Created; m_main_thread_stack_size = 0; - m_creation_time = KHardwareTimer::GetTick(); m_used_kernel_memory_size = 0; m_ideal_core_id = 0; m_flags = params.flags; @@ -209,6 +208,10 @@ namespace ams::kern { m_is_application = (params.flags & ams::svc::CreateProcessFlag_IsApplication); m_is_jit_debug = false; + #if defined(MESOSPHERE_ENABLE_PROCESS_CREATION_TIME) + m_creation_time = KHardwareTimer::GetTick(); + #endif + /* Set thread fields. */ for (size_t i = 0; i < cpu::NumCores; i++) { m_running_threads[i] = nullptr;