void Debugger_Disasm::showEvent(QShowEvent *) { #ifdef Q_WS_X11 // Hack to remove the X11 crash with threaded opengl when opening the first dialog EmuThread_LockDraw(true); QTimer::singleShot(100, this, SLOT(releaseLock())); #endif if(Core_IsStepping()) SetDebugMode(true); else SetDebugMode(false); }
MainWindow::MainWindow(const nglContextInfo& rContextInfo, const nglWindowInfo& rInfo, bool ShowFPS, const nglContext* pShared ) : nuiMainWindow(rContextInfo, rInfo, pShared, nglPath(ePathCurrent)), mEventSink(this) { NGL_OUT("MainWindow::MainWindow"); SetDebugMode(true); LoadCSS(_T("rsrc:/css/main.css")); }
void WindowsHost::BootDone() { g_symbolMap->SortSymbols(); SendMessage(mainWindow_, WM_USER + 1, 0, 0); SetDebugMode(!g_Config.bAutoRun); Core_EnableStepping(!g_Config.bAutoRun); }
void CDisasm::stepOut() { auto threads = GetThreadsInfo(); u32 entry, stackTop; for (size_t i = 0; i < threads.size(); i++) { if (threads[i].isCurrent) { entry = threads[i].entrypoint; stackTop = threads[i].initialStack; break; } } auto frames = MIPSStackWalk::Walk(cpu->GetPC(),cpu->GetRegValue(0,31),cpu->GetRegValue(0,29),entry,stackTop); if (frames.size() < 2) return; u32 breakpointAddress = frames[1].pc; // If the current PC is on a breakpoint, the user doesn't want to do nothing. CBreakPoints::SetSkipFirst(currentMIPS->pc); CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); ptr->setDontRedraw(true); SetDebugMode(false); CBreakPoints::AddBreakPoint(breakpointAddress,true); _dbg_update_(); Core_EnableStepping(false); Sleep(1); ptr->gotoAddr(breakpointAddress); UpdateDialog(); }
void Debugger_Disasm::Stop() { SetDebugMode(true); Core_EnableStepping(true); _dbg_update_(); mainWindow->updateMenus(); UpdateDialog(); }
void Debugger_Disasm::Go() { SetDebugMode(false); EmuThread_LockDraw(true); Core_EnableStepping(false); EmuThread_LockDraw(false); mainWindow->UpdateMenus(); }
void Debugger_Disasm::StepOver() { SetDebugMode(false); CBreakPoints::AddBreakPoint(cpu->GetPC()+cpu->getInstructionSize(0),true); _dbg_update_(); Core_EnableStepping(false); mainWindow->updateMenus(); }
void Debugger_Disasm::StepHLE() { hleDebugBreak(); SetDebugMode(false); _dbg_update_(); Core_EnableStepping(false); mainWindow->updateMenus(); }
void WindowsHost::BootDone() { symbolMap.SortSymbols(); SendMessage(MainWindow::GetHWND(), WM_USER+1, 0,0); SetDebugMode(!g_Config.bAutoRun); Core_EnableStepping(!g_Config.bAutoRun); }
MainWindow::MainWindow(const nglContextInfo& rContextInfo, const nglWindowInfo& rInfo, bool ShowFPS, const nglContext* pShared ) : nuiMainWindow(rContextInfo, rInfo, pShared, nglPath(ePathCurrent)), mEventSink(this) { #ifdef _DEBUG_ SetDebugMode(true); #endif LoadCSS(_T("rsrc:/css/style.css")); }
void CLightingEditor::LevelShutdownPreEntity() { SetEditorActive( false ); FlushEditorLights(); m_iCurrentSelectedAxis = EDITORAXIS_NONE; SetDebugMode( EDITOR_DBG_OFF ); }
CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Dialog((LPCSTR)IDD_DISASM, _hInstance, _hParent) { cpu = _cpu; SetWindowText(m_hDlg,_cpu->GetName()); #ifdef THEMES //if (WTL::CTheme::IsThemingSupported()) //EnableThemeDialogTexture(m_hDlg ,ETDT_ENABLETAB); #endif SetWindowPos(m_hDlg,0,500,200,0,0,SWP_NOSIZE); CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); ptr->setDebugger(cpu); ptr->gotoAddr(0x00000000); CtrlRegisterList *rl = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); rl->setCPU(cpu); GetWindowRect(m_hDlg,&minRect); //symbolMap.FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION); symbolMap.FillSymbolComboBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION); GetWindowRect(GetDlgItem(m_hDlg, IDC_REGLIST),®Rect); GetWindowRect(GetDlgItem(m_hDlg, IDC_DISASMVIEW),&disRect); HWND tabs = GetDlgItem(m_hDlg, IDC_LEFTTABS); TCITEM tcItem; ZeroMemory (&tcItem,sizeof (tcItem)); tcItem.mask = TCIF_TEXT; tcItem.dwState = 0; tcItem.pszText = "Regs"; tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; tcItem.iImage = 0; int result1 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); tcItem.pszText = "Funcs"; tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; int result2 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), SW_NORMAL); ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), SW_HIDE); SetTimer(m_hDlg,1,1000,0); /* DWORD intAddress[14] = {0x100, 0x200,0x300,0x400,0x500,0x600,0x700,0x800,0x900,0xc00,0xd00,0xf00,0x1300,0x1700}; char *intName[14] = {"100 Reset","200 Mcheck", "300 DSI","400 ISI","500 External", "600 Align","700 Program","800 FPU N/A","900 DEC","C00 SC", "D00 Trace","F00 Perf","1300 Breakpt","1700 Thermal"};*/ // // --- activate debug mode --- // SetDebugMode(true); }
void CDisasm::stepOver() { if (Core_IsActive()) return; CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); lastTicks = CoreTiming::GetTicks(); // If the current PC is on a breakpoint, the user doesn't want to do nothing. CBreakPoints::SetSkipFirst(currentMIPS->pc); u32 currentPc = cpu->GetPC(); u32 windowEnd = ptr->getWindowEnd(); MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(cpu,cpu->GetPC()); ptr->setDontRedraw(true); u32 breakpointAddress = currentPc+cpu->getInstructionSize(0); if (info.isBranch) { if (info.isConditional == false) { if (info.isLinkedBranch) // jal, jalr { // it's a function call with a delay slot - skip that too breakpointAddress += cpu->getInstructionSize(0); } else { // j, ... // in case of absolute branches, set the breakpoint at the branch target breakpointAddress = info.branchTarget; } } else { // beq, ... if (info.conditionMet) { breakpointAddress = info.branchTarget; } else { breakpointAddress = currentPc+2*cpu->getInstructionSize(0); if (breakpointAddress == windowEnd-4) ptr->scrollWindow(1); else if (breakpointAddress == windowEnd) ptr->scrollWindow(2); else if (breakpointAddress == windowEnd+4) ptr->scrollWindow(3); } } } else { if (breakpointAddress == windowEnd-4) ptr->scrollWindow(1); else if (breakpointAddress == windowEnd) ptr->scrollWindow(2); } SetDebugMode(false, true); CBreakPoints::AddBreakPoint(breakpointAddress,true); _dbg_update_(); Core_EnableStepping(false); Sleep(1); ptr->gotoAddr(breakpointAddress); UpdateDialog(); }
void Debugger_Disasm::StepHLE() { EmuThread_LockDraw(true); hleDebugBreak(); SetDebugMode(false); _dbg_update_(); Core_EnableStepping(false); EmuThread_LockDraw(false); mainWindow->UpdateMenus(); }
void Debugger_Disasm::Stop() { SetDebugMode(true); EmuThread_LockDraw(true); Core_EnableStepping(true); EmuThread_LockDraw(false); _dbg_update_(); mainWindow->UpdateMenus(); UpdateDialog(); }
MainWindow::MainWindow(const nglContextInfo& rContextInfo, const nglWindowInfo& rInfo, bool ShowFPS, const nglContext* pShared ) : nuiMainWindow(rContextInfo, rInfo, pShared, nglPath(ePathCurrent)), mEventSink(this) { #ifdef _DEBUG_ SetDebugMode(true); #endif LoadCSS(_T("rsrc:/css/main.css")); RegisterWithManager(this, NOTIF_FILEBROWSE_DONE); }
void CDisasm::runToLine() { CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); u32 pos = ptr->getSelection(); lastTicks = CoreTiming::GetTicks(); ptr->setDontRedraw(true); SetDebugMode(false); CBreakPoints::AddBreakPoint(pos,true); _dbg_update_(); Core_EnableStepping(false); }
MainWindow::MainWindow(const nglContextInfo& rContextInfo, const nglWindowInfo& rInfo ) : nuiMainWindow(rContextInfo, rInfo, NULL, nglPath((_T("../data")))), mWinSink(this) { //nuiTopLevel::EnablePartialRedraw(false); SetDebugMode(true); InitAttributes(); LoadCSS(_T("rsrc:/css/yapuka.css")); }
MainWindow::MainWindow(const nglContextInfo& rContextInfo, const nglWindowInfo& rInfo, bool ShowFPS, const nglContext* pShared ) : nuiMainWindow(rContextInfo, rInfo, pShared, nglPath(ePathCurrent)), mEventSink(this) { #ifdef _DEBUG_ SetDebugMode(true); #endif this->DBG_SetMouseOverInfo(true); this->DBG_SetMouseOverObject(true); LoadCSS(_T("rsrc:/css/main.css")); }
DeferredLighting::DeferredLighting() : m_debug_mode(false) { // Load shader // * Point Light m_point_light_shader = CShaderManager::Instance().LoadShader( "DeferredPointLight.shader"); ; // * Spot Light m_spot_light_shader = CShaderManager::Instance().LoadShader( "DeferredSpotLight.shader"); // * simple shader for the shadow map m_simple_shader = CShaderManager::Instance().LoadShader("ShadowMap.shader"); SetDebugMode(m_debug_mode); }
MainWindow::MainWindow(const nglContextInfo& rContextInfo, const nglWindowInfo& rInfo, bool ShowFPS, const nglContext* pShared ) : nuiMainWindow(rContextInfo, rInfo, pShared, nglPath(ePathCurrent)), mEventSink(this) { #ifdef _DEBUG_ SetDebugMode(true); #endif #ifdef NUI_IPHONE LoadCSS(_T("rsrc:/css/style-iPhone.css")); #else LoadCSS(_T("rsrc:/css/style.css")); #endif mpLoopVoice = NULL; }
void EventLevel(void) { // Check for any collision and handle the results DetectPlayerCollision(); // Handle any input for the current player InputPlayer(&CurrentPlayer); if(FoxInput_KeyTriggered('U')) { SetDebugMode(); } if(FoxInput_KeyTriggered('I')) { RemoveDebugMode(); } if(FoxInput_KeyTriggered(VK_ESCAPE)) { InitializePause(&DrawLevel); //TogglePauseSound(&BackgroundSnd); UpdatePause(); //TogglePauseSound(&BackgroundSnd); } }
CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Dialog((LPCSTR)IDD_DISASM, _hInstance, _hParent) { cpu = _cpu; lastTicks = PSP_IsInited() ? CoreTiming::GetTicks() : 0; keepStatusBarText = false; hideBottomTabs = false; SetWindowText(m_hDlg, ConvertUTF8ToWString(_cpu->GetName()).c_str()); #ifdef THEMES //if (WTL::CTheme::IsThemingSupported()) //EnableThemeDialogTexture(m_hDlg ,ETDT_ENABLETAB); #endif RECT windowRect; GetWindowRect(m_hDlg,&windowRect); int defaultWidth = windowRect.right-windowRect.left; int defaultHeight = windowRect.bottom-windowRect.top; minWidth = defaultWidth - 100; minHeight = defaultHeight - 200; int x = g_Config.iDisasmWindowX == -1 ? windowRect.left : g_Config.iDisasmWindowX; int y = g_Config.iDisasmWindowY == -1 ? windowRect.top : g_Config.iDisasmWindowY; int w = g_Config.iDisasmWindowW == -1 ? defaultWidth : g_Config.iDisasmWindowW; int h = g_Config.iDisasmWindowH == -1 ? defaultHeight : g_Config.iDisasmWindowH; // init status bar statusBarWnd = CreateWindowEx(0, STATUSCLASSNAME, L"", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, m_hDlg, (HMENU)IDC_DISASMSTATUSBAR, _hInstance, NULL); if (g_Config.bDisplayStatusBar == false) { ShowWindow(statusBarWnd,SW_HIDE); } CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); ptr->setDebugger(cpu); ptr->gotoAddr(0x00000000); CtrlRegisterList *rl = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); rl->setCPU(cpu); leftTabs = new TabControl(GetDlgItem(m_hDlg,IDC_LEFTTABS)); leftTabs->SetIgnoreBottomMargin(true); leftTabs->AddTab(GetDlgItem(m_hDlg,IDC_REGLIST),L"Regs"); leftTabs->AddTab(GetDlgItem(m_hDlg,IDC_FUNCTIONLIST),L"Funcs"); leftTabs->ShowTab(0); // subclass the goto edit box HWND editWnd = GetDlgItem(m_hDlg,IDC_ADDRESS); DefGotoEditProc = (WNDPROC)GetWindowLongPtr(editWnd,GWLP_WNDPROC); SetWindowLongPtr(editWnd,GWLP_WNDPROC,(LONG_PTR)GotoEditProc); // subclass the function list HWND funcListWnd = GetDlgItem(m_hDlg,IDC_FUNCTIONLIST); DefFuncListProc = (WNDPROC)GetWindowLongPtr(funcListWnd,GWLP_WNDPROC); SetWindowLongPtr(funcListWnd,GWLP_WNDPROC,(LONG_PTR)FuncListProc); // init bottom tabs bottomTabs = new TabControl(GetDlgItem(m_hDlg,IDC_DEBUG_BOTTOMTABS)); HWND memHandle = GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW); CtrlMemView *mem = CtrlMemView::getFrom(memHandle); mem->setDebugger(_cpu); bottomTabs->AddTab(memHandle,L"Memory"); breakpointList = new CtrlBreakpointList(GetDlgItem(m_hDlg,IDC_BREAKPOINTLIST),cpu,ptr); breakpointList->reloadBreakpoints(); bottomTabs->AddTab(breakpointList->GetHandle(),L"Breakpoints"); threadList = new CtrlThreadList(GetDlgItem(m_hDlg,IDC_THREADLIST)); threadList->reloadThreads(); bottomTabs->AddTab(threadList->GetHandle(),L"Threads"); stackTraceView = new CtrlStackTraceView(GetDlgItem(m_hDlg,IDC_STACKFRAMES),cpu,ptr); stackTraceView->loadStackTrace(); bottomTabs->AddTab(stackTraceView->GetHandle(),L"Stack frames"); moduleList = new CtrlModuleList(GetDlgItem(m_hDlg,IDC_MODULELIST),cpu); moduleList->loadModules(); bottomTabs->AddTab(moduleList->GetHandle(),L"Modules"); bottomTabs->SetShowTabTitles(g_Config.bShowBottomTabTitles); bottomTabs->ShowTab(memHandle); // Actually resize the window to the proper size (after the above setup.) // do it twice so that the window definitely receives a WM_SIZE message with // the correct size (the default from the .rc tends to be off) MoveWindow(m_hDlg,x,y,1,1,FALSE); MoveWindow(m_hDlg,x,y,w,h,TRUE); SetDebugMode(true, true); }
BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { //if (!m_hDlg) return FALSE; switch(message) { case WM_INITDIALOG: { return TRUE; } break; case WM_NOTIFY: switch (wParam) { case IDC_LEFTTABS: leftTabs->HandleNotify(lParam); break; case IDC_BREAKPOINTLIST: breakpointList->HandleNotify(lParam); break; case IDC_THREADLIST: threadList->HandleNotify(lParam); break; case IDC_STACKFRAMES: stackTraceView->HandleNotify(lParam); break; case IDC_MODULELIST: moduleList->HandleNotify(lParam); break; case IDC_DEBUG_BOTTOMTABS: bottomTabs->HandleNotify(lParam); break; } break; case WM_COMMAND: { CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); CtrlRegisterList *reglist = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); switch(LOWORD(wParam)) { case ID_TOGGLE_PAUSE: SendMessage(MainWindow::GetHWND(),WM_COMMAND,ID_TOGGLE_PAUSE,0); break; case ID_DEBUG_DISPLAYMEMVIEW: bottomTabs->ShowTab(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW)); break; case ID_DEBUG_DISPLAYBREAKPOINTLIST: bottomTabs->ShowTab(breakpointList->GetHandle()); break; case ID_DEBUG_DISPLAYTHREADLIST: bottomTabs->ShowTab(threadList->GetHandle()); break; case ID_DEBUG_DISPLAYSTACKFRAMELIST: bottomTabs->ShowTab(stackTraceView->GetHandle()); break; case ID_DEBUG_DSIPLAYREGISTERLIST: leftTabs->ShowTab(0); break; case ID_DEBUG_DSIPLAYFUNCTIONLIST: leftTabs->ShowTab(1); break; case ID_DEBUG_ADDBREAKPOINT: { keepStatusBarText = true; bool isRunning = Core_IsActive(); if (isRunning) { SetDebugMode(true, false); Core_EnableStepping(true); Core_WaitInactive(200); } BreakpointWindow bpw(m_hDlg,cpu); if (bpw.exec()) bpw.addBreakpoint(); if (isRunning) { SetDebugMode(false, false); Core_EnableStepping(false); } keepStatusBarText = false; } break; case ID_DEBUG_STEPOVER: if (GetFocus() == GetDlgItem(m_hDlg,IDC_DISASMVIEW)) stepOver(); break; case ID_DEBUG_STEPINTO: if (GetFocus() == GetDlgItem(m_hDlg,IDC_DISASMVIEW)) stepInto(); break; case ID_DEBUG_RUNTOLINE: if (GetFocus() == GetDlgItem(m_hDlg,IDC_DISASMVIEW)) runToLine(); break; case ID_DEBUG_STEPOUT: if (GetFocus() == GetDlgItem(m_hDlg,IDC_DISASMVIEW)) stepOut(); break; case ID_DEBUG_HIDEBOTTOMTABS: { RECT rect; hideBottomTabs = !hideBottomTabs; GetClientRect(m_hDlg,&rect); UpdateSize(rect.right-rect.left,rect.bottom-rect.top); } break; case ID_DEBUG_TOGGLEBOTTOMTABTITLES: bottomTabs->SetShowTabTitles(!bottomTabs->GetShowTabTitles()); break; case IDC_SHOWVFPU: vfpudlg->Show(true); break; case IDC_FUNCTIONLIST: switch (HIWORD(wParam)) { case CBN_DBLCLK: { HWND lb = GetDlgItem(m_hDlg,LOWORD(wParam)); int n = ListBox_GetCurSel(lb); if (n!=-1) { unsigned int addr = (unsigned int)ListBox_GetItemData(lb,n); ptr->gotoAddr(addr); SetFocus(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); } } break; }; break; case IDC_GOTOINT: switch (HIWORD(wParam)) { case LBN_SELCHANGE: { HWND lb =GetDlgItem(m_hDlg,LOWORD(wParam)); int n = ComboBox_GetCurSel(lb); unsigned int addr = (unsigned int)ComboBox_GetItemData(lb,n); if (addr != 0xFFFFFFFF) { ptr->gotoAddr(addr); SetFocus(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); } } break; }; break; case IDC_STOPGO: { if (!PSP_IsInited()) { break; } if (!Core_IsStepping()) // stop { ptr->setDontRedraw(false); SetDebugMode(true, true); Core_EnableStepping(true); _dbg_update_(); Sleep(1); //let cpu catch up ptr->gotoPC(); UpdateDialog(); vfpudlg->Update(); } else { // go lastTicks = CoreTiming::GetTicks(); // If the current PC is on a breakpoint, the user doesn't want to do nothing. CBreakPoints::SetSkipFirst(currentMIPS->pc); SetDebugMode(false, true); Core_EnableStepping(false); } } break; case IDC_STEP: stepInto(); break; case IDC_STEPOVER: stepOver(); break; case IDC_STEPOUT: stepOut(); break; case IDC_STEPHLE: { if (Core_IsActive()) break; lastTicks = CoreTiming::GetTicks(); // If the current PC is on a breakpoint, the user doesn't want to do nothing. CBreakPoints::SetSkipFirst(currentMIPS->pc); hleDebugBreak(); SetDebugMode(false, true); _dbg_update_(); Core_EnableStepping(false); } break; case IDC_MEMCHECK: SendMessage(m_hDlg,WM_COMMAND,ID_DEBUG_ADDBREAKPOINT,0); break; case IDC_GOTOPC: { ptr->gotoPC(); SetFocus(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); UpdateDialog(); } break; case IDC_GOTOLR: { ptr->gotoAddr(cpu->GetLR()); SetFocus(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); } break; case IDC_ALLFUNCTIONS: { symbolMap.FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION); break; } default: return FALSE; } return TRUE; } case WM_DEB_MAPLOADED: NotifyMapLoaded(); break; case WM_DEB_GOTOWPARAM: { CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); ptr->gotoAddr(wParam); SetFocus(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); break; } case WM_DEB_GOTOADDRESSEDIT: { if (!PSP_IsInited()) { break; } wchar_t szBuffer[256]; CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); GetWindowText(GetDlgItem(m_hDlg,IDC_ADDRESS),szBuffer,256); u32 addr; if (parseExpression(ConvertWStringToUTF8(szBuffer).c_str(),cpu,addr) == false) { displayExpressionError(GetDlgItem(m_hDlg,IDC_ADDRESS)); } else { ptr->gotoAddr(addr); SetFocus(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); } UpdateDialog(); } break; case WM_DEB_SETDEBUGLPARAM: SetDebugMode(lParam != 0, true); return TRUE; case WM_DEB_UPDATE: Update(); return TRUE; case WM_DEB_TABPRESSED: bottomTabs->NextTab(true); SetFocus(bottomTabs->CurrentTabHandle()); break; case WM_DEB_SETSTATUSBARTEXT: if (!keepStatusBarText) SetWindowText(statusBarWnd, ConvertUTF8ToWString((const char *)lParam).c_str()); break; case WM_DEB_GOTOHEXEDIT: { CtrlMemView *memory = CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW)); memory->gotoAddr(wParam); // display the memory viewer too bottomTabs->ShowTab(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW)); } break; case WM_SIZE: { UpdateSize(LOWORD(lParam), HIWORD(lParam)); SendMessage(statusBarWnd,WM_SIZE,0,10); SavePosition(); return TRUE; } case WM_MOVE: SavePosition(); break; case WM_GETMINMAXINFO: { MINMAXINFO *m = (MINMAXINFO *)lParam; // Reduce the minimum size slightly, so they can size it however they like. m->ptMinTrackSize.x = minWidth; //m->ptMaxTrackSize.x = m->ptMinTrackSize.x; m->ptMinTrackSize.y = minHeight; } return TRUE; case WM_CLOSE: Show(false); return TRUE; case WM_ACTIVATE: if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) { g_activeWindow = WINDOW_CPUDEBUGGER; } break; } return FALSE; }
BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { //if (!m_hDlg) return FALSE; switch(message) { case WM_INITDIALOG: { return TRUE; } break; case WM_TIMER: { int iPage = TabCtrl_GetCurSel (GetDlgItem(m_hDlg, IDC_LEFTTABS)); ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), iPage?SW_NORMAL:SW_HIDE); ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), iPage?SW_HIDE:SW_NORMAL); } break; case WM_NOTIFY: { HWND tabs = GetDlgItem(m_hDlg, IDC_LEFTTABS); NMHDR* pNotifyMessage = NULL; pNotifyMessage = (LPNMHDR)lParam; if (pNotifyMessage->hwndFrom == tabs) { int iPage = TabCtrl_GetCurSel (tabs); ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), iPage?SW_NORMAL:SW_HIDE); ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), iPage?SW_HIDE:SW_NORMAL); } break; } case WM_COMMAND: { CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); CtrlRegisterList *reglist = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); switch(LOWORD(wParam)) { case IDC_SHOWVFPU: vfpudlg->Show(true); break; case IDC_FUNCTIONLIST: switch (HIWORD(wParam)) { case CBN_DBLCLK: case CBN_SELCHANGE: { HWND lb = GetDlgItem(m_hDlg,LOWORD(wParam)); int n = ListBox_GetCurSel(lb); if (n!=-1) { unsigned int addr = (unsigned int)ListBox_GetItemData(lb,n); ptr->gotoAddr(addr); } } break; }; break; case IDC_GOTOINT: switch (HIWORD(wParam)) { case LBN_SELCHANGE: { HWND lb =GetDlgItem(m_hDlg,LOWORD(wParam)); int n = ComboBox_GetCurSel(lb); unsigned int addr = (unsigned int)ComboBox_GetItemData(lb,n); if (addr != 0xFFFFFFFF) ptr->gotoAddr(addr); } break; }; break; case IDC_GO: { SetDebugMode(false); Core_EnableStepping(false); } break; case IDC_STEP: { Core_DoSingleStep(); Sleep(1); _dbg_update_(); ptr->gotoPC(); UpdateDialog(); vfpudlg->Update(); } break; case IDC_STEPOVER: { SetDebugMode(false); CBreakPoints::AddBreakPoint(cpu->GetPC()+cpu->getInstructionSize(0),true); _dbg_update_(); Core_EnableStepping(false); Sleep(1); ptr->gotoPC(); UpdateDialog(); } break; case IDC_STEPHLE: { hleDebugBreak(); SetDebugMode(false); _dbg_update_(); Core_EnableStepping(false); } break; case IDC_STOP: { SetDebugMode(true); Core_EnableStepping(true); _dbg_update_(); Sleep(1); //let cpu catch up ptr->gotoPC(); UpdateDialog(); vfpudlg->Update(); } break; case IDC_SKIP: { cpu->SetPC(cpu->GetPC() + cpu->getInstructionSize(0)); Sleep(1); ptr->gotoPC(); UpdateDialog(); } break; case IDC_MEMCHECK: { bool isRunning = !Core_IsInactive(); if (isRunning) { SetDebugMode(true); Core_EnableStepping(true); Core_WaitInactive(200); } MemCheck check; if (InputBox_GetHex(GetModuleHandle(NULL), m_hDlg, "JIT (and not HLE) only for now, no delete", 0, check.iStartAddress)) { check.bBreak = true; check.bLog = true; check.bOnRead = true; check.bOnWrite = true; check.bRange = false; CBreakPoints::MemChecks.push_back(check); CBreakPoints::InvalidateJit(); } if (isRunning) { SetDebugMode(false); Core_EnableStepping(false); } } break; case IDC_ADDRESS: { if (HIWORD(wParam) == EN_CHANGE ) { char szBuffer[32]; GetWindowText ((HWND)lParam, szBuffer, 32); ptr->gotoAddr(parseHex(szBuffer)); UpdateDialog(); } } break; case IDC_UPDATECALLSTACK: { HWND hDlg = m_hDlg; HWND list = GetDlgItem(hDlg,IDC_CALLSTACK); ComboBox_ResetContent(list); u32 pc = currentMIPS->pc; u32 ra = currentMIPS->r[MIPS_REG_RA]; DWORD addr = Memory::ReadUnchecked_U32(pc); int count=1; ComboBox_SetItemData(list,ComboBox_AddString(list,symbolMap.GetDescription(pc)),pc); if (symbolMap.GetDescription(pc) != symbolMap.GetDescription(ra)) { ComboBox_SetItemData(list,ComboBox_AddString(list,symbolMap.GetDescription(ra)),ra); count++; } //walk the stack chain while (addr != 0xFFFFFFFF && addr!=0 && count++<20) { DWORD fun = Memory::ReadUnchecked_U32(addr+4); char *str = symbolMap.GetDescription(fun); if (strlen(str)==0) str = "(unknown)"; ComboBox_SetItemData(list, ComboBox_AddString(list,str), fun); addr = Memory::ReadUnchecked_U32(addr); } ComboBox_SetCurSel(list,0); } break; case IDC_GOTOPC: { ptr->gotoPC(); UpdateDialog(); } break; case IDC_GOTOLR: { ptr->gotoAddr(cpu->GetLR()); } break; case IDC_BACKWARDLINKS: { HWND box = GetDlgItem(m_hDlg, IDC_FUNCTIONLIST); int funcnum = symbolMap.GetSymbolNum(ListBox_GetItemData(box,ListBox_GetCurSel(box))); if (funcnum!=-1) symbolMap.FillListBoxBLinks(box,funcnum); break; } case IDC_ALLFUNCTIONS: { symbolMap.FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION); break; } default: return FALSE; } return TRUE; } case WM_USER+1: NotifyMapLoaded(); break; case WM_SIZE: { HWND disasm = GetDlgItem(m_hDlg, IDC_DISASMVIEW); HWND funclist = GetDlgItem(m_hDlg, IDC_FUNCTIONLIST); HWND regList = GetDlgItem(m_hDlg, IDC_REGLIST); int wf = regRect.right-regRect.left; int top = 138; MoveWindow(regList,8,top,wf,HIWORD(lParam)-top-8,TRUE); MoveWindow(funclist,8,top,wf,HIWORD(lParam)-top-8,TRUE); int w = LOWORD(lParam)-wf; top = 25; MoveWindow(disasm,wf+15,top, w-20,HIWORD(lParam)-top-8,TRUE); return TRUE; } case WM_GETMINMAXINFO: { MINMAXINFO *m = (MINMAXINFO *)lParam; m->ptMinTrackSize.x=minRect.right-minRect.left; //m->ptMaxTrackSize.x=m->ptMinTrackSize.x; m->ptMinTrackSize.y=minRect.bottom-minRect.top; } return TRUE; case WM_CLOSE: Show(false); return TRUE; } return FALSE; }
BOOL CDiskInfoApp::InitInstance() { BOOL flagEarthlight = FALSE; BOOL flagStartupExit = FALSE; m_FlagCopyExit = FALSE; int defaultDisk = -1; HANDLE hMutex = NULL; INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); // IE Version Check. /* if(GetFileVersion(_T("Shdocvw.dll")) < 471) { AfxMessageBox(_T("CrystalDiskInfo is required IE 6.0 or later.")); } */ // CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); // for WMI error SetErrorMode(SEM_FAILCRITICALERRORS); // Init m_Ini TCHAR *ptrEnd; TCHAR ini[MAX_PATH]; ::GetModuleFileName(NULL, ini, MAX_PATH); if((ptrEnd = _tcsrchr(ini, '.')) != NULL) { *ptrEnd = '\0'; _tcscat_s(ini, MAX_PATH, _T(".ini")); } m_Ini = ini; #ifdef SUISHO_SHIZUKU_SUPPORT m_Ini.Replace(_T("DiskInfoS.ini"), _T("DiskInfo.ini")); m_Ini.Replace(_T("DiskInfoSx64.ini"), _T("DiskInfoX64.ini")); #endif CString cstr; DWORD debugMode = GetPrivateProfileInt(_T("Setting"), _T("DebugMode"), 0, m_Ini); SetDebugMode(debugMode); cstr.Format(_T("%d"), debugMode); WritePrivateProfileString(_T("Setting"), _T("DebugMode"), cstr, m_Ini); int argc = 0; int index = 0; LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc); if(argc > 1) { CString cstr; cstr = argv[1]; if(cstr.CompareNoCase(_T("/Earthlight")) == 0) { flagEarthlight = TRUE; if(argc > 2) { defaultDisk = _tstoi(argv[2]); } } if(cstr.CompareNoCase(_T("/Startup")) == 0) { int time = 0; time = GetPrivateProfileInt(_T("Setting"), _T("StartupWaitTime"), 30, m_Ini); if(time >= 0) { Sleep(time * 1000); } TCHAR str[MAX_PATH]; ::GetModuleFileName(NULL, str, MAX_PATH); ShellExecute(NULL, NULL, str, NULL, NULL, SW_SHOWNORMAL); return FALSE; } if(cstr.CompareNoCase(_T("/Exit")) == 0) { flagStartupExit = TRUE; } if(cstr.CompareNoCase(_T("/Copy")) == 0) { m_SaveAsText = m_Ini; m_SaveAsText.Replace(_T("ini"), _T("txt")); } if(cstr.CompareNoCase(_T("/CopyExit")) == 0) { m_SaveAsText = m_Ini; m_SaveAsText.Replace(_T("ini"), _T("txt")); m_FlagCopyExit = TRUE; } } // DEBUG // flagEarthlight = TRUE; if(! flagEarthlight) { DebugPrint(_T("CreateMutex")); hMutex = ::CreateMutex(NULL, FALSE, PROJECT_NAME); if(GetLastError() == ERROR_ALREADY_EXISTS) { DebugPrint(_T("ERROR_ALREADY_EXISTS")); return FALSE; } } CString DefaultTheme; CString DefaultLanguage; TCHAR tmp[MAX_PATH]; GetModuleFileName(NULL, tmp, MAX_PATH); if((ptrEnd = _tcsrchr(tmp, '\\')) != NULL) { *ptrEnd = '\0'; } m_ExeDir.Format(_T("%s\\"), tmp); m_ThemeDir.Format(_T("%s\\%s"), tmp, THEME_DIR); m_LangDir.Format(_T("%s\\%s"), tmp, LANGUAGE_DIR); m_SmartDir.Format(_T("%s\\%s"), tmp, SMART_DIR); m_GadgetDir.Format(_T("%s\\%s"), tmp, GADGET_DIR); if(IsDotNet4()) { m_AlertMailPath.Format(_T("%s\\%s"), tmp, ALERT_MAIL_4_PATH); } else if(IsDotNet2()) { m_AlertMailPath.Format(_T("%s\\%s"), tmp, ALERT_MAIL_PATH); } else { m_AlertMailPath = _T(""); } m_OpusDecPath.Format(_T("%s\\%s"), tmp, OPUS_DEC_PATH); #ifdef SUISHO_SHIZUKU_SUPPORT m_ShizukuVoicePath.Format(_T("%s\\%s"), tmp, SHIZUKU_VOICE_PATH); #endif m_ThemeIndex = MENU_THEME_INDEX; m_LangIndex = MENU_LANG_INDEX; DefaultTheme.Format(_T("%s\\%s"), tmp, DEFAULT_THEME); DefaultLanguage.Format(_T("%s\\%s"), tmp, DEFAULT_LANGUAGE); OSVERSIONINFOEX osvi; BOOL bosVersionInfoEx; ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if(!(bosVersionInfoEx = GetVersionEx((OSVERSIONINFO *)&osvi))) { osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx((OSVERSIONINFO *)&osvi); } if((BOOL)GetPrivateProfileInt(_T("Workaround"), _T("IE8MODE"), 0, m_Ini)) { m_GraphDlgPath.Format(_T("%s\\") DIALOG_DIR GRAPH_DIALOG_IE8, tmp); if(! IsFileExistEx(m_GraphDlgPath, GRAPH_DIALOG_IE8)) { return FALSE; } } else { m_GraphDlgPath.Format(_T("%s\\") DIALOG_DIR GRAPH_DIALOG, tmp); if(! IsFileExistEx(m_GraphDlgPath, GRAPH_DIALOG)) { return FALSE; } } m_OptionDlgPath.Format(_T("%s\\") DIALOG_DIR OPTION_DIALOG, tmp); // if(! IsFileExistEx(DefaultTheme, DEFAULT_THEME)) { return FALSE; } if(! IsFileExistEx(DefaultLanguage, DEFAULT_LANGUAGE)) { return FALSE; } // for Windows NT family #ifdef _UNICODE if(! IsCurrentUserLocalAdministrator()) { if(osvi.dwMajorVersion < 6) { AfxMessageBox(_T("CrystalDiskInfo is required Administrator Privileges.")); } RunAsRestart(); return FALSE; } #endif BOOL flagAfxOleInit = FALSE; if(flagEarthlight) { CGraphDlg dlg(NULL, defaultDisk); m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); } else { // No Server Busy Dialog!! DebugPrint(_T("AfxOleInit()")); if(AfxOleInit()) { flagAfxOleInit = TRUE; DebugPrint(_T("AfxOleGetMessageFilter()->SetMessagePendingDelay")); AfxOleGetMessageFilter()->SetMessagePendingDelay(60 * 1000); DebugPrint(_T("AfxOleGetMessageFilter()->EnableNotRespondingDialog(FALSE)")); AfxOleGetMessageFilter()->EnableNotRespondingDialog(FALSE); DebugPrint(_T("AfxOleGetMessageFilter()->EnableBusyDialog(FALSE)")); AfxOleGetMessageFilter()->EnableBusyDialog(FALSE); } else { DebugPrint(_T("CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);")); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); } CDiskInfoDlg dlg(NULL, flagStartupExit); m_pMainWnd = &dlg; BOOL flagReExec = FALSE; DebugPrint(_T("dlg.DoModal()")); if(dlg.DoModal() == RE_EXEC) { flagReExec = TRUE; } ::ReleaseMutex(hMutex); ::CloseHandle(hMutex); if(flagReExec) { TCHAR str[MAX_PATH]; ::GetModuleFileName(NULL, str, MAX_PATH); ShellExecute(NULL, NULL, str, NULL, NULL, SW_SHOWNORMAL); } } if(! flagAfxOleInit) { DebugPrint(_T("CoUninitialize();")); CoUninitialize(); } return FALSE; }
CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Dialog((LPCSTR)IDD_DISASM, _hInstance, _hParent) { cpu = _cpu; lastTicks = CoreTiming::GetTicks(); SetWindowText(m_hDlg,_cpu->GetName()); #ifdef THEMES //if (WTL::CTheme::IsThemingSupported()) //EnableThemeDialogTexture(m_hDlg ,ETDT_ENABLETAB); #endif int x = g_Config.iDisasmWindowX == -1 ? 500 : g_Config.iDisasmWindowX; int y = g_Config.iDisasmWindowY == -1 ? 200 : g_Config.iDisasmWindowY; int w = g_Config.iDisasmWindowW; int h = g_Config.iDisasmWindowH; // Start with the initial size so we have the right minimum size from the rc. SetWindowPos(m_hDlg, 0, x, y, 0, 0, SWP_NOSIZE); CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); ptr->setDebugger(cpu); ptr->gotoAddr(0x00000000); CtrlRegisterList *rl = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); rl->setCPU(cpu); GetWindowRect(m_hDlg, &defaultRect); //symbolMap.FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION); symbolMap.FillSymbolComboBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION); GetWindowRect(GetDlgItem(m_hDlg, IDC_REGLIST), ®Rect); GetWindowRect(GetDlgItem(m_hDlg, IDC_DISASMVIEW), &disRect); GetWindowRect(GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST), &breakpointRect); GetWindowRect(GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST), &defaultBreakpointRect); HWND tabs = GetDlgItem(m_hDlg, IDC_LEFTTABS); TCITEM tcItem; ZeroMemory (&tcItem,sizeof (tcItem)); tcItem.mask = TCIF_TEXT; tcItem.dwState = 0; tcItem.pszText = "Regs"; tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; tcItem.iImage = 0; int result1 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); tcItem.pszText = "Funcs"; tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; int result2 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), SW_NORMAL); ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), SW_HIDE); SetTimer(m_hDlg,1,1000,0); // subclass the goto edit box HWND editWnd = GetDlgItem(m_hDlg,IDC_ADDRESS); DefGotoEditProc = (WNDPROC)GetWindowLongPtr(editWnd,GWLP_WNDPROC); SetWindowLongPtr(editWnd,GWLP_WNDPROC,(LONG_PTR)GotoEditProc); // init memory viewer CtrlMemView *mem = CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW)); mem->setDebugger(_cpu); breakpointList = new CtrlBreakpointList(); breakpointList->setCpu(cpu); breakpointList->setDisasm(ptr); breakpointList->setDialogItem(GetDlgItem(m_hDlg,IDC_BREAKPOINTLIST)); breakpointList->update(); threadList = new CtrlThreadList(); threadList->setDialogItem(GetDlgItem(m_hDlg,IDC_THREADLIST)); threadList->reloadThreads(); // init memory/breakpoint "tab" ShowWindow(GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST), SW_HIDE); ShowWindow(GetDlgItem(m_hDlg, IDC_DEBUGMEMVIEW), SW_NORMAL); ShowWindow(GetDlgItem(m_hDlg, IDC_THREADLIST), SW_HIDE); // Actually resize the window to the proper size (after the above setup.) if (w != -1 && h != -1) { // this will also call UpdateSize SetWindowPos(m_hDlg, 0, x, y, w, h, 0); } SetDebugMode(true); }
BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { //if (!m_hDlg) return FALSE; switch(message) { case WM_INITDIALOG: { return TRUE; } break; case WM_TIMER: { int iPage = TabCtrl_GetCurSel (GetDlgItem(m_hDlg, IDC_LEFTTABS)); ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), iPage?SW_NORMAL:SW_HIDE); ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), iPage?SW_HIDE:SW_NORMAL); } break; case WM_NOTIFY: switch (wParam) { case IDC_LEFTTABS: { HWND tabs = GetDlgItem(m_hDlg, IDC_LEFTTABS); NMHDR* pNotifyMessage = NULL; pNotifyMessage = (LPNMHDR)lParam; if (pNotifyMessage->hwndFrom == tabs) { int iPage = TabCtrl_GetCurSel (tabs); ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), iPage?SW_NORMAL:SW_HIDE); ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), iPage?SW_HIDE:SW_NORMAL); } } break; case IDC_BREAKPOINTLIST: breakpointList->handleNotify(lParam); break; case IDC_THREADLIST: threadList->handleNotify(lParam); break; } break; case WM_COMMAND: { CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); CtrlRegisterList *reglist = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); switch(LOWORD(wParam)) { case IDC_SHOWVFPU: vfpudlg->Show(true); break; case IDC_FUNCTIONLIST: switch (HIWORD(wParam)) { case CBN_DBLCLK: { HWND lb = GetDlgItem(m_hDlg,LOWORD(wParam)); int n = ListBox_GetCurSel(lb); if (n!=-1) { unsigned int addr = (unsigned int)ListBox_GetItemData(lb,n); ptr->gotoAddr(addr); SetFocus(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); } } break; }; break; case IDC_GOTOINT: switch (HIWORD(wParam)) { case LBN_SELCHANGE: { HWND lb =GetDlgItem(m_hDlg,LOWORD(wParam)); int n = ComboBox_GetCurSel(lb); unsigned int addr = (unsigned int)ComboBox_GetItemData(lb,n); if (addr != 0xFFFFFFFF) { ptr->gotoAddr(addr); SetFocus(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); } } break; }; break; case IDC_GO: { lastTicks = CoreTiming::GetTicks(); // If the current PC is on a breakpoint, the user doesn't want to do nothing. CBreakPoints::SetSkipFirst(currentMIPS->pc); SetDebugMode(false); Core_EnableStepping(false); } break; case IDC_STEP: { if (Core_IsActive()) break; lastTicks = CoreTiming::GetTicks(); // If the current PC is on a breakpoint, the user doesn't want to do nothing. CBreakPoints::SetSkipFirst(currentMIPS->pc); Core_DoSingleStep(); Sleep(1); _dbg_update_(); ptr->gotoPC(); UpdateDialog(); vfpudlg->Update(); CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW))->redraw(); threadList->reloadThreads(); updateThreadLabel(false); } break; case IDC_STEPOVER: { if (Core_IsActive()) break; lastTicks = CoreTiming::GetTicks(); // If the current PC is on a breakpoint, the user doesn't want to do nothing. CBreakPoints::SetSkipFirst(currentMIPS->pc); const char* dis = cpu->disasm(cpu->GetPC(),4); const char* pos = strstr(dis,"->$"); const char* reg = strstr(dis,"->"); ptr->setDontRedraw(true); u32 breakpointAddress = cpu->GetPC()+cpu->getInstructionSize(0); if (memcmp(dis,"jal\t",4) == 0 || memcmp(dis,"jalr\t",5) == 0) { // it's a function call with a delay slot - skip that too breakpointAddress += cpu->getInstructionSize(0); } else if (memcmp(dis,"j\t",2) == 0 || memcmp(dis,"b\t",2) == 0) { // in case of absolute branches, set the breakpoint at the branch target sscanf(pos+3,"%08x",&breakpointAddress); } else if (memcmp(dis,"jr\t",3) == 0) { // the same for jumps to registers int regNum = -1; for (int i = 0; i < 32; i++) { if (strcasecmp(reg+2,cpu->GetRegName(0,i)) == 0) { regNum = i; break; } } if (regNum == -1) break; breakpointAddress = cpu->GetRegValue(0,regNum); } else if (pos != NULL) { // get branch target sscanf(pos+3,"%08x",&breakpointAddress); CBreakPoints::AddBreakPoint(breakpointAddress,true); // also add a breakpoint after the delay slot breakpointAddress = cpu->GetPC()+2*cpu->getInstructionSize(0); } SetDebugMode(false); CBreakPoints::AddBreakPoint(breakpointAddress,true); _dbg_update_(); Core_EnableStepping(false); Sleep(1); ptr->gotoAddr(breakpointAddress); UpdateDialog(); } break; case IDC_STEPHLE: { if (Core_IsActive()) break; lastTicks = CoreTiming::GetTicks(); // If the current PC is on a breakpoint, the user doesn't want to do nothing. CBreakPoints::SetSkipFirst(currentMIPS->pc); hleDebugBreak(); SetDebugMode(false); _dbg_update_(); Core_EnableStepping(false); } break; case IDC_STOP: { ptr->setDontRedraw(false); SetDebugMode(true); Core_EnableStepping(true); _dbg_update_(); Sleep(1); //let cpu catch up ptr->gotoPC(); UpdateDialog(); vfpudlg->Update(); } break; case IDC_SKIP: { cpu->SetPC(cpu->GetPC() + cpu->getInstructionSize(0)); Sleep(1); ptr->gotoPC(); UpdateDialog(); } break; case IDC_MEMCHECK: { bool isRunning = Core_IsActive(); if (isRunning) { SetDebugMode(true); Core_EnableStepping(true); Core_WaitInactive(200); } BreakpointWindow bpw(m_hDlg,cpu); if (bpw.exec()) bpw.addBreakpoint(); if (isRunning) { SetDebugMode(false); Core_EnableStepping(false); } } break; case IDC_UPDATECALLSTACK: { HWND hDlg = m_hDlg; HWND list = GetDlgItem(hDlg,IDC_CALLSTACK); ComboBox_ResetContent(list); u32 pc = currentMIPS->pc; u32 ra = currentMIPS->r[MIPS_REG_RA]; DWORD addr = Memory::ReadUnchecked_U32(pc); int count=1; ComboBox_SetItemData(list,ComboBox_AddString(list,symbolMap.GetDescription(pc)),pc); if (symbolMap.GetDescription(pc) != symbolMap.GetDescription(ra)) { ComboBox_SetItemData(list,ComboBox_AddString(list,symbolMap.GetDescription(ra)),ra); count++; } //walk the stack chain while (addr != 0xFFFFFFFF && addr!=0 && count++<20) { DWORD fun = Memory::ReadUnchecked_U32(addr+4); const char *str = symbolMap.GetDescription(fun); if (strlen(str)==0) str = "(unknown)"; ComboBox_SetItemData(list, ComboBox_AddString(list,str), fun); addr = Memory::ReadUnchecked_U32(addr); } ComboBox_SetCurSel(list,0); } break; case IDC_GOTOPC: { ptr->gotoPC(); SetFocus(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); UpdateDialog(); } break; case IDC_GOTOLR: { ptr->gotoAddr(cpu->GetLR()); SetFocus(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); } break; case IDC_BACKWARDLINKS: { HWND box = GetDlgItem(m_hDlg, IDC_FUNCTIONLIST); int funcnum = symbolMap.GetSymbolNum(ListBox_GetItemData(box,ListBox_GetCurSel(box))); if (funcnum!=-1) symbolMap.FillListBoxBLinks(box,funcnum); break; } case IDC_ALLFUNCTIONS: { symbolMap.FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION); break; } default: return FALSE; } return TRUE; } case WM_DEB_MAPLOADED: NotifyMapLoaded(); break; case WM_DEB_RUNTOWPARAM: { lastTicks = CoreTiming::GetTicks(); CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); ptr->setDontRedraw(true); SetDebugMode(false); CBreakPoints::AddBreakPoint(wParam,true); _dbg_update_(); Core_EnableStepping(false); break; } case WM_DEB_GOTOWPARAM: { CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); ptr->gotoAddr(wParam); SetFocus(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); break; } case WM_DEB_GOTOADDRESSEDIT: { char szBuffer[256]; CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); GetWindowText(GetDlgItem(m_hDlg,IDC_ADDRESS),szBuffer,256); u32 addr; if (parseExpression(szBuffer,cpu,addr) == false) { displayExpressionError(GetDlgItem(m_hDlg,IDC_ADDRESS)); } else { ptr->gotoAddr(addr); SetFocus(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); } UpdateDialog(); } break; case WM_DEB_SETDEBUGLPARAM: SetDebugMode(lParam != 0); return TRUE; case WM_DEB_UPDATE: Update(); return TRUE; case WM_DEB_TABPRESSED: { HWND bp = GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST); HWND mem = GetDlgItem(m_hDlg, IDC_DEBUGMEMVIEW); HWND threads = GetDlgItem(m_hDlg, IDC_THREADLIST); if (IsWindowVisible(bp)) { ShowWindow(bp,SW_HIDE); ShowWindow(mem,SW_HIDE); ShowWindow(threads,SW_NORMAL); SetFocus(threads); } else if (IsWindowVisible(threads)) { ShowWindow(bp,SW_HIDE); ShowWindow(mem,SW_NORMAL); ShowWindow(threads,SW_HIDE); SetFocus(mem); } else { ShowWindow(bp,SW_NORMAL); ShowWindow(mem,SW_HIDE); ShowWindow(threads,SW_HIDE); SetFocus(bp); } } break; case WM_SIZE: { UpdateSize(LOWORD(lParam), HIWORD(lParam)); SavePosition(); return TRUE; } case WM_MOVE: SavePosition(); break; case WM_GETMINMAXINFO: { MINMAXINFO *m = (MINMAXINFO *)lParam; // Reduce the minimum size slightly, so they can size it however they like. m->ptMinTrackSize.x = defaultRect.right - defaultRect.left - 100; //m->ptMaxTrackSize.x = m->ptMinTrackSize.x; m->ptMinTrackSize.y = defaultRect.bottom - defaultRect.top - 200; } return TRUE; case WM_CLOSE: Show(false); return TRUE; } return FALSE; }
bool wxDebugContext::PrintStatistics(bool detailed) { { const wxChar* appName = wxT("application"); wxString appNameStr; if (wxTheApp) { appNameStr = wxTheApp->GetAppName(); appName = appNameStr.c_str(); OutputDumpLine(wxT("----- Memory statistics of %s at %s -----"), appName, static_cast<const wxChar *>(wxNow().c_str())); } else { OutputDumpLine( wxT("----- Memory statistics -----") ); } } bool currentMode = GetDebugMode(); SetDebugMode(false); long noNonObjectNodes = 0; long noObjectNodes = 0; long totalSize = 0; wxDebugStatsStruct *list = NULL; wxMemStruct *from = (checkPoint ? checkPoint->m_next : NULL ); if (!from) from = wxDebugContext::GetHead (); wxMemStruct *st; for (st = from; st != 0; st = st->m_next) { void* data = st->GetActualData(); if (detailed && (data != (void*) wxLog::GetActiveTarget())) { wxChar *className = (wxChar*) wxT("nonobject"); if (st->m_isObject && st->GetActualData()) { wxObject *obj = (wxObject *)st->GetActualData(); if (obj->GetClassInfo()->GetClassName()) className = (wxChar*)obj->GetClassInfo()->GetClassName(); } wxDebugStatsStruct *stats = FindStatsStruct(list, className); if (!stats) { stats = (wxDebugStatsStruct *)malloc(sizeof(wxDebugStatsStruct)); stats->instanceClass = className; stats->instanceCount = 0; stats->totalSize = 0; list = InsertStatsStruct(list, stats); } stats->instanceCount ++; stats->totalSize += st->RequestSize(); } if (data != (void*) wxLog::GetActiveTarget()) { totalSize += st->RequestSize(); if (st->m_isObject) noObjectNodes ++; else noNonObjectNodes ++; } } if (detailed) { while (list) { OutputDumpLine(wxT("%ld objects of class %s, total size %ld"), list->instanceCount, list->instanceClass, list->totalSize); wxDebugStatsStruct *old = list; list = old->next; free((char *)old); } OutputDumpLine(wxEmptyString); } SetDebugMode(currentMode); OutputDumpLine(wxT("Number of object items: %ld"), noObjectNodes); OutputDumpLine(wxT("Number of non-object items: %ld"), noNonObjectNodes); OutputDumpLine(wxT("Total allocated size: %ld"), totalSize); OutputDumpLine(wxEmptyString); OutputDumpLine(wxEmptyString); return true; }
BOOL WeightTableWindow::WtExecute(int id) { BOOL iret = FALSE; switch (id) { //edit case IDC_COPY : { SetCopyBuffer(); iret = TRUE; UpdatePasteButton(); break; } case IDC_PASTE : { PasteCopyBuffer(); InvalidateViews(); iret = TRUE; break; } case IDC_SELECTALL: { SetAllSelections(); InvalidateViews(); iret = TRUE; break; } case IDC_SELECTNONE: { ClearAllSelections(); InvalidateViews(); iret = TRUE; break; } case IDC_SELECTINVERT: { InvertSelections(); InvalidateViews(); iret = TRUE; break; } //sets case IDC_CREATE : { DialogBoxParam (hInstance, MAKEINTRESOURCE(IDD_WEIGHTTABLE_CUSTOMLISTNAME),hWnd, AddCustomListDlgProc, (LPARAM)this); iret = TRUE; break; } case IDC_DELETE : { if (GetActiveSet() >2) DeleteCustomList(GetActiveSet()); iret = TRUE; // PasteCopyBuffer(); // InvalidateViews(); break; } //options case IDC_AFFECTEDBONES_CHECK : { if (GetAffectedBonesOnly()) SetAffectedBonesOnly(FALSE); else SetAffectedBonesOnly(TRUE); iret = TRUE; break; } case IDC_UPDATEONMOUSEUP_CHECK2 : { if (GetUpdateOnMouseUp()) SetUpdateOnMouseUp(FALSE); else SetUpdateOnMouseUp(TRUE); iret = TRUE; break; } case IDC_FLIPFLOPUI_CHECK2 : { if (GetFlipFlopUI()) SetFlipFlopUI(FALSE); else SetFlipFlopUI(TRUE); iret = TRUE; break; } case IDC_ATTRIBUTE_CHECK2 : { if (GetShowAttributes()) SetShowAttributes(FALSE); else SetShowAttributes(TRUE); iret = TRUE; break; } case IDC_GLOBAL_CHECK2 : { if (GetShowGlobals()) SetShowGlobals(FALSE); else SetShowGlobals(TRUE); iret = TRUE; break; } case IDC_REDUCELABELS_CHECK2 : { if (GetReduceLabels()) SetReduceLabels(FALSE); else SetReduceLabels(TRUE); iret = TRUE; break; } case IDC_SHOWEXCLUSION_CHECK : { if (GetShowExclusion()) SetShowExclusion(FALSE); else SetShowExclusion(TRUE); iret = TRUE; break; } case IDC_SHOWLOCK_CHECK : { if (GetShowLock()) SetShowLock(FALSE); else SetShowLock(TRUE); iret = TRUE; break; } case IDC_NAMELISTGLOBAL_DROP : { if (GetAffectSelectedOnly()) SetAffectSelectedOnly(FALSE); else SetAffectSelectedOnly(TRUE); iret = TRUE; break; } case IDC_JBUIMETHOD : { if (GetJBMethod()) SetJBMethod(FALSE); else SetJBMethod(TRUE); iret = TRUE; break; } case IDC_SHOWMENU : { if (GetShowMenu()) SetShowMenu(FALSE); else SetShowMenu(TRUE); iret = TRUE; break; } case IDC_SHOWSETUI : { if (GetShowSetUI()) SetShowSetUI(FALSE); else SetShowSetUI(TRUE); iret = TRUE; break; } case IDC_SHOWOPTIONSUI : { if (GetShowOptionsUI()) SetShowOptionsUI(FALSE); else SetShowOptionsUI(TRUE); iret = TRUE; break; } case IDC_SHOWCOPYPASTEUI : { if (GetShowCopyPasteUI()) SetShowCopyPasteUI(FALSE); else SetShowCopyPasteUI(TRUE); iret = TRUE; break; } case IDC_DRAGMODE : { if (GetDragLeftMode()) SetDragLeftMode(FALSE); else SetDragLeftMode(TRUE); iret = TRUE; break; } case IDC_DEBUGMODE : { if (GetDebugMode()) SetDebugMode(FALSE); else SetDebugMode(TRUE); iret = TRUE; break; } case IDC_SHOWMARKER : { if (GetShowMarker()) SetShowMarker(FALSE); else SetShowMarker(TRUE); iret = TRUE; break; } //5.1.01 case IDC_RIGHTJUSTIFY: { if (GetRightJustify()) SetRightJustify(FALSE); else SetRightJustify(TRUE); break; } } IMenuBarContext* pContext = (IMenuBarContext*) GetCOREInterface()->GetMenuManager()->GetContext(kWeightTableMenuBar); if (pContext) pContext->UpdateWindowsMenu(); return iret; }