Merge pull request #1871 from shygoo/dma-log-export
[Debugger] Implement DMA log export (fix #1858)
This commit is contained in:
commit
372da9526f
|
@ -12,6 +12,7 @@
|
|||
#include "stdafx.h"
|
||||
#include "DebuggerUI.h"
|
||||
#include "DMALog.h"
|
||||
#include <fstream>
|
||||
|
||||
CDebugDMALogView::CDebugDMALogView(CDebuggerUI* debugger) :
|
||||
CDebugDialog<CDebugDMALogView>(debugger)
|
||||
|
@ -70,17 +71,21 @@ void CDebugDMALogView::RefreshList()
|
|||
int startIndex;
|
||||
int dmaLogSize = m_Debugger->DMALog()->GetNumEntries();
|
||||
|
||||
HWND hWndExportBtn = GetDlgItem(IDC_EXPORT_BTN);
|
||||
|
||||
if (dmaLogSize == 0)
|
||||
{
|
||||
// Reset
|
||||
m_DMAList.DeleteAllItems();
|
||||
startIndex = 0;
|
||||
m_bFilterChanged = false;
|
||||
::EnableWindow(hWndExportBtn, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Continue from last index
|
||||
startIndex = m_nLastStartIndex;
|
||||
::EnableWindow(hWndExportBtn, TRUE);
|
||||
}
|
||||
|
||||
m_DMAList.SetRedraw(FALSE);
|
||||
|
@ -130,6 +135,65 @@ void CDebugDMALogView::RefreshList()
|
|||
m_nLastStartIndex = dmaLogSize;
|
||||
}
|
||||
|
||||
void CDebugDMALogView::Export(void)
|
||||
{
|
||||
OPENFILENAME openfilename;
|
||||
TCHAR filePath[_MAX_PATH];
|
||||
|
||||
memset(&filePath, 0, sizeof(filePath));
|
||||
memset(&openfilename, 0, sizeof(openfilename));
|
||||
|
||||
wsprintf(filePath, L"*.csv");
|
||||
|
||||
const TCHAR* filters = (
|
||||
/*1*/ L"Comma separated values (*.csv)\0*.csv;\0"
|
||||
/*2*/ L"Plain text (*.txt)\0*.txt;\0"
|
||||
);
|
||||
|
||||
const char *extensions[] = { "", ".csv", ".txt" };
|
||||
|
||||
openfilename.lStructSize = sizeof(openfilename);
|
||||
openfilename.hwndOwner = (HWND)m_hWnd;
|
||||
openfilename.lpstrFilter = filters;
|
||||
openfilename.lpstrFile = filePath;
|
||||
openfilename.lpstrInitialDir = L".";
|
||||
openfilename.nMaxFile = MAX_PATH;
|
||||
openfilename.Flags = OFN_HIDEREADONLY;
|
||||
|
||||
if (GetSaveFileName(&openfilename))
|
||||
{
|
||||
stdstr path;
|
||||
path.FromUTF16(filePath);
|
||||
|
||||
if (openfilename.nFileExtension == 0)
|
||||
{
|
||||
path += extensions[openfilename.nFilterIndex];
|
||||
}
|
||||
|
||||
std::ofstream file;
|
||||
file.open(path, std::ios::out | std::ios::binary);
|
||||
|
||||
if (!file.is_open())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
file << "ROM Address,RAM Address,Length\r\n";
|
||||
|
||||
size_t numEntries = m_DMALog->GetNumEntries();
|
||||
|
||||
for (size_t nEntry = 0; nEntry < numEntries; nEntry++)
|
||||
{
|
||||
DMALOGENTRY* entry = m_DMALog->GetEntryByIndex(nEntry);
|
||||
|
||||
file << stdstr_f("0x%08X,0x%08X,0x%08X\r\n",
|
||||
entry->romAddr, entry->ramAddr, entry->length);
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CDebugDMALogView::OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
//RefreshList();
|
||||
|
@ -233,6 +297,9 @@ LRESULT CDebugDMALogView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL&
|
|||
m_DMALog->ClearEntries();
|
||||
RefreshList();
|
||||
break;
|
||||
case IDC_EXPORT_BTN:
|
||||
Export();
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ private:
|
|||
};
|
||||
|
||||
void RefreshList(void);
|
||||
void Export(void);
|
||||
|
||||
CDMALog* m_DMALog;
|
||||
|
||||
|
@ -82,6 +83,6 @@ private:
|
|||
DLGRESIZE_CONTROL(IDC_DMA_ROM_EDIT, DLSZ_MOVE_Y)
|
||||
DLGRESIZE_CONTROL(IDC_DMA_RAM_EDIT, DLSZ_MOVE_Y)
|
||||
DLGRESIZE_CONTROL(IDC_CLEAR_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
|
||||
DLGRESIZE_CONTROL(IDC_BUTTON1, DLSZ_MOVE_X | DLSZ_MOVE_Y)
|
||||
DLGRESIZE_CONTROL(IDC_EXPORT_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
|
||||
END_DLGRESIZE_MAP()
|
||||
};
|
||||
|
|
|
@ -904,7 +904,7 @@ BEGIN
|
|||
CONTROL "",IDC_DMA_LIST,"SysListView32",LVS_REPORT | LVS_OWNERDRAWFIXED | LVS_ALIGNLEFT | WS_TABSTOP,0,0,309,172
|
||||
PUSHBUTTON "Clear",IDC_CLEAR_BTN,224,176,42,14
|
||||
EDITTEXT IDC_DMA_RAM_EDIT,28,185,47,13,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Export...",IDC_BUTTON1,266,176,41,14,WS_DISABLED
|
||||
PUSHBUTTON "Export...",IDC_EXPORT_BTN,266,176,41,14,WS_DISABLED
|
||||
GROUPBOX "Trace",IDC_TRACE_STATIC,3,174,177,38,0,WS_EX_TRANSPARENT
|
||||
LTEXT "RAM",IDC_RAM_STATIC,9,187,15,9
|
||||
LTEXT "ROM",IDC_ROM_STATIC,80,187,15,9
|
||||
|
|
|
@ -453,7 +453,7 @@
|
|||
#define IDC_CLEAR_BTN 1302
|
||||
#define IDC_DMA_RAM_EDIT 1303
|
||||
#define IDC_COPY_BTN 1303
|
||||
#define IDC_BUTTON1 1305
|
||||
#define IDC_EXPORT_BTN 1305
|
||||
#define IDC_DMA_ROM_EDIT 1306
|
||||
#define IDC_TRACE_STATIC 1307
|
||||
#define IDC_RAM_STATIC 1308
|
||||
|
|
Loading…
Reference in New Issue