mirror of https://github.com/PCSX2/pcsx2.git
Added a new function "DevAssert", which is intended to provide assert-like functionality to Devel builds of Pcsx2. Developers: Check the code comments for more details.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1417 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
101dbdd132
commit
ed89876ba6
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
extern void DevAssert( bool condition, const char* msg );
|
||||||
|
|
||||||
// This class provides an easy and clean method for ensuring objects are not copyable.
|
// This class provides an easy and clean method for ensuring objects are not copyable.
|
||||||
class NoncopyableObject
|
class NoncopyableObject
|
||||||
{
|
{
|
||||||
|
@ -121,6 +123,14 @@ namespace Exception
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AssertionFailure : public LogicError
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit AssertionFailure( const std::string& msg="Assertion Failure" ) :
|
||||||
|
LogicError( msg ) {}
|
||||||
|
virtual ~AssertionFailure() throw() {}
|
||||||
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
class OutOfMemory : public RuntimeError
|
class OutOfMemory : public RuntimeError
|
||||||
|
|
|
@ -139,6 +139,40 @@ const char *LabelGreets = { N_(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Force DevAssert to *not* inline for devel/debug builds (allows using breakpoints to trap
|
||||||
|
// assertions), and force it to inline for release builds (optimizes it out completely since
|
||||||
|
// IsDevBuild is false). Since Devel builds typically aren't enabled with Global Optimization/
|
||||||
|
// LTCG, this currently isn't even necessary. But might as well, in case we decide at a later
|
||||||
|
// date to re-enable LTCG for devel.
|
||||||
|
#ifdef PCSX2_DEVBUILD
|
||||||
|
# define DEVASSERT_INLINE __noinline
|
||||||
|
#else
|
||||||
|
# define DEVASSERT_INLINE __forceinline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Assertion tool for Devel builds, intended for sanity checking and/or bounds checking
|
||||||
|
// variables in areas which are not performance critical.
|
||||||
|
//
|
||||||
|
// How it works: This function throws an exception of type Exception::AssertionFailure if
|
||||||
|
// the assertion conditional is false. Typically for the end-user, this exception is handled
|
||||||
|
// by the general handler, which (should eventually) create some state dumps and other
|
||||||
|
// information for troubleshooting purposes.
|
||||||
|
//
|
||||||
|
// From a debugging environment, you can trap your DevAssert by either breakpointing the
|
||||||
|
// exception throw below, or by adding either Exception::AssertionFailure or
|
||||||
|
// Exception::LogicError to your First-Chance Exception catch list (Visual Studio, under
|
||||||
|
// the Debug->Exceptions menu/dialog).
|
||||||
|
//
|
||||||
|
DEVASSERT_INLINE void DevAssert( bool condition, const char* msg )
|
||||||
|
{
|
||||||
|
if( IsDevBuild && !condition )
|
||||||
|
{
|
||||||
|
throw Exception::AssertionFailure( msg );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u32 GetBiosVersion() {
|
u32 GetBiosVersion() {
|
||||||
unsigned int fileOffset=0;
|
unsigned int fileOffset=0;
|
||||||
s8 *ROMVER;
|
s8 *ROMVER;
|
||||||
|
|
|
@ -150,12 +150,13 @@ typedef int BOOL;
|
||||||
#endif // ENABLE_NLS
|
#endif // ENABLE_NLS
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Forceinline macro that is enabled for RELEASE/PUBLIC builds ONLY. (non-inline in devel)
|
// Forceinline macro that is enabled for RELEASE/PUBLIC builds ONLY. (compiler-picked in devel)
|
||||||
// This is useful because forceinline can make certain types of debugging problematic since
|
// This is useful because forceinline can make certain types of debugging problematic since
|
||||||
// functions that look like they should be called won't breakpoint since their code is inlined.
|
// functions that look like they should be called won't breakpoint since their code is inlined.
|
||||||
// Henceforth, use release_inline for things which we want inlined on public/release builds but
|
// Henceforth, use __releaseinline for things which are generally large functions where trace
|
||||||
// *not* in devel builds.
|
// debugging from Devel builds is likely useful; but which should be inlined in an optimized
|
||||||
|
// Release environment.
|
||||||
|
//
|
||||||
#ifdef PCSX2_DEVBUILD
|
#ifdef PCSX2_DEVBUILD
|
||||||
# define __releaseinline
|
# define __releaseinline
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue