-
-
Notifications
You must be signed in to change notification settings - Fork 124
Breakpoint improvements #1809
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
Merged
nicolasnoble
merged 17 commits into
grumpycoders:main
from
rocketz:Breakpoints-improvements
Mar 4, 2025
Merged
Breakpoint improvements #1809
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fcf092f
Breakpoint improvements
rocketz c964647
Added missing code for change-type BPs.
rocketz 5ce6d40
Renamed variable to be more clear
rocketz a3353a6
Merge branch 'main' into Breakpoints-improvements
nicolasnoble 111979a
Merge branch 'grumpycoders:main' into Breakpoints-improvements
rocketz 77fffa0
linux compile fix
rocketz e45d591
Merge branch 'grumpycoders:main' into Breakpoints-improvements
rocketz c10ee53
Merge branch 'grumpycoders:main' into Breakpoints-improvements
rocketz 1ce423e
Merge branch 'grumpycoders:main' into Breakpoints-improvements
rocketz 46109a2
Merge branch 'main' into Breakpoints-improvements
nicolasnoble 19598ec
Merge branch 'grumpycoders:main' into Breakpoints-improvements
rocketz 0c33f1d
Merge branch 'grumpycoders:main' into Breakpoints-improvements
rocketz dbe144e
Merge branch 'grumpycoders:main' into Breakpoints-improvements
rocketz a962441
Merge branch 'grumpycoders:main' into Breakpoints-improvements
rocketz 94e3921
Merge branch 'main' into Breakpoints-improvements
nicolasnoble 602bda9
small fixes from review
rocketz e2096cd
Fixing the last few details.
nicolasnoble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ class Debug { | |
static bool isInKernel(uint32_t address, bool biosIsKernel = true); | ||
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); | ||
|
@@ -66,7 +67,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, | ||
|
@@ -78,6 +79,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; } | ||
|
@@ -95,6 +100,8 @@ class Debug { | |
} | ||
|
||
const BreakpointType m_type; | ||
BreakpointCondition m_condition = BreakpointCondition::Always; | ||
uint32_t m_conditionData = 0; | ||
const std::string m_source; | ||
const BreakpointInvoker m_invoker; | ||
mutable std::string m_label; | ||
|
@@ -158,6 +165,10 @@ class Debug { | |
if (m_lastBP == bp) m_lastBP = nullptr; | ||
delete const_cast<Breakpoint*>(bp); | ||
} | ||
void removeAllBreakpoints() { | ||
m_breakpoints.clear(); | ||
m_lastBP = nullptr; | ||
} | ||
|
||
private: | ||
bool triggerBP(Breakpoint* bp, uint32_t address, unsigned width, const char* reason = ""); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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