newHostVM: Linux fixes.

* Removed some missing / obsolete files from codeblocks projects.
 * Fixed a segfault on exit
 * Implemented a platform-consistent pointer value string formatter (%p has no defined standard)

git-svn-id: http://pcsx2.googlecode.com/svn/branches/newHostVM@4026 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-11-17 03:18:36 +00:00
parent 63b254c8bd
commit 0692ab1bc5
10 changed files with 85 additions and 60 deletions

View File

@ -42,7 +42,7 @@ static void SysPageFaultSignalFilter( int signal, siginfo_t *siginfo, void * )
// be safe even on the main thread.
// (in other words, stdio limitations only really apply to process-level asynchronous
// signals)
// Note: Use of stdio functions isn't safe here. Avoid console logs,
// assertions, file logs, or just about anything else useful.
@ -106,7 +106,7 @@ static bool _memprotect( void* baseaddr, size_t size, const PageProtectionMode&
const int result = mprotect( baseaddr, size, lnxmode );
if (result == 0) return true;
switch(errno)
{
case EINVAL:
@ -114,7 +114,7 @@ static bool _memprotect( void* baseaddr, size_t size, const PageProtectionMode&
baseaddr, (uptr)baseaddr+size, mode.ToString().c_str())
);
break;
case EACCES:
pxFailDev(pxsFmt(L"mprotect returned EACCES @ 0x%08X -> 0x%08X (mode=%s)",
baseaddr, (uptr)baseaddr+size, mode.ToString().c_str())
@ -201,6 +201,7 @@ void* HostSys::Mmap(uptr base, size_t size)
void HostSys::Munmap(uptr base, size_t size)
{
if (!base) return;
munmap((void*)base, size);
}

View File

@ -14,15 +14,16 @@
*/
#include "PrecompiledHeader.h"
#include "PageFaultSource.h"
#include "EventSource.inl"
#include "MemsetFast.inl"
#ifndef __WXMSW__
#include <wx/thread.h>
#endif
#include "EventSource.inl"
#include "MemsetFast.inl"
#include "TlsVariable.inl"
template class EventSource< IEventListener_PageFault >;
SrcType_PageFault* Source_PageFault = NULL;
@ -90,7 +91,7 @@ VirtualMemoryReserve& VirtualMemoryReserve::SetName( const wxString& newname )
VirtualMemoryReserve& VirtualMemoryReserve::SetBaseAddr( uptr newaddr )
{
if (!pxAssertDev(!m_pages_reserved, "Invalid object state: you must release the virtual memory reserve prior to changing its base address!")) return *this;
m_baseptr = (void*)newaddr;
return *this;
}
@ -101,6 +102,34 @@ VirtualMemoryReserve& VirtualMemoryReserve::SetPageAccessOnCommit( const PagePro
return *this;
}
template< uint T >
struct pxMiniCharBuffer
{
wxChar chars[T];
pxMiniCharBuffer() {}
};
// Rational for this function: %p behavior is undefined, and not well-implemented in most cases.
// MSVC doesn't prefix 0x, and Linux doesn't pad with zeros. (furthermore, 64-bit formatting is unknown
// and has even more room for variation and confusion). As is typical, we need portability, and so this
// isn't really acceptable. So here's a portable version!
const wxChar* pxPtrToString( void* ptr )
{
static Threading::TlsVariable< pxMiniCharBuffer < 32 > > buffer;
#ifdef __x86_64__
wxSnprintf( buffer->chars, 31, wxT("0x%08X.%08X"), ptr );
#else
wxSnprintf( buffer->chars, 31, wxT("0x%08X"), ptr );
#endif
return buffer->chars;
}
const wxChar* pxPtrToString( uptr ptr )
{
pxPtrToString( (void*)ptr );
}
// Notes:
// * This method should be called if the object is already in an released (unreserved) state.
@ -129,8 +158,8 @@ void* VirtualMemoryReserve::Reserve( size_t size, uptr base, uptr upper_bounds )
if (!m_baseptr || (upper_bounds != 0 && (((uptr)m_baseptr + reserved_bytes) > upper_bounds)))
{
DevCon.Warning( L"%s: host memory @ 0x%08x -> 0x%08x is unavailable; attempting to map elsewhere...",
m_name.c_str(), base, base + size );
DevCon.Warning( L"%s: host memory @ %s -> %s is unavailable; attempting to map elsewhere...",
m_name.c_str(), pxPtrToString(base), pxPtrToString(base + size) );
SafeSysMunmap(m_baseptr, reserved_bytes);
@ -141,7 +170,7 @@ void* VirtualMemoryReserve::Reserve( size_t size, uptr base, uptr upper_bounds )
m_baseptr = HostSys::MmapReserve( 0, reserved_bytes );
}
}
if ((upper_bounds != 0) && (((uptr)m_baseptr + reserved_bytes) > upper_bounds))
{
SafeSysMunmap(m_baseptr, reserved_bytes);
@ -157,8 +186,8 @@ void* VirtualMemoryReserve::Reserve( size_t size, uptr base, uptr upper_bounds )
else
mbkb.Write( "[%ukb]", reserved_bytes / 1024 );
DevCon.WriteLn( Color_Gray, L"%-32s @ 0x%08p -> 0x%08p %s", m_name.c_str(),
m_baseptr, (uptr)m_baseptr+reserved_bytes, mbkb.c_str());
DevCon.WriteLn( Color_Gray, L"%-32s @ %s -> %s %s", m_name.c_str(),
pxPtrToString(m_baseptr), pxPtrToString((uptr)m_baseptr+reserved_bytes), mbkb.c_str());
return m_baseptr;
}
@ -213,16 +242,16 @@ bool VirtualMemoryReserve::TryResize( uint newsize )
if (!m_baseptr)
{
Console.Warning("%-32s could not be passively resized due to virtual memory conflict!");
Console.Indent().Warning("(attempted to map memory @ 0x%08p -> 0x%08p", m_baseptr, (uptr)m_baseptr+toReserveBytes);
Console.Indent().Warning("(attempted to map memory @ %08p -> %08p)", m_baseptr, (uptr)m_baseptr+toReserveBytes);
}
DevCon.WriteLn( Color_Gray, L"%-32s @ 0x%08p -> 0x%08p [%umb]", m_name.c_str(),
DevCon.WriteLn( Color_Gray, L"%-32s @ %08p -> %08p [%umb]", m_name.c_str(),
m_baseptr, (uptr)m_baseptr+toReserveBytes, toReserveBytes / _1mb);
}
else if (newPages < m_pages_reserved)
{
if (m_pages_commited > newsize) return false;
uint toRemovePages = m_pages_reserved - newPages;
uint toRemoveBytes = toRemovePages * __pagesize;
@ -230,10 +259,10 @@ bool VirtualMemoryReserve::TryResize( uint newsize )
HostSys::MmapResetPtr(GetPtrEnd(), toRemoveBytes);
DevCon.WriteLn( Color_Gray, L"%-32s @ 0x%08p -> 0x%08p [%umb]", m_name.c_str(),
DevCon.WriteLn( Color_Gray, L"%-32s @ %08p -> %08p [%umb]", m_name.c_str(),
m_baseptr, (uptr)m_baseptr+toRemoveBytes, toRemoveBytes / _1mb);
}
return true;
}
@ -274,7 +303,7 @@ void BaseVmReserveListener::OnPageFaultEvent(const PageFaultInfo& info, bool& ha
sptr offset = (info.addr - (uptr)m_baseptr) / __pagesize;
if ((offset < 0) || ((uptr)offset >= m_pages_reserved)) return;
// Linux Note! the SIGNAL handler is very limited in what it can do, and not only can't
// Linux Note! the SIGNAL handler is very limited in what it can do, and not only can't
// we let the C++ exception try to unwind the stack, we may not be able to log it either.
// (but we might as well try -- kernel/posix rules says not to do it, but Linux kernel
// implementations seem to support it).
@ -358,7 +387,7 @@ void SpatialArrayReserve::Reset()
}
// Important! The number of blocks of the array will be altered when using this method.
//
//
bool SpatialArrayReserve::TryResize( uint newsize )
{
uint newpages = (newsize + __pagesize - 1) / __pagesize;
@ -376,11 +405,11 @@ bool SpatialArrayReserve::TryResize( uint newsize )
if (newpages < pages_in_use) return false;
if (!_parent::TryResize( newsize )) return false;
// On success, we must re-calibrate the internal blockbits array.
m_blockbits.Resize( (m_numblocks + 7) / 8 );
return true;
}
@ -399,7 +428,7 @@ SpatialArrayReserve& SpatialArrayReserve::SetBlockCount( uint blocks )
m_numblocks = blocks;
m_blocksize = (m_pages_reserved + m_numblocks-1) / m_numblocks;
return *this;
}
@ -434,7 +463,7 @@ void SpatialArrayReserve::DoCommitAndProtect( uptr page )
{
// Spatial Arrays work on block granularity only:
// Round the page into a block, and commit the whole block that the page belongs to.
uint block = page / m_blocksize;
CommitBlocks(block*m_blocksize, 1);
}
@ -442,12 +471,12 @@ void SpatialArrayReserve::DoCommitAndProtect( uptr page )
void SpatialArrayReserve::OnCommittedBlock( void* block )
{
// Determine the block position in the blockbits array, flag it, and be done!
uptr relative = (uptr)block - (uptr)m_baseptr;
relative /= m_blocksize * __pagesize;
//DbgCon.WriteLn("Check me out @ 0x%08x", block);
pxAssert( (m_blockbits[relative/8] & (1 << (relative & 7))) == 0 );
m_blockbits[relative/8] |= 1 << (relative & 7);
}

