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
|
||||
{
|
||||
DEFINE_RUNTIME_EXCEPTION( OutOfMemory, RuntimeError, wxLt("Out of memory?!") )
|
||||
DEFINE_RUNTIME_EXCEPTION( OutOfMemory, RuntimeError, wxEmptyString )
|
||||
|
||||
public:
|
||||
wxString AllocDescription;
|
||||
|
@ -236,7 +236,12 @@ public: \
|
|||
// we'd really like to have access to.
|
||||
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
|
||||
|
|
|
@ -133,7 +133,8 @@ public:
|
|||
virtual void Free();
|
||||
|
||||
bool IsOk() const { return m_baseptr != NULL; }
|
||||
|
||||
wxString GetName() const { return Name; }
|
||||
|
||||
uptr GetReserveSizeInBytes() const { return m_reserved * __pagesize; }
|
||||
uptr GetReserveSizeInPages() const { return m_reserved; }
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ SafeArray<T>::SafeArray( const wxChar* name, T* allocated_mem, int initSize )
|
|||
m_size = initSize;
|
||||
|
||||
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 >
|
||||
|
@ -79,7 +80,8 @@ SafeArray<T>::SafeArray( int initialSize, const wxChar* name )
|
|||
m_size = initialSize;
|
||||
|
||||
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.
|
||||
|
@ -106,9 +108,8 @@ void SafeArray<T>::ExactAlloc( int newsize )
|
|||
|
||||
m_ptr = _virtual_realloc( newsize );
|
||||
if( m_ptr == NULL )
|
||||
throw Exception::OutOfMemory(Name +
|
||||
wxsFormat(L" (SafeArray::ExactAlloc) [oldsize=%d] [newsize=%d]", m_size, newsize)
|
||||
);
|
||||
throw Exception::OutOfMemory(Name)
|
||||
.SetDiagMsg(wxsFormat(L"Called from 'SafeArray::ExactAlloc' [oldsize=%d] [newsize=%d]", 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) );
|
||||
|
||||
if( m_ptr == NULL )
|
||||
throw Exception::OutOfMemory(Name +
|
||||
wxsFormat(L" (SafeList::Constructor) [length=%d]", m_length)
|
||||
);
|
||||
throw Exception::OutOfMemory(Name)
|
||||
.SetDiagMsg(wxsFormat(L"called from 'SafeList::ctor' [length=%d]", m_length));
|
||||
|
||||
for( int i=0; i<m_allocsize; ++i )
|
||||
{
|
||||
|
@ -227,9 +227,8 @@ void SafeList<T>::MakeRoomFor( int blockSize )
|
|||
const int newalloc = blockSize + ChunkSize;
|
||||
m_ptr = _virtual_realloc( newalloc );
|
||||
if( m_ptr == NULL )
|
||||
throw Exception::OutOfMemory(Name +
|
||||
wxsFormat(L" (SafeList::MakeRoomFor) [oldlen=%d] [newlen=%d]", m_length, blockSize)
|
||||
);
|
||||
throw Exception::OutOfMemory(Name)
|
||||
.SetDiagMsg(wxsFormat(L"Called from 'SafeList::MakeRoomFor' [oldlen=%d] [newlen=%d]", m_length, blockSize));
|
||||
|
||||
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 )
|
||||
{
|
||||
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.");
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
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 );
|
||||
|
||||
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);
|
||||
mmap_faultHandler = new mmap_PageFaultHandler();
|
||||
|
|
|
@ -531,8 +531,9 @@ bool Pcsx2App::OnInit()
|
|||
g_Conf = new AppConfig();
|
||||
wxInitAllImageHandlers();
|
||||
|
||||
Console.WriteLn("Begin parsing commandline...");
|
||||
Console.WriteLn("Command line parsing...");
|
||||
if( !_parent::OnInit() ) return false;
|
||||
Console.WriteLn("Command line parsed!");
|
||||
|
||||
wxLocale::AddCatalogLookupPathPrefix( wxGetCwd() );
|
||||
|
||||
|
|
|
@ -577,7 +577,7 @@ static void recReserveCache()
|
|||
|
||||
if (!recMem->IsOk())
|
||||
{
|
||||
throw Exception::VirtualMemoryMapConflict()
|
||||
throw Exception::VirtualMemoryMapConflict(recMem->GetName())
|
||||
.SetDiagMsg(pxsFmt( L"R5900-32 recompiled code cache could not be mapped." ))
|
||||
.SetUserMsg(GetMsg_RecVmFailed("R5900-32"));
|
||||
}
|
||||
|
|
|
@ -357,7 +357,7 @@ static void SuperVUAlloc(int vuindex)
|
|||
if (!s_recVUMem[vuindex]->IsOk())
|
||||
{
|
||||
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." ))
|
||||
.SetUserMsg(pxE( ".Error:superVU:VirtualMemoryAlloc",
|
||||
L"Out of Memory (sorta): The SuperVU recompiler was unable to reserve the specific memory "
|
||||
|
|
Loading…
Reference in New Issue