Skip to content

Commit 4720f19

Browse files
committed
[debugger] Add PR drhelius#123 removed features back
1 parent 7c9a5a7 commit 4720f19

4 files changed

Lines changed: 66 additions & 14 deletions

File tree

platforms/shared/desktop/gui_debug.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ void gui_debug_reset(void)
6464
{
6565
gui_debug_disassembler_reset();
6666
gui_debug_memory_reset();
67-
gui_debug_reset_breakpoints();
6867
gui_debug_reset_symbols();
6968
}
7069

@@ -134,7 +133,8 @@ void gui_debug_windows(void)
134133
}
135134
}
136135

137-
static const char* GGDEBUG_MAGIC = "GGDEBUG3";
136+
static const char* GGDEBUG_MAGIC_V2 = "GGDEBUG2";
137+
static const char* GGDEBUG_MAGIC_V3 = "GGDEBUG3";
138138
static const int GGDEBUG_MAGIC_LEN = 8;
139139

140140
void gui_debug_save_settings(const char* file_path)
@@ -146,7 +146,7 @@ void gui_debug_save_settings(const char* file_path)
146146
return;
147147
}
148148

149-
file.write(GGDEBUG_MAGIC, GGDEBUG_MAGIC_LEN);
149+
file.write(GGDEBUG_MAGIC_V3, GGDEBUG_MAGIC_LEN);
150150

151151
GeargrafxCore* core = emu_get_core();
152152
HuC6280* processor = core->GetHuC6280();
@@ -202,7 +202,9 @@ void gui_debug_load_settings(const char* file_path)
202202
char magic[8];
203203
file.read(magic, GGDEBUG_MAGIC_LEN);
204204

205-
if (memcmp(magic, GGDEBUG_MAGIC, GGDEBUG_MAGIC_LEN) != 0)
205+
bool is_v2 = memcmp(magic, GGDEBUG_MAGIC_V2, GGDEBUG_MAGIC_LEN) == 0;
206+
bool is_v3 = memcmp(magic, GGDEBUG_MAGIC_V3, GGDEBUG_MAGIC_LEN) == 0;
207+
if (!is_v2 && !is_v3)
206208
{
207209
Log("Invalid debug settings file: %s", file_path);
208210
file.close();
@@ -221,8 +223,24 @@ void gui_debug_load_settings(const char* file_path)
221223
HuC6280::GG_Breakpoint bp{};
222224
file.read((char*)&bp.enabled, sizeof(bool));
223225
file.read((char*)&bp.type, sizeof(int));
224-
file.read((char*)&bp.address1, sizeof(u32));
225-
file.read((char*)&bp.address2, sizeof(u32));
226+
227+
if (is_v2)
228+
{
229+
u16 address1 = 0;
230+
u16 address2 = 0;
231+
232+
file.read((char*)&address1, sizeof(u16));
233+
file.read((char*)&address2, sizeof(u16));
234+
235+
bp.address1 = address1;
236+
bp.address2 = address2;
237+
}
238+
else
239+
{
240+
file.read((char*)&bp.address1, sizeof(u32));
241+
file.read((char*)&bp.address2, sizeof(u32));
242+
}
243+
226244
file.read((char*)&bp.read, sizeof(bool));
227245
file.read((char*)&bp.write, sizeof(bool));
228246
file.read((char*)&bp.execute, sizeof(bool));

platforms/shared/desktop/gui_debug_disassembler.cpp

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,10 @@ static const BreakpointTypeInfo k_breakpoint_type_info[HuC6280::HuC6280_BREAKPOI
460460

461461
static const int k_breakpoint_type_info_count =
462462
(int)(sizeof(k_breakpoint_type_info) / sizeof(k_breakpoint_type_info[0]));
463+
static_assert(
464+
k_breakpoint_type_info_count == HuC6280::HuC6280_BREAKPOINT_TYPE_COUNT,
465+
"k_breakpoint_type_info has wrong number of BP types"
466+
);
463467

464468
static const BreakpointTypeInfo* get_breakpoint_type_info(int type)
465469
{
@@ -710,6 +714,8 @@ static void draw_breakpoints_content(void)
710714
ImGui::PushFont(gui_default_font);
711715

712716
int remove = -1;
717+
int move_up = -1;
718+
int move_down = -1;
713719
HuC6280* cpu = emu_get_core()->GetHuC6280();
714720
const std::vector<HuC6280::GG_Breakpoint>* breakpoints = cpu->GetBreakpoints();
715721

@@ -735,27 +741,25 @@ static void draw_breakpoints_content(void)
735741

736742
ImGui::PushID((int)b);
737743

738-
//ImGui::PushFont(gui_material_icons_font);
744+
ImGui::PushFont(gui_material_icons_font);
739745
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 1.0f));
740-
ImVec2 bp_icon_btn_size = ImGui::CalcTextSize("X");
746+
ImVec2 bp_icon_btn_size = ImGui::CalcTextSize(ICON_MD_KEYBOARD_ARROW_UP);
741747
bp_icon_btn_size.x += ImGui::GetStyle().FramePadding.x * 2.0f;
742748
bp_icon_btn_size.y += ImGui::GetStyle().FramePadding.y * 2.0f;
743749

744750
if (ImGui::Button("X##remove", bp_icon_btn_size))
745751
{
746752
remove = b;
747753
ImGui::PopStyleVar();
748-
//ImGui::PopFont();
754+
ImGui::PopFont();
749755
ImGui::PopID();
750756
continue;
751757
}
752758
if (ImGui::IsItemHovered())
753759
{
754-
ImGui::PopFont();
755760
ImGui::BeginTooltip();
756761
ImGui::Text("Remove breakpoint");
757762
ImGui::EndTooltip();
758-
ImGui::PushFont(gui_default_font);
759763
}
760764

761765
ImGui::SameLine(0, 2);
@@ -766,15 +770,27 @@ static void draw_breakpoints_content(void)
766770
}
767771
if (ImGui::IsItemHovered())
768772
{
769-
ImGui::PopFont();
770773
ImGui::BeginTooltip();
771774
ImGui::Text(brk->enabled ? "Disable breakpoint" : "Enable breakpoint");
772775
ImGui::EndTooltip();
773-
ImGui::PushFont(gui_default_font);
774776
}
775777

