[Debugger] Code clean up and fix some warnings

This commit is contained in:
zilmar 2017-09-13 22:00:53 +10:00
parent fda0ce24e6
commit 0e508ebc20
21 changed files with 2706 additions and 2684 deletions

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)

View File

@ -18,8 +18,6 @@ bool CRegisterTabs::m_bColorsEnabled = false;
void CRegisterTabs::Attach(HWND hWndNew)
{
m_TabWindows.clear();
CTabCtrl::Attach(hWndNew);
HFONT monoFont = CreateFont(-11, 0, 0, 0,
@ -78,6 +76,31 @@ void CRegisterTabs::Attach(HWND hWndNew)
RedrawCurrentTab();
}
HWND CRegisterTabs::Detach()
{
m_GPRTab = NULL;
m_FPRTab = NULL;
m_COP0Tab = NULL;
m_RDRAMTab = NULL;
m_SPTab = NULL;
m_DPCTab = NULL;
m_MITab = NULL;
m_VITab = NULL;
m_AITab = NULL;
m_PITab = NULL;
m_RITab = NULL;
m_SITab = NULL;
m_DDTab = NULL;
for (size_t i = 0; i < m_TabWindows.size(); i++)
{
m_TabWindows[i].DestroyWindow();
}
m_TabWindows.clear();
m_CauseTip.Detach();
CTabCtrl::Detach();
return NULL;
}
void CRegisterTabs::RefreshEdits()
{
if (g_Reg == NULL)
@ -437,7 +460,7 @@ void CRegisterTabs::RegisterChanged(HWND hDlg, TAB_ID srcTabId, WPARAM wParam)
}
}
INT_PTR CALLBACK CRegisterTabs::TabProcDefault(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
INT_PTR CALLBACK CRegisterTabs::TabProcDefault(HWND hDlg, UINT msg, WPARAM wParam, LPARAM /*lParam*/)
{
if (msg == WM_INITDIALOG)
{
@ -538,7 +561,7 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L
return FALSE;
}
INT_PTR CALLBACK CRegisterTabs::TabProcFPR(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
INT_PTR CALLBACK CRegisterTabs::TabProcFPR(HWND hDlg, UINT msg, WPARAM wParam, LPARAM /*lParam*/)
{
if (msg == WM_INITDIALOG)
{

View File

@ -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();

View File

@ -195,7 +195,7 @@ void CDebugScripts::RefreshStatus()
{
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
char* szState;
char* szState = "";
switch (state)
{
case STATE_RUNNING: szState = "Running"; break;
@ -375,7 +375,6 @@ LRESULT CEditEval::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan
return 0;
}
void CDebugScripts::RunSelected()
{
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);

View File

@ -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)
{

View File

@ -74,6 +74,7 @@ LRESULT CDebugStackTrace::OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BO
LRESULT CDebugStackTrace::OnDestroy(void)
{
m_List.Detach();
return FALSE;
}

View File

@ -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)

View File

@ -49,6 +49,8 @@ LRESULT CDebugStackView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /
LRESULT CDebugStackView::OnDestroy(void)
{
m_StackList.Detach();
m_SPStatic.Detach();
return 0;
}

View File

@ -22,7 +22,7 @@ CDebugSymbols::CDebugSymbols(CDebuggerUI * 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);
@ -51,6 +51,7 @@ LRESULT CDebugSymbols::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOO
LRESULT CDebugSymbols::OnDestroy(void)
{
m_SymbolsListView.Detach();
if (m_AutoRefreshThread != NULL)
{
TerminateThread(m_AutoRefreshThread, 0);
@ -116,6 +117,10 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
void CDebugSymbols::Refresh()
{
if (m_SymbolsListView.m_hWnd == NULL)
{
return;
}
m_SymbolsListView.SetRedraw(FALSE);
m_SymbolsListView.DeleteAllItems();

View File

@ -28,7 +28,6 @@ m_MemoryList(NULL)
}
m_Breakpoints = m_Debugger->Breakpoints();
}
CDebugMemoryView::~CDebugMemoryView()
@ -130,9 +129,9 @@ LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
return TRUE;
}
DWORD WINAPI CDebugMemoryView::AutoRefreshProc(void* _this)
DWORD WINAPI CDebugMemoryView::AutoRefreshProc(void* _self)
{
CDebugMemoryView* self = (CDebugMemoryView*)_this;
CDebugMemoryView* self = (CDebugMemoryView*)_self;
while (true)
{
self->RefreshMemory(true);
@ -140,7 +139,7 @@ DWORD WINAPI CDebugMemoryView::AutoRefreshProc(void* _this)
}
}
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;
@ -155,7 +154,6 @@ LRESULT CALLBACK CDebugMemoryView::HookProc(int nCode, WPARAM wParam, LPARAM lPa
if (pMsg->message == WM_MOUSEWHEEL)
{
BOOL bHandled = TRUE;
_this->InterceptMouseWheel(pMsg->wParam, pMsg->lParam);
}
@ -323,9 +321,7 @@ LRESULT CDebugMemoryView::OnMemoryModified(LPNMHDR 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)
{
@ -399,7 +395,7 @@ void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl)
}
}
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);
@ -701,8 +697,8 @@ void CDebugMemoryView::SelectColors(uint32_t vaddr, bool changed, COLORREF& bgCo
CSymbols::LeaveCriticalSection();
bool bHaveReadBP = m_Breakpoints->RBPExists(vaddr);
bool bHaveWriteBP = m_Breakpoints->WBPExists(vaddr);
bool bHaveReadBP = m_Breakpoints->RBPExists(vaddr) == CBreakpoints::BP_SET;
bool bHaveWriteBP = m_Breakpoints->WBPExists(vaddr) == CBreakpoints::BP_SET;
fgHiColor = RGB(0x00, 0x00, 0x00);

View File

@ -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);

View File

@ -339,7 +339,7 @@ void CDebuggerUI::Debug_RefreshStackWindow(void)
void CDebuggerUI::Debug_RefreshStackTraceWindow(void)
{
if (m_StackTrace != NULL)
if (m_StackTrace != NULL && m_StackTrace->m_hWnd != NULL)
{
m_StackTrace->Refresh();
}
@ -365,7 +365,6 @@ CDMALog* CDebuggerUI::DMALog()
return m_DMALog;
}
void CDebuggerUI::BreakpointHit()
{
m_Breakpoints->KeepDebugging();
@ -375,7 +374,6 @@ void CDebuggerUI::BreakpointHit()
m_Breakpoints->Pause();
}
// CDebugger implementation
void CDebuggerUI::TLBChanged()

View File

@ -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;

View File

@ -105,7 +105,7 @@ void CScriptHook::RemoveByInstance(CScriptInstance* scriptInstance)
bool CScriptHook::HasContext(CScriptInstance* scriptInstance)
{
for (int i = 0; i < m_Callbacks.size(); i++)
for (size_t i = 0; i < m_Callbacks.size(); i++)
{
if (m_Callbacks[i].scriptInstance == scriptInstance)
{

View File

@ -17,7 +17,7 @@ void CScriptInstance::CacheInstance(CScriptInstance* _this)
void CScriptInstance::UncacheInstance(CScriptInstance* _this)
{
for (int i = 0; i < Cache.size(); i++)
for (size_t i = 0; i < Cache.size(); i++)
{
if (Cache[i] == _this)
{
@ -29,7 +29,7 @@ void CScriptInstance::UncacheInstance(CScriptInstance* _this)
CScriptInstance* CScriptInstance::FetchInstance(duk_context* ctx)
{
for (int i = 0; i < Cache.size(); i++)
for (size_t i = 0; i < Cache.size(); i++)
{
if (Cache[i]->DukContext() == ctx)
{
@ -685,7 +685,7 @@ duk_ret_t CScriptInstance::js_AddCallback(duk_context* ctx)
param2 = duk_get_uint(ctx, 3);
if (argc > 4)
{
bOnce = duk_get_boolean(ctx, 4);
bOnce = duk_get_boolean(ctx, 4) != 0;
}
}
}
@ -732,7 +732,7 @@ duk_ret_t CScriptInstance::js_SetPCVal(duk_context* ctx)
duk_ret_t CScriptInstance::js_GetLOVal(duk_context* ctx)
{
bool bUpper = duk_get_boolean(ctx, 0);
bool bUpper = duk_get_boolean(ctx, 0) != 0;
duk_pop_n(ctx, 1);
if (!bUpper)
@ -749,7 +749,7 @@ duk_ret_t CScriptInstance::js_GetLOVal(duk_context* ctx)
duk_ret_t CScriptInstance::js_SetLOVal(duk_context* ctx)
{
bool bUpper = duk_get_boolean(ctx, 0);
bool bUpper = duk_get_boolean(ctx, 0) != 0;
uint32_t val = duk_to_uint32(ctx, 1);
duk_pop_n(ctx, 2);
@ -768,7 +768,7 @@ duk_ret_t CScriptInstance::js_SetLOVal(duk_context* ctx)
duk_ret_t CScriptInstance::js_GetHIVal(duk_context* ctx)
{
bool bUpper = duk_get_boolean(ctx, 0);
bool bUpper = duk_get_boolean(ctx, 0) != 0;
duk_pop_n(ctx, 1);
if (!bUpper)
@ -785,7 +785,7 @@ duk_ret_t CScriptInstance::js_GetHIVal(duk_context* ctx)
duk_ret_t CScriptInstance::js_SetHIVal(duk_context* ctx)
{
bool bUpper = duk_get_boolean(ctx, 0);
bool bUpper = duk_get_boolean(ctx, 0) != 0;
uint32_t val = duk_to_uint32(ctx, 1);
duk_pop_n(ctx, 2);
@ -809,7 +809,7 @@ duk_ret_t CScriptInstance::js_GetGPRVal(duk_context* ctx)
if (nargs > 1)
{
bUpper = duk_to_boolean(ctx, 1);
bUpper = duk_to_boolean(ctx, 1) != 0;
}
duk_pop_n(ctx, nargs);
@ -828,9 +828,8 @@ duk_ret_t CScriptInstance::js_GetGPRVal(duk_context* ctx)
duk_ret_t CScriptInstance::js_SetGPRVal(duk_context* ctx)
{
int nargs = duk_get_top(ctx);
int regnum = duk_to_int(ctx, 0);
bool bUpper = duk_to_boolean(ctx, 1);
bool bUpper = duk_to_boolean(ctx, 1) != 0;
uint32_t val = duk_to_uint32(ctx, 2);
if (!bUpper)
@ -854,7 +853,7 @@ duk_ret_t CScriptInstance::js_GetFPRVal(duk_context* ctx)
if (nargs > 1)
{
bDouble = duk_get_boolean(ctx, 1);
bDouble = duk_get_boolean(ctx, 1) != 0;
}
duk_pop_n(ctx, nargs);
@ -872,9 +871,8 @@ duk_ret_t CScriptInstance::js_GetFPRVal(duk_context* ctx)
duk_ret_t CScriptInstance::js_SetFPRVal(duk_context* ctx)
{
int nargs = duk_get_top(ctx);
int regnum = duk_to_int(ctx, 0);
bool bDouble = duk_to_boolean(ctx, 1);
bool bDouble = duk_to_boolean(ctx, 1) != 0;
duk_double_t val = duk_to_number(ctx, 2);
if (!bDouble)
@ -1437,7 +1435,6 @@ duk_ret_t CScriptInstance::js_ScreenPrint(duk_context* ctx)
////////////
static BOOL ConnectEx(SOCKET s, const SOCKADDR* name, int namelen, PVOID lpSendBuffer,
DWORD dwSendDataLength, LPDWORD lpdwBytesSent, LPOVERLAPPED lpOverlapped)
{

View File

@ -49,7 +49,7 @@ CScriptSystem::CScriptSystem(CDebuggerUI* debugger)
CScriptSystem::~CScriptSystem()
{
for (int i = 0; i < m_Hooks.size(); i++)
for (size_t i = 0; i < m_Hooks.size(); i++)
{
delete m_Hooks[i].cbList;
}
@ -74,8 +74,6 @@ void CScriptSystem::RunScript(char* path)
void CScriptSystem::StopScript(char* path)
{
int nInstances = m_RunningInstances.size();
CScriptInstance* scriptInstance = GetInstance(path);
if (scriptInstance == NULL)
@ -103,7 +101,7 @@ void CScriptSystem::DeleteStoppedInstances()
INSTANCE_STATE CScriptSystem::GetInstanceState(char* path)
{
for (int i = 0; i < m_RunningInstances.size(); i++)
for (size_t i = 0; i < m_RunningInstances.size(); i++)
{
if (strcmp(m_RunningInstances[i].path, path) == 0)
{
@ -115,7 +113,7 @@ INSTANCE_STATE CScriptSystem::GetInstanceState(char* path)
CScriptInstance* CScriptSystem::GetInstance(char* path)
{
for (int i = 0; i < m_RunningInstances.size(); i++)
for (size_t i = 0; i < m_RunningInstances.size(); i++)
{
if (strcmp(m_RunningInstances[i].path, path) == 0)
{
@ -127,7 +125,7 @@ CScriptInstance* CScriptSystem::GetInstance(char* path)
bool CScriptSystem::HasCallbacksForInstance(CScriptInstance* scriptInstance)
{
for (int i = 0; i < m_Hooks.size(); i++)
for (size_t i = 0; i < m_Hooks.size(); i++)
{
if (m_Hooks[i].cbList->HasContext(scriptInstance))
{
@ -139,7 +137,7 @@ bool CScriptSystem::HasCallbacksForInstance(CScriptInstance* scriptInstance)
void CScriptSystem::ClearCallbacksForInstance(CScriptInstance* scriptInstance)
{
for (int i = 0; i < m_Hooks.size(); i++)
for (size_t i = 0; i < m_Hooks.size(); i++)
{
m_Hooks[i].cbList->RemoveByInstance(scriptInstance);
}
@ -147,7 +145,7 @@ void CScriptSystem::ClearCallbacksForInstance(CScriptInstance* scriptInstance)
void CScriptSystem::RemoveCallbackById(int callbackId)
{
for (int i = 0; i < m_Hooks.size(); i++)
for (size_t i = 0; i < m_Hooks.size(); i++)
{
m_Hooks[i].cbList->RemoveById(callbackId);
}
@ -166,8 +164,8 @@ void CScriptSystem::UnregisterHooks()
CScriptHook* CScriptSystem::GetHook(const char* hookId)
{
int size = m_Hooks.size();
for (int i = 0; i < size; i++)
size_t size = m_Hooks.size();
for (size_t i = 0; i < size; i++)
{
if (strcmp(m_Hooks[i].hookId, hookId) == 0)
{