mirror of https://github.com/PCSX2/pcsx2.git
newHostVM: More error/exception handling WIP stuff.
git-svn-id: http://pcsx2.googlecode.com/svn/branches/newHostVM@3980 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
b568256653
commit
bd8127f75e
|
@ -209,7 +209,7 @@ public: \
|
||||||
//
|
//
|
||||||
class OutOfMemory : public RuntimeError
|
class OutOfMemory : public RuntimeError
|
||||||
{
|
{
|
||||||
DEFINE_RUNTIME_EXCEPTION( OutOfMemory, RuntimeError, wxLt("Out of memory?!") )
|
DEFINE_RUNTIME_EXCEPTION( OutOfMemory, RuntimeError, wxEmptyString )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxString AllocDescription;
|
wxString AllocDescription;
|
||||||
|
@ -236,7 +236,12 @@ public: \
|
||||||
// we'd really like to have access to.
|
// we'd really like to have access to.
|
||||||
class VirtualMemoryMapConflict : public OutOfMemory
|
class VirtualMemoryMapConflict : public OutOfMemory
|
||||||
{
|
{
|
||||||
DEFINE_RUNTIME_EXCEPTION( VirtualMemoryMapConflict, OutOfMemory, wxLt("Virtual memory map confict: Unable to claim specific required memory regions.") )
|
DEFINE_RUNTIME_EXCEPTION( VirtualMemoryMapConflict, OutOfMemory, wxEmptyString )
|
||||||
|
|
||||||
|
VirtualMemoryMapConflict( const wxString& allocdesc );
|
||||||
|
|
||||||
|
virtual wxString FormatDisplayMessage() const;
|
||||||
|
virtual wxString FormatDiagnosticMessage() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HardwareDeficiency : public RuntimeError
|
class HardwareDeficiency : public RuntimeError
|
||||||
|
|
|
@ -133,6 +133,7 @@ public:
|
||||||
virtual void Free();
|
virtual void Free();
|
||||||
|
|
||||||
bool IsOk() const { return m_baseptr != NULL; }
|
bool IsOk() const { return m_baseptr != NULL; }
|
||||||
|
wxString GetName() const { return Name; }
|
||||||
|
|
||||||
uptr GetReserveSizeInBytes() const { return m_reserved * __pagesize; }
|
uptr GetReserveSizeInBytes() const { return m_reserved * __pagesize; }
|
||||||
uptr GetReserveSizeInPages() const { return m_reserved; }
|
uptr GetReserveSizeInPages() const { return m_reserved; }
|
||||||
|
|
|
@ -31,7 +31,8 @@ SafeArray<T>::SafeArray( const wxChar* name, T* allocated_mem, int initSize )
|
||||||
m_size = initSize;
|
m_size = initSize;
|
||||||
|
|
||||||
if( m_ptr == NULL )
|
if( m_ptr == NULL )
|
||||||
throw Exception::OutOfMemory(name + wxsFormat(L" (SafeArray::constructor) [size=%d]", initSize));
|
throw Exception::OutOfMemory(name)
|
||||||
|
.SetDiagMsg(wxsFormat(L"Called from 'SafeArray::ctor' [size=%d]", initSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
|
@ -79,7 +80,8 @@ SafeArray<T>::SafeArray( int initialSize, const wxChar* name )
|
||||||
m_size = initialSize;
|
m_size = initialSize;
|
||||||
|
|
||||||
if( (initialSize != 0) && (m_ptr == NULL) )
|
if( (initialSize != 0) && (m_ptr == NULL) )
|
||||||
throw Exception::OutOfMemory(name + wxsFormat(L" (SafeArray::constructor) [size=%d]", initialSize));
|
throw Exception::OutOfMemory(name)
|
||||||
|
.SetDiagMsg(wxsFormat(L"Called from 'SafeArray::ctor' [size=%d]", initialSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clears the contents of the array to zero, and frees all memory allocations.
|
// Clears the contents of the array to zero, and frees all memory allocations.
|
||||||
|
@ -106,9 +108,8 @@ void SafeArray<T>::ExactAlloc( int newsize )
|
||||||
|
|
||||||
m_ptr = _virtual_realloc( newsize );
|
m_ptr = _virtual_realloc( newsize );
|
||||||
if( m_ptr == NULL )
|
if( m_ptr == NULL )
|
||||||
throw Exception::OutOfMemory(Name +
|
throw Exception::OutOfMemory(Name)
|
||||||
wxsFormat(L" (SafeArray::ExactAlloc) [oldsize=%d] [newsize=%d]", m_size, newsize)
|
.SetDiagMsg(wxsFormat(L"Called from 'SafeArray::ExactAlloc' [oldsize=%d] [newsize=%d]", m_size, newsize));
|
||||||
);
|
|
||||||
|
|
||||||
m_size = newsize;
|
m_size = newsize;
|
||||||
}
|
}
|
||||||
|
@ -199,9 +200,8 @@ SafeList<T>::SafeList( int initialSize, const wxChar* name )
|
||||||
m_ptr = (T*)malloc( initialSize * sizeof(T) );
|
m_ptr = (T*)malloc( initialSize * sizeof(T) );
|
||||||
|
|
||||||
if( m_ptr == NULL )
|
if( m_ptr == NULL )
|
||||||
throw Exception::OutOfMemory(Name +
|
throw Exception::OutOfMemory(Name)
|
||||||
wxsFormat(L" (SafeList::Constructor) [length=%d]", m_length)
|
.SetDiagMsg(wxsFormat(L"called from 'SafeList::ctor' [length=%d]", m_length));
|
||||||
);
|
|
||||||
|
|
||||||
for( int i=0; i<m_allocsize; ++i )
|
for( int i=0; i<m_allocsize; ++i )
|
||||||
{
|
{
|
||||||
|
@ -227,9 +227,8 @@ void SafeList<T>::MakeRoomFor( int blockSize )
|
||||||
const int newalloc = blockSize + ChunkSize;
|
const int newalloc = blockSize + ChunkSize;
|
||||||
m_ptr = _virtual_realloc( newalloc );
|
m_ptr = _virtual_realloc( newalloc );
|
||||||
if( m_ptr == NULL )
|
if( m_ptr == NULL )
|
||||||
throw Exception::OutOfMemory(Name +
|
throw Exception::OutOfMemory(Name)
|
||||||
wxsFormat(L" (SafeList::MakeRoomFor) [oldlen=%d] [newlen=%d]", m_length, blockSize)
|
.SetDiagMsg(wxsFormat(L"Called from 'SafeList::MakeRoomFor' [oldlen=%d] [newlen=%d]", m_length, blockSize));
|
||||||
);
|
|
||||||
|
|
||||||
for( ; m_allocsize<newalloc; ++m_allocsize )
|
for( ; m_allocsize<newalloc; ++m_allocsize )
|
||||||
{
|
{
|
||||||
|
|
|
@ -195,19 +195,47 @@ Exception::RuntimeError::RuntimeError( const std::exception& ex, const wxString&
|
||||||
Exception::OutOfMemory::OutOfMemory( const wxString& allocdesc )
|
Exception::OutOfMemory::OutOfMemory( const wxString& allocdesc )
|
||||||
{
|
{
|
||||||
AllocDescription = allocdesc;
|
AllocDescription = allocdesc;
|
||||||
m_message_diag = L"Out of memory exception, while allocating the %s.";
|
|
||||||
m_message_user = _("Memory allocation failure! Your system has insufficient memory or resources to meet PCSX2's lofty needs.");
|
m_message_user = _("Memory allocation failure! Your system has insufficient memory or resources to meet PCSX2's lofty needs.");
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Exception::OutOfMemory::FormatDiagnosticMessage() const
|
wxString Exception::OutOfMemory::FormatDiagnosticMessage() const
|
||||||
{
|
{
|
||||||
return wxsFormat(m_message_diag, AllocDescription.c_str());
|
FastFormatUnicode details;
|
||||||
|
if (!m_message_diag.IsEmpty())
|
||||||
|
details.Write(":\n%s",m_message_diag.c_str());
|
||||||
|
|
||||||
|
return pxsFmt(L"Out of memory while allocating '%s'%s", AllocDescription.c_str(), details.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Exception::OutOfMemory::FormatDisplayMessage() const
|
wxString Exception::OutOfMemory::FormatDisplayMessage() const
|
||||||
{
|
{
|
||||||
if (m_message_user.IsEmpty()) return FormatDisplayMessage();
|
if (m_message_user.IsEmpty()) return FormatDisplayMessage();
|
||||||
return m_message_user + pxsFmt( L"\n\nInternal allocation descriptor: %s", AllocDescription.c_str());
|
return m_message_user;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------
|
||||||
|
// Exception::VirtualMemoryMapConflict (implementations)
|
||||||
|
// --------------------------------------------------------------------------------------
|
||||||
|
Exception::VirtualMemoryMapConflict::VirtualMemoryMapConflict( const wxString& allocdesc )
|
||||||
|
{
|
||||||
|
AllocDescription = allocdesc;
|
||||||
|
m_message_user = _("Virtual memory mapping failure! Your system may have conflicting device drivers, services, or may simply have insufficient memory or resources to meet PCSX2's lofty needs.");
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString Exception::VirtualMemoryMapConflict::FormatDiagnosticMessage() const
|
||||||
|
{
|
||||||
|
FastFormatUnicode details;
|
||||||
|
if (!m_message_diag.IsEmpty())
|
||||||
|
details.Write(":\n%s",m_message_diag.c_str());
|
||||||
|
|
||||||
|
return pxsFmt(L"Out of virtual memory while reserving '%s'%s", AllocDescription.c_str(), details.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString Exception::VirtualMemoryMapConflict::FormatDisplayMessage() const
|
||||||
|
{
|
||||||
|
if (m_message_user.IsEmpty()) return FormatDisplayMessage();
|
||||||
|
return m_message_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -595,7 +595,8 @@ void memAlloc()
|
||||||
eeMem = (EEVM_MemoryAllocMess*)vtlb_malloc( sizeof(*eeMem), 4096 );
|
eeMem = (EEVM_MemoryAllocMess*)vtlb_malloc( sizeof(*eeMem), 4096 );
|
||||||
|
|
||||||
if( eeMem == NULL)
|
if( eeMem == NULL)
|
||||||
throw Exception::OutOfMemory( L"memAlloc > failed to allocate PS2's base ram/rom/scratchpad." );
|
throw Exception::OutOfMemory( L"PS2 Main Memory (VTLB)" )
|
||||||
|
.SetUserMsg(L"Could not allocate memory needed for the PS2 virtual machine's main memory (approx. 42mb).");
|
||||||
|
|
||||||
pxAssume(Source_PageFault);
|
pxAssume(Source_PageFault);
|
||||||
mmap_faultHandler = new mmap_PageFaultHandler();
|
mmap_faultHandler = new mmap_PageFaultHandler();
|
||||||
|
|
|
@ -531,8 +531,9 @@ bool Pcsx2App::OnInit()
|
||||||
g_Conf = new AppConfig();
|
g_Conf = new AppConfig();
|
||||||
wxInitAllImageHandlers();
|
wxInitAllImageHandlers();
|
||||||
|
|
||||||
Console.WriteLn("Begin parsing commandline...");
|
Console.WriteLn("Command line parsing...");
|
||||||
if( !_parent::OnInit() ) return false;
|
if( !_parent::OnInit() ) return false;
|
||||||
|
Console.WriteLn("Command line parsed!");
|
||||||
|
|
||||||
wxLocale::AddCatalogLookupPathPrefix( wxGetCwd() );
|
wxLocale::AddCatalogLookupPathPrefix( wxGetCwd() );
|
||||||
|
|
||||||
|
|
|
@ -577,7 +577,7 @@ static void recReserveCache()
|
||||||
|
|
||||||
if (!recMem->IsOk())
|
if (!recMem->IsOk())
|
||||||
{
|
{
|
||||||
throw Exception::VirtualMemoryMapConflict()
|
throw Exception::VirtualMemoryMapConflict(recMem->GetName())
|
||||||
.SetDiagMsg(pxsFmt( L"R5900-32 recompiled code cache could not be mapped." ))
|
.SetDiagMsg(pxsFmt( L"R5900-32 recompiled code cache could not be mapped." ))
|
||||||
.SetUserMsg(GetMsg_RecVmFailed("R5900-32"));
|
.SetUserMsg(GetMsg_RecVmFailed("R5900-32"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -357,7 +357,7 @@ static void SuperVUAlloc(int vuindex)
|
||||||
if (!s_recVUMem[vuindex]->IsOk())
|
if (!s_recVUMem[vuindex]->IsOk())
|
||||||
{
|
{
|
||||||
safe_delete(s_recVUMem[vuindex]);
|
safe_delete(s_recVUMem[vuindex]);
|
||||||
throw Exception::VirtualMemoryMapConflict()
|
throw Exception::VirtualMemoryMapConflict( s_recVUMem[vuindex]->GetName() )
|
||||||
.SetDiagMsg(pxsFmt( L"SuperVU failed to allocate virtual memory below 256MB." ))
|
.SetDiagMsg(pxsFmt( L"SuperVU failed to allocate virtual memory below 256MB." ))
|
||||||
.SetUserMsg(pxE( ".Error:superVU:VirtualMemoryAlloc",
|
.SetUserMsg(pxE( ".Error:superVU:VirtualMemoryAlloc",
|
||||||
L"Out of Memory (sorta): The SuperVU recompiler was unable to reserve the specific memory "
|
L"Out of Memory (sorta): The SuperVU recompiler was unable to reserve the specific memory "
|
||||||
|
|
Loading…
Reference in New Issue