Skip to content

Multiple bps - #175

Open
io-no wants to merge 13 commits into
single-thread-control-flowfrom
multiple-bps
Open

io-no wants to merge 13 commits into
single-thread-control-flowfrom
multiple-bps

Conversation

@io-no

@io-no io-no commented Dec 11, 2024

Copy link
Copy Markdown
Member

This PR introduces support for multiple breakpoints at the same location. Below are the design choices I made during development to ensure alignment:

  • Breakpoint Dictionary Enhancement:

    • The breakpoints dictionary now contains, for each key, a BreakpointList type similar to other custom types in libdebug. This supports the filter method, allowing filtering by any breakpoint attribute.
  • Hardware Breakpoints on Specific Threads:

    • When you install a hardware breakpoint on a specific thread, it is installed only on that thread. While this behavior is not entirely consistent with software breakpoints internally in libdebug, it aligns with external behavior and allows the saving of precious hardware breakpoints.
  • Process-Scoped Software Breakpoints:

    • Since software breakpoints must be installed process-scoped, when they are installed on a specific thread, they are ignored if hit by other threads internally by libdebug.
  • Managing Multiple Hardware Breakpoints:

    • Multiple hardware breakpoints installed at the same position with identical conditions and lengths are managed internally, resulting in only one hardware breakpoint register being used. If they differ in any way, different registers are used. Again, I tried to save as many hw breakpoints as possible without making risky assumptions.
  • Coexistence of Software and Hardware Breakpoints:

    • If a user installs both software and hardware breakpoints at the same location, both are installed within the process/thread. While we can optimize by converting all breakpoints to hardware for increased speed, software and hardware breakpoints may exhibit different behaviors that users might want to exploit.

@property
def hit_count(self: BreakpointList) -> int:
"""Returns the sum of the hit counts of all the breakpoints inside the BreakpointList."""
return sum(bp.hit_count for bp in self)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would multiply the hit count for the number of superimposed breakpoints... Is this really what we want?

return [bp.callback for bp in self]

@property
def enabled(self: BreakpointList) -> bool:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to set enabled on the list to enable all or disable all breakpoints at that address? If not, I would rename this property to avoid confusion (because of the symmetry with the property of the breakpoint object itself).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants