Merge pull request #1884 from shygoo/debugger-fixes

[Debugger] Miscellaneous fixes
This commit is contained in:
zilmar 2020-12-18 09:57:11 +10:30 committed by GitHub
commit e97b04b751
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 129 additions and 53 deletions

View File

@ -255,43 +255,6 @@ LRESULT CALLBACK CDebugCommandsView::HookProc(int nCode, WPARAM wParam, LPARAM l
return 0; return 0;
} }
LRESULT CDebugCommandsView::OnOpKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
{
if (wParam == VK_UP)
{
m_SelectedAddress -= 4;
BeginOpEdit(m_SelectedAddress);
bHandled = TRUE;
}
else if (wParam == VK_DOWN)
{
m_SelectedAddress += 4;
BeginOpEdit(m_SelectedAddress);
bHandled = TRUE;
}
else if (wParam == VK_RETURN)
{
wchar_t text[256] = { 0 };
m_OpEdit.GetWindowText(text, (sizeof(text) / sizeof(text[0])) - 1);
uint32_t op;
bool bValid = CAssembler::AssembleLine(stdstr().FromUTF16(text).c_str(), &op, m_SelectedAddress);
if (bValid)
{
m_OpEdit.SetWindowText(L"");
EditOp(m_SelectedAddress, op);
m_SelectedAddress += 4;
BeginOpEdit(m_SelectedAddress);
}
bHandled = TRUE;
}
else if (wParam == VK_ESCAPE)
{
EndOpEdit();
bHandled = TRUE;
}
return 1;
}
void CDebugCommandsView::ClearBranchArrows() void CDebugCommandsView::ClearBranchArrows()
{ {
m_BranchArrows.clear(); m_BranchArrows.clear();
@ -1286,7 +1249,14 @@ LRESULT CDebugCommandsView::OnPopupmenuViewMemory(WORD /*wNotifyCode*/, WORD /*w
LRESULT CDebugCommandsView::OnPopupmenuToggleBP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) LRESULT CDebugCommandsView::OnPopupmenuToggleBP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/)
{ {
m_Breakpoints->EBPToggle(m_SelectedAddress); if (m_Breakpoints->ExecutionBPExists(m_SelectedAddress))
{
m_Breakpoints->RemoveExecution(m_SelectedAddress);
}
else
{
m_Breakpoints->AddExecution(m_SelectedAddress);
}
ShowAddress(m_StartAddress, TRUE); ShowAddress(m_StartAddress, TRUE);
return FALSE; return FALSE;
} }
@ -1621,7 +1591,7 @@ BOOL CDebugCommandsView::IsOpEdited(uint32_t address)
return FALSE; return FALSE;
} }
void CDebugCommandsView::EditOp(uint32_t address, uint32_t op) void CDebugCommandsView::EditOp(uint32_t address, uint32_t op, bool bRefresh)
{ {
uint32_t currentOp; uint32_t currentOp;
if (!m_Debugger->DebugLoad_VAddr(address, currentOp)) if (!m_Debugger->DebugLoad_VAddr(address, currentOp))
@ -1641,7 +1611,10 @@ void CDebugCommandsView::EditOp(uint32_t address, uint32_t op)
m_EditedOps.push_back({ address, currentOp }); m_EditedOps.push_back({ address, currentOp });
} }
ShowAddress(m_StartAddress, TRUE); if (bRefresh)
{
ShowAddress(m_StartAddress, TRUE);
}
} }
void CDebugCommandsView::RestoreOp(uint32_t address) void CDebugCommandsView::RestoreOp(uint32_t address)
@ -1697,13 +1670,107 @@ void CDebugCommandsView::ToggleHistoryButtons()
// Opcode editor // Opcode editor
LRESULT CDebugCommandsView::OnOpEditKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
{
if (wParam == VK_UP)
{
m_SelectedAddress -= 4;
BeginOpEdit(m_SelectedAddress);
bHandled = TRUE;
}
else if (wParam == VK_DOWN)
{
m_SelectedAddress += 4;
BeginOpEdit(m_SelectedAddress);
bHandled = TRUE;
}
else if (wParam == VK_RETURN)
{
wchar_t text[256] = { 0 };
m_OpEdit.GetWindowText(text, (sizeof(text) / sizeof(text[0])) - 1);
uint32_t op;
bool bValid = CAssembler::AssembleLine(stdstr().FromUTF16(text).c_str(), &op, m_SelectedAddress);
if (bValid)
{
m_OpEdit.SetWindowText(L"");
EditOp(m_SelectedAddress, op);
m_SelectedAddress += 4;
BeginOpEdit(m_SelectedAddress);
}
bHandled = TRUE;
}
else if (wParam == VK_ESCAPE)
{
EndOpEdit();
bHandled = TRUE;
}
return 1;
}
LRESULT CDebugCommandsView::OnOpEditChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/)
{
// handle multiline input
size_t length = m_OpEdit.GetWindowTextLength();
wchar_t* text = new wchar_t[length + 1];
m_OpEdit.GetWindowText(text, length + 1);
if (wcschr(text, L'\n') == NULL)
{
delete[] text;
return FALSE;
}
EndOpEdit();
for (size_t i = 0; i < length; i++)
{
if (text[i] == '\r')
{
text[i] = '\n';
}
}
wchar_t *tokctx;
wchar_t *line = wcstok_s(text, L"\n", &tokctx);
while (line != NULL)
{
if (wcslen(line) != 0)
{
uint32_t op;
bool bValid = CAssembler::AssembleLine(stdstr().FromUTF16(line).c_str(), &op, m_SelectedAddress);
if (bValid)
{
EditOp(m_SelectedAddress, op, false);
m_SelectedAddress += 4;
}
else
{
ShowAddress(m_StartAddress, TRUE);
BeginOpEdit(m_SelectedAddress);
m_OpEdit.SetWindowText(line);
delete[] text;
return FALSE;
}
}
line = wcstok_s(NULL, L"\n", &tokctx);
}
ShowAddress(m_StartAddress, TRUE);
BeginOpEdit(m_SelectedAddress);
delete[] text;
return FALSE;
}
LRESULT CEditOp::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CEditOp::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ {
if (m_CommandsWindow == NULL) if (m_CommandsWindow == NULL)
{ {
return FALSE; return FALSE;
} }
return m_CommandsWindow->OnOpKeyDown(uMsg, wParam, lParam, bHandled); return m_CommandsWindow->OnOpEditKeyDown(uMsg, wParam, lParam, bHandled);
} }
void CEditOp::SetCommandsWindow(CDebugCommandsView* commandsWindow) void CEditOp::SetCommandsWindow(CDebugCommandsView* commandsWindow)

View File

@ -60,7 +60,7 @@ private:
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
MESSAGE_HANDLER(WM_KEYUP, OnKeyUp) MESSAGE_HANDLER(WM_KEYUP, OnKeyUp)
MESSAGE_HANDLER(WM_CHAR, OnKeyUp) MESSAGE_HANDLER(WM_CHAR, OnKeyUp)
END_MSG_MAP() END_MSG_MAP()
public: public:
void SetCommandsWindow(CDebugCommandsView* commandsWindow); void SetCommandsWindow(CDebugCommandsView* commandsWindow);
@ -120,12 +120,15 @@ private:
COMMAND_HANDLER(ID_POPUPMENU_FOLLOWJUMP, BN_CLICKED, OnPopupmenuFollowJump) COMMAND_HANDLER(ID_POPUPMENU_FOLLOWJUMP, BN_CLICKED, OnPopupmenuFollowJump)
COMMAND_HANDLER(ID_POPUPMENU_VIEWMEMORY, BN_CLICKED, OnPopupmenuViewMemory) COMMAND_HANDLER(ID_POPUPMENU_VIEWMEMORY, BN_CLICKED, OnPopupmenuViewMemory)
COMMAND_HANDLER(ID_POPUPMENU_TOGGLEBP, BN_CLICKED, OnPopupmenuToggleBP) COMMAND_HANDLER(ID_POPUPMENU_TOGGLEBP, BN_CLICKED, OnPopupmenuToggleBP)
COMMAND_HANDLER(ID_POPUPMENU_CLEARBPS, BN_CLICKED, OnPopupmenuClearBP ) COMMAND_HANDLER(ID_POPUPMENU_CLEARBPS, BN_CLICKED, OnPopupmenuClearBP)
COMMAND_HANDLER(IDC_OP_EDIT, EN_CHANGE, OnOpEditChanged)
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_CLICK, OnCommandListClicked) NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_CLICK, OnCommandListClicked)
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_DBLCLK, OnCommandListDblClicked) NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_DBLCLK, OnCommandListDblClicked)
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_RCLICK, OnCommandListRightClicked) NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_RCLICK, OnCommandListRightClicked)
NOTIFY_HANDLER_EX(IDC_REG_TABS, TCN_SELCHANGE, OnRegisterTabChange) NOTIFY_HANDLER_EX(IDC_REG_TABS, TCN_SELCHANGE, OnRegisterTabChange)
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_CUSTOMDRAW, OnCustomDrawList) NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_CUSTOMDRAW, OnCustomDrawList)
MSG_WM_DESTROY(OnDestroy) MSG_WM_DESTROY(OnDestroy)
CHAIN_MSG_MAP(CDialogResize<CDebugCommandsView>) CHAIN_MSG_MAP(CDialogResize<CDebugCommandsView>)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove) MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
@ -207,8 +210,8 @@ private:
LRESULT OnPopupmenuToggleBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled); LRESULT OnPopupmenuToggleBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnPopupmenuClearBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled); LRESULT OnPopupmenuClearBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnOpEditChanged(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnOpKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnOpEditKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCommandListClicked(NMHDR* pNMHDR); LRESULT OnCommandListClicked(NMHDR* pNMHDR);
LRESULT OnCommandListDblClicked(NMHDR* pNMHDR); LRESULT OnCommandListDblClicked(NMHDR* pNMHDR);
@ -219,7 +222,7 @@ private:
void OnExitSizeMove(void); void OnExitSizeMove(void);
void ClearEditedOps(); void ClearEditedOps();
void EditOp(uint32_t address, uint32_t op); void EditOp(uint32_t address, uint32_t op, bool bRefresh = true);
void RestoreOp(uint32_t address); void RestoreOp(uint32_t address);
void RestoreAllOps(); void RestoreAllOps();
BOOL IsOpEdited(uint32_t address); BOOL IsOpEdited(uint32_t address);

View File

@ -652,7 +652,7 @@ BEGIN
CONTROL "",IDC_CMD_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_OWNERDRAWFIXED | LVS_NOSCROLL | LVS_NOSORTHEADER | WS_TABSTOP,0,0,284,327 CONTROL "",IDC_CMD_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_OWNERDRAWFIXED | LVS_NOSCROLL | LVS_NOSORTHEADER | WS_TABSTOP,0,0,284,327
LISTBOX IDC_BP_LIST,422,17,88,42,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP LISTBOX IDC_BP_LIST,422,17,88,42,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
GROUPBOX "",IDC_OPCODE_BOX,298,14,119,45,0,WS_EX_TRANSPARENT GROUPBOX "",IDC_OPCODE_BOX,298,14,119,45,0,WS_EX_TRANSPARENT
EDITTEXT IDC_OP_EDIT,458,51,59,12,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_VISIBLE | NOT WS_BORDER EDITTEXT IDC_OP_EDIT,458,51,59,12,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_VISIBLE | NOT WS_BORDER
SCROLLBAR IDC_SCRL_BAR,284,0,12,327,SBS_VERT SCROLLBAR IDC_SCRL_BAR,284,0,12,327,SBS_VERT
PUSHBUTTON "Copy Tab Registers",IDC_COPYTABREGISTERS_BTN,298,313,70,13 PUSHBUTTON "Copy Tab Registers",IDC_COPYTABREGISTERS_BTN,298,313,70,13
PUSHBUTTON "Copy All Registers",IDC_COPYALLREGISTERS_BTN,370,313,70,13 PUSHBUTTON "Copy All Registers",IDC_COPYALLREGISTERS_BTN,370,313,70,13

View File

@ -121,8 +121,8 @@ span.tag2 {
<div class="property"> <div class="property">
<div class="propertyname">mem.u8|u16|u32|s8|s16|s32|float|double</div> <div class="propertyname">mem.u8|u16|u32|s8|s16|s32|float|double</div>
<div class="propertydesc"> <div class="propertydesc">
Arrays for reading and modifying values in virtual memory. Arrays for reading and writing values in virtual memory.
Virtual addresses are always used for indeces regardless of type size. Virtual addresses are always used for indices regardless of type size.
<pre class="example"> <pre class="example">
var addr_power = 0x8033B21E var addr_power = 0x8033B21E
@ -281,7 +281,7 @@ events.onexec(0x802CB1C0, function()
}) })
</pre> </pre>
<pre class="example"> <pre class="example">
events.onexec(ADDR_ANY, function(pc)) events.onexec(ADDR_ANY, function(pc)
{ {
// Log every step! // Log every step!
console.log('CPU is executing 0x' + pc.hex()) console.log('CPU is executing 0x' + pc.hex())
@ -843,6 +843,12 @@ server.on('connection', function(socket)
Writes <span class="snip">data</span> to the socket. Writes <span class="snip">data</span> to the socket.
</div> </div>
</div> </div>
<div class="property">
<div class="propertyname">socket.close()</div>
<div class="propertydesc">
Closes the socket.
</div>
</div>
<div class="property"> <div class="property">
<div class="propertyname">socket.on('data', callback)</div> <div class="propertyname">socket.on('data', callback)</div>
<div class="propertydesc"> <div class="propertydesc">
@ -868,9 +874,9 @@ server.on('connection', function(socket)
<pre> <pre>
<b>ADDR_ANY</b> 0x00000000 : 0xFFFFFFFF Any 32-bit address <b>ADDR_ANY</b> 0x00000000 : 0xFFFFFFFF Any 32-bit address
<b>ADDR_ANY_KUSEG</b> 0x00000000 : 0x7FFFFFFF MIPS user mode TLB mapped segment <b>ADDR_ANY_KUSEG</b> 0x00000000 : 0x7FFFFFFF MIPS user mode TLB mapped segment
<b>ADDR_ANY_KSEG0</b> 0x80000000 : 0x9FFFFFFF MIPS cached unmapped segment <b>ADDR_ANY_KSEG0</b> 0x80000000 : 0x9FFFFFFF MIPS cached unmapped segment
<b>ADDR_ANY_KSEG1</b> 0xA0000000 : 0xBFFFFFFF MIPS uncached unmapped segment <b>ADDR_ANY_KSEG1</b> 0xA0000000 : 0xBFFFFFFF MIPS uncached unmapped segment
<b>ADDR_ANY_KSEG2</b> 0xC0000000 : 0xFFFFFFFF MIPS kernel mode TLB mapped segment <b>ADDR_ANY_KSEG2</b> 0xC0000000 : 0xFFFFFFFF MIPS kernel mode TLB mapped segment
<b>ADDR_ANY_RDRAM</b> 0x80000000 : 0x807FFFFF Cached RDRAM <b>ADDR_ANY_RDRAM</b> 0x80000000 : 0x807FFFFF Cached RDRAM