Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breakpoint improvements #1809

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/core/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Debug {
uint32_t normalizeAddress(uint32_t address);
static inline std::function<const char*()> s_breakpoint_type_names[] = {l_("Exec"), l_("Read"), l_("Write")};
enum class BreakpointType { Exec, Read, Write };
enum class BreakpointCondition { Always, Change, Greater, Less, Equal };

void checkDMAread(unsigned c, uint32_t address, uint32_t len) {
std::string cause = fmt::format("DMA channel {} read", c);
Expand Down Expand Up @@ -76,6 +77,10 @@ class Debug {
: m_type(type), m_source(source), m_invoker(invoker), m_base(base), m_label(label) {}
std::string name() const;
BreakpointType type() const { return m_type; }
BreakpointCondition condition() const { return m_condition; }
void setCondition(BreakpointCondition condition) { m_condition = condition; }
uint32_t conditionData() const { return m_conditionData; }
void setConditionData(uint32_t data) { m_conditionData = data; }
unsigned width() const { return getHigh() - getLow() + 1; }
uint32_t address() const { return getLow(); }
bool enabled() const { return m_enabled; }
Expand All @@ -93,6 +98,8 @@ class Debug {
}

const BreakpointType m_type;
BreakpointCondition m_condition = BreakpointCondition::Always;
uint32_t m_conditionData;
const std::string m_source;
const BreakpointInvoker m_invoker;
mutable std::string m_label;
Expand Down Expand Up @@ -155,6 +162,7 @@ class Debug {
if (m_lastBP == bp) m_lastBP = nullptr;
delete const_cast<Breakpoint*>(bp);
}
void removeAllBreakpoints() { m_breakpoints.clear(); }

private:
bool triggerBP(Breakpoint* bp, uint32_t address, unsigned width, const char* reason = "");
Expand Down
6 changes: 6 additions & 0 deletions src/gui/widgets/assembly.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/***************************************************************************

Check notice on line 1 in src/gui/widgets/assembly.cc

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Lines of Code in a Single File

The lines of code increases from 1013 to 1019, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.

Check notice on line 1 in src/gui/widgets/assembly.cc

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 7.60 to 7.67, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
* Copyright (C) 2019 PCSX-Redux authors *
* *
* This program is free software; you can redistribute it and/or modify *
Expand Down Expand Up @@ -340,6 +340,12 @@
itemLabel = fmt::format(f_("Go to in Memory Editor #{}"), i + 1);
if (ImGui::MenuItem(itemLabel.c_str())) jumpToMemory(addr, size, i, true);
}
if (ImGui::MenuItem(_("Create Memory Read Breakpoint"))) {
g_emulator->m_debug->addBreakpoint(addr, Debug::BreakpointType::Read, size, _("GUI"));
}
if (ImGui::MenuItem(_("Create Memory Write Breakpoint"))) {
g_emulator->m_debug->addBreakpoint(addr, Debug::BreakpointType::Write, size, _("GUI"));
}

Check warning on line 348 in src/gui/widgets/assembly.cc

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

PCSX::Widgets::Assembly::addMemoryEditorContext has a cyclomatic complexity of 9, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
ImGui::EndPopup();
}
}
Expand Down
Loading
Loading