Debugger improved: Instruction editor added

How to use the instruction editor:
1. Load an .ELF file
2. Select an instruction from any valid memory address inside any
thread.
3. Press 'E' key and have fun. :P

Note1: I suggest to remove the function InterpreterDisAsmFrame::DClick
and use InterpreterDisAsmFrame::InstrKey to do all debugging-related
actions (Add breakpoint, Edit, Step, Run, etc.) using the same keyboard
layout as debuggers like OllyDbg.

Note2: The final binary is 200 KB larger due to this feature. This issue
should be fixed in the future. This has probably something to do with
the #include's.
This commit is contained in:
Alexandro Sánchez Bach 2013-09-21 02:40:36 +02:00
parent a11de0f607
commit bf293ebbfc
6 changed files with 136 additions and 0 deletions

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "InterpreterDisAsm.h"
#include "InstructionEditor.h"
//static const int show_lines = 30;
@ -67,6 +68,7 @@ InterpreterDisAsmFrame::InterpreterDisAsmFrame(wxWindow* parent)
Connect(m_btn_step->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(InterpreterDisAsmFrame::DoStep));
Connect(m_btn_run->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(InterpreterDisAsmFrame::DoRun));
Connect(m_btn_pause->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(InterpreterDisAsmFrame::DoPause));
Connect(m_list->GetId(), wxEVT_COMMAND_LIST_KEY_DOWN, wxListEventHandler(InterpreterDisAsmFrame::InstrKey));
Connect(m_list->GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(InterpreterDisAsmFrame::DClick));
Connect(m_choice_units->GetId(),wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(InterpreterDisAsmFrame::OnSelectUnit));
Connect(wxEVT_SIZE, wxSizeEventHandler(InterpreterDisAsmFrame::OnResize));
@ -442,6 +444,23 @@ void InterpreterDisAsmFrame::DoStep(wxCommandEvent& WXUNUSED(event))
ThreadBase::Start();
}
void InterpreterDisAsmFrame::InstrKey(wxListEvent& event)
{
long i = m_list->GetFirstSelected();
if(i < 0) return;
const u64 start_pc = PC - m_item_count*4;
const u64 pc = start_pc + i*4;
switch(event.GetKeyCode())
{
case 'E':
InstructionEditorDialog(this, pc, CPU, decoder, disasm);
DoUpdate();
return;
}
}
void InterpreterDisAsmFrame::DClick(wxListEvent& event)
{
long i = m_list->GetFirstSelected();