From f71cc4e609b57ff7dcff6a207e555a31c7480181 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Sat, 18 Oct 2008 19:25:33 +0000 Subject: [PATCH] Added a verbosity setting to the log manager. And a timestamp to the debug log. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@911 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Core.vcproj | 12 +- Source/Core/Core/Src/LogManager.cpp | 171 ++++++++++++------ Source/Core/Core/Src/LogManager.h | 27 ++- .../Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp | 20 +- Source/Core/DebuggerWX/Src/Debugger.h | 1 + Source/Core/DebuggerWX/Src/LogWindow.cpp | 131 +++++++++++--- Source/Core/DebuggerWX/Src/LogWindow.h | 2 + Source/Dolphin.sln | 2 + 8 files changed, 260 insertions(+), 106 deletions(-) diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj index bd2ab5fb2d..0084e6eb7b 100644 --- a/Source/Core/Core/Core.vcproj +++ b/Source/Core/Core/Core.vcproj @@ -45,7 +45,7 @@ +#include // for the timestamps #include "Common.h" #include "StringUtil.h" #include "LogManager.h" #include "PowerPC/PowerPC.h" +#include "PowerPC/SymbolDB.h" // for g_symbolDB #include "Debugger/Debugger_SymbolMap.h" -LogManager::SMessage *LogManager::m_Messages; -int LogManager::m_nextMessages = 0; +LogManager::SMessage (*LogManager::m_Messages)[MAX_MESSAGES]; +int LogManager::m_nextMessages[LogManager::VERBOSITY_LEVELS + 1]; -CDebugger_Log* LogManager::m_Log[LogTypes::NUMBER_OF_LOGS]; +CDebugger_Log* LogManager::m_Log[LogTypes::NUMBER_OF_LOGS + (LogManager::VERBOSITY_LEVELS * 100)]; int LogManager::m_activeLog = LogTypes::MASTER_LOG; bool LogManager::m_bDirty = true; bool LogManager::m_bInitialized = false; @@ -43,15 +45,16 @@ void __Log(int log, const char *format, ...) LogManager::Log((LogTypes::LOG_TYPE)log, temp); } -CDebugger_Log::CDebugger_Log(const char* _szShortName, const char* _szName) : +CDebugger_Log::CDebugger_Log(const char* _szShortName, const char* _szName, int a) : m_bLogToFile(true), m_bShowInLog(true), m_bEnable(true), m_pFile(NULL) { strcpy((char*)m_szName, _szName); - strcpy((char*)m_szShortName, _szShortName); - sprintf((char*)m_szFilename, "Logs/%s.txt", _szName); + strcpy((char*)m_szShortName_, _szShortName); + sprintf((char*)m_szShortName, "%s%i", _szShortName, a); + sprintf((char*)m_szFilename, "Logs/%s%i.txt", _szName, a); unlink(m_szFilename); } @@ -65,6 +68,10 @@ CDebugger_Log::~CDebugger_Log(void) } } +// we may need to declare these +CDebugger_LogSettings::CDebugger_LogSettings() {} +CDebugger_LogSettings::~CDebugger_LogSettings(void) {} + void CDebugger_Log::Init() { m_pFile = fopen(m_szFilename, "wtb"); @@ -82,40 +89,48 @@ void CDebugger_Log::Shutdown() void LogManager::Init() { - m_Messages = new SMessage[MAX_MESSAGES]; + m_Messages = new SMessage[LogManager::VERBOSITY_LEVELS + 1][MAX_MESSAGES]; m_bDirty = true; // create Logs - m_Log[LogTypes::MASTER_LOG] = new CDebugger_Log("*", "Master Log"); - m_Log[LogTypes::BOOT] = new CDebugger_Log("BOOT", "Boot"); - m_Log[LogTypes::PIXELENGINE] = new CDebugger_Log("PE", "PixelEngine"); - m_Log[LogTypes::COMMANDPROCESSOR] = new CDebugger_Log("CP", "CommandProc"); - m_Log[LogTypes::VIDEOINTERFACE] = new CDebugger_Log("VI", "VideoInt"); - m_Log[LogTypes::SERIALINTERFACE] = new CDebugger_Log("SI", "SerialInt"); - m_Log[LogTypes::PERIPHERALINTERFACE]= new CDebugger_Log("PI", "PeripheralInt"); - m_Log[LogTypes::MEMMAP] = new CDebugger_Log("MI", "MI & memmap"); - m_Log[LogTypes::STREAMINGINTERFACE] = new CDebugger_Log("Stream", "StreamingInt"); - m_Log[LogTypes::DSPINTERFACE] = new CDebugger_Log("DSP", "DSPInterface"); - m_Log[LogTypes::DVDINTERFACE] = new CDebugger_Log("DVD", "DVDInterface"); - m_Log[LogTypes::GPFIFO] = new CDebugger_Log("GP", "GPFifo"); - m_Log[LogTypes::EXPANSIONINTERFACE] = new CDebugger_Log("EXI", "ExpansionInt."); - m_Log[LogTypes::AUDIO_INTERFACE] = new CDebugger_Log("AI", "AudioInt."); - m_Log[LogTypes::GEKKO] = new CDebugger_Log("GEKKO", "IBM CPU"); - m_Log[LogTypes::HLE] = new CDebugger_Log("HLE", "HLE"); - m_Log[LogTypes::DSPHLE] = new CDebugger_Log("DSPHLE", "DSP HLE"); - m_Log[LogTypes::VIDEO] = new CDebugger_Log("Video", "Video Plugin"); - m_Log[LogTypes::AUDIO] = new CDebugger_Log("Audio", "Audio Plugin"); - m_Log[LogTypes::DYNA_REC] = new CDebugger_Log("DYNA", "Dynamic Recompiler"); - m_Log[LogTypes::CONSOLE] = new CDebugger_Log("CONSOLE", "Dolphin Console"); - m_Log[LogTypes::OSREPORT] = new CDebugger_Log("OSREPORT", "OSReport"); - m_Log[LogTypes::WII_IOB] = new CDebugger_Log("WII_IOB", "WII IO Bridge"); - m_Log[LogTypes::WII_IPC] = new CDebugger_Log("WII_IPC", "WII IPC"); - m_Log[LogTypes::WII_IPC_HLE] = new CDebugger_Log("WII_IPC_HLE", "WII IPC HLE"); - m_Log[LogTypes::WIIMOTE] = new CDebugger_Log("WIIMOTE", "WIIMOTE"); + for(int i = 0; i <= LogManager::VERBOSITY_LEVELS; i++) + { + m_Log[LogTypes::MASTER_LOG + i*100] = new CDebugger_Log("*", "Master Log", i); + m_Log[LogTypes::BOOT + i*100] = new CDebugger_Log("BOOT", "Boot", i); + m_Log[LogTypes::PIXELENGINE + i*100] = new CDebugger_Log("PE", "PixelEngine", i); + m_Log[LogTypes::COMMANDPROCESSOR + i*100] = new CDebugger_Log("CP", "CommandProc", i); + m_Log[LogTypes::VIDEOINTERFACE + i*100] = new CDebugger_Log("VI", "VideoInt", i); + m_Log[LogTypes::SERIALINTERFACE + i*100] = new CDebugger_Log("SI", "SerialInt", i); + m_Log[LogTypes::PERIPHERALINTERFACE + i*100]= new CDebugger_Log("PI", "PeripheralInt", i); + m_Log[LogTypes::MEMMAP + i*100] = new CDebugger_Log("MI", "MI & memmap", i); + m_Log[LogTypes::STREAMINGINTERFACE + i*100] = new CDebugger_Log("Stream", "StreamingInt", i); + m_Log[LogTypes::DSPINTERFACE + i*100] = new CDebugger_Log("DSP", "DSPInterface", i); + m_Log[LogTypes::DVDINTERFACE + i*100] = new CDebugger_Log("DVD", "DVDInterface", i); + m_Log[LogTypes::GPFIFO + i*100] = new CDebugger_Log("GP", "GPFifo", i); + m_Log[LogTypes::EXPANSIONINTERFACE + i*100] = new CDebugger_Log("EXI", "ExpansionInt", i); + m_Log[LogTypes::AUDIO_INTERFACE + i*100] = new CDebugger_Log("AI", "AudioInt", i); + m_Log[LogTypes::GEKKO + i*100] = new CDebugger_Log("GEKKO", "IBM CPU", i); + m_Log[LogTypes::HLE + i*100] = new CDebugger_Log("HLE", "HLE", i); + m_Log[LogTypes::DSPHLE + i*100] = new CDebugger_Log("DSPHLE", "DSP HLE", i); + m_Log[LogTypes::VIDEO + i*100] = new CDebugger_Log("Video", "Video Plugin", i); + m_Log[LogTypes::AUDIO + i*100] = new CDebugger_Log("Audio", "Audio Plugin", i); + m_Log[LogTypes::DYNA_REC + i*100] = new CDebugger_Log("DYNA", "Dynamic Recompiler", i); + m_Log[LogTypes::CONSOLE + i*100] = new CDebugger_Log("CONSOLE", "Dolphin Console", i); + m_Log[LogTypes::OSREPORT + i*100] = new CDebugger_Log("OSREPORT", "OSReport", i); + m_Log[LogTypes::WII_IOB + i*100] = new CDebugger_Log("WII_IOB", "WII IO Bridge", i); + m_Log[LogTypes::WII_IPC + i*100] = new CDebugger_Log("WII_IPC", "WII IPC", i); + m_Log[LogTypes::WII_IPC_HLE + i*100] = new CDebugger_Log("WII_IPC_HLE", "WII IPC HLE", i); + m_Log[LogTypes::WIIMOTE + i*100] = new CDebugger_Log("WIIMOTE", "WIIMOTE", i); + + m_nextMessages[i] = 0; // initiate to zero + } for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) { - m_Log[i]->Init(); + for (int j = 0; j <= LogManager::VERBOSITY_LEVELS; j++) + { + m_Log[i]->Init(); + } } m_bInitialized = true; } @@ -123,13 +138,16 @@ void LogManager::Init() void LogManager::Clear() { - for (int i = 0;i < MAX_MESSAGES;i++) + for (int v = 0; v <= LogManager::VERBOSITY_LEVELS; v++) { - strcpy(m_Messages[i].m_szMessage,""); - m_Messages[i].m_dwMsgLen = 0; - m_Messages[i].m_bInUse = false; + for (int i = 0; i < MAX_MESSAGES; i++) + { + strcpy(m_Messages[v][i].m_szMessage,""); + m_Messages[v][i].m_dwMsgLen = 0; + m_Messages[v][i].m_bInUse = false; + } + m_nextMessages[v] = 0; } - m_nextMessages = 0; } // __________________________________________________________________________________________________ @@ -156,52 +174,87 @@ void LogManager::Shutdown() void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...) { - if (m_Log[_type] == NULL || !m_Log[_type]->m_bEnable) + // declarations + int v = m_LogSettings->m_iVerbosity; + int vv; + char cvv[20]; + std::string svv; + + // get the current verbosity level + sprintf(cvv, "%03i", (int)_type); + svv = cvv; + vv = atoi(svv.substr(0, 1).c_str()); + + // security checks + if (m_Log[_type] == NULL + || _type > (LogTypes::NUMBER_OF_LOGS + LogManager::VERBOSITY_LEVELS * 100) + || _type < 0) return; + // prepare message char Msg[512]; va_list ap; va_start(ap, _fmt); vsprintf(Msg, _fmt, ap); va_end(ap); - - SMessage& Message = m_Messages[m_nextMessages]; static u32 count = 0; + wxDateTime datetime = wxDateTime::UNow(); // get timestamp char* Msg2 = (char*)alloca(strlen(_fmt)+512); - int Index = 0; //Debugger::FindSymbol(PC); + // Here's the old symbol request + //Debugger::FindSymbol(PC); + // const Debugger::Symbol& symbol = Debugger::GetSymbol(Index); + //symbol.GetName().c_str(), + + int Index = 1; const char *eol = "\n"; if (Index > 0) { - // const Debugger::Symbol& symbol = Debugger::GetSymbol(Index); - sprintf(Msg2, "%i: %x %s (%s, %08x ) : %s%s", - ++count, + + sprintf(Msg2, "%i %02i:%02i:%03i: %x %s (%s, %08x) : %s%s", + ++count, + datetime.GetMinute(), datetime.GetSecond(), datetime.GetMillisecond(), PowerPC::ppcState.DebugCount, - m_Log[_type]->m_szShortName, - "", //symbol.GetName().c_str(), + m_Log[_type]->m_szShortName_, + g_symbolDB.GetDescription(PC), PC, Msg, eol); } else { - sprintf(Msg2, "%i: %x %s ( %08x ) : %s%s", ++count, PowerPC::ppcState.DebugCount, m_Log[_type]->m_szShortName, PC, Msg, eol); + sprintf(Msg2, "%i: %x %s ( %08x ) : %s%s", ++count, PowerPC::ppcState.DebugCount, + m_Log[_type]->m_szShortName_, PC, Msg, eol); } - Message.Set(_type, Msg2); + int type = _type; + for (int i = LogManager::VERBOSITY_LEVELS; i >= vv ; i--) + { + // safety checks again + if (m_Log[_type] == NULL || !m_Log[_type]->m_bEnable) + continue; - if (m_Log[_type]->m_pFile && m_Log[_type]->m_bLogToFile) - fprintf(m_Log[_type]->m_pFile, "%s", Msg2); - if (m_Log[LogTypes::MASTER_LOG] && m_Log[LogTypes::MASTER_LOG]->m_pFile && m_Log[_type]->m_bShowInLog) - fprintf(m_Log[LogTypes::MASTER_LOG]->m_pFile, "%s", Msg2); + // write to memory + m_Messages[i][m_nextMessages[i]].Set(_type, Msg2); - printf("%s", Msg2); + // ---------------------------------------------------------------------------------------- + // write to file + // --------------- + if (m_Log[_type]->m_pFile && m_Log[_type]->m_bLogToFile) + fprintf(m_Log[_type]->m_pFile, "%s", Msg2); + if (m_Log[LogTypes::MASTER_LOG] && m_Log[LogTypes::MASTER_LOG]->m_pFile && m_Log[_type]->m_bShowInLog) + fprintf(m_Log[LogTypes::MASTER_LOG]->m_pFile, "%s", Msg2); - m_nextMessages++; - if (m_nextMessages >= MAX_MESSAGES) - m_nextMessages = 0; - m_bDirty = true; + printf("%s", Msg2); // write to console screen + + // this limits the memory space used for the memory logs to MAX_MESSAGES rows + m_nextMessages[i]++; + if (m_nextMessages[i] >= MAX_MESSAGES) + m_nextMessages[i] = 0; + m_bDirty = true; + // --------------- + } } bool IsLoggingActivated() diff --git a/Source/Core/Core/Src/LogManager.h b/Source/Core/Core/Src/LogManager.h index f36adfe96a..53ad50a6c3 100644 --- a/Source/Core/Core/Src/LogManager.h +++ b/Source/Core/Core/Src/LogManager.h @@ -30,6 +30,7 @@ struct CDebugger_Log { char m_szName[128]; char m_szShortName[32]; + char m_szShortName_[32]; // save the unadjusted originals here char m_szFilename[256]; bool m_bLogToFile; bool m_bShowInLog; @@ -40,12 +41,24 @@ struct CDebugger_Log void Shutdown(); // constructor - CDebugger_Log(const char* _szShortName, const char* _szName); + CDebugger_Log(const char* _szShortName, const char* _szName, int a); // destructor ~CDebugger_Log(); }; +// make a variable that can be accessed from both LogManager.cpp and LogWindow.cpp +struct CDebugger_LogSettings +{ + int m_iVerbosity; // verbosity level 0 - 2 + + // constructor + CDebugger_LogSettings(); + + // destructor + ~CDebugger_LogSettings(); +}; + class LogManager { #define MAX_MESSAGES 8000 // the old value was to large @@ -86,14 +99,20 @@ public: static void Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...); }; private: + enum LOG_SETTINGS + { + VERBOSITY_LEVELS = 3 + }; + friend class CDebugger_LogWindow; friend class CLogWindow; - static SMessage *m_Messages; - static int m_nextMessages; + static SMessage (*m_Messages)[MAX_MESSAGES]; + static int m_nextMessages[VERBOSITY_LEVELS + 1]; static int m_activeLog; static bool m_bDirty; static bool m_bInitialized; - static CDebugger_Log* m_Log[LogTypes::NUMBER_OF_LOGS]; + 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); diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp index 6619cb3cd0..2a94d3a427 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp @@ -55,8 +55,8 @@ namespace Jit64 void lbzx(UGeckoInstruction inst) { #ifdef JIT_OFF_OPTIONS - //if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) - // {Default(inst); return;} // turn off from debugger + if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) + {Default(inst); return;} // turn off from debugger #endif INSTRUCTION_START; @@ -80,8 +80,8 @@ namespace Jit64 void lXz(UGeckoInstruction inst) { #ifdef JIT_OFF_OPTIONS - //if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) - // {Default(inst); return;} // turn off from debugger + if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) + {Default(inst); return;} // turn off from debugger #endif INSTRUCTION_START; @@ -167,8 +167,8 @@ namespace Jit64 void lha(UGeckoInstruction inst) { #ifdef JIT_OFF_OPTIONS - //if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) - // {Default(inst); return;} // turn off from debugger + if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) + {Default(inst); return;} // turn off from debugger #endif INSTRUCTION_START; @@ -191,8 +191,8 @@ namespace Jit64 void dcbz(UGeckoInstruction inst) { #ifdef JIT_OFF_OPTIONS - //if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) - // {Default(inst); return;} // turn off from debugger + if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) + {Default(inst); return;} // turn off from debugger #endif INSTRUCTION_START; @@ -214,8 +214,8 @@ namespace Jit64 void stX(UGeckoInstruction inst) { #ifdef JIT_OFF_OPTIONS - //if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) - // {Default(inst); return;} // turn off from debugger + if(Core::g_CoreStartupParameter.bJITOff || Core::g_CoreStartupParameter.bJITLoadStoreOff) + {Default(inst); return;} // turn off from debugger #endif INSTRUCTION_START; diff --git a/Source/Core/DebuggerWX/Src/Debugger.h b/Source/Core/DebuggerWX/Src/Debugger.h index 62b10b3556..dd7bdce235 100644 --- a/Source/Core/DebuggerWX/Src/Debugger.h +++ b/Source/Core/DebuggerWX/Src/Debugger.h @@ -25,6 +25,7 @@ enum IDM_CLEARLOG, IDM_LOGCHECKS, IDM_ENABLEALL, + IDM_RADIO0, IDM_SUBMITCMD = 300, }; diff --git a/Source/Core/DebuggerWX/Src/LogWindow.cpp b/Source/Core/DebuggerWX/Src/LogWindow.cpp index 7e23dbf19b..69508c572f 100644 --- a/Source/Core/DebuggerWX/Src/LogWindow.cpp +++ b/Source/Core/DebuggerWX/Src/LogWindow.cpp @@ -23,16 +23,21 @@ #include #include +#include "Core.h" // for Core::GetState() #include "LogWindow.h" #include "Console.h" #include "IniFile.h" +// declare this now to be able to use it in Load() +CDebugger_LogSettings* LogManager::m_LogSettings; + BEGIN_EVENT_TABLE(CLogWindow, wxDialog) EVT_BUTTON(IDM_SUBMITCMD, CLogWindow::OnSubmit) EVT_BUTTON(IDM_UPDATELOG, CLogWindow::OnUpdateLog) EVT_BUTTON(IDM_CLEARLOG, CLogWindow::OnClear) EVT_BUTTON(IDM_ENABLEALL, CLogWindow::OnEnableAll) EVT_CHECKLISTBOX(IDM_LOGCHECKS, CLogWindow::OnLogCheck) + EVT_RADIOBOX(IDM_RADIO0, CLogWindow::OnRadioChange) END_EVENT_TABLE() @@ -40,11 +45,24 @@ CLogWindow::CLogWindow(wxWindow* parent) : wxDialog(parent, wxID_ANY, _T("Log/Console"), wxPoint(100, 700), wxSize(800, 270), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - wxBoxSizer* sizerTop = new wxBoxSizer(wxHORIZONTAL), - * sizerUber = new wxBoxSizer(wxHORIZONTAL), - * sizerBig = new wxBoxSizer(wxVERTICAL), - * sizerBottom = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer* sizerTop = new wxBoxSizer(wxHORIZONTAL), // buttons + * sizerUber = new wxBoxSizer(wxHORIZONTAL), // whole plane + * sizerBig = new wxBoxSizer(wxVERTICAL), // RIGHT sizer + * sizerBottom = new wxBoxSizer(wxHORIZONTAL), // submit row + * sizerLeft = new wxBoxSizer(wxVERTICAL); // LEFT sizer + // left checkboxes and radio boxes ----------------------------------- + m_checks = new wxCheckListBox(this, IDM_LOGCHECKS, wxDefaultPosition, wxSize(120, 280)); + + int m_radioBoxNChoices[1]; + wxString m_radioBoxChoices0[] = { wxT("0"), wxT("1"), wxT("2"), wxT("3") }; + m_radioBoxNChoices[0] = sizeof( m_radioBoxChoices0 ) / sizeof( wxString ); + m_RadioBox[0] = new wxRadioBox( this, IDM_RADIO0, wxT("Verbosity"), + wxDefaultPosition, wxDefaultSize, m_radioBoxNChoices[0], m_radioBoxChoices0, 1, wxRA_SPECIFY_ROWS); + sizerLeft->Add(m_RadioBox[0], 0, wxGROW); + sizerLeft->Add(m_checks, 1, wxGROW); + + // right windows ----------------------------------------------------- m_log = new wxTextCtrl(this, IDM_LOG, _T(""), wxDefaultPosition, wxSize(600, 120), wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP); m_cmdline = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition); wxButton* btn = new wxButton(this, IDM_SUBMITCMD, _T("Submit")); @@ -52,7 +70,7 @@ CLogWindow::CLogWindow(wxWindow* parent) sizerTop->Add(new wxButton(this, IDM_UPDATELOG, _T("Update"))); sizerTop->Add(new wxButton(this, IDM_CLEARLOG, _T("Clear"))); sizerTop->Add(new wxButton(this, IDM_ENABLEALL, _T("Enable all"))); - m_checks = new wxCheckListBox(this, IDM_LOGCHECKS, wxDefaultPosition, wxSize(120, 280)); + sizerBottom->Add(m_cmdline, 8, wxGROW | wxRIGHT, 5); sizerBottom->Add(btn, 1, wxGROW, 0); @@ -60,12 +78,15 @@ CLogWindow::CLogWindow(wxWindow* parent) sizerBig->Add(m_log, 1, wxGROW | wxSHRINK); sizerBig->Add(sizerBottom, 0, wxGROW); - sizerUber->Add(m_checks, 0, wxGROW); + sizerUber->Add(sizerLeft, 0, wxGROW); sizerUber->Add(sizerBig, 1, wxGROW); SetSizer(sizerUber); SetAffirmativeId(IDM_SUBMITCMD); + // declare this now to be able to use it in Load() + LogManager::m_LogSettings = new CDebugger_LogSettings; + //sizerTop->SetSizeHints(this); //sizerTop->Fit(this); UpdateChecks(); @@ -91,6 +112,12 @@ void CLogWindow::Load(IniFile& _IniFile) _IniFile.Get("LogWindow", "w", &w, GetSize().GetWidth()); _IniFile.Get("LogWindow", "h", &h, GetSize().GetHeight()); SetSize(x, y, w, h); + + // load verbosity setting + int v; + _IniFile.Get("LogWindow", "Verbosity", &v, m_RadioBox[0]->GetSelection()); + m_RadioBox[0]->SetSelection(v); + LogManager::m_LogSettings->m_iVerbosity = v; } void CLogWindow::OnSubmit(wxCommandEvent& event) @@ -103,9 +130,12 @@ void CLogWindow::OnSubmit(wxCommandEvent& event) void CLogWindow::OnClear(wxCommandEvent& event) { - LogManager::Clear(); - LOG(MASTER_LOG, "(log cleared)."); - NotifyUpdate(); + if (Core::GetState() != Core::CORE_UNINITIALIZED) // avoid crash + { + LogManager::Clear(); + LOG(MASTER_LOG, "(log cleared)."); + NotifyUpdate(); + } } void CLogWindow::OnEnableAll(wxCommandEvent& event) @@ -113,20 +143,24 @@ void CLogWindow::OnEnableAll(wxCommandEvent& event) if (!LogManager::m_Log[0]) return; static bool enable = true; + int v = LogManager::m_LogSettings->m_iVerbosity; IniFile ini; - ini.Load("Dolphin.ini"); + ini.Load("Debugger.ini"); for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) { m_checks->Check(i, enable); - LogManager::m_Log[i]->m_bEnable = enable; - LogManager::m_Log[i]->m_bShowInLog = enable; - ini.Set("LogManager", LogManager::m_Log[i]->m_szShortName, enable); + LogManager::m_Log[i + v*100]->m_bEnable = enable; + LogManager::m_Log[i + v*100]->m_bShowInLog = enable; + ini.Set("LogManager", LogManager::m_Log[i + v*100]->m_szShortName, enable); } - ini.Save("Dolphin.ini"); + ini.Save("Debugger.ini"); enable = !enable; } +// ---------------------------------------------------------------------------------------- +// enable or disable logging groups +// --------------- void CLogWindow::OnLogCheck(wxCommandEvent& event) { if (!LogManager::m_bInitialized) @@ -135,24 +169,60 @@ void CLogWindow::OnLogCheck(wxCommandEvent& event) } IniFile ini; - ini.Load("Dolphin.ini"); + ini.Load("Debugger.ini"); + int v = LogManager::m_LogSettings->m_iVerbosity; for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) { + // update groups to enabled or disabled bool Enabled = m_checks->IsChecked(i); - LogManager::m_Log[i]->m_bEnable = Enabled; - LogManager::m_Log[i]->m_bShowInLog = Enabled; + LogManager::m_Log[i + 100*v]->m_bEnable = Enabled; + LogManager::m_Log[i + 100*v]->m_bShowInLog = Enabled; - ini.Set("LogManager", LogManager::m_Log[i]->m_szShortName, Enabled); + ini.Set("LogManager", LogManager::m_Log[i + 100*v]->m_szShortName, Enabled); } - ini.Save("Dolphin.ini"); + ini.Save("Debugger.ini"); m_bCheckDirty = true; - UpdateLog(); + if (Core::GetState() != Core::CORE_UNINITIALIZED) UpdateLog(); +} + +// ---------------------------------------------------------------------------------------- +// Change verbosity level +// ------------- +void CLogWindow::OnRadioChange(wxCommandEvent& event) +{ + // get selection + int v = m_RadioBox[0]->GetSelection(); + + // save it + LogManager::m_LogSettings->m_iVerbosity = v; + IniFile ini; + ini.Load("Debugger.ini"); + ini.Set("LogWindow", "Verbosity", v); + ini.Save("Debugger.ini"); + + if (Core::GetState() != Core::CORE_UNINITIALIZED) + { + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) + { + // update groups to enabled or disabled + bool Enabled; + ini.Get("LogManager", LogManager::m_Log[i + 100*v]->m_szShortName, &Enabled, false); + LogManager::m_Log[i + 100*v]->m_bEnable = Enabled; + LogManager::m_Log[i + 100*v]->m_bShowInLog = Enabled; + m_checks->Check(i, Enabled); + } + + UpdateLog(); + } } +// ---------------------------------------------------------------------------------------- +// Update checked groups. +// ------------- void CLogWindow::UpdateChecks() { if (!LogManager::m_bInitialized) @@ -160,9 +230,11 @@ void CLogWindow::UpdateChecks() return; } + // This is only run once to append checkboxes to the wxCheckListBox. if (m_checks->GetCount() == 0) { - // [F|RES] hide the window while we fill it... wxwidgets gets trouble if you don't do it (at least the win version) + // [F|RES] hide the window while we fill it... wxwidgets gets trouble if you don't do it + // (at least the win version) m_checks->Show(false); for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) @@ -173,13 +245,17 @@ void CLogWindow::UpdateChecks() m_checks->Show(true); } + // ---------------------------------------------------------------------------------------- + // Load the correct values + // ------------- + int v = LogManager::m_LogSettings->m_iVerbosity; IniFile ini; - ini.Load("Dolphin.ini"); + ini.Load("Debugger.ini"); for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) { bool Enabled = false; - ini.Get("LogManager", LogManager::m_Log[i]->m_szShortName, &Enabled, false); + ini.Get("LogManager", LogManager::m_Log[i + v*100]->m_szShortName, &Enabled, false); m_checks->Check(i, Enabled); @@ -188,13 +264,12 @@ void CLogWindow::UpdateChecks() } m_bCheckDirty = true; - UpdateLog(); } void CLogWindow::OnUpdateLog(wxCommandEvent& event) { - NotifyUpdate(); + if (Core::GetState() != Core::CORE_UNINITIALIZED) NotifyUpdate(); } @@ -208,7 +283,8 @@ void CLogWindow::NotifyUpdate() void CLogWindow::UpdateLog() { static int last = -1; - int i = LogManager::m_nextMessages; + int v = LogManager::m_LogSettings->m_iVerbosity; + int i = LogManager::m_nextMessages[v]; if ((last == i) && !m_bCheckDirty) { @@ -221,10 +297,11 @@ void CLogWindow::UpdateLog() int count = 0; char* p = m_logBuffer; + // go through all rows while (count < MAX_MESSAGES) { count++; - const LogManager::SMessage& message = LogManager::m_Messages[i]; + const LogManager::SMessage& message = LogManager::m_Messages[v][i]; if (message.m_bInUse) { diff --git a/Source/Core/DebuggerWX/Src/LogWindow.h b/Source/Core/DebuggerWX/Src/LogWindow.h index 9e43624365..ab65e3aa0c 100644 --- a/Source/Core/DebuggerWX/Src/LogWindow.h +++ b/Source/Core/DebuggerWX/Src/LogWindow.h @@ -39,12 +39,14 @@ class CLogWindow char m_logBuffer[LogBufferSize]; wxTextCtrl* m_log, * m_cmdline; wxCheckListBox* m_checks; + wxRadioBox *m_RadioBox[1]; // radio boxes bool m_bCheckDirty; DECLARE_EVENT_TABLE() void OnSubmit(wxCommandEvent& event); void OnUpdateLog(wxCommandEvent& event); void OnLogCheck(wxCommandEvent& event); + void OnRadioChange(wxCommandEvent& event); // verbosity buttons void OnClear(wxCommandEvent& event); void OnEnableAll(wxCommandEvent& event); diff --git a/Source/Dolphin.sln b/Source/Dolphin.sln index 612d104b53..d1bddba3f2 100644 --- a/Source/Dolphin.sln +++ b/Source/Dolphin.sln @@ -2,6 +2,8 @@ Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "Core\Core\Core.vcproj", "{F0B874CB-4476-4199-9315-8343D05AE684}" ProjectSection(ProjectDependencies) = postProject + {48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F} + {0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0} {29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {29C2ABC1-ADA5-42CD-A5FC-96022D52A510} {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} {B7F1A9FB-BEA8-416E-9460-AE35A6A5165C} = {B7F1A9FB-BEA8-416E-9460-AE35A6A5165C}