Initial work for comment detail in debugger
This commit is contained in:
@@ -2,24 +2,34 @@
|
||||
#include <imgui.h>
|
||||
#include <execution>
|
||||
|
||||
void BreakpointFunc(s64 addr, s64 startAddr, const Disassembler::DisassemblyResult&) {
|
||||
void BreakpointFunc(s64 addr, s64 startAddr, Disassembler::DisassemblyResult&) {
|
||||
n64::Core& core = n64::Core::GetInstance();
|
||||
bool isBroken = core.breakpoints.contains(addr + 4);
|
||||
ImGui::PushStyleColor(ImGuiCol_CheckMark, 0xff0000ff);
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, 0);
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, 0);
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, 0x800000ff);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 0.5f);
|
||||
if(ImGui::Checkbox(std::format("##toggleBreakpoint{}", (addr - startAddr) / 4).c_str(), &isBroken)) {
|
||||
core.ToggleBreakpoint(addr + 4);
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
void AddressFunc(s64, s64, const Disassembler::DisassemblyResult& disasm) {
|
||||
if(disasm.success) {
|
||||
ImGui::TextColored(ImColor(0xffeaefb6), "%s", std::format("{:016X}:", disasm.address).c_str());
|
||||
void AddressFunc(s64, s64, Disassembler::DisassemblyResult& disasm) {
|
||||
if(!disasm.success) {
|
||||
ImGui::TextColored(ImColor(0xffeaefb6), "????????????????");
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::TextColored(ImColor(0xffeaefb6), "????????????????");
|
||||
ImGui::TextColored(ImColor(0xffeaefb6), "%s", std::format("{:016X}:", disasm.address).c_str());
|
||||
}
|
||||
|
||||
void InstructionFunc(s64, s64, const Disassembler::DisassemblyResult& disasm) {
|
||||
void InstructionFunc(s64, s64, Disassembler::DisassemblyResult& disasm) {
|
||||
if(!disasm.success) {
|
||||
ImGui::TextColored(ImColor(0xffcbf1ae), "Disassembly unsuccessful...");
|
||||
return;
|
||||
@@ -46,17 +56,54 @@ void InstructionFunc(s64, s64, const Disassembler::DisassemblyResult& disasm) {
|
||||
}
|
||||
}
|
||||
|
||||
void CommentFunc(s64, s64, const Disassembler::DisassemblyResult& disasm) {
|
||||
if(disasm.success) {
|
||||
ImGui::TextColored(ImColor(0xff71efe5), "%s", std::format("{}", disasm.comment).c_str());
|
||||
void CommentFunc(s64, s64, Disassembler::DisassemblyResult& disasm) {
|
||||
n64::Core& core = n64::Core::GetInstance();
|
||||
n64::Mem& mem = core.cpu->GetMem();
|
||||
n64::Registers& regs = core.cpu->GetRegs();
|
||||
|
||||
if(!disasm.success) {
|
||||
ImGui::TextColored(ImColor(0xff71efe5), "");
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::TextColored(ImColor(0xff71efe5), "");
|
||||
ImGui::TextColored(ImColor(0xff71efe5), "%s", std::format("{}", disasm.GetFormattedComment()).c_str());
|
||||
if(!ImGui::BeginItemTooltip())
|
||||
return;
|
||||
|
||||
ImGui::Text("%s", std::format("Memory contents @ 0x{:016X}", disasm.address).c_str());
|
||||
ImGui::BeginTable("##memoryContents", 16);
|
||||
for(int col = 0; col < 16; col++)
|
||||
ImGui::TableSetupColumn(std::format("##hexCol{}", col).c_str());
|
||||
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
for(int row = 0; row < 16; row++) {
|
||||
ImGui::TableNextRow();
|
||||
for(int col = 0; col < 16; col+=4) {
|
||||
u32 paddr;
|
||||
if(!regs.cop0.MapVAddr(n64::Cop0::LOAD, disasm.GetResolvedAddressFromComment(), paddr))
|
||||
continue;
|
||||
|
||||
u32 val = mem.Read<u32>(paddr);
|
||||
|
||||
ImGui::TableSetColumnIndex(col+0);
|
||||
ImGui::Text("%02X", val >> 24);
|
||||
ImGui::TableSetColumnIndex(col+1);
|
||||
ImGui::Text("%02X", val >> 16);
|
||||
ImGui::TableSetColumnIndex(col+2);
|
||||
ImGui::Text("%02X", val >> 8);
|
||||
ImGui::TableSetColumnIndex(col+3);
|
||||
ImGui::Text("%02X", val >> 0);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
bool Debugger::render() {
|
||||
n64::Core& core = n64::Core::GetInstance();
|
||||
n64::Registers& regs = core.cpu->GetRegs();
|
||||
|
||||
if(!enabled)
|
||||
return false;
|
||||
@@ -81,13 +128,13 @@ bool Debugger::render() {
|
||||
ImGui::SameLine(0,0);
|
||||
|
||||
if(followPC)
|
||||
startAddr = core.cpu->GetRegs().pc - 256; // TODO: arbitrary???
|
||||
startAddr = regs.pc - 256; // TODO: arbitrary???
|
||||
|
||||
if(ImGui::Button(core.breakpoints.contains(startAddr) ? "-" : "+")) {
|
||||
core.ToggleBreakpoint(startAddr);
|
||||
}
|
||||
|
||||
ImGui::BeginTable("Disassembly", columns.size(), ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingFixedFit);
|
||||
ImGui::BeginTable("Disassembly", columns.size(), ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody);
|
||||
for(int i = 0; i < columns.size(); i++)
|
||||
ImGui::TableSetupColumn(columns[i].name);
|
||||
|
||||
@@ -95,26 +142,31 @@ bool Debugger::render() {
|
||||
|
||||
for(u64 addr = startAddr; addr < startAddr + MAX_LINES_OF_DISASM * sizeof(u32); addr += sizeof(u32)) {
|
||||
auto disasm = Disassembler::GetInstance().Disassemble(addr);
|
||||
auto shouldColorRed = addr == core.cpu->GetRegs().nextPC || core.breakpoints.contains(addr);
|
||||
if(shouldColorRed) {
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBg, 0x809a9ade);
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, 0x807777bf);
|
||||
auto addrIsCurrent = addr == regs.nextPC;
|
||||
auto addrIsBreakpoint = core.breakpoints.contains(addr);
|
||||
ImColor colorChoice = ImGui::GetStyle().Colors[ImGuiCol_TableRowBg];
|
||||
ImColor colorChoiceAlt = ImGui::GetStyle().Colors[ImGuiCol_TableRowBgAlt];
|
||||
if(addrIsCurrent) {
|
||||
colorChoice = 0x80e27fbc;
|
||||
colorChoiceAlt = 0x80e27fbc;
|
||||
}
|
||||
|
||||
if(addrIsBreakpoint) {
|
||||
colorChoice = 0x800000ff;
|
||||
colorChoiceAlt = 0x800000ff;
|
||||
}
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBg, colorChoice.Value);
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, colorChoiceAlt.Value);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
for(int i = 0; i < columns.size(); i++) {
|
||||
ImGui::TableSetColumnIndex(i);
|
||||
columns[i].func(addr, startAddr, disasm);
|
||||
}
|
||||
|
||||
if(shouldColorRed) {
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
|
||||
if(ImGui::TableGetHoveredColumn() == 2) {
|
||||
// TODO: do the thing with the little fucking hover popup that shows the memory view
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
Reference in New Issue
Block a user