From aa0aa36ee483bb2176b2b8b7db305b7a076948da Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 31 Dec 2019 15:23:25 -0800 Subject: [PATCH] fatal: include stack/tls in reports --- .../stratosphere/fatal/fatal_types.hpp | 6 +++++ .../include/vapours/util/util_alignment.hpp | 23 +++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/libstratosphere/include/stratosphere/fatal/fatal_types.hpp b/libstratosphere/include/stratosphere/fatal/fatal_types.hpp index d0740194..a0fd2e8b 100644 --- a/libstratosphere/include/stratosphere/fatal/fatal_types.hpp +++ b/libstratosphere/include/stratosphere/fatal/fatal_types.hpp @@ -327,7 +327,10 @@ namespace ams::fatal { Event erpt_event; Event battery_event; size_t stack_dump_size; + u64 stack_dump_base; u8 stack_dump[0x100]; + u64 tls_address; + u8 tls_dump[0x100]; void ClearState() { this->result = ResultSuccess(); @@ -339,7 +342,10 @@ namespace ams::fatal { std::memset(&this->erpt_event, 0, sizeof(this->erpt_event)); std::memset(&this->battery_event, 0, sizeof(this->battery_event)); this->stack_dump_size = 0; + this->stack_dump_base = 0; std::memset(this->stack_dump, 0, sizeof(this->stack_dump)); + this->tls_address = 0; + std::memset(this->tls_dump, 0, sizeof(this->tls_dump)); } }; diff --git a/libvapours/include/vapours/util/util_alignment.hpp b/libvapours/include/vapours/util/util_alignment.hpp index 36f28e71..d300dce8 100644 --- a/libvapours/include/vapours/util/util_alignment.hpp +++ b/libvapours/include/vapours/util/util_alignment.hpp @@ -20,55 +20,60 @@ namespace ams::util { /* Utilities for alignment to power of two. */ + template + constexpr ALWAYS_INLINE bool IsPowerOfTwo(T value) { + using U = typename std::make_unsigned::type; + return (static_cast(value) & static_cast(value - 1)) == 0; + } template - constexpr inline T AlignUp(T value, size_t alignment) { + constexpr ALWAYS_INLINE T AlignUp(T value, size_t alignment) { using U = typename std::make_unsigned::type; const U invmask = static_cast(alignment - 1); return static_cast((value + invmask) & ~invmask); } template - constexpr inline T AlignDown(T value, size_t alignment) { + constexpr ALWAYS_INLINE T AlignDown(T value, size_t alignment) { using U = typename std::make_unsigned::type; const U invmask = static_cast(alignment - 1); return static_cast(value & ~invmask); } template - constexpr inline bool IsAligned(T value, size_t alignment) { + constexpr ALWAYS_INLINE bool IsAligned(T value, size_t alignment) { using U = typename std::make_unsigned::type; const U invmask = static_cast(alignment - 1); return (value & invmask) == 0; } template<> - constexpr inline void *AlignUp(void *value, size_t alignment) { + constexpr ALWAYS_INLINE void *AlignUp(void *value, size_t alignment) { return reinterpret_cast(AlignUp(reinterpret_cast(value), alignment)); } template<> - constexpr inline const void *AlignUp(const void *value, size_t alignment) { + constexpr ALWAYS_INLINE const void *AlignUp(const void *value, size_t alignment) { return reinterpret_cast(AlignUp(reinterpret_cast(value), alignment)); } template<> - constexpr inline void *AlignDown(void *value, size_t alignment) { + constexpr ALWAYS_INLINE void *AlignDown(void *value, size_t alignment) { return reinterpret_cast(AlignDown(reinterpret_cast(value), alignment)); } template<> - constexpr inline const void *AlignDown(const void *value, size_t alignment) { + constexpr ALWAYS_INLINE const void *AlignDown(const void *value, size_t alignment) { return reinterpret_cast(AlignDown(reinterpret_cast(value), alignment)); } template<> - constexpr inline bool IsAligned(void *value, size_t alignment) { + constexpr ALWAYS_INLINE bool IsAligned(void *value, size_t alignment) { return IsAligned(reinterpret_cast(value), alignment); } template<> - constexpr inline bool IsAligned(const void *value, size_t alignment) { + constexpr ALWAYS_INLINE bool IsAligned(const void *value, size_t alignment) { return IsAligned(reinterpret_cast(value), alignment); }