Start work on a debug view
This commit is contained in:
@@ -1,23 +1,69 @@
|
||||
#include <Debugger.hpp>
|
||||
#include <imgui.h>
|
||||
#include <execution>
|
||||
|
||||
Debugger::Debugger() {
|
||||
/*
|
||||
disassembly->setWindowTitle("Disassembly");
|
||||
disassembly->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
|
||||
codeView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
codeView->setHeaderHidden(true);
|
||||
codeView->setModel(codeModel.get());
|
||||
cpuState->setWindowTitle("Registers");
|
||||
cpuState->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
|
||||
registers->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
bool Debugger::render() {
|
||||
if(enabled && ImGui::Begin("Debugger", &enabled)) {
|
||||
static u64 startAddr = 0xFFFF'FFFF'8000'0000;
|
||||
static constexpr int addrStep = 4;
|
||||
static bool followPC = false;
|
||||
ImGui::BeginDisabled(followPC);
|
||||
ImGui::InputScalar("Address", ImGuiDataType_U64, &startAddr, &addrStep, nullptr, "%016lX", ImGuiInputTextFlags_CharsHexadecimal);
|
||||
ImGui::EndDisabled();
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox("Follow program counter:", &followPC);
|
||||
if(followPC)
|
||||
startAddr = core->cpu->GetRegs().oldPC - 64; // TODO: arbitrary???
|
||||
|
||||
horLayout->addWidget(disassembly.get());
|
||||
horLayout->addWidget(cpuState.get());
|
||||
if(ImGui::BeginTable("Disassembly", 3, ImGuiTableFlags_RowBg)) {
|
||||
ImGui::TableSetupColumn("Address");
|
||||
ImGui::TableSetupColumn("Mnemonic");
|
||||
ImGui::TableSetupColumn("Comment");
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
verLayout->addLayout(horLayout.get());
|
||||
for(u64 addr = startAddr; addr < startAddr + MAX_LINES_OF_DISASM * sizeof(u32); addr += sizeof(u32)) {
|
||||
auto disasm = core->cpu->Disassemble(addr);
|
||||
std::string op_str;
|
||||
for(int i = 0; i < 3; i++) {
|
||||
if(i < 2) {
|
||||
if(!disasm.ops[i].empty()) {
|
||||
op_str += disasm.ops[i];
|
||||
if(!disasm.ops[i+1].empty()) op_str += ", ";
|
||||
}
|
||||
} else {
|
||||
if(!disasm.ops[i].empty()) op_str += disasm.ops[i];
|
||||
}
|
||||
}
|
||||
auto isPc = addr == core->cpu->GetRegs().oldPC;
|
||||
if(isPc) {
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBg, 0x809a9ade);
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, 0x807777bf);
|
||||
}
|
||||
ImGui::TableNextRow();
|
||||
if(disasm.success) {
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextColored(ImColor(0xffeaefb6), "%s", std::format("{:016X}:", disasm.address).c_str());
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextColored(ImColor(0xffcbf1ae), "%s", std::format("{} {}", disasm.mnemonic, op_str).c_str());
|
||||
ImGui::TableSetColumnIndex(2);
|
||||
ImGui::TextColored(ImColor(0xff71efe5), "%s", std::format("{}", "// no comments for now!").c_str());
|
||||
} else {
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextColored(ImColor(0xffeaefb6), "????????????????");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextColored(ImColor(0xffcbf1ae), "Disassembly unsuccessful...");
|
||||
ImGui::TableSetColumnIndex(2);
|
||||
ImGui::TextColored(ImColor(0xff71efe5), "");
|
||||
}
|
||||
if(isPc) {
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
setLayout(verLayout.get());
|
||||
|
||||
// connect(codeView.get(), &QTreeView::activated, this, );
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user