View File

@ -268,9 +268,7 @@
<Unit filename="../DebugTools/DisVUmicro.h" />
<Unit filename="../DebugTools/DisVUops.h" />
<Unit filename="../Dmac.h" />
<Unit filename="../Docs/ChangeLog.txt" />
<Unit filename="../Docs/License.txt" />
<Unit filename="../Docs/devblog.txt" />
<Unit filename="../Dump.cpp" />
<Unit filename="../Dump.h" />
<Unit filename="../Elfheader.cpp" />
@ -316,7 +314,6 @@
<Unit filename="../IopMem.h" />
<Unit filename="../IopSio2.cpp" />
<Unit filename="../IopSio2.h" />
<Unit filename="../Ipu_fifo.h" />
<Unit filename="LnxKeyCodes.cpp">
<Option compiler="gcc" use="1" buildCommand="$compiler $options $includes `pkg-config gtk+-2.0 --cflags` -c $file -o $object" />
</Unit>
@ -362,14 +359,13 @@
<Unit filename="../SourceLog.cpp" />
<Unit filename="../Stats.cpp" />
<Unit filename="../Stats.h" />
<Unit filename="../StringUtils.h" />
<Unit filename="../SysForwardDefs.h" />
<Unit filename="../System.cpp" />
<Unit filename="../System.h" />
<Unit filename="../System/RecTypes.h" />
<Unit filename="../System/SysCoreThread.cpp" />
<Unit filename="../System/SysThreadBase.cpp" />
<Unit filename="../System/SysThreads.h" />
<Unit filename="../System/RecTypes.h" />
<Unit filename="../Utilities/AsciiFile.h" />
<Unit filename="../Utilities/FileUtils.cpp" />
<Unit filename="../Utilities/folderdesc.txt" />
@ -420,7 +416,6 @@
<Unit filename="../gui/AppRes.cpp" />
<Unit filename="../gui/AppSaveStates.h" />
<Unit filename="../gui/ApplyState.h" />
<Unit filename="../gui/CheckedStaticBox.h" />
<Unit filename="../gui/ConsoleLogger.cpp" />
<Unit filename="../gui/ConsoleLogger.h" />
<Unit filename="../gui/CpuUsageProvider.cpp" />
@ -448,7 +443,6 @@
<Unit filename="../gui/Dialogs/StuckThreadDialog.cpp" />
<Unit filename="../gui/Dialogs/SysConfigDialog.cpp" />
<Unit filename="../gui/ExecutorThread.cpp" />
<Unit filename="../gui/ExecutorThread.h" />
<Unit filename="../gui/FrameForGS.cpp" />
<Unit filename="../gui/GlobalCommands.cpp" />
<Unit filename="../gui/IsoDropTarget.cpp" />
@ -465,7 +459,6 @@
<Unit filename="../gui/MessageBoxes.cpp" />
<Unit filename="../gui/Panels/AudioPanel.cpp" />
<Unit filename="../gui/Panels/BaseApplicableConfigPanel.cpp" />
<Unit filename="../gui/Panels/BaseConfigPanel.h" />
<Unit filename="../gui/Panels/BiosSelectorPanel.cpp" />
<Unit filename="../gui/Panels/ConfigurationPanels.h" />
<Unit filename="../gui/Panels/CpuPanel.cpp" />
@ -571,10 +564,8 @@
<Unit filename="../gui/Saveslots.cpp" />
<Unit filename="../gui/SysState.cpp" />
<Unit filename="../gui/UpdateUI.cpp" />
<Unit filename="../gui/gsFrame.h" />
<Unit filename="../gui/i18n.cpp" />
<Unit filename="../gui/i18n.h" />
<Unit filename="../gui/pxEvtThread.h" />
<Unit filename="../gui/pxLogTextCtrl.cpp" />
<Unit filename="../ps2/BiosTools.cpp" />
<Unit filename="../ps2/BiosTools.h" />

