2009-09-08 12:08:10 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
|
|
|
* Copyright (C) 2002-2009 PCSX2 Dev Team
|
|
|
|
*
|
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2009-04-27 02:04:31 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is distributed in the hope that 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.
|
2009-04-28 05:56:22 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-04-27 02:04:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PrecompiledHeader.h"
|
|
|
|
|
|
|
|
wxString GetEnglish( const char* msg )
|
|
|
|
{
|
2009-07-14 06:18:52 +00:00
|
|
|
return wxString::FromAscii(msg);
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString GetTranslation( const char* msg )
|
|
|
|
{
|
|
|
|
return wxGetTranslation( wxString::FromAscii(msg).c_str() );
|
|
|
|
}
|
|
|
|
|
2009-09-12 02:58:22 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// 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::LogicError( msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
namespace Exception
|
|
|
|
{
|
|
|
|
BaseException::~BaseException() throw() {}
|
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
void BaseException::InitBaseEx( const wxString& msg_eng, const wxString& msg_xlt )
|
2009-04-27 02:04:31 +00:00
|
|
|
{
|
2009-09-01 00:43:28 +00:00
|
|
|
m_message_diag = msg_eng;
|
|
|
|
m_message_user = msg_xlt;
|
|
|
|
|
2009-07-20 00:39:38 +00:00
|
|
|
// Linux/GCC exception handling is still suspect (this is likely to do with GCC more
|
|
|
|
// than linux), and fails to propagate exceptions up the stack from EErec code. This
|
|
|
|
// could likely be because of the EErec using EBP. So to ensure the user at least
|
|
|
|
// gets a log of the error, we output to console here in the constructor.
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
#ifdef __LINUX__
|
2009-07-20 00:39:38 +00:00
|
|
|
//wxLogError( msg_eng.c_str() );
|
|
|
|
Console::Error( msg_eng );
|
2009-04-27 02:04:31 +00:00
|
|
|
#endif
|
|
|
|
}
|
2009-04-28 05:56:22 +00:00
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// given message is assumed to be a translation key, and will be stored in translated
|
|
|
|
// and untranslated forms.
|
2009-09-01 00:43:28 +00:00
|
|
|
void BaseException::InitBaseEx( const char* msg_eng )
|
2009-04-27 02:04:31 +00:00
|
|
|
{
|
2009-09-01 00:43:28 +00:00
|
|
|
m_message_diag = GetEnglish( msg_eng );
|
|
|
|
m_message_user = GetTranslation( msg_eng );
|
|
|
|
|
2009-07-20 00:39:38 +00:00
|
|
|
#ifdef __LINUX__
|
2009-09-01 00:43:28 +00:00
|
|
|
//wxLogError( m_message_diag.c_str() );
|
2009-07-20 00:39:38 +00:00
|
|
|
Console::Error( msg_eng );
|
|
|
|
#endif
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString BaseException::FormatDiagnosticMessage() const
|
2009-04-27 02:04:31 +00:00
|
|
|
{
|
2009-09-01 00:43:28 +00:00
|
|
|
return m_message_diag + L"\n\n" + m_stacktrace;
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString Stream::FormatDiagnosticMessage() const
|
2009-04-27 02:04:31 +00:00
|
|
|
{
|
|
|
|
return wxsFormat(
|
2009-09-16 17:23:02 +00:00
|
|
|
L"Stream exception: %s\n\tFile/Object: %s",
|
2009-09-01 00:43:28 +00:00
|
|
|
m_message_diag.c_str(), StreamName.c_str()
|
2009-04-27 02:04:31 +00:00
|
|
|
) + m_stacktrace;
|
|
|
|
}
|
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString Stream::FormatDisplayMessage() const
|
2009-04-27 02:04:31 +00:00
|
|
|
{
|
2009-09-16 17:23:02 +00:00
|
|
|
return m_message_user + L"\n\n" +
|
|
|
|
wxsFormat( _("Name: %s"), StreamName.c_str() );
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString UnsupportedStateVersion::FormatDiagnosticMessage() const
|
2009-04-27 02:04:31 +00:00
|
|
|
{
|
|
|
|
// Note: no stacktrace needed for this one...
|
2009-05-01 02:15:18 +00:00
|
|
|
return wxsFormat( L"Unknown or unsupported savestate version: 0x%x", Version );
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString UnsupportedStateVersion::FormatDisplayMessage() const
|
2009-04-27 02:04:31 +00:00
|
|
|
{
|
2009-09-01 00:43:28 +00:00
|
|
|
// m_message_user contains a recoverable savestate error which is helpful to the user.
|
2009-04-27 02:04:31 +00:00
|
|
|
return wxsFormat(
|
2009-09-01 00:43:28 +00:00
|
|
|
m_message_user + L"\n\n" +
|
2009-08-31 03:47:05 +00:00
|
|
|
wxsFormat( _("Cannot load savestate. It is of an unknown or unsupported version."), Version )
|
2009-04-27 02:04:31 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString StateCrcMismatch::FormatDiagnosticMessage() const
|
2009-04-27 02:04:31 +00:00
|
|
|
{
|
|
|
|
// Note: no stacktrace needed for this one...
|
|
|
|
return wxsFormat(
|
2009-05-01 02:15:18 +00:00
|
|
|
L"Game/CDVD does not match the savestate CRC.\n"
|
|
|
|
L"\tCdvd CRC: 0x%X\n\tGame CRC: 0x%X\n",
|
2009-04-27 02:04:31 +00:00
|
|
|
Crc_Savestate, Crc_Cdvd
|
|
|
|
);
|
|
|
|
}
|
2009-04-28 05:56:22 +00:00
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString StateCrcMismatch::FormatDisplayMessage() const
|
2009-04-27 02:04:31 +00:00
|
|
|
{
|
|
|
|
return wxsFormat(
|
2009-09-01 00:43:28 +00:00
|
|
|
m_message_user + L"\n\n" +
|
2009-05-01 02:15:18 +00:00
|
|
|
wxsFormat(
|
|
|
|
L"Savestate game/crc mismatch. Cdvd CRC: 0x%X Game CRC: 0x%X\n",
|
2009-04-27 02:04:31 +00:00
|
|
|
Crc_Savestate, Crc_Cdvd
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2009-04-28 05:56:22 +00:00
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString IndexBoundsFault::FormatDiagnosticMessage() const
|
2009-04-27 02:04:31 +00:00
|
|
|
{
|
2009-05-01 02:15:18 +00:00
|
|
|
return L"Index out of bounds on SafeArray: " + ArrayName +
|
|
|
|
wxsFormat( L"(index=%d, size=%d)", BadIndex, ArrayLength );
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString IndexBoundsFault::FormatDisplayMessage() const
|
2009-04-27 02:04:31 +00:00
|
|
|
{
|
2009-09-01 00:43:28 +00:00
|
|
|
return m_message_user;
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
}
|