Skip to content

gdb: snapshot restore breaks breakpoints #1972

Open

Description

@ludfjig
  • Hardware breakpoints are lost on MSHV and WHP. Those backends store gdb hardware breakpoints in the guest's DR0-DR7 (mshv/x86_64.rs#L853, whp/x86_64.rs#L1181). reset_vcpu zeroes those registers (x86_64.rs#L327). gdb still lists the breakpoints. KVM keeps them in kvm_guest_debug, so they survive there.
  • Software breakpoints are written into snapshot memory. gdb builds make snapshot memory writable for this (build.rs#L162).
    • snapshot() captures the 0xCC bytes. After restore nothing tracks them.
    • restore() can remove a breakpoint that sw_breakpoints still lists. Removing it later writes the saved byte over whatever the restored snapshot holds at that address.

Possible fix: keep breakpoint state on the host and apply it again after restore(). Take software breakpoints out before snapshot().

Activity

  1. added theissue type on Oct 22, 2026
  2. added
    S-confirmedBug is verified or proposal seems reasonable
    and removed
    S-needs-triageThe issue has not yet been reviewed.
    on Nov 16, 2026
  3. syntactically commented on Nov 16, 2026

    @syntactically
    Member

    Might it be better to send a notification that the target terminated (and maybe restarted) on snapshot restore? There is a pretty good likelihood that we are looking at a totally different binary after a restore, so blindly re-applying the breakpoints in use on the previous one seems a bit odd? I am also not sure whether there is anything that the client will potentially be caching that could be rewritten e.g. the list of dynamically loaded objects.

    The biggest argument against that is that maybe taking a snapshot is now itself also implicitly restoring the snapshot in order to make sure that future snapshots are taken against the correct layer tree. It does kind of make sense that you should be able to preserve GDB state across a snapshot operation, even if not a restore one.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-confirmedBug is verified or proposal seems reasonable

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions