mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-20 16:37:03 +00:00
Add debug asserts for invalid MEMPTR
Also fixed some corruptions this uncovered
This commit is contained in:
parent
7886b594a2
commit
808d1bb424
13 changed files with 193 additions and 156 deletions
|
|
@ -37,7 +37,10 @@ public:
|
|||
if (ptr == nullptr)
|
||||
m_value = 0;
|
||||
else
|
||||
m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base);
|
||||
{
|
||||
cemu_assert_debug((uint8*)ptr >= memory_base && (uint8*)ptr <= memory_base + 0x100000000);
|
||||
m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base);
|
||||
}
|
||||
}
|
||||
|
||||
constexpr MEMPTR(const MEMPTR& memptr)
|
||||
|
|
@ -63,10 +66,13 @@ public:
|
|||
|
||||
MEMPTR& operator=(T* ptr)
|
||||
{
|
||||
if (ptr == nullptr)
|
||||
if (ptr == nullptr)
|
||||
m_value = 0;
|
||||
else
|
||||
m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base);
|
||||
{
|
||||
cemu_assert_debug((uint8*)ptr >= memory_base && (uint8*)ptr <= memory_base + 0x100000000);
|
||||
m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -296,6 +296,61 @@ inline unsigned char _addcarry_u64(unsigned char carry, unsigned long long a, un
|
|||
|
||||
#endif
|
||||
|
||||
// asserts
|
||||
|
||||
|
||||
inline void cemu_assert(bool _condition)
|
||||
{
|
||||
if ((_condition) == false)
|
||||
{
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CEMU_DEBUG_ASSERT
|
||||
//#define cemu_assert_debug(__cond) -> Forcing __cond not to be evaluated currently has unexpected side-effects
|
||||
|
||||
inline void cemu_assert_debug(bool _condition)
|
||||
{
|
||||
}
|
||||
|
||||
inline void cemu_assert_unimplemented()
|
||||
{
|
||||
}
|
||||
|
||||
inline void cemu_assert_suspicious()
|
||||
{
|
||||
}
|
||||
|
||||
inline void cemu_assert_error()
|
||||
{
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
#else
|
||||
inline void cemu_assert_debug(bool _condition)
|
||||
{
|
||||
if ((_condition) == false)
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
|
||||
inline void cemu_assert_unimplemented()
|
||||
{
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
|
||||
inline void cemu_assert_suspicious()
|
||||
{
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
|
||||
inline void cemu_assert_error()
|
||||
{
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define assert_dbg() DEBUG_BREAK // old style unconditional generic assert
|
||||
|
||||
// MEMPTR
|
||||
#include "Common/MemPtr.h"
|
||||
|
||||
|
|
@ -380,58 +435,6 @@ bool match_any_of(T1 value, T2 compareTo, Types&&... others)
|
|||
#endif
|
||||
}
|
||||
|
||||
inline void cemu_assert(bool _condition)
|
||||
{
|
||||
if ((_condition) == false)
|
||||
{
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CEMU_DEBUG_ASSERT
|
||||
//#define cemu_assert_debug(__cond) -> Forcing __cond not to be evaluated currently has unexpected side-effects
|
||||
|
||||
inline void cemu_assert_debug(bool _condition)
|
||||
{
|
||||
}
|
||||
|
||||
inline void cemu_assert_unimplemented()
|
||||
{
|
||||
}
|
||||
|
||||
inline void cemu_assert_suspicious()
|
||||
{
|
||||
}
|
||||
|
||||
inline void cemu_assert_error()
|
||||
{
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
#else
|
||||
inline void cemu_assert_debug(bool _condition)
|
||||
{
|
||||
if ((_condition) == false)
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
|
||||
inline void cemu_assert_unimplemented()
|
||||
{
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
|
||||
inline void cemu_assert_suspicious()
|
||||
{
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
|
||||
inline void cemu_assert_error()
|
||||
{
|
||||
DEBUG_BREAK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define assert_dbg() DEBUG_BREAK // old style unconditional generic assert
|
||||
|
||||
// Some string conversion helpers because C++20 std::u8string is too cumbersome to use in practice
|
||||
// mixing string types generally causes loads of issues and many of the libraries we use dont expose interfaces for u8string
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue