mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-31 23:08:22 -04:00
kern: implement svc trace
This commit is contained in:
parent
f9d68db3f6
commit
920b017677
8 changed files with 203 additions and 19 deletions
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if 1 || defined(AMS_BUILD_FOR_AUDITING)
|
||||
#define MESOSPHERE_BUILD_FOR_AUDITING
|
||||
#endif
|
||||
|
||||
#if defined(MESOSPHERE_BUILD_FOR_AUDITING) || defined(AMS_BUILD_FOR_DEBUGGING)
|
||||
#define MESOSPHERE_BUILD_FOR_DEBUGGING
|
||||
#endif
|
||||
|
||||
#ifdef MESOSPHERE_BUILD_FOR_DEBUGGING
|
||||
#define MESOSPHERE_ENABLE_ASSERTIONS
|
||||
#define MESOSPHERE_ENABLE_DEBUG_PRINT
|
||||
#endif
|
||||
|
||||
#define MESOSPHERE_BUILD_FOR_TRACING
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <mesosphere/kern_build_config.hpp>
|
||||
#include <mesosphere/svc/kern_svc_results.hpp>
|
||||
|
||||
namespace ams::kern {
|
||||
|
||||
|
@ -23,20 +25,3 @@ namespace ams::kern {
|
|||
ams::TargetFirmware GetTargetFirmware();
|
||||
|
||||
}
|
||||
|
||||
#if 1 || defined(AMS_BUILD_FOR_AUDITING)
|
||||
#define MESOSPHERE_BUILD_FOR_AUDITING
|
||||
#endif
|
||||
|
||||
#if defined(MESOSPHERE_BUILD_FOR_AUDITING) || defined(AMS_BUILD_FOR_DEBUGGING)
|
||||
#define MESOSPHERE_BUILD_FOR_DEBUGGING
|
||||
#endif
|
||||
|
||||
#ifdef MESOSPHERE_BUILD_FOR_DEBUGGING
|
||||
#define MESOSPHERE_ENABLE_ASSERTIONS
|
||||
#define MESOSPHERE_ENABLE_DEBUG_PRINT
|
||||
#endif
|
||||
|
||||
#define MESOSPHERE_BUILD_FOR_TRACING
|
||||
|
||||
#include <mesosphere/svc/kern_svc_results.hpp>
|
||||
|
|
|
@ -30,6 +30,13 @@ namespace ams::kern {
|
|||
static_assert(IsKTraceEnabled || !IsKTraceEnabled);
|
||||
|
||||
class KTrace {
|
||||
public:
|
||||
enum Type {
|
||||
Type_SvcEntry0 = 3,
|
||||
Type_SvcEntry1 = 4,
|
||||
Type_SvcExit0 = 5,
|
||||
Type_SvcExit1 = 6,
|
||||
};
|
||||
private:
|
||||
static bool s_is_active;
|
||||
public:
|
||||
|
@ -37,6 +44,8 @@ namespace ams::kern {
|
|||
static void Start();
|
||||
static void Stop();
|
||||
|
||||
static void PushRecord(u8 type, u64 param0 = 0, u64 param1 = 0, u64 param2 = 0, u64 param3 = 0, u64 param4 = 0, u64 param5 = 0);
|
||||
|
||||
static ALWAYS_INLINE bool IsActive() { return s_is_active; }
|
||||
};
|
||||
|
||||
|
@ -55,3 +64,23 @@ namespace ams::kern {
|
|||
::ams::kern::KTrace::Stop(); \
|
||||
} \
|
||||
})
|
||||
|
||||
#define MESOSPHERE_KTRACE_SVC_ENTRY(SVC_ID, PARAM0, PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7) \
|
||||
({ \
|
||||
if constexpr (::ams::kern::IsKTraceEnabled) { \
|
||||
if (::ams::kern::KTrace::IsActive()) { \
|
||||
::ams::kern::KTrace::PushRecord(::ams::kern::KTrace::Type_SvcEntry0, SVC_ID, PARAM0, PARAM1, PARAM2, PARAM3, PARAM4); \
|
||||
::ams::kern::KTrace::PushRecord(::ams::kern::KTrace::Type_SvcEntry1, PARAM5, PARAM6, PARAM7); \
|
||||
} \
|
||||
} \
|
||||
})
|
||||
|
||||
#define MESOSPHERE_KTRACE_SVC_EXIT(SVC_ID, PARAM0, PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7) \
|
||||
({ \
|
||||
if constexpr (::ams::kern::IsKTraceEnabled) { \
|
||||
if (::ams::kern::KTrace::IsActive()) { \
|
||||
::ams::kern::KTrace::PushRecord(::ams::kern::KTrace::Type_SvcExit0, SVC_ID, PARAM0, PARAM1, PARAM2, PARAM3, PARAM4); \
|
||||
::ams::kern::KTrace::PushRecord(::ams::kern::KTrace::Type_SvcExit1, PARAM5, PARAM6, PARAM7); \
|
||||
} \
|
||||
} \
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue