Skip to content

Commit

Permalink
Debugging the debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
indigodarkwolf committed Oct 19, 2021
1 parent 0eb4f2c commit 75ba784
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ void debugger_add_breakpoint(uint16_t address, uint8_t bank /* = 0 */)
if (Breakpoints.find(new_bp) == Breakpoints.end()) {
Breakpoints.insert(new_bp);
Active_breakpoints.insert(new_bp);
Breakpoint_check[address] = true;
}
}

Expand All @@ -260,6 +261,13 @@ void debugger_remove_breakpoint(uint16_t address, uint8_t bank /* = 0 */)
breakpoint_type old_bp{ address, bank };
Breakpoints.erase(old_bp);
Active_breakpoints.erase(old_bp);
Breakpoint_check[address] = false;
for (const auto &bp : Active_breakpoints) {
if (breakpoint_addr(bp) == address) {
Breakpoint_check[address] = true;
break;
}
}
}

void debugger_activate_breakpoint(uint16_t address, uint8_t bank /* = 0 */)
Expand All @@ -274,6 +282,7 @@ void debugger_activate_breakpoint(uint16_t address, uint8_t bank /* = 0 */)
}
if (Active_breakpoints.find(new_bp) == Active_breakpoints.end()) {
Active_breakpoints.insert(new_bp);
Breakpoint_check[address] = true;
}
}

Expand All @@ -285,6 +294,14 @@ void debugger_deactivate_breakpoint(uint16_t address, uint8_t bank /* = 0 */)

breakpoint_type old_bp{ address, bank };
Active_breakpoints.erase(old_bp);

Breakpoint_check[address] = false;
for (const auto &bp : Active_breakpoints) {
if (breakpoint_addr(bp) == address) {
Breakpoint_check[address] = true;
break;
}
}
}

bool debugger_breakpoint_is_active(uint16_t address, uint8_t bank /* = 0 */)
Expand Down
8 changes: 8 additions & 0 deletions src/overlay/overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1630,10 +1630,15 @@ static void draw_breakpoints()

const auto &breakpoints = debugger_get_breakpoints();
for (auto &[address, bank] : breakpoints) {
ImGui::PushID(address);
ImGui::PushID(bank);

ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::TileButton(ICON_REMOVE)) {
debugger_remove_breakpoint(address, bank);
ImGui::PopID();
ImGui::PopID();
break;
}

Expand Down Expand Up @@ -1678,6 +1683,9 @@ static void draw_breakpoints()
}
}
}

ImGui::PopID();
ImGui::PopID();
}

ImGui::EndTable();
Expand Down

0 comments on commit 75ba784

Please sign in to comment.