View File

@ -193,7 +193,7 @@ void ConsoleLogFrame::ColorArray::Create( int fontsize )
new (&m_table[Color_StrongCyan]) wxTextAttr( wxNullColour, wxNullColour, fixedB );
new (&m_table[Color_StrongYellow]) wxTextAttr( wxNullColour, wxNullColour, fixedB );
new (&m_table[Color_StrongWhite]) wxTextAttr( wxNullColour, wxNullColour, fixedB );
SetColorScheme_Light();
}
@ -281,10 +281,10 @@ enum MenuIDs_t
MenuId_FontSize_Normal,
MenuId_FontSize_Large,
MenuId_FontSize_Huge,
MenuId_ColorScheme_Light = 0x20,
MenuId_ColorScheme_Dark,
MenuId_LogSource_EnableAll = 0x30,
MenuId_LogSource_DisableAll,
MenuId_LogSource_Devel,
@ -322,7 +322,7 @@ public:
}
};
static ConsoleLogSource* const ConLogSources[] =
static ConsoleLogSource* const ConLogSources[] =
{
(ConsoleLogSource*)&SysConsole.eeConsole,
(ConsoleLogSource*)&SysConsole.iopConsole,
@ -334,7 +334,7 @@ static ConsoleLogSource* const ConLogSources[] =
(ConsoleLogSource*)&pxConLog_Thread,
};
static const bool ConLogDefaults[] =
static const bool ConLogDefaults[] =
{
true,
true,
@ -437,7 +437,7 @@ ConsoleLogFrame::ConsoleLogFrame( MainEmuFrame *parent, const wxString& title, A
menuSources.Append( MenuId_LogSource_Devel, _("Dev/Verbose"), _("Shows PCSX2 developer logs"), wxITEM_CHECK );
menuSources.AppendSeparator();
uint srcnt = ArraySize(ConLogSources);
for (uint i=0; i<srcnt; ++i)
{
@ -609,7 +609,7 @@ bool ConsoleLogFrame::Write( ConsoleColors color, const wxString& text )
{
// Too many color changes causes huge slowdowns when decorating the rich textview, so
// include a secondary check to avoid having a colorful log spam killing gui responsiveness.
if( m_CurQueuePos > 0x100000 || m_QueueColorSection.GetLength() > 256 )
{
++m_WaitingThreadsForFlush;
@ -629,7 +629,7 @@ bool ConsoleLogFrame::Write( ConsoleColors color, const wxString& text )
if( m_WaitingThreadsForFlush != 0 ) --m_WaitingThreadsForFlush;
}
}
return false;
}
@ -790,7 +790,7 @@ void ConsoleLogFrame::OnToggleSource( wxCommandEvent& evt )
if (!pxAssertDev( ArraySize(ConLogSources) > srcid, "Invalid source log index (out of bounds)" )) return;
if (!pxAssertDev( ConLogSources[srcid] != NULL, "Invalid source log index (NULL pointer [separator])" )) return;
if( wxMenuItem* item = GetMenuBar()->FindItem(evt.GetId()) )
{
pxAssertDev( item->IsCheckable(), "Uncheckable log source menu item? Seems fishy!" );
@ -926,7 +926,7 @@ void ConsoleLogFrame::DoFlushQueue()
// cap at 512k for now...
// fixme - 512k runs well on win32 but appears to be very sluggish on linux (but that could
// be a result of my using Xming + CoLinux). Might need platform dependent defaults here. --air
static const int BufferSize = 0x80000;
if( (insertPoint + m_CurQueuePos) > BufferSize )
{
@ -1040,6 +1040,8 @@ const IConsoleWriter ConsoleWriter_File =
ConsoleToFile_DoWrite,
ConsoleToFile_Newline,
ConsoleToFile_SetTitle,
0
};
Mutex& Pcsx2App::GetProgramLogLock()
@ -1111,6 +1113,8 @@ static const IConsoleWriter ConsoleWriter_Window =
ConsoleToWindow_DoWrite<ConsoleWriter_Stdout>,
ConsoleToWindow_Newline<ConsoleWriter_Stdout>,
ConsoleToWindow_SetTitle<ConsoleWriter_Stdout>,
0
};
static const IConsoleWriter ConsoleWriter_WindowAndFile =
@ -1122,6 +1126,8 @@ static const IConsoleWriter ConsoleWriter_WindowAndFile =
ConsoleToWindow_DoWrite<ConsoleWriter_File>,
ConsoleToWindow_Newline<ConsoleWriter_File>,
ConsoleToWindow_SetTitle<ConsoleWriter_File>,
0
};
void Pcsx2App::EnableAllLogging()

View File

@ -56,7 +56,7 @@ DefaultCpuUsageProvider::DefaultCpuUsageProvider()
void DefaultCpuUsageProvider::Reset()
{
for( int i=0; i<QueueDepth; ++i )
for( uint i=0; i<QueueDepth; ++i )
m_queue[i].LoadWithCurrentTimes();
}

View File

@ -39,7 +39,7 @@ bool MsgButtons::Allows( wxWindowID id ) const
// [TODO] : maybe add in an Ignore All?
case wxID_IGNORE: return HasIgnore();
case wxID_RESET: return HasReset();
case wxID_CLOSE: return HasClose();
}
@ -94,7 +94,7 @@ static wxWindowID ParseThatResult( const wxString& src, const MsgButtons& validT
wxID_ANY,
};
for( int i=0; i<ArraySize( retvals ); ++i )
for( uint i=0; i<ArraySize( retvals ); ++i )
{
if( (validTypes.Allows( retvals[i] )) && (src == ResultToString(retvals[i], validTypes)) )
return retvals[i];

View File

@ -144,10 +144,10 @@ static SysTraceLog * const traceLogList[] =
&SysTrace.EE.SPR,
&SysTrace.EE.VIF,
&SysTrace.EE.GIF,
// IOP Section
&SysTrace.IOP.Bios,
&SysTrace.IOP.Memcards,
&SysTrace.IOP.PAD,
@ -164,7 +164,7 @@ static SysTraceLog * const traceLogList[] =
&SysTrace.IOP.CDVD,
};
static const int traceLogCount = ArraySize(traceLogList);
static const uint traceLogCount = ArraySize(traceLogList);
void SysTraceLog_LoadSaveSettings( IniInterface& ini )
{
@ -270,7 +270,7 @@ Panels::BaseCpuLogOptionsPanel* Panels::LogOptionsPanel::GetCpuPanel( const wxSt
{
if( token == L"EE" ) return m_eeSection;
if( token == L"IOP" ) return m_iopSection;
return NULL;
}
@ -316,7 +316,7 @@ void Panels::LogOptionsPanel::Apply()
m_iopSection->Apply();
m_IsDirty = false;
for( uint i = 0; i<traceLogCount; ++i )
{
if (!traceLogList[i] || !m_checks[i]) continue;

View File

@ -19,7 +19,7 @@
#include "VU.h"
#include "x86emitter/x86emitter.h"
#include "RecTypes.h"
#include "System/RecTypes.h"
using namespace x86Emitter;

View File

@ -53,7 +53,6 @@
<Unit filename="ini.cpp" />
<Unit filename="linux.cpp" />
<Unit filename="linux.h" />
<Unit filename="onepad.glade" />
<Unit filename="../analog.cpp" />
<Unit filename="../analog.h" />
<Unit filename="../bitwise.h" />
@ -68,6 +67,7 @@
<Extensions>
<code_completion />
<debugger />
<envvars />
</Extensions>
</Project>
</CodeBlocks_project_file>

View File

@ -132,9 +132,6 @@
</Unit>
<Unit filename="../../Win32/Win32.h" />
<Unit filename="../../Win32/aviUtil.h" />
<Unit filename="../../Win32/jconfig.h" />
<Unit filename="../../Win32/jmorecfg.h" />
<Unit filename="../../Win32/jpeglib.h" />
<Unit filename="../../Win32/resource.h" />
<Unit filename="../../Win32/resrc1.h" />
<Unit filename="../../Win32/wglext.h" />
@ -177,6 +174,7 @@
<Extensions>
<code_completion />
<debugger />
<envvars />
</Extensions>
</Project>
</CodeBlocks_project_file>