small speedup of logmanager, minor logging improvements, misc code standard improvements, replace a crash with an error message in ppcanalyst

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1521 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-12-13 16:58:06 +00:00
parent 4355c37397
commit 522752c77d
16 changed files with 188 additions and 197 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ void CriticalSection::Enter()
bool CriticalSection::TryEnter()
{
return(TryEnterCriticalSection(&section) ? true : false);
return TryEnterCriticalSection(&section) ? true : false;
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -39,7 +39,7 @@ ARCode ActionReplay_GetARCode(size_t index);
void ActionReplay_SetARCode_IsActive(bool active, size_t index);
void ActionReplay_UpdateActiveList();
void ActionReplay_EnableSelfLogging(bool enable);
std::vector<std::string> ActionReplay_GetSelfLog();
const std::vector<std::string> &ActionReplay_GetSelfLog();
bool ActionReplay_IsSelfLogging();
#endif //_ACTIONREPLAY_H_
+14 -14
View File
@@ -73,7 +73,7 @@ namespace Core
void Callback_VideoLog(const TCHAR* _szMessage, int _bDoBreak);
void Callback_VideoCopiedToXFB();
void Callback_DSPLog(const TCHAR* _szMessage, int _v);
char *Callback_ISOName(void);
const char *Callback_ISOName(void);
void Callback_DSPInterrupt();
void Callback_PADLog(const TCHAR* _szMessage);
void Callback_WiimoteLog(const TCHAR* _szMessage, int _v);
@@ -371,16 +371,16 @@ THREAD_RETURN EmuThread(void *pArg)
}
// Wait for CPU thread to exit - it should have been signaled to do so by now
if(cpuThread)
if (cpuThread)
cpuThread->WaitForDeath();
if( g_pUpdateFPSDisplay != NULL )
if (g_pUpdateFPSDisplay != NULL)
g_pUpdateFPSDisplay("Stopping...");
if(cpuThread) {
delete cpuThread;
if (cpuThread) {
delete cpuThread; // This joins the cpu thread.
// Returns after game exited
cpuThread = NULL;
}
// Returns after game exited
g_bHwInit = false;
PluginPAD::PAD_Shutdown();
@@ -395,8 +395,8 @@ THREAD_RETURN EmuThread(void *pArg)
HW::Shutdown();
LOG(MASTER_LOG, "EmuThread exited");
//The CPU should return when a game is stopped and cleanup should be done here,
//so we can restart the plugins (or load new ones) for the next game
// The CPU should return when a game is stopped and cleanup should be done here,
// so we can restart the plugins (or load new ones) for the next game.
if (_CoreParameter.hMainWindow == g_pWindowHandle)
Host_UpdateMainFrame();
return 0;
@@ -514,7 +514,7 @@ void Callback_VideoCopiedToXFB()
(int)(idleDiff),
SystemTimers::GetTicksPerSecond()/1000000);
if( g_pUpdateFPSDisplay != NULL )
if (g_pUpdateFPSDisplay != NULL)
g_pUpdateFPSDisplay(temp);
Host_UpdateStatusBar(temp);
@@ -555,12 +555,12 @@ void Callback_PADLog(const TCHAR* _szMessage)
// Callback_ISOName: Let the DSP plugin get the game name
//
//std::string Callback_ISOName(void)
char * Callback_ISOName(void)
const char *Callback_ISOName(void)
{
if(g_CoreStartupParameter.m_strName.length() > 0)
return (char *)g_CoreStartupParameter.m_strName.c_str();
if (g_CoreStartupParameter.m_strName.length() > 0)
return (const char *)g_CoreStartupParameter.m_strName.c_str();
else
return (char *)"";
return (const char *)"";
}
// __________________________________________________________________________________________________
+1 -2
View File
@@ -72,7 +72,6 @@ void CheckGatherPipe()
memcpy(Memory::GetPointer(CPeripheralInterface::Fifo_CPUWritePointer), m_gatherPipe, GATHER_PIPE_SIZE);
// [F|RES]: i thought GP is forced to mem1 ... strange
// memcpy(&Memory::GetMainRAMPtr()[CPeripheralInterface::Fifo_CPUWritePointer], m_gatherPipe, GATHER_PIPE_SIZE);
// move back the spill bytes
m_gatherPipeCount -= GATHER_PIPE_SIZE;
@@ -85,7 +84,7 @@ void CheckGatherPipe()
// increase the CPUWritePointer
CPeripheralInterface::Fifo_CPUWritePointer += GATHER_PIPE_SIZE;
if (CPeripheralInterface::Fifo_CPUWritePointer > CPeripheralInterface::Fifo_CPUEnd)
_assert_msg_(DYNA_REC, 0, "Fifo_CPUWritePointer out of bounds");
_assert_msg_(DYNA_REC, 0, "Fifo_CPUWritePointer out of bounds: %08x (end = %08x)", CPeripheralInterface::Fifo_CPUWritePointer, CPeripheralInterface::Fifo_CPUEnd);
if (CPeripheralInterface::Fifo_CPUWritePointer >= CPeripheralInterface::Fifo_CPUEnd)
CPeripheralInterface::Fifo_CPUWritePointer = CPeripheralInterface::Fifo_CPUBase;
+2 -2
View File
@@ -623,7 +623,6 @@ bool Init()
position += FAKEVMEM_SIZE;
}
//WriteProtectMemory(base + 24*1024*1024, 8*1024*1024);
if (wii)
{
m_pPhysicalEXRAM = (u8*)g_arena.CreateViewAt(position, EXRAM_SIZE, base + 0x10000000);
@@ -673,6 +672,7 @@ bool Init()
else
InitHWMemFuncs();
LOG(MEMMAP, "Memory system initialized. RAM at %p (0x80000000 @ %p)", base, base + 0x80000000);
m_IsInitialized = true;
return true;
}
@@ -690,7 +690,6 @@ void DoState(PointerWrap &p)
bool Shutdown()
{
m_IsInitialized = false;
bool wii = Core::GetStartupParameter().bWii;
g_arena.ReleaseView(m_pRAM, RAM_SIZE);
@@ -728,6 +727,7 @@ bool Shutdown()
g_arena.ReleaseView(m_pPhysicalFakeVMEM, FAKEVMEM_SIZE);
#endif
g_arena.ReleaseSpace();
LOG(MEMMAP, "Memory system shut down.");
return true;
}
@@ -511,7 +511,6 @@ void Update()
if (VerticalBeamPos == NextXFBRender)
{
u8* xfbPtr = 0;
int yOffset = 0;
+8 -25
View File
@@ -197,24 +197,18 @@ void LogManager::Shutdown()
// ==========================================================================================
// The function that finally writes the log.
// ---------------
u32 lastPC;
std::string lastSymbol;
void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
{
static u32 lastPC;
static std::string lastSymbol;
if (m_LogSettings == NULL)
return;
// declarations
int v; // verbosity level
int type; // the log type, CONSOLE etc.
char cvv[20];
std::string svv;
// get the current verbosity level and type
sprintf(cvv, "%03i", (int)_type);
svv = cvv;
v = atoi(svv.substr(0, 1).c_str());
type = atoi(svv.substr(1, 2).c_str());
// TODO: Base 100 is bad for speed.
int v = _type / 100;
int type = _type % 100;
// security checks
if (m_Log[_type] == NULL || !m_Log[_type]->m_bEnable
@@ -310,7 +304,7 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
fprintf(m_Log[ver*100 + LogTypes::MASTER_LOG]->m_pFile, "%s", Msg2);
/* In case it crashes write now to make sure you get the last messages.
Is this slower than caching it? */
Is this slower than caching it? Most likely yes, fflush can be really slow.*/
//fflush(m_Log[id]->m_pFile);
//fflush(m_Log[ver*100 + LogTypes::MASTER_LOG]->m_pFile);
@@ -320,15 +314,13 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
m_nextMessages[ver]++;
if (m_nextMessages[ver] >= MAX_MESSAGES)
m_nextMessages[ver] = 0;
// ---------------
}
else // write to separate files and structs
{
int id;
for (int i = VERBOSITY_LEVELS; i >= v ; i--)
{
// prepare the right id
id = i*100 + type;
int id = i*100 + type;
// write to memory
m_Messages[i][m_nextMessages[i]].Set((LogTypes::LOG_TYPE)id, v, Msg2);
@@ -357,12 +349,3 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
}
m_bDirty = true; // tell LogWindow that the log has been updated
}
bool IsLoggingActivated()
{
#ifdef LOGGING
return true;
#else
return false;
#endif
}
+9 -10
View File
@@ -30,8 +30,9 @@ struct CDebugger_Log
{
char m_szName[128];
char m_szShortName[32];
char m_szShortName_[32]; // save the unadjusted originals here
char m_szShortName_[32]; // save the unadjusted originals here ( ???? )
char m_szFilename[256];
bool m_bLogToFile;
bool m_bShowInLog;
bool m_bEnable;
@@ -40,10 +41,7 @@ struct CDebugger_Log
void Init();
void Shutdown();
// constructor
CDebugger_Log(const char* _szShortName, const char* _szName, int a);
// destructor
~CDebugger_Log();
};
@@ -55,10 +53,7 @@ struct CDebugger_LogSettings
bool bWriteMaster;
bool bUnify;
// constructor
CDebugger_LogSettings();
// destructor
~CDebugger_LogSettings();
};
@@ -67,7 +62,6 @@ class LogManager
#define MAX_MESSAGES 8000 // the old value was to large
#define MAX_MSGLEN 256
public:
// Message
struct SMessage
{
@@ -103,6 +97,7 @@ public:
//
static void Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...);
};
private:
enum LOG_SETTINGS
{
@@ -118,13 +113,17 @@ private:
static bool m_bInitialized;
static CDebugger_LogSettings* m_LogSettings;
static CDebugger_Log* m_Log[LogTypes::NUMBER_OF_LOGS + (VERBOSITY_LEVELS * 100)]; // make 326 of them
public:
static void Init();
static void Clear(void);
static void Shutdown();
#ifdef LOGGING
static bool Enabled() { return true; }
#else
static bool Enabled() { return false; }
#endif
static void Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...);
};
extern bool IsLoggingActivated();
#endif
+3 -2
View File
@@ -359,8 +359,9 @@ CodeOp *Flatten(u32 address, u32 &realsize, BlockStats &st, BlockRegStats &gpa,
code[i].branchToIndex = -1;
code[i].x86ptr = 0;
GekkoOPInfo *opinfo = GetOpInfo(inst);
numCycles += opinfo->numCyclesMinusOne + 1;
_assert_msg_(GEKKO, opinfo != 0,"Invalid Op - Error flattening %08x op %08x",address+i*4,inst);
if (opinfo)
numCycles += opinfo->numCyclesMinusOne + 1;
_assert_msg_(GEKKO, opinfo != 0, "Invalid Op - Error flattening %08x op %08x",address+i*4,inst);
int flags = opinfo->flags;
bool follow = false;
+1 -1
View File
@@ -309,7 +309,7 @@ bool SymbolDB::SaveMap(const char *filename, bool WithCodes) const
{
// Format the name for the codes version
std::string mapFile = filename;
if(WithCodes) mapFile = mapFile.substr(0, mapFile.find_last_of(".")) + "_code.map";
if (WithCodes) mapFile = mapFile.substr(0, mapFile.find_last_of(".")) + "_code.map";
// Make a file
FILE *f = fopen(mapFile.c_str(), "w");
+5 -4
View File
@@ -284,11 +284,13 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart
// additional dialogs
if (IsLoggingActivated() && bLogWindow)
#ifdef LOGGING
if (bLogWindow)
{
m_LogWindow = new CLogWindow(this);
m_LogWindow->Show(true);
}
#endif
if (bRegisterWindow)
{
@@ -380,7 +382,7 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
{
wxMenu* pDebugDialogs = new wxMenu;
if (IsLoggingActivated())
if (LogManager::Enabled())
{
wxMenuItem* pLogWindow = pDebugDialogs->Append(IDM_LOGWINDOW, _T("&LogManager"), wxEmptyString, wxITEM_CHECK);
pLogWindow->Check(bLogWindow);
@@ -905,12 +907,11 @@ void CCodeWindow::OnSymbolListContextMenu(wxContextMenuEvent& event)
/////////////////////////////////////////////////////////////////////////////////////////////////
// Show and hide windows
// -----------------------
/////////////////////////////////////////////////////////////////////////////////////////////////
void CCodeWindow::OnToggleLogWindow(wxCommandEvent& event)
{
if (IsLoggingActivated())
if (LogManager::Enabled())
{
bool show = GetMenuBar()->IsChecked(event.GetId());
+1 -1
View File
@@ -198,7 +198,7 @@ void wxCheatsWindow::OnEvent_ButtonUpdateCodes_Press(wxCommandEvent& WXUNUSED (e
void wxCheatsWindow::OnEvent_ButtonUpdateLog_Press(wxCommandEvent& WXUNUSED (event))
{
m_TextCtrl_Log->Clear();
std::vector<std::string> arLog = ActionReplay_GetSelfLog();
const std::vector<std::string> &arLog = ActionReplay_GetSelfLog();
for (int i = 0; i < arLog.size(); i++)
{
m_TextCtrl_Log->AppendText(wxString::FromAscii(arLog[i].c_str()));
+2 -2
View File
@@ -592,7 +592,7 @@ void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event))
if (!iso)
return;
if (wxMessageBox(_("Are you sure you want to delete this file?\nIt will be gone forever!"),
wxMessageBoxCaptionStr, wxYES_NO|wxICON_EXCLAMATION) == wxYES)
wxMessageBoxCaptionStr, wxYES_NO | wxICON_EXCLAMATION) == wxYES)
{
File::Delete(iso->GetFileName().c_str());
Update();
@@ -601,7 +601,7 @@ void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event))
else
{
if (wxMessageBox(_("Are you sure you want to delete these files?\nThey will be gone forever!"),
wxMessageBoxCaptionStr, wxYES_NO|wxICON_EXCLAMATION) == wxYES)
wxMessageBoxCaptionStr, wxYES_NO | wxICON_EXCLAMATION) == wxYES)
{
int selected = GetSelectedItemCount();
+1 -1
View File
@@ -371,7 +371,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0WIN32;_LIB;__WXMSW__;wxUSE_BASE=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;__WXMSW__;wxUSE_BASE=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
+8 -8
View File
@@ -8,14 +8,14 @@
#include "PluginSpecs.h"
#include "ExportProlog.h"
typedef unsigned char (*TARAM_Read_U8)(const unsigned int _uAddress);
typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _uAddress);
typedef unsigned char* (*TGetARAMPointer)(void);
typedef void (*TLogv)(const char* _szMessage, int _v);
typedef char* (*TName)(void);
typedef void (*TDebuggerBreak)(void);
typedef void (*TGenerateDSPInt)(void);
typedef unsigned int(*TAudioGetStreaming)(short* _pDestBuffer, unsigned int _numSamples);
typedef unsigned char (*TARAM_Read_U8)(const unsigned int _uAddress);
typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _uAddress);
typedef unsigned char* (*TGetARAMPointer)(void);
typedef void (*TLogv)(const char* _szMessage, int _v);
typedef const char* (*TName)(void);
typedef void (*TDebuggerBreak)(void);
typedef void (*TGenerateDSPInt)(void);
typedef unsigned int (*TAudioGetStreaming)(short* _pDestBuffer, unsigned int _numSamples);
typedef struct
{