Merge pull request #1705 from Drahsid/master

Added type, name, value, desc editing in the symbols window; 'new tab' shortcut to memory viewer
This commit is contained in:
zilmar 2020-02-20 12:30:26 +10:30 committed by GitHub
commit f2462cbc18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 145 additions and 9 deletions

View File

@ -17,6 +17,21 @@
#include "Symbols.h"
const CSetValueDlg::ComboItem CDebugSymbols::ModalChangeTypeItems[] = {
{ "code", SYM_CODE},
{ "uint8", SYM_U8 },
{ "int8", SYM_S8 },
{ "uint16", SYM_U16 },
{ "int16", SYM_S16 },
{ "uint32", SYM_U32 },
{ "int32", SYM_S32 },
{ "uint64", SYM_U64 },
{ "int64", SYM_S64 },
{ "float", SYM_FLOAT },
{ "double", SYM_DOUBLE },
{ NULL, 0 }
};
CDebugSymbols::CDebugSymbols(CDebuggerUI * debugger) :
CDebugDialog<CDebugSymbols>(debugger)
{
@ -99,10 +114,41 @@ LRESULT CDebugSymbols::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*
LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
{
// Open it in memory viewer/commands viewer
if (g_MMU == NULL)
{
return true;
}
LONG iItem = m_SymbolsListView.GetNextItem(-1, LVNI_SELECTED);
if (iItem == -1)
{
return true;
}
int nSelectedCol = -1;
// hit test for column
POINT mousePt;
RECT listRect;
GetCursorPos(&mousePt);
m_SymbolsListView.GetWindowRect(&listRect);
int mouseX = mousePt.x - listRect.left;
for (int nCol = 0, colX = 0; nCol < SymbolsListView_Num_Columns; nCol++)
{
int colWidth = m_SymbolsListView.GetColumnWidth(nCol);
if (mouseX >= colX && mouseX <= colX + colWidth)
{
nSelectedCol = nCol;
break;
}
colX += colWidth;
}
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
int nItem = pIA->iItem;
int id = m_SymbolsListView.GetItemData(nItem);
CSymbol symbol;
@ -111,6 +157,10 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
return 0;
}
switch (nSelectedCol)
{
case SymbolsListView_Col_Address:
// Open it in memory viewer/commands viewer
if (symbol.m_Type == SYM_CODE) // code
{
m_Debugger->Debug_ShowCommandsLocation(symbol.m_Address, true);
@ -119,6 +169,77 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
{
m_Debugger->Debug_ShowMemoryLocation(symbol.m_Address, true);
}
break;
case SymbolsListView_Col_Type:
if (m_SetValueDlg.DoModal("Change type", "New type:", symbol.m_Type, ModalChangeTypeItems))
{
ValueType t = (ValueType)m_SetValueDlg.GetEnteredData();
//Is there a better way?
m_Debugger->SymbolTable()->RemoveSymbolById(id);
m_Debugger->SymbolTable()->AddSymbol(t, symbol.m_Address, symbol.m_Name, symbol.m_Description);
}
break;
case SymbolsListView_Col_Name:
if (m_SetValueDlg.DoModal("Set name", "New name:", symbol.m_Name))
{
char* szEnteredString = m_SetValueDlg.GetEnteredString();
m_Debugger->SymbolTable()->RemoveSymbolById(id);
m_Debugger->SymbolTable()->AddSymbol(symbol.m_Type, symbol.m_Address, szEnteredString, symbol.m_Description);
}
break;
case SymbolsListView_Col_Value:
char szValue[64];
m_Debugger->SymbolTable()->GetValueString(szValue, &symbol);
if (m_SetValueDlg.DoModal("Change value", "New value:", szValue))
{
switch (symbol.m_Type)
{
case SYM_U8:
m_Debugger->DebugStore_VAddr<uint8_t>(symbol.m_Address, atoi(m_SetValueDlg.GetEnteredString()));
break;
case SYM_U16:
m_Debugger->DebugStore_VAddr<uint16_t>(symbol.m_Address, atoi(m_SetValueDlg.GetEnteredString()));
break;
case SYM_U32:
m_Debugger->DebugStore_VAddr<uint32_t>(symbol.m_Address, atoi(m_SetValueDlg.GetEnteredString()));
break;
case SYM_U64:
m_Debugger->DebugStore_VAddr<uint64_t>(symbol.m_Address, atoll(m_SetValueDlg.GetEnteredString()));
break;
case SYM_S8:
m_Debugger->DebugStore_VAddr<int8_t>(symbol.m_Address, atoi(m_SetValueDlg.GetEnteredString()));
break;
case SYM_S16:
m_Debugger->DebugStore_VAddr<int16_t>(symbol.m_Address, atoi(m_SetValueDlg.GetEnteredString()));
break;
case SYM_S32:
m_Debugger->DebugStore_VAddr<int>(symbol.m_Address, atoi(m_SetValueDlg.GetEnteredString()));
break;
case SYM_S64:
m_Debugger->DebugStore_VAddr<int64_t>(symbol.m_Address, atoll(m_SetValueDlg.GetEnteredString()));
break;
case SYM_FLOAT:
m_Debugger->DebugStore_VAddr<float>(symbol.m_Address, atof(m_SetValueDlg.GetEnteredString()));
break;
case SYM_DOUBLE:
m_Debugger->DebugStore_VAddr<double>(symbol.m_Address, atof(m_SetValueDlg.GetEnteredString()));
break;
}
}
break;
case SymbolsListView_Col_Description:
if (m_SetValueDlg.DoModal("Set description", "New description:", symbol.m_Description))
{
char* szEnteredString = m_SetValueDlg.GetEnteredString();
m_Debugger->SymbolTable()->RemoveSymbolById(id);
m_Debugger->SymbolTable()->AddSymbol(symbol.m_Type, symbol.m_Address, symbol.m_Name, szEnteredString);
}
break;
}
m_Debugger->SymbolTable()->Save();
Refresh();
return 0;
}

View File

@ -20,7 +20,19 @@ class CDebugSymbols :
public CDialogResize<CDebugSymbols>
{
private:
enum {
SymbolsListView_Col_Address,
SymbolsListView_Col_Type,
SymbolsListView_Col_Name,
SymbolsListView_Col_Value,
SymbolsListView_Col_Description,
SymbolsListView_Num_Columns
};
static const CSetValueDlg::ComboItem ModalChangeTypeItems[];
CListViewCtrl m_SymbolsListView;
CSetValueDlg m_SetValueDlg;
CAddSymbolDlg m_AddSymbolDlg;
public:

View File

@ -562,6 +562,9 @@ LRESULT CDebugMemoryView::OnHxCtrlKeyPressed(LPNMHDR lpNMHDR)
case 'W':
m_Breakpoints->WBPToggle(address);
break;
case 'N':
AddTab(0x80000000, true, 4);
break;
case 'R':
m_Breakpoints->RBPToggle(address);
break;