From 0980591fa2bb28ad78443d604ac6509cf274182d Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Tue, 25 Mar 2014 17:31:52 +0100 Subject: [PATCH] pcsx2 debugger: be more friendly with linux * Fix a couple of gcc warning and replace deprecated function * Fix the redraw of the memory zone * Avoid a crash if we breakpoint before running * Use %s on linux because %S isn't supported * Properly check .result in recMemCheck. Add some code to print hit breakpoint. * breakpoint window isn't properly resized so used a static size as a temporary workaround --- pcsx2/DebugTools/DebugInterface.cpp | 3 ++- pcsx2/gui/Debugger/CtrlDisassemblyView.cpp | 2 +- pcsx2/gui/Debugger/CtrlMemView.cpp | 8 +++++++ pcsx2/gui/Debugger/CtrlRegisterList.cpp | 8 +++---- pcsx2/gui/Debugger/DebuggerLists.cpp | 25 ++++++++++++++++++++++ pcsx2/x86/ix86-32/iR5900-32.cpp | 18 ++++++++++++++-- 6 files changed, 56 insertions(+), 8 deletions(-) diff --git a/pcsx2/DebugTools/DebugInterface.cpp b/pcsx2/DebugTools/DebugInterface.cpp index fd7635c8bd..409a34f307 100644 --- a/pcsx2/DebugTools/DebugInterface.cpp +++ b/pcsx2/DebugTools/DebugInterface.cpp @@ -6,6 +6,7 @@ #include "AppCoreThread.h" #include "Debug.h" #include "../VU.h" +#include "Counters.h" #include "../R3000A.h" #include "../IopMem.h" @@ -149,7 +150,7 @@ private: bool DebugInterface::isAlive() { - return GetCoreThread().IsOpen(); + return GetCoreThread().IsOpen() && g_FrameCount > 0; } bool DebugInterface::isCpuPaused() diff --git a/pcsx2/gui/Debugger/CtrlDisassemblyView.cpp b/pcsx2/gui/Debugger/CtrlDisassemblyView.cpp index 0901f71803..32e71d25a9 100644 --- a/pcsx2/gui/Debugger/CtrlDisassemblyView.cpp +++ b/pcsx2/gui/Debugger/CtrlDisassemblyView.cpp @@ -291,7 +291,7 @@ void CtrlDisassemblyView::drawBranchLine(wxDC& dc, std::map& addressPos int getBackgroundColor(unsigned int address) { - int colors[6] = {0xFFe0FFFF,0xFFFFe0e0,0xFFe8e8FF,0xFFFFe0FF,0xFFe0FFe0,0xFFFFFFe0}; + u32 colors[6] = {0xFFe0FFFF,0xFFFFe0e0,0xFFe8e8FF,0xFFFFe0FF,0xFFe0FFe0,0xFFFFFFe0}; int n=symbolMap.GetFunctionNum(address); if (n==-1) return 0xFFFFFFFF; return colors[n%6]; diff --git a/pcsx2/gui/Debugger/CtrlMemView.cpp b/pcsx2/gui/Debugger/CtrlMemView.cpp index 1162b2643c..9666bd3357 100644 --- a/pcsx2/gui/Debugger/CtrlMemView.cpp +++ b/pcsx2/gui/Debugger/CtrlMemView.cpp @@ -108,6 +108,14 @@ void CtrlMemView::render(wxDC& dc) bool hasFocus = wxWindow::FindFocus() == this; int visibleRows = GetClientSize().y/rowHeight; + wxColor white = wxColor(0xFFFFFFFF); + dc.SetBrush(wxBrush(white)); + dc.SetPen(wxPen(white)); + + int width,height; + dc.GetSize(&width,&height); + dc.DrawRectangle(0,0,width,height); + for (int i = 0; i < visibleRows+1; i++) { wchar_t temp[32]; diff --git a/pcsx2/gui/Debugger/CtrlRegisterList.cpp b/pcsx2/gui/Debugger/CtrlRegisterList.cpp index b6c85df711..f6a4ad1470 100644 --- a/pcsx2/gui/Debugger/CtrlRegisterList.cpp +++ b/pcsx2/gui/Debugger/CtrlRegisterList.cpp @@ -53,7 +53,7 @@ CtrlRegisterList::CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu) } SetDoubleBuffered(true); - SetInitialBestSize(ClientToWindowSize(GetMinClientSize())); + SetInitialSize(ClientToWindowSize(GetMinClientSize())); } void CtrlRegisterList::postEvent(wxEventType type, wxString text) @@ -341,19 +341,19 @@ void CtrlRegisterList::onPopupClick(wxCommandEvent& evt) { case ID_REGISTERLIST_DISPLAY32: maxBits = 32; - SetBestSize(ClientToWindowSize(GetMinClientSize())); + SetInitialSize(ClientToWindowSize(GetMinClientSize())); postEvent(debEVT_UPDATELAYOUT,0); Refresh(); break; case ID_REGISTERLIST_DISPLAY64: maxBits = 64; - SetBestSize(ClientToWindowSize(GetMinClientSize())); + SetInitialSize(ClientToWindowSize(GetMinClientSize())); postEvent(debEVT_UPDATELAYOUT,0); Refresh(); break; case ID_REGISTERLIST_DISPLAY128: maxBits = 128; - SetBestSize(ClientToWindowSize(GetMinClientSize())); + SetInitialSize(ClientToWindowSize(GetMinClientSize())); postEvent(debEVT_UPDATELAYOUT,0); Refresh(); break; diff --git a/pcsx2/gui/Debugger/DebuggerLists.cpp b/pcsx2/gui/Debugger/DebuggerLists.cpp index ec044076b6..2a7b0a8503 100644 --- a/pcsx2/gui/Debugger/DebuggerLists.cpp +++ b/pcsx2/gui/Debugger/DebuggerLists.cpp @@ -49,6 +49,11 @@ GenericListViewColumn breakpointColumns[BPL_COLUMNCOUNT] = { BreakpointList::BreakpointList(wxWindow* parent, DebugInterface* _cpu, CtrlDisassemblyView* _disassembly) : wxListView(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxLC_VIRTUAL|wxLC_REPORT|wxLC_SINGLE_SEL|wxNO_BORDER), cpu(_cpu), disasm(_disassembly) { +#ifdef __LINUX__ + // On linux wx failed to resize properly the page. I don't know why so for the moment I just create a static size page + // Far from ideal but at least I can use the memory window! + this->SetSize(wxSize(1000, 200)); +#endif insertListViewColumns(this,breakpointColumns,BPL_COLUMNCOUNT); } @@ -130,7 +135,11 @@ wxString BreakpointList::OnGetItemText(long item, long col) const const std::string sym = symbolMap.GetLabelString(displayedBreakPoints_[index].addr); if (!sym.empty()) { +#ifdef __LINUX__ + swprintf(dest,256,L"%s",sym.c_str()); +#else swprintf(dest,256,L"%S",sym.c_str()); +#endif } else { wcscpy(dest,L"-"); } @@ -144,7 +153,11 @@ wxString BreakpointList::OnGetItemText(long item, long col) const } else { char temp[256]; disasm->getOpcodeText(displayedBreakPoints_[index].addr, temp); +#ifdef __LINUX__ + swprintf(dest,256,L"%s",temp); +#else swprintf(dest,256,L"%S",temp); +#endif } } break; @@ -153,7 +166,11 @@ wxString BreakpointList::OnGetItemText(long item, long col) const if (isMemory || displayedBreakPoints_[index].hasCond == false) { wcscpy(dest,L"-"); } else { +#ifdef __LINUX__ + swprintf(dest,256,L"%s",displayedBreakPoints_[index].cond.expressionString); +#else swprintf(dest,256,L"%S",displayedBreakPoints_[index].cond.expressionString); +#endif } } break; @@ -169,9 +186,17 @@ wxString BreakpointList::OnGetItemText(long item, long col) const case BPL_ENABLED: { if (isMemory) { +#ifdef __LINUX__ + swprintf(dest,256,L"%s",displayedMemChecks_[index].cond & MEMCHECK_BREAK ? "true" : "false"); +#else swprintf(dest,256,L"%S",displayedMemChecks_[index].cond & MEMCHECK_BREAK ? "true" : "false"); +#endif } else { +#ifdef __LINUX__ + swprintf(dest,256,L"%s",displayedBreakPoints_[index].enabled ? "true" : "false"); +#else swprintf(dest,256,L"%S",displayedBreakPoints_[index].enabled ? "true" : "false"); +#endif } } break; diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index e4dd361ae9..ec7d5a89e7 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -1295,6 +1295,14 @@ void dynarecMemcheck() recExitExecution(); } +__fastcall void dynarecMemLogcheck(u32 start, bool store) +{ + if (store) + DevCon.WriteLn("Hit store breakpoint @0x%x", start); + else + DevCon.WriteLn("Hit load breakpoint @0x%x", start); +} + void recMemcheck(u32 bits, bool store) { iFlushCall(FLUSH_INTERPRETER); @@ -1315,7 +1323,7 @@ void recMemcheck(u32 bits, bool store) auto checks = CBreakPoints::GetMemChecks(); for (size_t i = 0; i < checks.size(); i++) { - if ((checks[i].cond & MEMCHECK_BREAK) == 0) + if (checks[i].result == 0) continue; if ((checks[i].cond & MEMCHECK_WRITE) == 0 && store == true) continue; @@ -1333,7 +1341,13 @@ void recMemcheck(u32 bits, bool store) xForwardJGE8 next2; // if start >= address+size then goto next2 // hit the breakpoint - xCALL(&dynarecMemcheck); + if (checks[i].result & MEMCHECK_LOG) { + xMOV(edx, store); + xCALL(&dynarecMemLogcheck); + } + if (checks[i].result & MEMCHECK_BREAK) { + xCALL(&dynarecMemcheck); + } next1.SetTarget(); next2.SetTarget();