-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
base: main
Are you sure you want to change the base?
Breakpoint improvements #1809
Changes from 10 commits
fcf092f
c964647
5ce6d40
a3353a6
111979a
77fffa0
e45d591
c10ee53
1ce423e
46109a2
19598ec
0c33f1d
dbe144e
a962441
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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); | ||||||||||||
|
@@ -64,7 +65,7 @@ class Debug { | |||||||||||
struct InternalTemporaryList {}; | ||||||||||||
typedef Intrusive::List<Breakpoint, InternalTemporaryList> BreakpointTemporaryListType; | ||||||||||||
|
||||||||||||
typedef std::function<bool(const Breakpoint*, uint32_t address, unsigned width, const char* cause)> | ||||||||||||
typedef std::function<bool(Breakpoint*, uint32_t address, unsigned width, const char* cause)> | ||||||||||||
BreakpointInvoker; | ||||||||||||
|
||||||||||||
class Breakpoint : public BreakpointTreeType::Node, | ||||||||||||
|
@@ -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; } | ||||||||||||
Comment on lines
+82
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add validation and documentation for condition methods The condition methods need:
+ /// @returns The current condition for this breakpoint
BreakpointCondition condition() const { return m_condition; }
+ /// @param condition The new condition to set
void setCondition(BreakpointCondition condition) { m_condition = condition; }
+ /// @returns The condition-specific data:
+ /// - For Greater/Less/Equal: The value to compare against
+ /// - For Range: The upper bound (lower bound stored internally)
+ /// - For Always/Change: Unused
uint32_t conditionData() const { return m_conditionData; }
+ /// @param data The condition-specific data to set
+ /// @throws std::invalid_argument if data is invalid for current condition
void setConditionData(uint32_t data) {
+ switch (m_condition) {
+ case BreakpointCondition::Range:
+ if (data <= getLow()) throw std::invalid_argument("Range upper bound must be greater than lower bound");
+ break;
+ case BreakpointCondition::Always:
+ case BreakpointCondition::Change:
+ if (data != 0) throw std::invalid_argument("Condition data must be 0 for Always/Change conditions");
+ break;
+ }
m_conditionData = data;
}
|
||||||||||||
unsigned width() const { return getHigh() - getLow() + 1; } | ||||||||||||
uint32_t address() const { return getLow(); } | ||||||||||||
bool enabled() const { return m_enabled; } | ||||||||||||
|
@@ -93,6 +98,8 @@ class Debug { | |||||||||||
} | ||||||||||||
|
||||||||||||
const BreakpointType m_type; | ||||||||||||
BreakpointCondition m_condition = BreakpointCondition::Always; | ||||||||||||
uint32_t m_conditionData; | ||||||||||||
Comment on lines
+103
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initialize m_conditionData member The BreakpointCondition m_condition = BreakpointCondition::Always;
- uint32_t m_conditionData;
+ uint32_t m_conditionData = 0; 📝 Committable suggestion
Suggested change
|
||||||||||||
const std::string m_source; | ||||||||||||
const BreakpointInvoker m_invoker; | ||||||||||||
mutable std::string m_label; | ||||||||||||
|
@@ -155,6 +162,7 @@ class Debug { | |||||||||||
if (m_lastBP == bp) m_lastBP = nullptr; | ||||||||||||
delete const_cast<Breakpoint*>(bp); | ||||||||||||
} | ||||||||||||
void removeAllBreakpoints() { m_breakpoints.clear(); } | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reset m_lastBP in removeAllBreakpoints The - void removeAllBreakpoints() { m_breakpoints.clear(); }
+ void removeAllBreakpoints() {
+ m_lastBP = nullptr;
+ m_breakpoints.clear();
+ } 📝 Committable suggestion
Suggested change
|
||||||||||||
|
||||||||||||
private: | ||||||||||||
bool triggerBP(Breakpoint* bp, uint32_t address, unsigned width, const char* reason = ""); | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add documentation and Range condition
The new
BreakpointCondition
enum should include:Range
condition mentioned in the PR objectives📝 Committable suggestion