[Debugger] Code clean up and fix some warnings
This commit is contained in:
parent
fda0ce24e6
commit
0e508ebc20
|
@ -56,7 +56,7 @@ LRESULT CAddSymbolDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*l
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
LRESULT CAddSymbolDlg::OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
LRESULT CAddSymbolDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
switch (wID)
|
||||
{
|
||||
|
|
|
@ -63,7 +63,7 @@ private:
|
|||
CDebugCommandsView* m_CommandsWindow;
|
||||
|
||||
LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnKeyUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
LRESULT OnKeyUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
|
||||
{
|
||||
if (wParam == VK_RETURN || wParam == VK_ESCAPE)
|
||||
{
|
||||
|
|
|
@ -68,7 +68,7 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/,
|
|||
int CurrentFormatSel = m_FormatList.GetCurSel();
|
||||
DumpFormat Format = (DumpFormat)m_FormatList.GetItemData(CurrentFormatSel);
|
||||
|
||||
const char* FileFilter;
|
||||
const char* FileFilter = "All files (*.*)\0*.*\0";
|
||||
|
||||
if (Format == RawBigEndian)
|
||||
{
|
||||
|
|
|
@ -200,6 +200,7 @@ LRESULT CDebugMemorySearch::OnResultDblClick(LPNMHDR)
|
|||
int ItemId = m_SearchResults.GetItemData(iItem);
|
||||
SearchResultItem & Result = m_SearchResult[ItemId];
|
||||
m_Debugger->Debug_ShowMemoryLocation(Result.PAddr, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDebugMemorySearch::EnableValueOptions(bool Enable)
|
||||
|
|
|
@ -54,7 +54,7 @@ private:
|
|||
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
|
||||
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_RCLICK, OnResultRClick)
|
||||
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_DBLCLK, OnResultDblClick)
|
||||
END_MSG_MAP()
|
||||
END_MSG_MAP()
|
||||
|
||||
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
|
||||
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -272,6 +272,7 @@ private:
|
|||
|
||||
public:
|
||||
void Attach(HWND hWndNew);
|
||||
HWND Detach();
|
||||
CWindow AddTab(char* caption, int dialogId, DLGPROC dlgProc);
|
||||
void ShowTab(int nPage);
|
||||
CRect GetPageRect();
|
||||
|
|
|
@ -16,381 +16,380 @@
|
|||
//char* CEditEval::m_EvalString;
|
||||
|
||||
CDebugScripts::CDebugScripts(CDebuggerUI* debugger) :
|
||||
CDebugDialog<CDebugScripts>(debugger)
|
||||
CDebugDialog<CDebugScripts>(debugger)
|
||||
{
|
||||
m_SelectedScriptName = (char*)malloc(MAX_PATH);
|
||||
//CScriptSystem::SetScriptsWindow(this);
|
||||
m_SelectedScriptName = (char*)malloc(MAX_PATH);
|
||||
//CScriptSystem::SetScriptsWindow(this);
|
||||
}
|
||||
|
||||
CDebugScripts::~CDebugScripts(void)
|
||||
{
|
||||
free(m_SelectedScriptName);
|
||||
free(m_SelectedScriptName);
|
||||
}
|
||||
|
||||
LRESULT CDebugScripts::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
DlgResize_Init(false, true);
|
||||
DlgResize_Init(false, true);
|
||||
|
||||
HFONT monoFont = CreateFont(-11, 0, 0, 0,
|
||||
FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
|
||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
CLEARTYPE_QUALITY, FF_DONTCARE, "Consolas"
|
||||
);
|
||||
|
||||
m_InstanceInfoEdit.Attach(GetDlgItem(IDC_CTX_INFO_EDIT));
|
||||
HFONT monoFont = CreateFont(-11, 0, 0, 0,
|
||||
FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
|
||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
CLEARTYPE_QUALITY, FF_DONTCARE, "Consolas"
|
||||
);
|
||||
|
||||
m_ScriptList.Attach(GetDlgItem(IDC_SCRIPT_LIST));
|
||||
m_ScriptList.AddColumn("Script", 0, 0);
|
||||
m_ScriptList.SetColumnWidth(0, 100);
|
||||
m_ScriptList.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
|
||||
m_ScriptList.ModifyStyle(LVS_OWNERDRAWFIXED, 0, 0);
|
||||
m_InstanceInfoEdit.Attach(GetDlgItem(IDC_CTX_INFO_EDIT));
|
||||
|
||||
m_EvalEdit.Attach(GetDlgItem(IDC_EVAL_EDIT));
|
||||
m_EvalEdit.SetScriptWindow(this);
|
||||
m_EvalEdit.SetFont(monoFont);
|
||||
m_EvalEdit.EnableWindow(FALSE);
|
||||
m_ScriptList.Attach(GetDlgItem(IDC_SCRIPT_LIST));
|
||||
m_ScriptList.AddColumn("Script", 0, 0);
|
||||
m_ScriptList.SetColumnWidth(0, 100);
|
||||
m_ScriptList.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
|
||||
m_ScriptList.ModifyStyle(LVS_OWNERDRAWFIXED, 0, 0);
|
||||
|
||||
m_ConsoleEdit.Attach(GetDlgItem(IDC_CONSOLE_EDIT));
|
||||
m_ConsoleEdit.SetLimitText(0);
|
||||
m_ConsoleEdit.SetFont(monoFont);
|
||||
|
||||
RefreshList();
|
||||
m_EvalEdit.Attach(GetDlgItem(IDC_EVAL_EDIT));
|
||||
m_EvalEdit.SetScriptWindow(this);
|
||||
m_EvalEdit.SetFont(monoFont);
|
||||
m_EvalEdit.EnableWindow(FALSE);
|
||||
|
||||
WindowCreated();
|
||||
return 0;
|
||||
m_ConsoleEdit.Attach(GetDlgItem(IDC_CONSOLE_EDIT));
|
||||
m_ConsoleEdit.SetLimitText(0);
|
||||
m_ConsoleEdit.SetFont(monoFont);
|
||||
|
||||
RefreshList();
|
||||
|
||||
WindowCreated();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CDebugScripts::ConsolePrint(const char* text)
|
||||
{
|
||||
::ShowWindow(*this, SW_SHOWNOACTIVATE);
|
||||
int textPos = m_ConsoleEdit.GetWindowTextLengthA();
|
||||
|
||||
// Get scrollbar state
|
||||
SCROLLINFO scroll;
|
||||
scroll.cbSize = sizeof(SCROLLINFO);
|
||||
scroll.fMask = SIF_ALL;
|
||||
m_ConsoleEdit.GetScrollInfo(SB_VERT, &scroll);
|
||||
|
||||
m_ConsoleEdit.SetRedraw(FALSE);
|
||||
::ShowWindow(*this, SW_SHOWNOACTIVATE);
|
||||
int textPos = m_ConsoleEdit.GetWindowTextLengthA();
|
||||
|
||||
m_ConsoleEdit.AppendText(text);
|
||||
// Get scrollbar state
|
||||
SCROLLINFO scroll;
|
||||
scroll.cbSize = sizeof(SCROLLINFO);
|
||||
scroll.fMask = SIF_ALL;
|
||||
m_ConsoleEdit.GetScrollInfo(SB_VERT, &scroll);
|
||||
|
||||
m_ConsoleEdit.SetRedraw(TRUE);
|
||||
m_ConsoleEdit.SetRedraw(FALSE);
|
||||
|
||||
if ((scroll.nPage + scroll.nPos) - 1 == scroll.nMax)
|
||||
{
|
||||
m_ConsoleEdit.ScrollCaret();
|
||||
}
|
||||
m_ConsoleEdit.AppendText(text);
|
||||
|
||||
m_ConsoleEdit.SetRedraw(TRUE);
|
||||
|
||||
if ((scroll.nPage + scroll.nPos) - 1 == scroll.nMax)
|
||||
{
|
||||
m_ConsoleEdit.ScrollCaret();
|
||||
}
|
||||
}
|
||||
|
||||
void CDebugScripts::RefreshConsole()
|
||||
{
|
||||
m_Debugger->Debug_ShowScriptsWindow();
|
||||
CScriptSystem* scriptSystem = m_Debugger->ScriptSystem();
|
||||
vector<char*>* logData = scriptSystem->LogData();
|
||||
m_Debugger->Debug_ShowScriptsWindow();
|
||||
CScriptSystem* scriptSystem = m_Debugger->ScriptSystem();
|
||||
vector<char*>* logData = scriptSystem->LogData();
|
||||
|
||||
while(logData->size() != 0)
|
||||
{
|
||||
ConsolePrint((*logData)[0]);
|
||||
free((*logData)[0]);
|
||||
logData->erase(logData->begin() + 0);
|
||||
}
|
||||
while (logData->size() != 0)
|
||||
{
|
||||
ConsolePrint((*logData)[0]);
|
||||
free((*logData)[0]);
|
||||
logData->erase(logData->begin() + 0);
|
||||
}
|
||||
}
|
||||
|
||||
void CDebugScripts::ConsoleClear()
|
||||
{
|
||||
m_ConsoleEdit.SetWindowTextA("");
|
||||
m_ConsoleEdit.SetWindowTextA("");
|
||||
}
|
||||
|
||||
void CDebugScripts::ConsoleCopy()
|
||||
{
|
||||
if (!OpenClipboard())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!OpenClipboard())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EmptyClipboard();
|
||||
EmptyClipboard();
|
||||
|
||||
size_t nChars = m_ConsoleEdit.GetWindowTextLengthA() + 1;
|
||||
size_t nChars = m_ConsoleEdit.GetWindowTextLengthA() + 1;
|
||||
|
||||
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, nChars);
|
||||
|
||||
char* memBuf = (char*) GlobalLock(hMem);
|
||||
m_ConsoleEdit.GetWindowTextA(memBuf, nChars);
|
||||
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, nChars);
|
||||
|
||||
GlobalUnlock(hMem);
|
||||
HANDLE hRes = SetClipboardData(CF_TEXT, hMem);
|
||||
|
||||
GlobalFree(hMem);
|
||||
CloseClipboard();
|
||||
char* memBuf = (char*)GlobalLock(hMem);
|
||||
m_ConsoleEdit.GetWindowTextA(memBuf, nChars);
|
||||
|
||||
GlobalUnlock(hMem);
|
||||
HANDLE hRes = SetClipboardData(CF_TEXT, hMem);
|
||||
|
||||
GlobalFree(hMem);
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
void CDebugScripts::RefreshList()
|
||||
{
|
||||
int nIndex = m_ScriptList.GetSelectedIndex();
|
||||
|
||||
CPath SearchPath("Scripts", "*");
|
||||
int nIndex = m_ScriptList.GetSelectedIndex();
|
||||
|
||||
if (!SearchPath.FindFirst(CPath::FIND_ATTRIBUTE_ALLFILES))
|
||||
{
|
||||
return;
|
||||
}
|
||||
CPath SearchPath("Scripts", "*");
|
||||
|
||||
m_ScriptList.SetRedraw(false);
|
||||
m_ScriptList.DeleteAllItems();
|
||||
if (!SearchPath.FindFirst(CPath::FIND_ATTRIBUTE_ALLFILES))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
stdstr scriptFileName = SearchPath.GetNameExtension();
|
||||
m_ScriptList.AddItem(0, 0, scriptFileName.c_str());
|
||||
} while (SearchPath.FindNext());
|
||||
m_ScriptList.SetRedraw(false);
|
||||
m_ScriptList.DeleteAllItems();
|
||||
|
||||
m_ScriptList.SetRedraw(true);
|
||||
m_ScriptList.Invalidate();
|
||||
do
|
||||
{
|
||||
stdstr scriptFileName = SearchPath.GetNameExtension();
|
||||
m_ScriptList.AddItem(0, 0, scriptFileName.c_str());
|
||||
} while (SearchPath.FindNext());
|
||||
|
||||
if (nIndex >= 0)
|
||||
{
|
||||
m_ScriptList.SelectItem(nIndex);
|
||||
RefreshStatus();
|
||||
}
|
||||
m_ScriptList.SetRedraw(true);
|
||||
m_ScriptList.Invalidate();
|
||||
|
||||
if (nIndex >= 0)
|
||||
{
|
||||
m_ScriptList.SelectItem(nIndex);
|
||||
RefreshStatus();
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CDebugScripts::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
switch (wID)
|
||||
{
|
||||
case IDCANCEL:
|
||||
EndDialog(0);
|
||||
break;
|
||||
case ID_POPUP_RUN:
|
||||
RunSelected();
|
||||
break;
|
||||
case ID_POPUP_STOP:
|
||||
StopSelected();
|
||||
break;
|
||||
case IDC_CLEAR_BTN:
|
||||
ConsoleClear();
|
||||
break;
|
||||
case IDC_COPY_BTN:
|
||||
ConsoleCopy();
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
switch (wID)
|
||||
{
|
||||
case IDCANCEL:
|
||||
EndDialog(0);
|
||||
break;
|
||||
case ID_POPUP_RUN:
|
||||
RunSelected();
|
||||
break;
|
||||
case ID_POPUP_STOP:
|
||||
StopSelected();
|
||||
break;
|
||||
case IDC_CLEAR_BTN:
|
||||
ConsoleClear();
|
||||
break;
|
||||
case IDC_COPY_BTN:
|
||||
ConsoleCopy();
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LRESULT CDebugScripts::OnScriptListDblClicked(NMHDR* pNMHDR)
|
||||
{
|
||||
// Run script on double click
|
||||
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
|
||||
int nItem = pIA->iItem;
|
||||
// Run script on double click
|
||||
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
|
||||
int nItem = pIA->iItem;
|
||||
|
||||
m_ScriptList.SelectItem(nItem);
|
||||
m_ScriptList.SelectItem(nItem);
|
||||
|
||||
RunSelected();
|
||||
|
||||
return 0;
|
||||
RunSelected();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CDebugScripts::RefreshStatus()
|
||||
{
|
||||
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
|
||||
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
|
||||
|
||||
char* szState;
|
||||
switch (state)
|
||||
{
|
||||
case STATE_RUNNING: szState = "Running"; break;
|
||||
case STATE_STARTED: szState = "Started"; break;
|
||||
case STATE_STOPPED: szState = "Stopped"; break;
|
||||
case STATE_INVALID: szState = "Not running"; break;
|
||||
}
|
||||
char* szState = "";
|
||||
switch (state)
|
||||
{
|
||||
case STATE_RUNNING: szState = "Running"; break;
|
||||
case STATE_STARTED: szState = "Started"; break;
|
||||
case STATE_STOPPED: szState = "Stopped"; break;
|
||||
case STATE_INVALID: szState = "Not running"; break;
|
||||
}
|
||||
|
||||
stdstr instanceInfo = stdstr_f("%s (%s)", m_SelectedScriptName, szState);
|
||||
stdstr instanceInfo = stdstr_f("%s (%s)", m_SelectedScriptName, szState);
|
||||
|
||||
m_InstanceInfoEdit.SetWindowTextA(instanceInfo.c_str());
|
||||
m_InstanceInfoEdit.SetWindowTextA(instanceInfo.c_str());
|
||||
|
||||
if (state == STATE_RUNNING)
|
||||
{
|
||||
m_EvalEdit.EnableWindow(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_EvalEdit.EnableWindow(FALSE);
|
||||
}
|
||||
if (state == STATE_RUNNING)
|
||||
{
|
||||
m_EvalEdit.EnableWindow(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_EvalEdit.EnableWindow(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CDebugScripts::OnScriptListClicked(NMHDR* pNMHDR)
|
||||
{
|
||||
// Select instance for console input
|
||||
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
|
||||
int nItem = pIA->iItem;
|
||||
|
||||
m_ScriptList.GetItemText(nItem, 0, m_SelectedScriptName, MAX_PATH);
|
||||
|
||||
RefreshStatus();
|
||||
// Select instance for console input
|
||||
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
|
||||
int nItem = pIA->iItem;
|
||||
|
||||
return 0;
|
||||
m_ScriptList.GetItemText(nItem, 0, m_SelectedScriptName, MAX_PATH);
|
||||
|
||||
RefreshStatus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CDebugScripts::OnScriptListRClicked(NMHDR* pNMHDR)
|
||||
{
|
||||
OnScriptListClicked(pNMHDR);
|
||||
OnScriptListClicked(pNMHDR);
|
||||
|
||||
HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_SCRIPT_POPUP));
|
||||
HMENU hPopupMenu = GetSubMenu(hMenu, 0);
|
||||
|
||||
/*
|
||||
if (m_Breakpoints->m_RBP.size() == 0 && m_Breakpoints->m_WBP.size() == 0)
|
||||
{
|
||||
EnableMenuItem(hPopupMenu, ID_POPUPMENU_CLEARALLBPS, MF_DISABLED | MF_GRAYED);
|
||||
}
|
||||
*/
|
||||
HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_SCRIPT_POPUP));
|
||||
HMENU hPopupMenu = GetSubMenu(hMenu, 0);
|
||||
|
||||
POINT mouse;
|
||||
GetCursorPos(&mouse);
|
||||
/*
|
||||
if (m_Breakpoints->m_RBP.size() == 0 && m_Breakpoints->m_WBP.size() == 0)
|
||||
{
|
||||
EnableMenuItem(hPopupMenu, ID_POPUPMENU_CLEARALLBPS, MF_DISABLED | MF_GRAYED);
|
||||
}
|
||||
*/
|
||||
|
||||
TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN, mouse.x, mouse.y, 0, m_hWnd, NULL);
|
||||
POINT mouse;
|
||||
GetCursorPos(&mouse);
|
||||
|
||||
DestroyMenu(hMenu);
|
||||
TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN, mouse.x, mouse.y, 0, m_hWnd, NULL);
|
||||
|
||||
return 0;
|
||||
DestroyMenu(hMenu);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CDebugScripts::OnScriptListCustomDraw(NMHDR* pNMHDR)
|
||||
{
|
||||
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
|
||||
DWORD drawStage = pLVCD->nmcd.dwDrawStage;
|
||||
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
|
||||
DWORD drawStage = pLVCD->nmcd.dwDrawStage;
|
||||
|
||||
switch (drawStage)
|
||||
{
|
||||
case CDDS_PREPAINT:
|
||||
return CDRF_NOTIFYITEMDRAW;
|
||||
case CDDS_ITEMPREPAINT:
|
||||
return CDRF_NOTIFYSUBITEMDRAW;
|
||||
case (CDDS_ITEMPREPAINT | CDDS_SUBITEM):
|
||||
break;
|
||||
default:
|
||||
return CDRF_DODEFAULT;
|
||||
}
|
||||
switch (drawStage)
|
||||
{
|
||||
case CDDS_PREPAINT:
|
||||
return CDRF_NOTIFYITEMDRAW;
|
||||
case CDDS_ITEMPREPAINT:
|
||||
return CDRF_NOTIFYSUBITEMDRAW;
|
||||
case (CDDS_ITEMPREPAINT | CDDS_SUBITEM):
|
||||
break;
|
||||
default:
|
||||
return CDRF_DODEFAULT;
|
||||
}
|
||||
|
||||
DWORD nItem = pLVCD->nmcd.dwItemSpec;
|
||||
DWORD nItem = pLVCD->nmcd.dwItemSpec;
|
||||
|
||||
char scriptName[MAX_PATH];
|
||||
m_ScriptList.GetItemText(nItem, 0, scriptName, MAX_PATH);
|
||||
char scriptName[MAX_PATH];
|
||||
m_ScriptList.GetItemText(nItem, 0, scriptName, MAX_PATH);
|
||||
|
||||
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(scriptName);
|
||||
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(scriptName);
|
||||
|
||||
if (state == STATE_STARTED)
|
||||
{
|
||||
pLVCD->clrTextBk = RGB(0xFF, 0xFF, 0xAA);
|
||||
}
|
||||
else if (state == STATE_RUNNING)
|
||||
{
|
||||
pLVCD->clrTextBk = RGB(0xAA, 0xFF, 0xAA);
|
||||
}
|
||||
|
||||
return CDRF_DODEFAULT;
|
||||
if (state == STATE_STARTED)
|
||||
{
|
||||
pLVCD->clrTextBk = RGB(0xFF, 0xFF, 0xAA);
|
||||
}
|
||||
else if (state == STATE_RUNNING)
|
||||
{
|
||||
pLVCD->clrTextBk = RGB(0xAA, 0xFF, 0xAA);
|
||||
}
|
||||
|
||||
return CDRF_DODEFAULT;
|
||||
}
|
||||
|
||||
void CDebugScripts::EvaluateInSelectedInstance(char* code)
|
||||
{
|
||||
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
|
||||
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
|
||||
|
||||
if (state == STATE_RUNNING || state == STATE_STARTED)
|
||||
{
|
||||
CScriptInstance* instance = m_Debugger->ScriptSystem()->GetInstance(m_SelectedScriptName);
|
||||
//instance->EvalAsync(code);
|
||||
instance->Eval(code);
|
||||
}
|
||||
if (state == STATE_RUNNING || state == STATE_STARTED)
|
||||
{
|
||||
CScriptInstance* instance = m_Debugger->ScriptSystem()->GetInstance(m_SelectedScriptName);
|
||||
//instance->EvalAsync(code);
|
||||
instance->Eval(code);
|
||||
}
|
||||
}
|
||||
|
||||
// Console input
|
||||
LRESULT CEditEval::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (wParam == VK_UP)
|
||||
{
|
||||
if (m_HistoryIdx > 0)
|
||||
{
|
||||
char* code = m_History[--m_HistoryIdx];
|
||||
SetWindowTextA(code);
|
||||
int selEnd = strlen(code);
|
||||
SetSel(selEnd, selEnd);
|
||||
}
|
||||
}
|
||||
else if (wParam == VK_DOWN)
|
||||
{
|
||||
int size = m_History.size();
|
||||
if (m_HistoryIdx < size - 1)
|
||||
{
|
||||
char* code = m_History[++m_HistoryIdx];
|
||||
SetWindowTextA(code);
|
||||
int selEnd = strlen(code);
|
||||
SetSel(selEnd, selEnd);
|
||||
}
|
||||
else if (m_HistoryIdx < size)
|
||||
{
|
||||
SetWindowTextA("");
|
||||
m_HistoryIdx++;
|
||||
}
|
||||
}
|
||||
else if (wParam == VK_RETURN)
|
||||
{
|
||||
if (m_ScriptWindow == NULL)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
if (wParam == VK_UP)
|
||||
{
|
||||
if (m_HistoryIdx > 0)
|
||||
{
|
||||
char* code = m_History[--m_HistoryIdx];
|
||||
SetWindowTextA(code);
|
||||
int selEnd = strlen(code);
|
||||
SetSel(selEnd, selEnd);
|
||||
}
|
||||
}
|
||||
else if (wParam == VK_DOWN)
|
||||
{
|
||||
int size = m_History.size();
|
||||
if (m_HistoryIdx < size - 1)
|
||||
{
|
||||
char* code = m_History[++m_HistoryIdx];
|
||||
SetWindowTextA(code);
|
||||
int selEnd = strlen(code);
|
||||
SetSel(selEnd, selEnd);
|
||||
}
|
||||
else if (m_HistoryIdx < size)
|
||||
{
|
||||
SetWindowTextA("");
|
||||
m_HistoryIdx++;
|
||||
}
|
||||
}
|
||||
else if (wParam == VK_RETURN)
|
||||
{
|
||||
if (m_ScriptWindow == NULL)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t codeLength = GetWindowTextLength() + 1;
|
||||
char* code = (char*)malloc(codeLength);
|
||||
GetWindowTextA(code, codeLength);
|
||||
|
||||
m_ScriptWindow->EvaluateInSelectedInstance(code);
|
||||
|
||||
SetWindowTextA("");
|
||||
int historySize = m_History.size();
|
||||
size_t codeLength = GetWindowTextLength() + 1;
|
||||
char* code = (char*)malloc(codeLength);
|
||||
GetWindowTextA(code, codeLength);
|
||||
|
||||
// remove duplicate
|
||||
for (int i = 0; i < historySize; i++)
|
||||
{
|
||||
if (strcmp(code, m_History[i]) == 0)
|
||||
{
|
||||
free(m_History[i]);
|
||||
m_History.erase(m_History.begin() + i);
|
||||
historySize--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_ScriptWindow->EvaluateInSelectedInstance(code);
|
||||
|
||||
// remove oldest if maxed
|
||||
if (historySize >= HISTORY_MAX_ENTRIES)
|
||||
{
|
||||
m_History.erase(m_History.begin() + 0);
|
||||
historySize--;
|
||||
}
|
||||
SetWindowTextA("");
|
||||
int historySize = m_History.size();
|
||||
|
||||
m_History.push_back(code);
|
||||
m_HistoryIdx = ++historySize;
|
||||
}
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
// remove duplicate
|
||||
for (int i = 0; i < historySize; i++)
|
||||
{
|
||||
if (strcmp(code, m_History[i]) == 0)
|
||||
{
|
||||
free(m_History[i]);
|
||||
m_History.erase(m_History.begin() + i);
|
||||
historySize--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// remove oldest if maxed
|
||||
if (historySize >= HISTORY_MAX_ENTRIES)
|
||||
{
|
||||
m_History.erase(m_History.begin() + 0);
|
||||
historySize--;
|
||||
}
|
||||
|
||||
m_History.push_back(code);
|
||||
m_HistoryIdx = ++historySize;
|
||||
}
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void CDebugScripts::RunSelected()
|
||||
{
|
||||
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
|
||||
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
|
||||
|
||||
if (state == STATE_INVALID || state == STATE_STOPPED)
|
||||
{
|
||||
m_Debugger->ScriptSystem()->RunScript(m_SelectedScriptName);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Debugger->Debug_LogScriptsWindow("[Error: Script is already running]\n");
|
||||
}
|
||||
if (state == STATE_INVALID || state == STATE_STOPPED)
|
||||
{
|
||||
m_Debugger->ScriptSystem()->RunScript(m_SelectedScriptName);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Debugger->Debug_LogScriptsWindow("[Error: Script is already running]\n");
|
||||
}
|
||||
}
|
||||
|
||||
void CDebugScripts::StopSelected()
|
||||
{
|
||||
m_Debugger->ScriptSystem()->StopScript(m_SelectedScriptName);
|
||||
m_Debugger->ScriptSystem()->StopScript(m_SelectedScriptName);
|
||||
}
|
|
@ -55,7 +55,7 @@ public:
|
|||
class CEditConsole : public CWindowImpl<CEditEval, CEdit>
|
||||
{
|
||||
private:
|
||||
LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
if (GetKeyState(VK_CONTROL) < 0)
|
||||
{
|
||||
|
|
|
@ -74,6 +74,7 @@ LRESULT CDebugStackTrace::OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BO
|
|||
|
||||
LRESULT CDebugStackTrace::OnDestroy(void)
|
||||
{
|
||||
m_List.Detach();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ private:
|
|||
|
||||
BEGIN_MSG_MAP_EX(CDebugStackTrace)
|
||||
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
|
||||
MSG_WM_DESTROY(OnDestroy)
|
||||
MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
|
||||
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
|
||||
NOTIFY_HANDLER_EX(IDC_STACKTRACE_LIST, NM_DBLCLK, OnListDblClicked)
|
||||
|
|
|
@ -49,6 +49,8 @@ LRESULT CDebugStackView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /
|
|||
|
||||
LRESULT CDebugStackView::OnDestroy(void)
|
||||
{
|
||||
m_StackList.Detach();
|
||||
m_SPStatic.Detach();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,159 +18,164 @@
|
|||
#include "Symbols.h"
|
||||
|
||||
CDebugSymbols::CDebugSymbols(CDebuggerUI * debugger) :
|
||||
CDebugDialog<CDebugSymbols>(debugger)
|
||||
{
|
||||
CDebugDialog<CDebugSymbols>(debugger)
|
||||
{
|
||||
}
|
||||
|
||||
LRESULT CDebugSymbols::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
LRESULT CDebugSymbols::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
DlgResize_Init(false, true);
|
||||
DlgResize_Init(false, true);
|
||||
|
||||
m_SymbolsListView.Attach(GetDlgItem(IDC_SYMBOLS_LIST));
|
||||
m_SymbolsListView.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
|
||||
m_SymbolsListView.Attach(GetDlgItem(IDC_SYMBOLS_LIST));
|
||||
m_SymbolsListView.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
|
||||
|
||||
m_SymbolsListView.AddColumn("Address", 0);
|
||||
m_SymbolsListView.AddColumn("Type", 1);
|
||||
m_SymbolsListView.AddColumn("Name", 2);
|
||||
m_SymbolsListView.AddColumn("Value", 3);
|
||||
m_SymbolsListView.AddColumn("Description", 4);
|
||||
m_SymbolsListView.AddColumn("Address", 0);
|
||||
m_SymbolsListView.AddColumn("Type", 1);
|
||||
m_SymbolsListView.AddColumn("Name", 2);
|
||||
m_SymbolsListView.AddColumn("Value", 3);
|
||||
m_SymbolsListView.AddColumn("Description", 4);
|
||||
|
||||
m_SymbolsListView.SetColumnWidth(0, 70);
|
||||
m_SymbolsListView.SetColumnWidth(1, 40);
|
||||
m_SymbolsListView.SetColumnWidth(2, 120);
|
||||
m_SymbolsListView.SetColumnWidth(3, 100);
|
||||
m_SymbolsListView.SetColumnWidth(4, 120);
|
||||
|
||||
Refresh();
|
||||
m_SymbolsListView.SetColumnWidth(0, 70);
|
||||
m_SymbolsListView.SetColumnWidth(1, 40);
|
||||
m_SymbolsListView.SetColumnWidth(2, 120);
|
||||
m_SymbolsListView.SetColumnWidth(3, 100);
|
||||
m_SymbolsListView.SetColumnWidth(4, 120);
|
||||
|
||||
m_AutoRefreshThread = CreateThread(NULL, 0, AutoRefreshProc, (void*)this, 0, NULL);
|
||||
Refresh();
|
||||
|
||||
WindowCreated();
|
||||
return 0;
|
||||
m_AutoRefreshThread = CreateThread(NULL, 0, AutoRefreshProc, (void*)this, 0, NULL);
|
||||
|
||||
WindowCreated();
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CDebugSymbols::OnDestroy(void)
|
||||
{
|
||||
if (m_AutoRefreshThread != NULL)
|
||||
{
|
||||
TerminateThread(m_AutoRefreshThread, 0);
|
||||
CloseHandle(m_AutoRefreshThread);
|
||||
}
|
||||
return 0;
|
||||
m_SymbolsListView.Detach();
|
||||
if (m_AutoRefreshThread != NULL)
|
||||
{
|
||||
TerminateThread(m_AutoRefreshThread, 0);
|
||||
CloseHandle(m_AutoRefreshThread);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI CDebugSymbols::AutoRefreshProc(void* _this)
|
||||
{
|
||||
CDebugSymbols* self = (CDebugSymbols*)_this;
|
||||
while (true)
|
||||
{
|
||||
self->RefreshValues();
|
||||
Sleep(100);
|
||||
}
|
||||
CDebugSymbols* self = (CDebugSymbols*)_this;
|
||||
while (true)
|
||||
{
|
||||
self->RefreshValues();
|
||||
Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CDebugSymbols::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
switch (wID)
|
||||
{
|
||||
case IDCANCEL:
|
||||
EndDialog(0);
|
||||
break;
|
||||
case IDC_ADDSYMBOL_BTN:
|
||||
m_AddSymbolDlg.DoModal(m_Debugger);
|
||||
break;
|
||||
case IDC_REMOVESYMBOL_BTN:
|
||||
{
|
||||
int id = m_SymbolsListView.GetItemData(m_SymbolsListView.GetSelectedIndex());
|
||||
CSymbols::EnterCriticalSection();
|
||||
CSymbols::RemoveEntryById(id);
|
||||
CSymbols::Save();
|
||||
CSymbols::LeaveCriticalSection();
|
||||
Refresh();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
switch (wID)
|
||||
{
|
||||
case IDCANCEL:
|
||||
EndDialog(0);
|
||||
break;
|
||||
case IDC_ADDSYMBOL_BTN:
|
||||
m_AddSymbolDlg.DoModal(m_Debugger);
|
||||
break;
|
||||
case IDC_REMOVESYMBOL_BTN:
|
||||
{
|
||||
int id = m_SymbolsListView.GetItemData(m_SymbolsListView.GetSelectedIndex());
|
||||
CSymbols::EnterCriticalSection();
|
||||
CSymbols::RemoveEntryById(id);
|
||||
CSymbols::Save();
|
||||
CSymbols::LeaveCriticalSection();
|
||||
Refresh();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
|
||||
{
|
||||
// Open it in memory viewer/commands viewer
|
||||
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
|
||||
int nItem = pIA->iItem;
|
||||
// Open it in memory viewer/commands viewer
|
||||
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
|
||||
int nItem = pIA->iItem;
|
||||
|
||||
int id = m_SymbolsListView.GetItemData(nItem);
|
||||
CSymbolEntry* symbol = CSymbols::GetEntryById(id);
|
||||
|
||||
if (symbol->m_Type == 0) // code
|
||||
{
|
||||
m_Debugger->Debug_ShowCommandsLocation(symbol->m_Address, true);
|
||||
}
|
||||
else // data/number
|
||||
{
|
||||
m_Debugger->Debug_ShowMemoryLocation(symbol->m_Address, true);
|
||||
}
|
||||
int id = m_SymbolsListView.GetItemData(nItem);
|
||||
CSymbolEntry* symbol = CSymbols::GetEntryById(id);
|
||||
|
||||
return 0;
|
||||
if (symbol->m_Type == 0) // code
|
||||
{
|
||||
m_Debugger->Debug_ShowCommandsLocation(symbol->m_Address, true);
|
||||
}
|
||||
else // data/number
|
||||
{
|
||||
m_Debugger->Debug_ShowMemoryLocation(symbol->m_Address, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CDebugSymbols::Refresh()
|
||||
{
|
||||
m_SymbolsListView.SetRedraw(FALSE);
|
||||
m_SymbolsListView.DeleteAllItems();
|
||||
|
||||
CSymbols::EnterCriticalSection();
|
||||
if (m_SymbolsListView.m_hWnd == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_SymbolsListView.SetRedraw(FALSE);
|
||||
m_SymbolsListView.DeleteAllItems();
|
||||
|
||||
int count = CSymbols::GetCount();
|
||||
CSymbols::EnterCriticalSection();
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
CSymbolEntry* lpSymbol = CSymbols::GetEntryByIndex(i);
|
||||
|
||||
stdstr addrStr = stdstr_f("%08X", lpSymbol->m_Address);
|
||||
|
||||
m_SymbolsListView.AddItem(i, 0, addrStr.c_str());
|
||||
m_SymbolsListView.AddItem(i, 1, lpSymbol->TypeName());
|
||||
m_SymbolsListView.AddItem(i, 2, lpSymbol->m_Name);
|
||||
m_SymbolsListView.AddItem(i, 4, lpSymbol->m_Description);
|
||||
|
||||
m_SymbolsListView.SetItemData(i, lpSymbol->m_Id);
|
||||
int count = CSymbols::GetCount();
|
||||
|
||||
if (g_MMU)
|
||||
{
|
||||
char szValue[64];
|
||||
CSymbols::GetValueString(szValue, lpSymbol);
|
||||
m_SymbolsListView.AddItem(i, 3, szValue);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
CSymbolEntry* lpSymbol = CSymbols::GetEntryByIndex(i);
|
||||
|
||||
CSymbols::LeaveCriticalSection();
|
||||
stdstr addrStr = stdstr_f("%08X", lpSymbol->m_Address);
|
||||
|
||||
m_SymbolsListView.SetRedraw(TRUE);
|
||||
m_SymbolsListView.AddItem(i, 0, addrStr.c_str());
|
||||
m_SymbolsListView.AddItem(i, 1, lpSymbol->TypeName());
|
||||
m_SymbolsListView.AddItem(i, 2, lpSymbol->m_Name);
|
||||
m_SymbolsListView.AddItem(i, 4, lpSymbol->m_Description);
|
||||
|
||||
m_SymbolsListView.SetItemData(i, lpSymbol->m_Id);
|
||||
|
||||
if (g_MMU)
|
||||
{
|
||||
char szValue[64];
|
||||
CSymbols::GetValueString(szValue, lpSymbol);
|
||||
m_SymbolsListView.AddItem(i, 3, szValue);
|
||||
}
|
||||
}
|
||||
|
||||
CSymbols::LeaveCriticalSection();
|
||||
|
||||
m_SymbolsListView.SetRedraw(TRUE);
|
||||
}
|
||||
|
||||
void CDebugSymbols::RefreshValues()
|
||||
{
|
||||
if (g_MMU == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (g_MMU == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int count = m_SymbolsListView.GetItemCount();
|
||||
int count = m_SymbolsListView.GetItemCount();
|
||||
|
||||
CSymbols::EnterCriticalSection();
|
||||
CSymbols::EnterCriticalSection();
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int symbolId = m_SymbolsListView.GetItemData(i);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int symbolId = m_SymbolsListView.GetItemData(i);
|
||||
|
||||
CSymbolEntry* lpSymbol = CSymbols::GetEntryById(symbolId);
|
||||
CSymbolEntry* lpSymbol = CSymbols::GetEntryById(symbolId);
|
||||
|
||||
char szValue[64];
|
||||
CSymbols::GetValueString(szValue, lpSymbol);
|
||||
char szValue[64];
|
||||
CSymbols::GetValueString(szValue, lpSymbol);
|
||||
|
||||
m_SymbolsListView.SetItemText(i, 3, szValue);
|
||||
}
|
||||
m_SymbolsListView.SetItemText(i, 3, szValue);
|
||||
}
|
||||
|
||||
CSymbols::LeaveCriticalSection();
|
||||
CSymbols::LeaveCriticalSection();
|
||||
}
|
|
@ -16,7 +16,7 @@ class CDebugTlb :
|
|||
BEGIN_MSG_MAP_EX(CDebugTlb)
|
||||
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
|
||||
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
|
||||
END_MSG_MAP()
|
||||
END_MSG_MAP()
|
||||
|
||||
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
|
||||
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
|
||||
|
|
|
@ -18,8 +18,8 @@ CDebugMemoryView* CDebugMemoryView::_this = NULL;
|
|||
HHOOK CDebugMemoryView::hWinMessageHook = NULL;
|
||||
|
||||
CDebugMemoryView::CDebugMemoryView(CDebuggerUI * debugger) :
|
||||
CDebugDialog<CDebugMemoryView>(debugger),
|
||||
m_MemoryList(NULL)
|
||||
CDebugDialog<CDebugMemoryView>(debugger),
|
||||
m_MemoryList(NULL)
|
||||
{
|
||||
if (m_MemoryList == NULL)
|
||||
{
|
||||
|
@ -27,8 +27,7 @@ m_MemoryList(NULL)
|
|||
m_MemoryList->RegisterClass();
|
||||
}
|
||||
|
||||
m_Breakpoints = m_Debugger->Breakpoints();
|
||||
|
||||
m_Breakpoints = m_Debugger->Breakpoints();
|
||||
}
|
||||
|
||||
CDebugMemoryView::~CDebugMemoryView()
|
||||
|
@ -37,8 +36,8 @@ CDebugMemoryView::~CDebugMemoryView()
|
|||
|
||||
LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
m_SymbolColorStride = 0;
|
||||
m_SymbolColorPhase = 0;
|
||||
m_SymbolColorStride = 0;
|
||||
m_SymbolColorPhase = 0;
|
||||
m_DataStartLoc = (DWORD)-1;
|
||||
m_CompareStartLoc = (DWORD)-1;
|
||||
memset(m_CompareData, 0, sizeof(m_CompareData));
|
||||
|
@ -115,72 +114,71 @@ LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
|
|||
::SetWindowPos(GetDlgItem(IDC_SCRL_BAR), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
|
||||
}
|
||||
|
||||
m_SymInfo.Attach(GetDlgItem(IDC_SYM_INFO));
|
||||
m_DMAInfo.Attach(GetDlgItem(IDC_DMA_INFO));
|
||||
m_SymInfo.Attach(GetDlgItem(IDC_SYM_INFO));
|
||||
m_DMAInfo.Attach(GetDlgItem(IDC_DMA_INFO));
|
||||
|
||||
_this = this;
|
||||
_this = this;
|
||||
|
||||
DWORD dwThreadID = ::GetCurrentThreadId();
|
||||
hWinMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc, NULL, dwThreadID);
|
||||
DWORD dwThreadID = ::GetCurrentThreadId();
|
||||
hWinMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc, NULL, dwThreadID);
|
||||
|
||||
WindowCreated();
|
||||
|
||||
m_AutoRefreshThread = CreateThread(NULL, 0, AutoRefreshProc, (void*)this, 0, NULL);
|
||||
|
||||
m_AutoRefreshThread = CreateThread(NULL, 0, AutoRefreshProc, (void*)this, 0, NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DWORD WINAPI CDebugMemoryView::AutoRefreshProc(void* _this)
|
||||
DWORD WINAPI CDebugMemoryView::AutoRefreshProc(void* _self)
|
||||
{
|
||||
CDebugMemoryView* self = (CDebugMemoryView*)_this;
|
||||
while (true)
|
||||
{
|
||||
self->RefreshMemory(true);
|
||||
Sleep(100);
|
||||
}
|
||||
CDebugMemoryView* self = (CDebugMemoryView*)_self;
|
||||
while (true)
|
||||
{
|
||||
self->RefreshMemory(true);
|
||||
Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
void CDebugMemoryView::InterceptMouseWheel(WPARAM wParam, LPARAM lParam)
|
||||
void CDebugMemoryView::InterceptMouseWheel(WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
uint32_t newAddress = m_DataStartLoc - ((short)HIWORD(wParam) / WHEEL_DELTA) * 16;
|
||||
uint32_t newAddress = m_DataStartLoc - ((short)HIWORD(wParam) / WHEEL_DELTA) * 16;
|
||||
|
||||
m_DataStartLoc = newAddress;
|
||||
m_DataStartLoc = newAddress;
|
||||
|
||||
m_MemAddr.SetValue(m_DataStartLoc, false, true);
|
||||
m_MemAddr.SetValue(m_DataStartLoc, false, true);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK CDebugMemoryView::HookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
MSG *pMsg = (MSG*)lParam;
|
||||
MSG *pMsg = (MSG*)lParam;
|
||||
|
||||
if (pMsg->message == WM_MOUSEWHEEL)
|
||||
{
|
||||
BOOL bHandled = TRUE;
|
||||
_this->InterceptMouseWheel(pMsg->wParam, pMsg->lParam);
|
||||
}
|
||||
if (pMsg->message == WM_MOUSEWHEEL)
|
||||
{
|
||||
_this->InterceptMouseWheel(pMsg->wParam, pMsg->lParam);
|
||||
}
|
||||
|
||||
if (nCode < 0)
|
||||
{
|
||||
return CallNextHookEx(hWinMessageHook, nCode, wParam, lParam);
|
||||
}
|
||||
if (nCode < 0)
|
||||
{
|
||||
return CallNextHookEx(hWinMessageHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CDebugMemoryView::OnDestroy(void)
|
||||
{
|
||||
if (m_AutoRefreshThread != NULL)
|
||||
{
|
||||
TerminateThread(m_AutoRefreshThread, 0);
|
||||
CloseHandle(m_AutoRefreshThread);
|
||||
}
|
||||
if (m_AutoRefreshThread != NULL)
|
||||
{
|
||||
TerminateThread(m_AutoRefreshThread, 0);
|
||||
CloseHandle(m_AutoRefreshThread);
|
||||
}
|
||||
if (m_MemoryList)
|
||||
{
|
||||
m_MemoryList->UnsubclassWindow();
|
||||
delete m_MemoryList;
|
||||
m_MemoryList = NULL;
|
||||
}
|
||||
UnhookWindowsHookEx(hWinMessageHook);
|
||||
UnhookWindowsHookEx(hWinMessageHook);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -200,138 +198,136 @@ LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL&
|
|||
case IDC_SEARCH_MEM:
|
||||
m_Debugger->Debug_ShowMemorySearch();
|
||||
break;
|
||||
case IDC_SYMBOLS_BTN:
|
||||
m_Debugger->Debug_ShowSymbolsWindow();
|
||||
break;
|
||||
case IDC_SYMBOLS_BTN:
|
||||
m_Debugger->Debug_ShowSymbolsWindow();
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog(0);
|
||||
break;
|
||||
case ID_POPUPMENU_TOGGLERBP:
|
||||
m_Breakpoints->RBPToggle(m_CtxMenuAddr);
|
||||
RefreshMemory(true);
|
||||
break;
|
||||
case ID_POPUPMENU_TOGGLEWBP:
|
||||
m_Breakpoints->WBPToggle(m_CtxMenuAddr);
|
||||
RefreshMemory(true);
|
||||
break;
|
||||
case ID_POPUPMENU_CLEARALLBPS:
|
||||
m_Breakpoints->RBPClear();
|
||||
m_Breakpoints->WBPClear();
|
||||
RefreshMemory(true);
|
||||
break;
|
||||
case ID_POPUPMENU_VIEWDISASM:
|
||||
m_Debugger->Debug_ShowCommandsLocation(m_CtxMenuAddr, true);
|
||||
break;
|
||||
case ID_POPUPMENU_ADDSYMBOL:
|
||||
m_AddSymbolDlg.DoModal(m_Debugger, m_CtxMenuAddr);
|
||||
break;
|
||||
case ID_POPUPMENU_TOGGLERBP:
|
||||
m_Breakpoints->RBPToggle(m_CtxMenuAddr);
|
||||
RefreshMemory(true);
|
||||
break;
|
||||
case ID_POPUPMENU_TOGGLEWBP:
|
||||
m_Breakpoints->WBPToggle(m_CtxMenuAddr);
|
||||
RefreshMemory(true);
|
||||
break;
|
||||
case ID_POPUPMENU_CLEARALLBPS:
|
||||
m_Breakpoints->RBPClear();
|
||||
m_Breakpoints->WBPClear();
|
||||
RefreshMemory(true);
|
||||
break;
|
||||
case ID_POPUPMENU_VIEWDISASM:
|
||||
m_Debugger->Debug_ShowCommandsLocation(m_CtxMenuAddr, true);
|
||||
break;
|
||||
case ID_POPUPMENU_ADDSYMBOL:
|
||||
m_AddSymbolDlg.DoModal(m_Debugger, m_CtxMenuAddr);
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LRESULT CDebugMemoryView::OnMemoryRightClicked(LPNMHDR lpNMHDR)
|
||||
{
|
||||
uint32_t address;
|
||||
bool bData = GetItemAddress(lpNMHDR, address);
|
||||
uint32_t address;
|
||||
bool bData = GetItemAddress(lpNMHDR, address);
|
||||
|
||||
if (!bData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!bData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_CtxMenuAddr = address;
|
||||
m_CtxMenuAddr = address;
|
||||
|
||||
HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MEM_BP_POPUP));
|
||||
HMENU hPopupMenu = GetSubMenu(hMenu, 0);
|
||||
|
||||
if (m_Breakpoints->m_RBP.size() == 0 && m_Breakpoints->m_WBP.size() == 0)
|
||||
{
|
||||
EnableMenuItem(hPopupMenu, ID_POPUPMENU_CLEARALLBPS, MF_DISABLED | MF_GRAYED);
|
||||
}
|
||||
|
||||
POINT mouse;
|
||||
GetCursorPos(&mouse);
|
||||
HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MEM_BP_POPUP));
|
||||
HMENU hPopupMenu = GetSubMenu(hMenu, 0);
|
||||
|
||||
TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN, mouse.x, mouse.y, 0, m_hWnd, NULL);
|
||||
if (m_Breakpoints->m_RBP.size() == 0 && m_Breakpoints->m_WBP.size() == 0)
|
||||
{
|
||||
EnableMenuItem(hPopupMenu, ID_POPUPMENU_CLEARALLBPS, MF_DISABLED | MF_GRAYED);
|
||||
}
|
||||
|
||||
DestroyMenu(hMenu);
|
||||
POINT mouse;
|
||||
GetCursorPos(&mouse);
|
||||
|
||||
return 0;
|
||||
TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN, mouse.x, mouse.y, 0, m_hWnd, NULL);
|
||||
|
||||
DestroyMenu(hMenu);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CDebugMemoryView::OnHotItemChanged(LPNMHDR lpNMHDR)
|
||||
{
|
||||
uint32_t address;
|
||||
bool bData = GetItemAddress(lpNMHDR, address);
|
||||
uint32_t address;
|
||||
bool bData = GetItemAddress(lpNMHDR, address);
|
||||
|
||||
if (!bData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!bData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
CSymbols::EnterCriticalSection();
|
||||
CSymbols::EnterCriticalSection();
|
||||
|
||||
CSymbolEntry* lpSymbol = CSymbols::GetEntryByAddress(address);
|
||||
CSymbolEntry* lpSymbol = CSymbols::GetEntryByAddress(address);
|
||||
|
||||
stdstr symbolInfo;
|
||||
stdstr symbolInfo;
|
||||
|
||||
if (lpSymbol != NULL)
|
||||
{
|
||||
char* desc = lpSymbol->m_Description;
|
||||
desc = desc ? desc : "";
|
||||
symbolInfo = stdstr_f("%08X: %s %s // %s", address, lpSymbol->TypeName(), lpSymbol->m_Name, desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
symbolInfo = stdstr_f("%08X", address);
|
||||
}
|
||||
if (lpSymbol != NULL)
|
||||
{
|
||||
char* desc = lpSymbol->m_Description;
|
||||
desc = desc ? desc : "";
|
||||
symbolInfo = stdstr_f("%08X: %s %s // %s", address, lpSymbol->TypeName(), lpSymbol->m_Name, desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
symbolInfo = stdstr_f("%08X", address);
|
||||
}
|
||||
|
||||
CSymbols::LeaveCriticalSection();
|
||||
CSymbols::LeaveCriticalSection();
|
||||
|
||||
m_SymInfo.SetWindowTextA(symbolInfo.c_str());
|
||||
|
||||
uint32_t romAddr, offset;
|
||||
DMALOGENTRY* lpEntry = m_Debugger->DMALog()->GetEntryByRamAddress(address, &romAddr, &offset);
|
||||
m_SymInfo.SetWindowTextA(symbolInfo.c_str());
|
||||
|
||||
stdstr dmaInfo;
|
||||
uint32_t romAddr, offset;
|
||||
DMALOGENTRY* lpEntry = m_Debugger->DMALog()->GetEntryByRamAddress(address, &romAddr, &offset);
|
||||
|
||||
if (lpEntry != NULL)
|
||||
{
|
||||
dmaInfo = stdstr_f("Last DMA: %08X -> %08X [%X] (%08X, +%X) ", lpEntry->romAddr, lpEntry->ramAddr, lpEntry->length, romAddr, offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
dmaInfo = stdstr_f("Last DMA: ?");
|
||||
}
|
||||
stdstr dmaInfo;
|
||||
|
||||
m_DMAInfo.SetWindowTextA(dmaInfo.c_str());
|
||||
if (lpEntry != NULL)
|
||||
{
|
||||
dmaInfo = stdstr_f("Last DMA: %08X -> %08X [%X] (%08X, +%X) ", lpEntry->romAddr, lpEntry->ramAddr, lpEntry->length, romAddr, offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
dmaInfo = stdstr_f("Last DMA: ?");
|
||||
}
|
||||
|
||||
return 0;
|
||||
m_DMAInfo.SetWindowTextA(dmaInfo.c_str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CDebugMemoryView::OnMemoryModified(LPNMHDR lpNMHDR)
|
||||
{
|
||||
uint32_t Pos = 0;
|
||||
bool bData = GetItemOffset(lpNMHDR, Pos);
|
||||
uint32_t Pos = 0;
|
||||
bool bData = GetItemOffset(lpNMHDR, Pos);
|
||||
|
||||
if (!bData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!bData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
CListNotify *pListNotify = reinterpret_cast<CListNotify *>(lpNMHDR);
|
||||
int LineNumber = pListNotify->m_nItem;
|
||||
|
||||
|
||||
LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem, pListNotify->m_nSubItem);
|
||||
int Finish = strlen(strValue);
|
||||
|
||||
DWORD Value = strtoull(strValue, NULL, 16);
|
||||
|
||||
unsigned long long Value = strtoull(strValue, NULL, 16);
|
||||
|
||||
if (m_CurrentData[Pos] == Value)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (m_CompareStartLoc != m_DataStartLoc ||
|
||||
m_CompareVAddrr != m_DataVAddrr)
|
||||
{
|
||||
|
@ -341,10 +337,10 @@ LRESULT CDebugMemoryView::OnMemoryModified(LPNMHDR lpNMHDR)
|
|||
memcpy(m_CompareData, m_CurrentData, sizeof(m_CurrentData));
|
||||
memcpy(m_CompareValid, m_DataValid, sizeof(m_CompareValid));
|
||||
}
|
||||
|
||||
|
||||
m_CompareData[Pos] = m_CurrentData[Pos];
|
||||
m_CurrentData[Pos] = (BYTE)Value;
|
||||
|
||||
|
||||
//sb
|
||||
if (m_DataVAddrr)
|
||||
{
|
||||
|
@ -367,50 +363,50 @@ LRESULT CDebugMemoryView::OnMemoryModified(LPNMHDR lpNMHDR)
|
|||
|
||||
void CDebugMemoryView::OnAddrChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
|
||||
{
|
||||
RefreshMemory(false);
|
||||
RefreshMemory(false);
|
||||
}
|
||||
|
||||
void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl)
|
||||
{
|
||||
if (ctrl != GetDlgItem(IDC_SCRL_BAR))
|
||||
{
|
||||
return;
|
||||
}
|
||||
DWORD Location = m_MemAddr.GetValue();
|
||||
switch (request)
|
||||
{
|
||||
case SB_LINEDOWN:
|
||||
m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF, false, true);
|
||||
break;
|
||||
case SB_LINEUP:
|
||||
m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0, false, true);
|
||||
break;
|
||||
case SB_PAGEDOWN:
|
||||
m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF, false, true);
|
||||
break;
|
||||
case SB_PAGEUP:
|
||||
m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0, false, true);
|
||||
break;
|
||||
case SB_THUMBPOSITION:
|
||||
m_MemAddr.SetValue((DWORD)Pos << 0x10, false, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (ctrl != GetDlgItem(IDC_SCRL_BAR))
|
||||
{
|
||||
return;
|
||||
}
|
||||
DWORD Location = m_MemAddr.GetValue();
|
||||
switch (request)
|
||||
{
|
||||
case SB_LINEDOWN:
|
||||
m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF, false, true);
|
||||
break;
|
||||
case SB_LINEUP:
|
||||
m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0, false, true);
|
||||
break;
|
||||
case SB_PAGEDOWN:
|
||||
m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF, false, true);
|
||||
break;
|
||||
case SB_PAGEUP:
|
||||
m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0, false, true);
|
||||
break;
|
||||
case SB_THUMBPOSITION:
|
||||
m_MemAddr.SetValue((DWORD)Pos << 0x10, false, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CDebugMemoryView::OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
LRESULT CDebugMemoryView::OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||
{
|
||||
WORD type = LOWORD(wParam);
|
||||
WORD type = LOWORD(wParam);
|
||||
|
||||
if (type == WA_INACTIVE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (type == WA_INACTIVE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RefreshMemory(false);
|
||||
RefreshMemory(false);
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CDebugMemoryView::ShowAddress(DWORD Address, bool VAddr)
|
||||
|
@ -475,20 +471,20 @@ void CDebugMemoryView::Insert_MemoryLineDump(int LineNumber)
|
|||
}
|
||||
|
||||
sprintf(Hex, "%02X", m_CurrentData[Pos]);
|
||||
|
||||
m_MemoryList->SetItemText(LineNumber, col, Hex);
|
||||
|
||||
m_MemoryList->SetItemText(LineNumber, col, Hex);
|
||||
m_MemoryList->SetItemFormat(LineNumber, col, ITEM_FORMAT_EDIT, ITEM_FLAGS_EDIT_HEX);
|
||||
m_MemoryList->SetItemMaxEditLen(LineNumber, col, 2);
|
||||
|
||||
uint32_t vaddr = 0x80000000 | (m_DataStartLoc + Pos);
|
||||
uint32_t vaddr = 0x80000000 | (m_DataStartLoc + Pos);
|
||||
|
||||
COLORREF bgColor, fgColor, fgHiColor;
|
||||
SelectColors(vaddr, Changed, bgColor, fgColor, fgHiColor);
|
||||
|
||||
m_MemoryList->SetItemColours(LineNumber, col, bgColor, fgColor);
|
||||
COLORREF bgColor, fgColor, fgHiColor;
|
||||
SelectColors(vaddr, Changed, bgColor, fgColor, fgHiColor);
|
||||
|
||||
m_MemoryList->SetItemColours(LineNumber, col, bgColor, fgColor);
|
||||
m_MemoryList->SetItemHighlightColours(LineNumber, col, fgHiColor);
|
||||
|
||||
if (m_CurrentData[Pos] < 30)
|
||||
|
||||
if (m_CurrentData[Pos] < 30)
|
||||
{
|
||||
strcat(Ascii, ".");
|
||||
}
|
||||
|
@ -522,12 +518,12 @@ void CDebugMemoryView::Insert_MemoryLineDump(int LineNumber)
|
|||
|
||||
void CDebugMemoryView::RefreshMemory(bool ResetCompare)
|
||||
{
|
||||
m_SymbolColorPhase = 0;
|
||||
m_SymbolColorPhase = 0;
|
||||
|
||||
if (g_MMU == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (g_MMU == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_MemoryList && m_MemoryList->GetHasEditItem())
|
||||
{
|
||||
|
@ -571,10 +567,10 @@ void CDebugMemoryView::RefreshMemory(bool ResetCompare)
|
|||
|
||||
if (m_DataVAddrr)
|
||||
{
|
||||
if (!AddressSafe(m_DataStartLoc & ~3))
|
||||
{
|
||||
ValidData = false;
|
||||
}
|
||||
if (!AddressSafe(m_DataStartLoc & ~3))
|
||||
{
|
||||
ValidData = false;
|
||||
}
|
||||
else if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW))
|
||||
{
|
||||
ValidData = false;
|
||||
|
@ -582,11 +578,11 @@ void CDebugMemoryView::RefreshMemory(bool ResetCompare)
|
|||
}
|
||||
else
|
||||
{
|
||||
if ((m_DataStartLoc & ~3) >= g_MMU->RdramSize())
|
||||
{
|
||||
ValidData = false;
|
||||
}
|
||||
else if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW))
|
||||
if ((m_DataStartLoc & ~3) >= g_MMU->RdramSize())
|
||||
{
|
||||
ValidData = false;
|
||||
}
|
||||
else if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW))
|
||||
{
|
||||
ValidData = false;
|
||||
}
|
||||
|
@ -615,10 +611,10 @@ void CDebugMemoryView::RefreshMemory(bool ResetCompare)
|
|||
|
||||
if (m_DataVAddrr)
|
||||
{
|
||||
if (!AddressSafe(Pos))
|
||||
{
|
||||
ValidData = false;
|
||||
}
|
||||
if (!AddressSafe(Pos))
|
||||
{
|
||||
ValidData = false;
|
||||
}
|
||||
else if (!g_MMU->LW_VAddr(Pos, word.UW))
|
||||
{
|
||||
ValidData = false;
|
||||
|
@ -626,10 +622,10 @@ void CDebugMemoryView::RefreshMemory(bool ResetCompare)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (Pos >= g_MMU->RdramSize())
|
||||
{
|
||||
ValidData = false;
|
||||
}
|
||||
if (Pos >= g_MMU->RdramSize())
|
||||
{
|
||||
ValidData = false;
|
||||
}
|
||||
else if (!g_MMU->LW_PAddr(Pos, word.UW))
|
||||
{
|
||||
ValidData = false;
|
||||
|
@ -658,98 +654,98 @@ void CDebugMemoryView::RefreshMemory(bool ResetCompare)
|
|||
|
||||
bool CDebugMemoryView::GetItemOffset(LPNMHDR lpNMHDR, uint32_t &offset)
|
||||
{
|
||||
CListNotify *pListNotify = reinterpret_cast<CListNotify *>(lpNMHDR);
|
||||
CListNotify *pListNotify = reinterpret_cast<CListNotify *>(lpNMHDR);
|
||||
|
||||
int nRow = pListNotify->m_nItem;
|
||||
int nCol = pListNotify->m_nSubItem - 1;
|
||||
int nRow = pListNotify->m_nItem;
|
||||
int nCol = pListNotify->m_nSubItem - 1;
|
||||
|
||||
if (nCol < 0 || (nCol % 5) == 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (nCol < 0 || (nCol % 5) == 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
offset = (nRow * 0x10) + (nCol / 5) * 4 + (nCol % 5);
|
||||
offset = (nRow * 0x10) + (nCol / 5) * 4 + (nCol % 5);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDebugMemoryView::GetItemAddress(LPNMHDR lpNMHDR, uint32_t &address)
|
||||
{
|
||||
uint32_t offset;
|
||||
bool bData = GetItemOffset(lpNMHDR, offset);
|
||||
uint32_t offset;
|
||||
bool bData = GetItemOffset(lpNMHDR, offset);
|
||||
|
||||
if (!bData)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!bData)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
address = 0x80000000 | (m_DataStartLoc + offset);
|
||||
address = 0x80000000 | (m_DataStartLoc + offset);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDebugMemoryView::SelectColors(uint32_t vaddr, bool changed, COLORREF& bgColor, COLORREF& fgColor, COLORREF& fgHiColor)
|
||||
{
|
||||
CSymbols::EnterCriticalSection();
|
||||
CSymbolEntry* lpSymbol = CSymbols::GetEntryByAddress(vaddr);
|
||||
|
||||
if (lpSymbol != NULL)
|
||||
{
|
||||
m_SymbolColorStride = lpSymbol->TypeSize();
|
||||
m_SymbolColorPhase = m_SymbolColorPhase ? 0 : 1;
|
||||
}
|
||||
CSymbols::EnterCriticalSection();
|
||||
CSymbolEntry* lpSymbol = CSymbols::GetEntryByAddress(vaddr);
|
||||
|
||||
CSymbols::LeaveCriticalSection();
|
||||
if (lpSymbol != NULL)
|
||||
{
|
||||
m_SymbolColorStride = lpSymbol->TypeSize();
|
||||
m_SymbolColorPhase = m_SymbolColorPhase ? 0 : 1;
|
||||
}
|
||||
|
||||
bool bHaveReadBP = m_Breakpoints->RBPExists(vaddr);
|
||||
bool bHaveWriteBP = m_Breakpoints->WBPExists(vaddr);
|
||||
CSymbols::LeaveCriticalSection();
|
||||
|
||||
fgHiColor = RGB(0x00, 0x00, 0x00);
|
||||
bool bHaveReadBP = m_Breakpoints->RBPExists(vaddr) == CBreakpoints::BP_SET;
|
||||
bool bHaveWriteBP = m_Breakpoints->WBPExists(vaddr) == CBreakpoints::BP_SET;
|
||||
|
||||
if (bHaveReadBP && bHaveWriteBP)
|
||||
{
|
||||
bgColor = RGB(0xAA, 0xDD, 0xDD);
|
||||
}
|
||||
else if (bHaveReadBP)
|
||||
{
|
||||
bgColor = RGB(0xDD, 0xDD, 0xAA);
|
||||
}
|
||||
else if (bHaveWriteBP)
|
||||
{
|
||||
bgColor = RGB(0xAA, 0xAA, 0xDD);
|
||||
}
|
||||
else if (m_SymbolColorStride > 0)
|
||||
{
|
||||
bgColor = m_SymbolColorPhase ? RGB(0xD0, 0xF0, 0xD0) : RGB(0xAA, 0xCC, 0xAA);
|
||||
}
|
||||
else
|
||||
{
|
||||
bgColor = GetSysColor(COLOR_WINDOW);
|
||||
fgHiColor = (changed ? RGB(255, 0, 0) : GetSysColor(COLOR_HIGHLIGHTTEXT));
|
||||
fgColor = (changed ? RGB(255, 0, 0) : GetSysColor(COLOR_WINDOWTEXT));
|
||||
}
|
||||
fgHiColor = RGB(0x00, 0x00, 0x00);
|
||||
|
||||
if (m_SymbolColorStride > 0)
|
||||
{
|
||||
m_SymbolColorStride--;
|
||||
}
|
||||
if (bHaveReadBP && bHaveWriteBP)
|
||||
{
|
||||
bgColor = RGB(0xAA, 0xDD, 0xDD);
|
||||
}
|
||||
else if (bHaveReadBP)
|
||||
{
|
||||
bgColor = RGB(0xDD, 0xDD, 0xAA);
|
||||
}
|
||||
else if (bHaveWriteBP)
|
||||
{
|
||||
bgColor = RGB(0xAA, 0xAA, 0xDD);
|
||||
}
|
||||
else if (m_SymbolColorStride > 0)
|
||||
{
|
||||
bgColor = m_SymbolColorPhase ? RGB(0xD0, 0xF0, 0xD0) : RGB(0xAA, 0xCC, 0xAA);
|
||||
}
|
||||
else
|
||||
{
|
||||
bgColor = GetSysColor(COLOR_WINDOW);
|
||||
fgHiColor = (changed ? RGB(255, 0, 0) : GetSysColor(COLOR_HIGHLIGHTTEXT));
|
||||
fgColor = (changed ? RGB(255, 0, 0) : GetSysColor(COLOR_WINDOWTEXT));
|
||||
}
|
||||
|
||||
if (m_SymbolColorStride > 0)
|
||||
{
|
||||
m_SymbolColorStride--;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if KSEG0 addr is out of bounds
|
||||
bool CDebugMemoryView::AddressSafe(uint32_t vaddr)
|
||||
{
|
||||
if (g_MMU == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (g_MMU == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (vaddr >= 0x80000000 && vaddr <= 0x9FFFFFFF)
|
||||
{
|
||||
if ((vaddr & 0x1FFFFFFF) >= g_MMU->RdramSize())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (vaddr >= 0x80000000 && vaddr <= 0x9FFFFFFF)
|
||||
{
|
||||
if ((vaddr & 0x1FFFFFFF) >= g_MMU->RdramSize())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
|
@ -50,7 +50,7 @@ private:
|
|||
void RefreshMemory(bool ResetCompare);
|
||||
|
||||
HANDLE m_AutoRefreshThread;
|
||||
static DWORD WINAPI AutoRefreshProc(void* _this);
|
||||
static DWORD WINAPI AutoRefreshProc(void* _self);
|
||||
|
||||
void SelectColors(uint32_t address, bool changed, COLORREF& bgColor, COLORREF& fgColor, COLORREF& fgHiColor);
|
||||
bool GetItemOffset(LPNMHDR lpNMHDR, uint32_t &offset);
|
||||
|
|
|
@ -23,23 +23,23 @@ CDebuggerUI::CDebuggerUI() :
|
|||
m_MemorySearch(NULL),
|
||||
m_DebugTLB(NULL),
|
||||
m_CommandsView(NULL),
|
||||
m_Scripts(NULL),
|
||||
m_Symbols(NULL),
|
||||
m_Breakpoints(NULL),
|
||||
m_ScriptSystem(NULL),
|
||||
m_StackTrace(NULL),
|
||||
m_StackView(NULL),
|
||||
m_DMALogView(NULL),
|
||||
m_DMALog(NULL)
|
||||
m_Scripts(NULL),
|
||||
m_Symbols(NULL),
|
||||
m_Breakpoints(NULL),
|
||||
m_ScriptSystem(NULL),
|
||||
m_StackTrace(NULL),
|
||||
m_StackView(NULL),
|
||||
m_DMALogView(NULL),
|
||||
m_DMALog(NULL)
|
||||
{
|
||||
g_Debugger = this;
|
||||
g_Debugger = this;
|
||||
|
||||
m_Breakpoints = new CBreakpoints();
|
||||
m_ScriptSystem = new CScriptSystem(this);
|
||||
m_Breakpoints = new CBreakpoints();
|
||||
m_ScriptSystem = new CScriptSystem(this);
|
||||
|
||||
m_DMALog = new CDMALog();
|
||||
m_DMALog = new CDMALog();
|
||||
|
||||
CSymbols::InitializeCriticalSection();
|
||||
CSymbols::InitializeCriticalSection();
|
||||
g_Settings->RegisterChangeCB(GameRunning_InReset, this, (CSettings::SettingChangedFunc)GameReset);
|
||||
}
|
||||
|
||||
|
@ -47,50 +47,50 @@ CDebuggerUI::~CDebuggerUI(void)
|
|||
{
|
||||
g_Settings->UnregisterChangeCB(GameRunning_InReset, this, (CSettings::SettingChangedFunc)GameReset);
|
||||
Debug_Reset();
|
||||
delete m_MemoryView;
|
||||
delete m_CommandsView;
|
||||
delete m_Scripts;
|
||||
delete m_ScriptSystem;
|
||||
delete m_Breakpoints;
|
||||
delete m_Symbols;
|
||||
delete m_MemorySearch;
|
||||
delete m_StackTrace;
|
||||
delete m_DMALogView;
|
||||
delete m_DMALog;
|
||||
delete m_MemoryView;
|
||||
delete m_CommandsView;
|
||||
delete m_Scripts;
|
||||
delete m_ScriptSystem;
|
||||
delete m_Breakpoints;
|
||||
delete m_Symbols;
|
||||
delete m_MemorySearch;
|
||||
delete m_StackTrace;
|
||||
delete m_DMALogView;
|
||||
delete m_DMALog;
|
||||
|
||||
CSymbols::DeleteCriticalSection();
|
||||
CSymbols::DeleteCriticalSection();
|
||||
}
|
||||
|
||||
void CDebuggerUI::GameReset(CDebuggerUI * _this)
|
||||
{
|
||||
if (!g_Settings->LoadBool(GameRunning_InReset))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_this->m_CommandsView)
|
||||
{
|
||||
_this->m_CommandsView->Reset();
|
||||
}
|
||||
if (!g_Settings->LoadBool(GameRunning_InReset))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_this->m_DMALog)
|
||||
{
|
||||
_this->m_DMALog->ClearEntries();
|
||||
}
|
||||
if (_this->m_CommandsView)
|
||||
{
|
||||
_this->m_CommandsView->Reset();
|
||||
}
|
||||
|
||||
if (_this->m_StackTrace)
|
||||
{
|
||||
_this->m_StackTrace->ClearEntries();
|
||||
}
|
||||
if (_this->m_DMALog)
|
||||
{
|
||||
_this->m_DMALog->ClearEntries();
|
||||
}
|
||||
|
||||
CSymbols::EnterCriticalSection();
|
||||
CSymbols::Load();
|
||||
CSymbols::LeaveCriticalSection();
|
||||
if (_this->m_StackTrace)
|
||||
{
|
||||
_this->m_StackTrace->ClearEntries();
|
||||
}
|
||||
|
||||
if (_this->m_Symbols)
|
||||
{
|
||||
_this->m_Symbols->Refresh();
|
||||
}
|
||||
CSymbols::EnterCriticalSection();
|
||||
CSymbols::Load();
|
||||
CSymbols::LeaveCriticalSection();
|
||||
|
||||
if (_this->m_Symbols)
|
||||
{
|
||||
_this->m_Symbols->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_Reset(void)
|
||||
|
@ -113,48 +113,48 @@ void CDebuggerUI::Debug_Reset(void)
|
|||
delete m_DebugTLB;
|
||||
m_DebugTLB = NULL;
|
||||
}
|
||||
if (m_MemoryView)
|
||||
{
|
||||
m_MemoryView->HideWindow();
|
||||
delete m_MemoryView;
|
||||
m_MemoryView = NULL;
|
||||
}
|
||||
if (m_CommandsView)
|
||||
{
|
||||
m_CommandsView->HideWindow();
|
||||
delete m_CommandsView;
|
||||
m_CommandsView = NULL;
|
||||
}
|
||||
if (m_Scripts)
|
||||
{
|
||||
m_Scripts->HideWindow();
|
||||
delete m_Scripts;
|
||||
m_Scripts = NULL;
|
||||
}
|
||||
if (m_Symbols)
|
||||
{
|
||||
m_Symbols->HideWindow();
|
||||
delete m_Symbols;
|
||||
m_Symbols = NULL;
|
||||
}
|
||||
if (m_DMALogView)
|
||||
{
|
||||
m_DMALogView->HideWindow();
|
||||
delete m_DMALogView;
|
||||
m_DMALogView = NULL;
|
||||
}
|
||||
if (m_StackTrace)
|
||||
{
|
||||
m_StackTrace->HideWindow();
|
||||
delete m_StackTrace;
|
||||
m_StackTrace = NULL;
|
||||
}
|
||||
if (m_StackView)
|
||||
{
|
||||
m_StackView->HideWindow();
|
||||
delete m_StackView;
|
||||
m_StackView = NULL;
|
||||
}
|
||||
if (m_MemoryView)
|
||||
{
|
||||
m_MemoryView->HideWindow();
|
||||
delete m_MemoryView;
|
||||
m_MemoryView = NULL;
|
||||
}
|
||||
if (m_CommandsView)
|
||||
{
|
||||
m_CommandsView->HideWindow();
|
||||
delete m_CommandsView;
|
||||
m_CommandsView = NULL;
|
||||
}
|
||||
if (m_Scripts)
|
||||
{
|
||||
m_Scripts->HideWindow();
|
||||
delete m_Scripts;
|
||||
m_Scripts = NULL;
|
||||
}
|
||||
if (m_Symbols)
|
||||
{
|
||||
m_Symbols->HideWindow();
|
||||
delete m_Symbols;
|
||||
m_Symbols = NULL;
|
||||
}
|
||||
if (m_DMALogView)
|
||||
{
|
||||
m_DMALogView->HideWindow();
|
||||
delete m_DMALogView;
|
||||
m_DMALogView = NULL;
|
||||
}
|
||||
if (m_StackTrace)
|
||||
{
|
||||
m_StackTrace->HideWindow();
|
||||
delete m_StackTrace;
|
||||
m_StackTrace = NULL;
|
||||
}
|
||||
if (m_StackView)
|
||||
{
|
||||
m_StackView->HideWindow();
|
||||
delete m_StackView;
|
||||
m_StackView = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_ShowMemoryDump()
|
||||
|
@ -236,301 +236,299 @@ void CDebuggerUI::Debug_ShowMemorySearch()
|
|||
|
||||
void CDebuggerUI::Debug_ShowCommandsWindow()
|
||||
{
|
||||
if (m_CommandsView == NULL)
|
||||
{
|
||||
m_CommandsView = new CDebugCommandsView(this);
|
||||
}
|
||||
m_CommandsView->ShowWindow();
|
||||
if (m_CommandsView == NULL)
|
||||
{
|
||||
m_CommandsView = new CDebugCommandsView(this);
|
||||
}
|
||||
m_CommandsView->ShowWindow();
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_ShowCommandsLocation(uint32_t address, bool top)
|
||||
{
|
||||
Debug_ShowCommandsWindow();
|
||||
if (m_CommandsView)
|
||||
{
|
||||
m_CommandsView->ShowAddress(address, top);
|
||||
}
|
||||
Debug_ShowCommandsWindow();
|
||||
if (m_CommandsView)
|
||||
{
|
||||
m_CommandsView->ShowAddress(address, top);
|
||||
}
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_ShowScriptsWindow()
|
||||
{
|
||||
if (m_Scripts == NULL)
|
||||
{
|
||||
m_Scripts = new CDebugScripts(this);
|
||||
}
|
||||
m_Scripts->ShowWindow();
|
||||
if (m_Scripts == NULL)
|
||||
{
|
||||
m_Scripts = new CDebugScripts(this);
|
||||
}
|
||||
m_Scripts->ShowWindow();
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_RefreshScriptsWindow()
|
||||
{
|
||||
if (m_Scripts != NULL)
|
||||
{
|
||||
m_Scripts->RefreshList();
|
||||
}
|
||||
if (m_Scripts != NULL)
|
||||
{
|
||||
m_Scripts->RefreshList();
|
||||
}
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_LogScriptsWindow(const char* text)
|
||||
{
|
||||
if (m_Scripts != NULL)
|
||||
{
|
||||
m_Scripts->ConsolePrint(text);
|
||||
}
|
||||
if (m_Scripts != NULL)
|
||||
{
|
||||
m_Scripts->ConsolePrint(text);
|
||||
}
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_ClearScriptsWindow()
|
||||
{
|
||||
if (m_Scripts != NULL)
|
||||
{
|
||||
m_Scripts->ConsoleClear();
|
||||
}
|
||||
if (m_Scripts != NULL)
|
||||
{
|
||||
m_Scripts->ConsoleClear();
|
||||
}
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_ShowSymbolsWindow()
|
||||
{
|
||||
if (m_Symbols == NULL)
|
||||
{
|
||||
m_Symbols = new CDebugSymbols(this);
|
||||
}
|
||||
m_Symbols->ShowWindow();
|
||||
if (m_Symbols == NULL)
|
||||
{
|
||||
m_Symbols = new CDebugSymbols(this);
|
||||
}
|
||||
m_Symbols->ShowWindow();
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_RefreshSymbolsWindow()
|
||||
{
|
||||
if (m_Symbols != NULL)
|
||||
{
|
||||
m_Symbols->Refresh();
|
||||
}
|
||||
if (m_Symbols != NULL)
|
||||
{
|
||||
m_Symbols->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_ShowDMALogWindow(void)
|
||||
{
|
||||
if (m_DMALogView == NULL)
|
||||
{
|
||||
m_DMALogView = new CDebugDMALogView(this);
|
||||
}
|
||||
m_DMALogView->ShowWindow();
|
||||
if (m_DMALogView == NULL)
|
||||
{
|
||||
m_DMALogView = new CDebugDMALogView(this);
|
||||
}
|
||||
m_DMALogView->ShowWindow();
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_ShowStackTrace(void)
|
||||
{
|
||||
if (m_StackTrace == NULL)
|
||||
{
|
||||
m_StackTrace = new CDebugStackTrace(this);
|
||||
}
|
||||
m_StackTrace->ShowWindow();
|
||||
if (m_StackTrace == NULL)
|
||||
{
|
||||
m_StackTrace = new CDebugStackTrace(this);
|
||||
}
|
||||
m_StackTrace->ShowWindow();
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_ShowStackWindow(void)
|
||||
{
|
||||
if (m_StackView == NULL)
|
||||
{
|
||||
m_StackView = new CDebugStackView(this);
|
||||
}
|
||||
m_StackView->ShowWindow();
|
||||
if (m_StackView == NULL)
|
||||
{
|
||||
m_StackView = new CDebugStackView(this);
|
||||
}
|
||||
m_StackView->ShowWindow();
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_RefreshStackWindow(void)
|
||||
{
|
||||
if (m_StackView != NULL)
|
||||
{
|
||||
m_StackView->Refresh();
|
||||
}
|
||||
if (m_StackView != NULL)
|
||||
{
|
||||
m_StackView->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CDebuggerUI::Debug_RefreshStackTraceWindow(void)
|
||||
{
|
||||
if (m_StackTrace != NULL)
|
||||
{
|
||||
m_StackTrace->Refresh();
|
||||
}
|
||||
if (m_StackTrace != NULL && m_StackTrace->m_hWnd != NULL)
|
||||
{
|
||||
m_StackTrace->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
CBreakpoints* CDebuggerUI::Breakpoints()
|
||||
{
|
||||
return m_Breakpoints;
|
||||
return m_Breakpoints;
|
||||
}
|
||||
|
||||
CScriptSystem* CDebuggerUI::ScriptSystem()
|
||||
{
|
||||
return m_ScriptSystem;
|
||||
return m_ScriptSystem;
|
||||
}
|
||||
|
||||
CDebugScripts* CDebuggerUI::ScriptConsole()
|
||||
{
|
||||
return m_Scripts;
|
||||
return m_Scripts;
|
||||
}
|
||||
|
||||
CDMALog* CDebuggerUI::DMALog()
|
||||
{
|
||||
return m_DMALog;
|
||||
return m_DMALog;
|
||||
}
|
||||
|
||||
|
||||
void CDebuggerUI::BreakpointHit()
|
||||
{
|
||||
m_Breakpoints->KeepDebugging();
|
||||
Debug_ShowCommandsLocation(g_Reg->m_PROGRAM_COUNTER, false);
|
||||
Debug_RefreshStackWindow();
|
||||
Debug_RefreshStackTraceWindow();
|
||||
m_Breakpoints->Pause();
|
||||
m_Breakpoints->KeepDebugging();
|
||||
Debug_ShowCommandsLocation(g_Reg->m_PROGRAM_COUNTER, false);
|
||||
Debug_RefreshStackWindow();
|
||||
Debug_RefreshStackTraceWindow();
|
||||
m_Breakpoints->Pause();
|
||||
}
|
||||
|
||||
|
||||
// CDebugger implementation
|
||||
|
||||
void CDebuggerUI::TLBChanged()
|
||||
{
|
||||
Debug_RefreshTLBWindow();
|
||||
Debug_RefreshTLBWindow();
|
||||
}
|
||||
|
||||
// Called from the interpreter core at the beginning of every CPU step
|
||||
// Returns false when the instruction should be skipped
|
||||
bool CDebuggerUI::CPUStepStarted()
|
||||
{
|
||||
uint32_t PROGRAM_COUNTER = g_Reg->m_PROGRAM_COUNTER;
|
||||
uint32_t JumpToLocation = R4300iOp::m_JumpToLocation;
|
||||
|
||||
m_ScriptSystem->HookCPUExec()->InvokeByParamInRange(PROGRAM_COUNTER);
|
||||
|
||||
// PC breakpoints
|
||||
uint32_t PROGRAM_COUNTER = g_Reg->m_PROGRAM_COUNTER;
|
||||
uint32_t JumpToLocation = R4300iOp::m_JumpToLocation;
|
||||
|
||||
if (m_Breakpoints->EBPExists(PROGRAM_COUNTER, true))
|
||||
{
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
m_ScriptSystem->HookCPUExec()->InvokeByParamInRange(PROGRAM_COUNTER);
|
||||
|
||||
// Memory breakpoints
|
||||
|
||||
OPCODE Opcode = R4300iOp::m_Opcode;
|
||||
uint32_t op = Opcode.op;
|
||||
// PC breakpoints
|
||||
|
||||
if (op >= R4300i_LDL && op <= R4300i_SD && op != R4300i_CACHE) // Read and write instructions
|
||||
{
|
||||
uint32_t memoryAddress = g_Reg->m_GPR[Opcode.base].UW[0] + (int16_t)Opcode.offset;
|
||||
|
||||
if ((op <= R4300i_LWU || (op >= R4300i_LL && op <= R4300i_LD))) // Read instructions
|
||||
{
|
||||
m_ScriptSystem->HookCPURead()->InvokeByParamInRange(memoryAddress);
|
||||
|
||||
if (m_Breakpoints->RBPExists(memoryAddress))
|
||||
{
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
}
|
||||
else // Write instructions
|
||||
{
|
||||
m_ScriptSystem->HookCPUWrite()->InvokeByParamInRange(memoryAddress);
|
||||
if (m_Breakpoints->EBPExists(PROGRAM_COUNTER, true))
|
||||
{
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
|
||||
if (m_Breakpoints->WBPExists(memoryAddress))
|
||||
{
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
|
||||
// Catch cart -> rdram dma
|
||||
if (memoryAddress == 0xA460000C) // PI_WR_LEN_REG
|
||||
{
|
||||
uint32_t dmaRomAddr = g_Reg->PI_CART_ADDR_REG & 0x0FFFFFFF;
|
||||
uint32_t dmaRamAddr = g_Reg->PI_DRAM_ADDR_REG | 0x80000000;
|
||||
uint32_t dmaLen = g_Reg->m_GPR[Opcode.rt].UW[0] + 1;
|
||||
uint32_t endAddr = dmaRamAddr + dmaLen;
|
||||
|
||||
m_DMALog->AddEntry(dmaRomAddr, dmaRamAddr, dmaLen);
|
||||
// Memory breakpoints
|
||||
|
||||
for (int i = 0; i < m_Breakpoints->m_nWBP; i++)
|
||||
{
|
||||
uint32_t wbpAddr = m_Breakpoints->m_WBP[i].address;
|
||||
if (wbpAddr >= dmaRamAddr && wbpAddr < endAddr)
|
||||
{
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
OPCODE Opcode = R4300iOp::m_Opcode;
|
||||
uint32_t op = Opcode.op;
|
||||
|
||||
if (!m_Breakpoints->isDebugging())
|
||||
{
|
||||
return !m_Breakpoints->isSkipping();
|
||||
}
|
||||
if (op >= R4300i_LDL && op <= R4300i_SD && op != R4300i_CACHE) // Read and write instructions
|
||||
{
|
||||
uint32_t memoryAddress = g_Reg->m_GPR[Opcode.base].UW[0] + (int16_t)Opcode.offset;
|
||||
|
||||
if (R4300iOp::m_NextInstruction != JUMP)
|
||||
{
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
if ((op <= R4300i_LWU || (op >= R4300i_LL && op <= R4300i_LD))) // Read instructions
|
||||
{
|
||||
m_ScriptSystem->HookCPURead()->InvokeByParamInRange(memoryAddress);
|
||||
|
||||
if (JumpToLocation == PROGRAM_COUNTER + 4)
|
||||
{
|
||||
// Only pause on delay slots when branch isn't taken
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
|
||||
return !m_Breakpoints->isSkipping();
|
||||
if (m_Breakpoints->RBPExists(memoryAddress))
|
||||
{
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
}
|
||||
else // Write instructions
|
||||
{
|
||||
m_ScriptSystem->HookCPUWrite()->InvokeByParamInRange(memoryAddress);
|
||||
|
||||
if (m_Breakpoints->WBPExists(memoryAddress))
|
||||
{
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
|
||||
// Catch cart -> rdram dma
|
||||
if (memoryAddress == 0xA460000C) // PI_WR_LEN_REG
|
||||
{
|
||||
uint32_t dmaRomAddr = g_Reg->PI_CART_ADDR_REG & 0x0FFFFFFF;
|
||||
uint32_t dmaRamAddr = g_Reg->PI_DRAM_ADDR_REG | 0x80000000;
|
||||
uint32_t dmaLen = g_Reg->m_GPR[Opcode.rt].UW[0] + 1;
|
||||
uint32_t endAddr = dmaRamAddr + dmaLen;
|
||||
|
||||
m_DMALog->AddEntry(dmaRomAddr, dmaRamAddr, dmaLen);
|
||||
|
||||
for (int i = 0; i < m_Breakpoints->m_nWBP; i++)
|
||||
{
|
||||
uint32_t wbpAddr = m_Breakpoints->m_WBP[i].address;
|
||||
if (wbpAddr >= dmaRamAddr && wbpAddr < endAddr)
|
||||
{
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_Breakpoints->isDebugging())
|
||||
{
|
||||
return !m_Breakpoints->isSkipping();
|
||||
}
|
||||
|
||||
if (R4300iOp::m_NextInstruction != JUMP)
|
||||
{
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
|
||||
if (JumpToLocation == PROGRAM_COUNTER + 4)
|
||||
{
|
||||
// Only pause on delay slots when branch isn't taken
|
||||
goto breakpoint_hit;
|
||||
}
|
||||
|
||||
return !m_Breakpoints->isSkipping();
|
||||
|
||||
breakpoint_hit:
|
||||
BreakpointHit();
|
||||
return !m_Breakpoints->isSkipping();
|
||||
BreakpointHit();
|
||||
return !m_Breakpoints->isSkipping();
|
||||
}
|
||||
|
||||
void CDebuggerUI::CPUStep()
|
||||
{
|
||||
OPCODE Opcode = R4300iOp::m_Opcode;
|
||||
uint32_t op = Opcode.op;
|
||||
uint32_t funct = Opcode.funct;
|
||||
OPCODE Opcode = R4300iOp::m_Opcode;
|
||||
uint32_t op = Opcode.op;
|
||||
uint32_t funct = Opcode.funct;
|
||||
|
||||
if (m_StackTrace == NULL)
|
||||
{
|
||||
m_StackTrace = new CDebugStackTrace(this);
|
||||
}
|
||||
if (m_StackTrace == NULL)
|
||||
{
|
||||
m_StackTrace = new CDebugStackTrace(this);
|
||||
}
|
||||
|
||||
if (op == R4300i_JAL || ((op == R4300i_SPECIAL) && (funct == R4300i_SPECIAL_JALR) && (Opcode.rd == 31))) // JAL or JALR RA, x
|
||||
{
|
||||
m_StackTrace->PushEntry(R4300iOp::m_JumpToLocation, g_Reg->m_PROGRAM_COUNTER);
|
||||
}
|
||||
else if (funct == R4300i_SPECIAL_JR && Opcode.rs == 31) // JR RA
|
||||
{
|
||||
m_StackTrace->PopEntry();
|
||||
}
|
||||
else if (op == R4300i_CP0 && funct == R4300i_COP0_CO_ERET) // TODO may need more work
|
||||
{
|
||||
m_StackTrace->ClearEntries();
|
||||
}
|
||||
if (op == R4300i_JAL || ((op == R4300i_SPECIAL) && (funct == R4300i_SPECIAL_JALR) && (Opcode.rd == 31))) // JAL or JALR RA, x
|
||||
{
|
||||
m_StackTrace->PushEntry(R4300iOp::m_JumpToLocation, g_Reg->m_PROGRAM_COUNTER);
|
||||
}
|
||||
else if (funct == R4300i_SPECIAL_JR && Opcode.rs == 31) // JR RA
|
||||
{
|
||||
m_StackTrace->PopEntry();
|
||||
}
|
||||
else if (op == R4300i_CP0 && funct == R4300i_COP0_CO_ERET) // TODO may need more work
|
||||
{
|
||||
m_StackTrace->ClearEntries();
|
||||
}
|
||||
}
|
||||
|
||||
void CDebuggerUI::FrameDrawn()
|
||||
{
|
||||
static HWND hMainWnd = NULL;
|
||||
static HWND hMainWnd = NULL;
|
||||
|
||||
static HFONT monoFont = CreateFont(-11, 0, 0, 0,
|
||||
FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
|
||||
OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
PROOF_QUALITY, FF_DONTCARE, "Consolas"
|
||||
);
|
||||
static HFONT monoFont = CreateFont(-11, 0, 0, 0,
|
||||
FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
|
||||
OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
PROOF_QUALITY, FF_DONTCARE, "Consolas"
|
||||
);
|
||||
|
||||
if (hMainWnd == NULL)
|
||||
{
|
||||
RenderWindow* mainWindow = g_Plugins->MainWindow();
|
||||
if (hMainWnd == NULL)
|
||||
{
|
||||
RenderWindow* mainWindow = g_Plugins->MainWindow();
|
||||
|
||||
if (mainWindow == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (mainWindow == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hMainWnd = (HWND)mainWindow->GetWindowHandle();
|
||||
}
|
||||
|
||||
HDC hdc = GetDC(hMainWnd);
|
||||
|
||||
CRect rt;
|
||||
hMainWnd = (HWND)mainWindow->GetWindowHandle();
|
||||
}
|
||||
|
||||
GetClientRect(hMainWnd, &rt);
|
||||
SetBkColor(hdc, RGB(0, 0, 0));
|
||||
|
||||
SelectObject(hdc, monoFont);
|
||||
SetTextColor(hdc, RGB(255, 255, 255));
|
||||
SetBkColor(hdc, RGB(0, 0, 0));
|
||||
HDC hdc = GetDC(hMainWnd);
|
||||
|
||||
m_ScriptSystem->SetScreenDC(hdc);
|
||||
m_ScriptSystem->HookFrameDrawn()->InvokeAll();
|
||||
|
||||
ReleaseDC(hMainWnd, hdc);
|
||||
CRect rt;
|
||||
|
||||
GetClientRect(hMainWnd, &rt);
|
||||
SetBkColor(hdc, RGB(0, 0, 0));
|
||||
|
||||
SelectObject(hdc, monoFont);
|
||||
SetTextColor(hdc, RGB(255, 255, 255));
|
||||
SetBkColor(hdc, RGB(0, 0, 0));
|
||||
|
||||
m_ScriptSystem->SetScreenDC(hdc);
|
||||
m_ScriptSystem->HookFrameDrawn()->InvokeAll();
|
||||
|
||||
ReleaseDC(hMainWnd, hdc);
|
||||
}
|
|
@ -156,7 +156,7 @@ public:
|
|||
return (short)m_OpCode.immediate > 0;
|
||||
}
|
||||
|
||||
bool ReadsGPR(int nReg)
|
||||
bool ReadsGPR(unsigned int nReg)
|
||||
{
|
||||
uint32_t op = m_OpCode.op;
|
||||
|
||||
|
@ -224,7 +224,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
bool WritesGPR(int nReg)
|
||||
bool WritesGPR(unsigned int nReg)
|
||||
{
|
||||
uint32_t op = m_OpCode.op;
|
||||
|
||||
|
|
|
@ -6,121 +6,121 @@
|
|||
|
||||
int CScriptHook::Add(CScriptInstance* scriptInstance, void* heapptr, uint32_t param, uint32_t param2, bool bOnce)
|
||||
{
|
||||
JSCALLBACK jsCallback;
|
||||
jsCallback.scriptInstance = scriptInstance;
|
||||
jsCallback.heapptr = heapptr;
|
||||
jsCallback.callbackId = m_ScriptSystem->GetNextCallbackId();
|
||||
jsCallback.param = param;
|
||||
jsCallback.param2 = param2;
|
||||
jsCallback.bOnce = bOnce;
|
||||
m_Callbacks.push_back(jsCallback);
|
||||
return jsCallback.callbackId;
|
||||
JSCALLBACK jsCallback;
|
||||
jsCallback.scriptInstance = scriptInstance;
|
||||
jsCallback.heapptr = heapptr;
|
||||
jsCallback.callbackId = m_ScriptSystem->GetNextCallbackId();
|
||||
jsCallback.param = param;
|
||||
jsCallback.param2 = param2;
|
||||
jsCallback.bOnce = bOnce;
|
||||
m_Callbacks.push_back(jsCallback);
|
||||
return jsCallback.callbackId;
|
||||
}
|
||||
|
||||
void CScriptHook::InvokeById(int callbackId)
|
||||
{
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
if (m_Callbacks[i].callbackId == callbackId)
|
||||
{
|
||||
m_Callbacks[i].scriptInstance->Invoke(m_Callbacks[i].heapptr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
if (m_Callbacks[i].callbackId == callbackId)
|
||||
{
|
||||
m_Callbacks[i].scriptInstance->Invoke(m_Callbacks[i].heapptr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptHook::InvokeByParam(uint32_t param)
|
||||
{
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
if (m_Callbacks[i].param == param)
|
||||
{
|
||||
m_Callbacks[i].scriptInstance->Invoke(m_Callbacks[i].heapptr, param);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
if (m_Callbacks[i].param == param)
|
||||
{
|
||||
m_Callbacks[i].scriptInstance->Invoke(m_Callbacks[i].heapptr, param);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptHook::InvokeByParamInRange(uint32_t param)
|
||||
{
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
if (param == m_Callbacks[i].param || (param >= m_Callbacks[i].param && param < m_Callbacks[i].param2))
|
||||
{
|
||||
m_Callbacks[i].scriptInstance->Invoke(m_Callbacks[i].heapptr, param);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
if (param == m_Callbacks[i].param || (param >= m_Callbacks[i].param && param < m_Callbacks[i].param2))
|
||||
{
|
||||
m_Callbacks[i].scriptInstance->Invoke(m_Callbacks[i].heapptr, param);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptHook::InvokeAll()
|
||||
{
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
m_Callbacks[i].scriptInstance->Invoke(m_Callbacks[i].heapptr);
|
||||
}
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
m_Callbacks[i].scriptInstance->Invoke(m_Callbacks[i].heapptr);
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptHook::RemoveById(int callbackId)
|
||||
{
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
if (m_Callbacks[i].callbackId == callbackId)
|
||||
{
|
||||
m_Callbacks.erase(m_Callbacks.begin() + i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
if (m_Callbacks[i].callbackId == callbackId)
|
||||
{
|
||||
m_Callbacks.erase(m_Callbacks.begin() + i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptHook::RemoveByParam(uint32_t param)
|
||||
{
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
if (m_Callbacks[i].param == param)
|
||||
{
|
||||
m_Callbacks.erase(m_Callbacks.begin() + i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int nCallbacks = m_Callbacks.size();
|
||||
for (int i = 0; i < nCallbacks; i++)
|
||||
{
|
||||
if (m_Callbacks[i].param == param)
|
||||
{
|
||||
m_Callbacks.erase(m_Callbacks.begin() + i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptHook::RemoveByInstance(CScriptInstance* scriptInstance)
|
||||
{
|
||||
int lastIndex = m_Callbacks.size() - 1;
|
||||
for (int i = lastIndex; i >= 0; i--)
|
||||
{
|
||||
if (m_Callbacks[i].scriptInstance == scriptInstance)
|
||||
{
|
||||
m_Callbacks.erase(m_Callbacks.begin() + i);
|
||||
}
|
||||
}
|
||||
int lastIndex = m_Callbacks.size() - 1;
|
||||
for (int i = lastIndex; i >= 0; i--)
|
||||
{
|
||||
if (m_Callbacks[i].scriptInstance == scriptInstance)
|
||||
{
|
||||
m_Callbacks.erase(m_Callbacks.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CScriptHook::HasContext(CScriptInstance* scriptInstance)
|
||||
{
|
||||
for (int i = 0; i < m_Callbacks.size(); i++)
|
||||
{
|
||||
if (m_Callbacks[i].scriptInstance == scriptInstance)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
for (size_t i = 0; i < m_Callbacks.size(); i++)
|
||||
{
|
||||
if (m_Callbacks[i].scriptInstance == scriptInstance)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CScriptHook::CScriptHook(CScriptSystem* scriptSystem)
|
||||
{
|
||||
m_ScriptSystem = scriptSystem;
|
||||
m_ScriptSystem = scriptSystem;
|
||||
}
|
||||
|
||||
CScriptHook::~CScriptHook()
|
||||
{
|
||||
m_Callbacks.clear();
|
||||
m_Callbacks.clear();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -17,167 +17,165 @@
|
|||
|
||||
CScriptSystem::CScriptSystem(CDebuggerUI* debugger)
|
||||
{
|
||||
WSADATA wsaData;
|
||||
WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
WSADATA wsaData;
|
||||
WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
|
||||
m_NextCallbackId = 0;
|
||||
m_NextCallbackId = 0;
|
||||
|
||||
m_Debugger = debugger;
|
||||
m_Debugger = debugger;
|
||||
|
||||
m_HookCPUExec = new CScriptHook(this);
|
||||
m_HookCPURead = new CScriptHook(this);
|
||||
m_HookCPUWrite = new CScriptHook(this);
|
||||
m_HookFrameDrawn = new CScriptHook(this);
|
||||
m_HookCPUExec = new CScriptHook(this);
|
||||
m_HookCPURead = new CScriptHook(this);
|
||||
m_HookCPUWrite = new CScriptHook(this);
|
||||
m_HookFrameDrawn = new CScriptHook(this);
|
||||
|
||||
RegisterHook("exec", m_HookCPUExec);
|
||||
RegisterHook("read", m_HookCPURead);
|
||||
RegisterHook("write", m_HookCPUWrite);
|
||||
RegisterHook("draw", m_HookFrameDrawn);
|
||||
RegisterHook("exec", m_HookCPUExec);
|
||||
RegisterHook("read", m_HookCPURead);
|
||||
RegisterHook("write", m_HookCPUWrite);
|
||||
RegisterHook("draw", m_HookFrameDrawn);
|
||||
|
||||
HMODULE hInst = GetModuleHandle(NULL);
|
||||
HRSRC hRes = FindResource(hInst, MAKEINTRESOURCE(IDR_JSAPI_TEXT), "TEXT");
|
||||
|
||||
HGLOBAL hGlob = LoadResource(hInst, hRes);
|
||||
DWORD resSize = SizeofResource(hInst, hRes);
|
||||
m_APIScript = (char*) malloc(resSize + 1);
|
||||
|
||||
void* resData = LockResource(hGlob);
|
||||
memcpy(m_APIScript, resData, resSize);
|
||||
m_APIScript[resSize] = '\0';
|
||||
FreeResource(hGlob);
|
||||
HMODULE hInst = GetModuleHandle(NULL);
|
||||
HRSRC hRes = FindResource(hInst, MAKEINTRESOURCE(IDR_JSAPI_TEXT), "TEXT");
|
||||
|
||||
HGLOBAL hGlob = LoadResource(hInst, hRes);
|
||||
DWORD resSize = SizeofResource(hInst, hRes);
|
||||
m_APIScript = (char*)malloc(resSize + 1);
|
||||
|
||||
void* resData = LockResource(hGlob);
|
||||
memcpy(m_APIScript, resData, resSize);
|
||||
m_APIScript[resSize] = '\0';
|
||||
FreeResource(hGlob);
|
||||
}
|
||||
|
||||
CScriptSystem::~CScriptSystem()
|
||||
{
|
||||
for (int i = 0; i < m_Hooks.size(); i++)
|
||||
{
|
||||
delete m_Hooks[i].cbList;
|
||||
}
|
||||
for (size_t i = 0; i < m_Hooks.size(); i++)
|
||||
{
|
||||
delete m_Hooks[i].cbList;
|
||||
}
|
||||
|
||||
UnregisterHooks();
|
||||
free(m_APIScript);
|
||||
UnregisterHooks();
|
||||
free(m_APIScript);
|
||||
}
|
||||
|
||||
const char* CScriptSystem::APIScript()
|
||||
{
|
||||
return m_APIScript;
|
||||
return m_APIScript;
|
||||
}
|
||||
|
||||
void CScriptSystem::RunScript(char* path)
|
||||
{
|
||||
CScriptInstance* scriptInstance = new CScriptInstance(m_Debugger);
|
||||
char* pathSaved = (char*)malloc(strlen(path)); // freed via DeleteStoppedInstances
|
||||
strcpy(pathSaved, path);
|
||||
m_RunningInstances.push_back({ pathSaved, scriptInstance });
|
||||
scriptInstance->Start(pathSaved);
|
||||
CScriptInstance* scriptInstance = new CScriptInstance(m_Debugger);
|
||||
char* pathSaved = (char*)malloc(strlen(path)); // freed via DeleteStoppedInstances
|
||||
strcpy(pathSaved, path);
|
||||
m_RunningInstances.push_back({ pathSaved, scriptInstance });
|
||||
scriptInstance->Start(pathSaved);
|
||||
}
|
||||
|
||||
void CScriptSystem::StopScript(char* path)
|
||||
{
|
||||
int nInstances = m_RunningInstances.size();
|
||||
CScriptInstance* scriptInstance = GetInstance(path);
|
||||
|
||||
CScriptInstance* scriptInstance = GetInstance(path);
|
||||
if (scriptInstance == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (scriptInstance == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
scriptInstance->ForceStop();
|
||||
scriptInstance->ForceStop();
|
||||
}
|
||||
|
||||
void CScriptSystem::DeleteStoppedInstances()
|
||||
{
|
||||
int lastIndex = m_RunningInstances.size() - 1;
|
||||
for (int i = lastIndex; i >= 0; i--)
|
||||
{
|
||||
if (m_RunningInstances[i].scriptInstance->GetState() == STATE_STOPPED)
|
||||
{
|
||||
free(m_RunningInstances[i].path);
|
||||
CScriptInstance* instance = m_RunningInstances[i].scriptInstance;
|
||||
delete instance;
|
||||
m_RunningInstances.erase(m_RunningInstances.begin() + i);
|
||||
}
|
||||
}
|
||||
int lastIndex = m_RunningInstances.size() - 1;
|
||||
for (int i = lastIndex; i >= 0; i--)
|
||||
{
|
||||
if (m_RunningInstances[i].scriptInstance->GetState() == STATE_STOPPED)
|
||||
{
|
||||
free(m_RunningInstances[i].path);
|
||||
CScriptInstance* instance = m_RunningInstances[i].scriptInstance;
|
||||
delete instance;
|
||||
m_RunningInstances.erase(m_RunningInstances.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANCE_STATE CScriptSystem::GetInstanceState(char* path)
|
||||
{
|
||||
for (int i = 0; i < m_RunningInstances.size(); i++)
|
||||
{
|
||||
if (strcmp(m_RunningInstances[i].path, path) == 0)
|
||||
{
|
||||
return m_RunningInstances[i].scriptInstance->GetState();
|
||||
}
|
||||
}
|
||||
return STATE_INVALID;
|
||||
for (size_t i = 0; i < m_RunningInstances.size(); i++)
|
||||
{
|
||||
if (strcmp(m_RunningInstances[i].path, path) == 0)
|
||||
{
|
||||
return m_RunningInstances[i].scriptInstance->GetState();
|
||||
}
|
||||
}
|
||||
return STATE_INVALID;
|
||||
}
|
||||
|
||||
CScriptInstance* CScriptSystem::GetInstance(char* path)
|
||||
{
|
||||
for (int i = 0; i < m_RunningInstances.size(); i++)
|
||||
{
|
||||
if (strcmp(m_RunningInstances[i].path, path) == 0)
|
||||
{
|
||||
return m_RunningInstances[i].scriptInstance;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
for (size_t i = 0; i < m_RunningInstances.size(); i++)
|
||||
{
|
||||
if (strcmp(m_RunningInstances[i].path, path) == 0)
|
||||
{
|
||||
return m_RunningInstances[i].scriptInstance;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CScriptSystem::HasCallbacksForInstance(CScriptInstance* scriptInstance)
|
||||
{
|
||||
for (int i = 0; i < m_Hooks.size(); i++)
|
||||
{
|
||||
if (m_Hooks[i].cbList->HasContext(scriptInstance))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
for (size_t i = 0; i < m_Hooks.size(); i++)
|
||||
{
|
||||
if (m_Hooks[i].cbList->HasContext(scriptInstance))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CScriptSystem::ClearCallbacksForInstance(CScriptInstance* scriptInstance)
|
||||
{
|
||||
for (int i = 0; i < m_Hooks.size(); i++)
|
||||
{
|
||||
m_Hooks[i].cbList->RemoveByInstance(scriptInstance);
|
||||
}
|
||||
for (size_t i = 0; i < m_Hooks.size(); i++)
|
||||
{
|
||||
m_Hooks[i].cbList->RemoveByInstance(scriptInstance);
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptSystem::RemoveCallbackById(int callbackId)
|
||||
{
|
||||
for (int i = 0; i < m_Hooks.size(); i++)
|
||||
{
|
||||
m_Hooks[i].cbList->RemoveById(callbackId);
|
||||
}
|
||||
for (size_t i = 0; i < m_Hooks.size(); i++)
|
||||
{
|
||||
m_Hooks[i].cbList->RemoveById(callbackId);
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptSystem::RegisterHook(const char* hookId, CScriptHook* cbList)
|
||||
{
|
||||
HOOKENTRY hook = { hookId, cbList };
|
||||
m_Hooks.push_back(hook);
|
||||
HOOKENTRY hook = { hookId, cbList };
|
||||
m_Hooks.push_back(hook);
|
||||
}
|
||||
|
||||
void CScriptSystem::UnregisterHooks()
|
||||
{
|
||||
m_Hooks.clear();
|
||||
m_Hooks.clear();
|
||||
}
|
||||
|
||||
CScriptHook* CScriptSystem::GetHook(const char* hookId)
|
||||
{
|
||||
int size = m_Hooks.size();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
if (strcmp(m_Hooks[i].hookId, hookId) == 0)
|
||||
{
|
||||
return m_Hooks[i].cbList;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
size_t size = m_Hooks.size();
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
if (strcmp(m_Hooks[i].hookId, hookId) == 0)
|
||||
{
|
||||
return m_Hooks[i].cbList;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CScriptSystem::GetNextCallbackId()
|
||||
{
|
||||
return m_NextCallbackId++;
|
||||
return m_NextCallbackId++;
|
||||
}
|
Loading…
Reference in New Issue