From 2a5b8f43660d00dbc6ed004bfbe61f643945e9f7 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Fri, 3 Apr 2009 18:04:08 +0000 Subject: [PATCH] some progress on dsp llet debugger. go dump some ucodes ;) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2854 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DebuggerWX/Src/CodeWindow.cpp | 3 +- .../Src/Debugger/Debugger.cpp | 74 +++++++++++++++---- .../Src/Debugger/Debugger.h | 9 ++- .../Plugin_DSP_LLE-testing/Src/Globals.h | 1 - .../Plugin_DSP_LLE-testing/Src/Tools.cpp | 6 +- .../Src/gdsp_interface.cpp | 5 +- .../Src/gdsp_interpreter.cpp | 1 + .../Src/gdsp_interpreter.h | 1 + 8 files changed, 74 insertions(+), 26 deletions(-) diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.cpp b/Source/Core/DebuggerWX/Src/CodeWindow.cpp index 60b46928c7..6d4f668eb0 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindow.cpp @@ -510,8 +510,7 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam wxMenuItem* pJit = pDebugDialogs->Append(IDM_JITWINDOW, _T("&Jit"), wxEmptyString, wxITEM_CHECK); pJit->Check(bJitWindow); - wxMenuItem* pSound = pDebugDialogs->Append(IDM_SOUNDWINDOW, _T("&Sound"), wxEmptyString, wxITEM_CHECK); - pSound->Check(bSoundWindow); + wxMenuItem* pSound = pDebugDialogs->Append(IDM_SOUNDWINDOW, _T("&Sound"), wxEmptyString); wxMenuItem* pVideo = pDebugDialogs->Append(IDM_VIDEOWINDOW, _T("&Video"), wxEmptyString, wxITEM_CHECK); pVideo->Check(bVideoWindow); diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Debugger/Debugger.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Debugger/Debugger.cpp index e3378aa340..3ada940956 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Debugger/Debugger.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Debugger/Debugger.cpp @@ -28,12 +28,11 @@ BEGIN_EVENT_TABLE(DSPDebuggerLLE, wxFrame) EVT_CLOSE(DSPDebuggerLLE::OnClose) EVT_SIZE(DSPDebuggerLLE::OnChangeSize) - //EVT_RIGHT_DOWN(DSPDebuggerLLE::ScrollBlocks) - //EVT_LEFT_DOWN(DSPDebuggerLLE::ScrollBlocks) - //EVT_MOUSE_EVENTS(DSPDebuggerLLE::ScrollBlocks) - //EVT_MOTION(DSPDebuggerLLE::ScrollBlocks) - //EVT_SCROLL(DSPDebuggerLLE::ScrollBlocks) - //EVT_SCROLLWIN(DSPDebuggerLLE::ScrollBlocks) + EVT_MENU_RANGE(ID_RUNTOOL, ID_STEPTOOL, DSPDebuggerLLE::OnChangeState) + EVT_MENU(ID_DUMPCODETOOL, DSPDebuggerLLE::OnDumpCode) + + EVT_LIST_ITEM_RIGHT_CLICK(ID_DISASM, DSPDebuggerLLE::OnRightClick) + EVT_LIST_ITEM_ACTIVATED(ID_DISASM, DSPDebuggerLLE::OnDoubleClick) END_EVENT_TABLE() DSPDebuggerLLE::DSPDebuggerLLE(wxWindow *parent, wxWindowID id, const wxString &title, @@ -60,11 +59,10 @@ void DSPDebuggerLLE::CreateGUIControls() m_Toolbar = CreateToolBar(wxTB_NODIVIDER|wxTB_NOICONS|wxTB_HORZ_TEXT|wxTB_DOCKABLE, ID_TOOLBAR); m_Toolbar->AddTool(ID_RUNTOOL, wxT("Run"), wxNullBitmap, wxEmptyString, wxITEM_NORMAL); - m_Toolbar->AddTool(ID_PAUSETOOL, wxT("Pause"), wxNullBitmap, wxEmptyString, wxITEM_NORMAL); m_Toolbar->AddTool(ID_STEPTOOL, wxT("Step"), wxNullBitmap, wxT("Step Code "), wxITEM_NORMAL); - m_Toolbar->AddTool(ID_RESETTOPCTOOL, wxT("Show Pc"), wxNullBitmap, wxT("Reset To PC counter"), wxITEM_NORMAL); + m_Toolbar->AddTool(ID_SHOWPCTOOL, wxT("Show Pc"), wxNullBitmap, wxT("Reset To PC counter"), wxITEM_NORMAL); m_Toolbar->AddTool(ID_JUMPTOTOOL, wxT("Jump"), wxNullBitmap, wxT("Jump to a specific Address"), wxITEM_NORMAL); - m_Toolbar->AddTool(ID_DUMPCODETOOL, wxT("Dump"), wxNullBitmap, wxT("Dump Code to File"), wxITEM_NORMAL); + m_Toolbar->AddCheckTool(ID_DUMPCODETOOL, wxT("Dump"), wxNullBitmap, wxNullBitmap, wxT("Dump UCode to File")); m_Toolbar->AddSeparator(); m_Toolbar->AddCheckTool(ID_CHECK_ASSERTINT, wxT("AssertInt"), wxNullBitmap, wxNullBitmap, wxEmptyString); m_Toolbar->AddCheckTool(ID_CHECK_HALT, wxT("Halt"), wxNullBitmap, wxNullBitmap, wxEmptyString); @@ -96,7 +94,8 @@ void DSPDebuggerLLE::CreateGUIControls() } void DSPDebuggerLLE::OnClose(wxCloseEvent& event) -{ +{ + wxWindow::Destroy(); event.Skip(); } @@ -106,6 +105,55 @@ void DSPDebuggerLLE::OnChangeSize(wxSizeEvent& event) event.Skip(); } +void DSPDebuggerLLE::OnChangeState(wxCommandEvent& event) +{ + switch (event.GetId()) + { + case ID_RUNTOOL: + if ((m_State == RUN) || (m_State == RUN_START)) + m_State = PAUSE; + else + m_State = RUN_START; + break; + + case ID_STEPTOOL: + m_State = STEP; + break; + } + + if ((m_State == RUN) || (m_State == RUN_START)) + m_Toolbar->FindById(ID_RUNTOOL)->SetLabel(wxT("Pause")); + else + m_Toolbar->FindById(ID_RUNTOOL)->SetLabel(wxT("Run")); + m_Toolbar->Realize(); +} + +void DSPDebuggerLLE::OnDumpCode(wxCommandEvent& event) +{ + g_dsp.dump_imem = event.IsChecked(); +} + +void DSPDebuggerLLE::OnRightClick(wxListEvent& event) +{ + long item = m_Disasm->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + u16 SelectedPC = static_cast(m_Disasm->GetItemData(item)); + g_dsp.pc = SelectedPC; + + Refresh(); +} + +void DSPDebuggerLLE::OnDoubleClick(wxListEvent& event) +{ + long item = m_Disasm->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + u16 SelectedPC = static_cast(m_Disasm->GetItemData(item)); + ToggleBreakPoint(SelectedPC); + + if (IsBreakPoint(SelectedPC)) + m_Disasm->SetItem(item, COLUMN_BP, wxT("*")); + else + m_Disasm->SetItem(item, COLUMN_BP, wxT("")); +} + void DSPDebuggerLLE::Refresh() { UpdateSymbolMap(); @@ -244,17 +292,13 @@ void DSPDebuggerLLE::UpdateDisAsmListView() m_CachedStepCounter = g_dsp.step_counter; -// RebuildDisAsmListView(); // TODO do we need this? - m_Regs->Update(); } void DSPDebuggerLLE::UpdateSymbolMap() { if (g_dsp.dram == NULL) - { return; - } if (m_CachedUCodeCRC != g_dsp.iram_crc) { @@ -265,7 +309,7 @@ void DSPDebuggerLLE::UpdateSymbolMap() LoadSymbolMap(FileName); // rebuild the disasm -// RebuildDisAsmListView(); // TODO do we need this? + RebuildDisAsmListView(); } } diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Debugger/Debugger.h b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Debugger/Debugger.h index 8eb1c49bf8..ae7d278bfd 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Debugger/Debugger.h +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Debugger/Debugger.h @@ -63,14 +63,13 @@ private: // Toolbar ID_TOOLBAR = 1000, ID_RUNTOOL, - ID_PAUSETOOL, ID_STEPTOOL, - ID_RESETTOPCTOOL, + ID_SHOWPCTOOL, ID_JUMPTOTOOL, + ID_DUMPCODETOOL, ID_CHECK_ASSERTINT, ID_CHECK_HALT, ID_CHECK_INIT, - ID_DUMPCODETOOL, // Disasm view ID_DISASM, @@ -147,6 +146,10 @@ private: void OnClose(wxCloseEvent& event); void OnChangeSize(wxSizeEvent& event); + void OnChangeState(wxCommandEvent& event); + void OnDumpCode(wxCommandEvent& event); + void OnRightClick(wxListEvent& event); + void OnDoubleClick(wxListEvent& event); void CreateGUIControls(); void Refresh(); diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.h b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.h index 95f752520c..9471b02a04 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.h +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.h @@ -22,7 +22,6 @@ #include #define WITH_DSP_ON_THREAD 1 -#define DUMP_DSP_IMEM 0 #define PROFILE 0 diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.cpp index 4d1325832c..770ed12f6c 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.cpp @@ -26,7 +26,7 @@ bool DumpDSPCode(u32 _Address, u32 _Length, u32 crc) { char szFilename[MAX_PATH]; - sprintf(szFilename, "c:\\_\\DSP_UC_%08X.bin", crc); + sprintf(szFilename, "%sDSP_UC_%08X.bin", FULL_DUMP_DIR, crc); FILE* pFile = fopen(szFilename, "wb"); if (pFile != NULL) @@ -73,7 +73,9 @@ u32 GenerateCRC(const unsigned char* _pBuffer, int _pLength) bool DumpCWCode(u32 _Address, u32 _Length) { - FILE* pFile = fopen("d:\\DSP_UCode.bin", "wb"); + char filename[256]; + sprintf(filename, "%sDSP_UCode.bin", FULL_DUMP_DIR); + FILE* pFile = fopen(filename, "wb"); if (pFile != NULL) { diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.cpp index ccf9b2b4cc..fd32292fb1 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.cpp @@ -256,9 +256,8 @@ void gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size) g_dsp.iram_crc = GenerateCRC(g_dsp.cpu_ram + (addr & 0x0fffffff), size); DEBUG_LOG(DSPHLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)\n", addr, dsp_addr, g_dsp.iram_crc); -#if DUMP_DSP_IMEM - DumpDSPCode(addr, size, g_dsp.iram_crc ); -#endif + if (g_dsp.dump_imem) + DumpDSPCode(addr, size, g_dsp.iram_crc ); } diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interpreter.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interpreter.cpp index d45f181671..5765e4366e 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interpreter.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interpreter.cpp @@ -53,6 +53,7 @@ void (*SDSP::irq_request)() = NULL; bool SDSP::exception_in_progress_hack = false; // for debugger only +bool SDSP::dump_imem = false; u32 SDSP::iram_crc = 0; u64 SDSP::step_counter = 0; diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interpreter.h b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interpreter.h index 787be8a951..e5bfe731ea 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interpreter.h +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interpreter.h @@ -79,6 +79,7 @@ struct SDSP static void (* irq_request)(void); // for debugger only + static bool dump_imem; static u32 iram_crc; static u64 step_counter; static bool exception_in_progress_hack;