778+
ImGui::SameLine(0, 2);
779+
if (b == 0)
780+
ImGui::BeginDisabled();
781+
if (ImGui::Button(ICON_MD_KEYBOARD_ARROW_UP "##move_up", bp_icon_btn_size))
782+
move_up = (int)b;
783+
if (b == 0)
784+
ImGui::EndDisabled();
785+
786+
ImGui::SameLine(0, 2);
787+
if (b == breakpoints->size() - 1) ImGui::BeginDisabled();
788+
if (ImGui::Button(ICON_MD_KEYBOARD_ARROW_DOWN "##move_down", bp_icon_btn_size))
789+
move_down = (int)b;
790+
if (b == breakpoints->size() - 1) ImGui::EndDisabled();
791+
776792
ImGui::PopStyleVar();
777-
//ImGui::PopFont();
793+
ImGui::PopFont();
778794

779795
ImGui::SameLine();
780796
const BreakpointTypeInfo* info = get_breakpoint_type_info(brk->type);
@@ -881,6 +897,12 @@ static void draw_breakpoints_content(void)
881897

882898
ImGui::PopFont();
883899

900+
if (move_up > 0)
901+
cpu->MoveBreakpoint(move_up, move_up - 1);
902+
903+
if (move_down >= 0 && move_down < (int)breakpoints->size() - 1)
904+
cpu->MoveBreakpoint(move_down, move_down + 1);
905+
884906
if (remove >= 0)
885907
{
886908
cpu->RemoveBreakpointAt(remove);

src/huc6280.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class HuC6280
158158
bool HasPhysicalMemoryBreakpoints(bool read) const;
159159
bool HasPhysicalExecuteBreakpoints() const;
160160
const std::vector<GG_Breakpoint>* GetBreakpoints() const;
161+
void MoveBreakpoint(int from, int to);
161162
void ClearDisassemblerCallStack();
162163
std::stack<GG_CallStackEntry>* GetDisassemblerCallStack();
163164
void CheckMemoryBreakpoints(int type, u32 address, bool read);

src/huc6280_inline.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,17 @@ INLINE const std::vector<HuC6280::GG_Breakpoint>* HuC6280::GetBreakpoints() cons
497497
return &m_breakpoints;
498498
}
499499

500+
INLINE void HuC6280::MoveBreakpoint(int from, int to)
501+
{
502+
if (from < 0 || to < 0)
503+
return;
504+
505+
if (from >= (int)m_breakpoints.size() || to >= (int)m_breakpoints.size())
506+
return;
507+
508+
std::swap(m_breakpoints[from], m_breakpoints[to]);
509+
}
510+
500511
INLINE bool HuC6280::HasPhysicalMemoryBreakpoints(bool read) const
501512
{
502513
return m_breakpoints_enabled &&

0 commit comments

Comments
 (0)