fatal: include stack/tls in reports

This commit is contained in:
Michael Scire 2019-12-31 15:23:25 -08:00
parent cc42df7d02
commit aa0aa36ee4
2 changed files with 20 additions and 9 deletions

View File

@ -327,7 +327,10 @@ namespace ams::fatal {
Event erpt_event; Event erpt_event;
Event battery_event; Event battery_event;
size_t stack_dump_size; size_t stack_dump_size;
u64 stack_dump_base;
u8 stack_dump[0x100]; u8 stack_dump[0x100];
u64 tls_address;
u8 tls_dump[0x100];
void ClearState() { void ClearState() {
this->result = ResultSuccess(); this->result = ResultSuccess();
@ -339,7 +342,10 @@ namespace ams::fatal {
std::memset(&this->erpt_event, 0, sizeof(this->erpt_event)); std::memset(&this->erpt_event, 0, sizeof(this->erpt_event));
std::memset(&this->battery_event, 0, sizeof(this->battery_event)); std::memset(&this->battery_event, 0, sizeof(this->battery_event));
this->stack_dump_size = 0; this->stack_dump_size = 0;
this->stack_dump_base = 0;
std::memset(this->stack_dump, 0, sizeof(this->stack_dump)); std::memset(this->stack_dump, 0, sizeof(this->stack_dump));
this->tls_address = 0;
std::memset(this->tls_dump, 0, sizeof(this->tls_dump));
} }
}; };

View File

@ -20,55 +20,60 @@
namespace ams::util { namespace ams::util {
/* Utilities for alignment to power of two. */ /* Utilities for alignment to power of two. */
template<typename T>
constexpr ALWAYS_INLINE bool IsPowerOfTwo(T value) {
using U = typename std::make_unsigned<T>::type;
return (static_cast<U>(value) & static_cast<U>(value - 1)) == 0;
}
template<typename T> template<typename T>
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<T>::type; using U = typename std::make_unsigned<T>::type;
const U invmask = static_cast<U>(alignment - 1); const U invmask = static_cast<U>(alignment - 1);
return static_cast<T>((value + invmask) & ~invmask); return static_cast<T>((value + invmask) & ~invmask);
} }
template<typename T> template<typename T>
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<T>::type; using U = typename std::make_unsigned<T>::type;
const U invmask = static_cast<U>(alignment - 1); const U invmask = static_cast<U>(alignment - 1);
return static_cast<T>(value & ~invmask); return static_cast<T>(value & ~invmask);
} }
template<typename T> template<typename T>
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<T>::type; using U = typename std::make_unsigned<T>::type;
const U invmask = static_cast<U>(alignment - 1); const U invmask = static_cast<U>(alignment - 1);
return (value & invmask) == 0; return (value & invmask) == 0;
} }
template<> template<>
constexpr inline void *AlignUp<void *>(void *value, size_t alignment) { constexpr ALWAYS_INLINE void *AlignUp<void *>(void *value, size_t alignment) {
return reinterpret_cast<void *>(AlignUp(reinterpret_cast<uintptr_t>(value), alignment)); return reinterpret_cast<void *>(AlignUp(reinterpret_cast<uintptr_t>(value), alignment));
} }
template<> template<>
constexpr inline const void *AlignUp<const void *>(const void *value, size_t alignment) { constexpr ALWAYS_INLINE const void *AlignUp<const void *>(const void *value, size_t alignment) {
return reinterpret_cast<const void *>(AlignUp(reinterpret_cast<uintptr_t>(value), alignment)); return reinterpret_cast<const void *>(AlignUp(reinterpret_cast<uintptr_t>(value), alignment));
} }
template<> template<>
constexpr inline void *AlignDown<void *>(void *value, size_t alignment) { constexpr ALWAYS_INLINE void *AlignDown<void *>(void *value, size_t alignment) {
return reinterpret_cast<void *>(AlignDown(reinterpret_cast<uintptr_t>(value), alignment)); return reinterpret_cast<void *>(AlignDown(reinterpret_cast<uintptr_t>(value), alignment));
} }
template<> template<>
constexpr inline const void *AlignDown<const void *>(const void *value, size_t alignment) { constexpr ALWAYS_INLINE const void *AlignDown<const void *>(const void *value, size_t alignment) {
return reinterpret_cast<void *>(AlignDown(reinterpret_cast<uintptr_t>(value), alignment)); return reinterpret_cast<void *>(AlignDown(reinterpret_cast<uintptr_t>(value), alignment));
} }
template<> template<>
constexpr inline bool IsAligned<void *>(void *value, size_t alignment) { constexpr ALWAYS_INLINE bool IsAligned<void *>(void *value, size_t alignment) {
return IsAligned(reinterpret_cast<uintptr_t>(value), alignment); return IsAligned(reinterpret_cast<uintptr_t>(value), alignment);
} }
template<> template<>
constexpr inline bool IsAligned<const void *>(const void *value, size_t alignment) { constexpr ALWAYS_INLINE bool IsAligned<const void *>(const void *value, size_t alignment) {
return IsAligned(reinterpret_cast<uintptr_t>(value), alignment); return IsAligned(reinterpret_cast<uintptr_t>(value), alignment);
} }