Skip to content

Breakpoint support on Linux - #108

Merged
bjorn3 merged 51 commits into
headcrab-rs:masterfrom
Arthamys:breakpoints
Sep 30, 2020
Merged

Breakpoint support on Linux#108
bjorn3 merged 51 commits into
headcrab-rs:masterfrom
Arthamys:breakpoints

Conversation

@Arthamys

@Arthamys Arthamys commented Sep 6, 2020

Copy link
Copy Markdown
Contributor

Here is a first version that supports setting and removing breakpoints, as well as a single_step function.
I wanted to get your feedback on the interface, as well as some inputs on the edge cases that should be handled.

Bjorn mentioned in #55 that code should handle "faulting instructions at the place of the breakpoint" but I don't know what should be the particular reaction we should have in this situation. Should we not allow settings the breakopint?

@bjorn3

bjorn3 commented Sep 6, 2020

Copy link
Copy Markdown
Contributor

Bjorn mentioned in #55 that code should handle "faulting instructions at the place of the breakpoint" but I don't know what should be the particular reaction we should have in this situation. Should we not allow settings the breakopint?

I was referring to the situation where you hit a breakpoint and then when continuing the first instruction causes a fault. You need to make sure that you don't immediately set the breakpoint again such that continuing would run the instruction again instead of hitting the breakpoint, but you must also ensure that when the instruction does succeed this time the breakpoint is set again.

Comment thread src/target/linux.rs
Comment thread src/target/linux.rs Outdated
Comment thread src/target/linux.rs Outdated
Comment thread src/target/linux.rs Outdated
Comment thread src/target/linux/software_breakpoint.rs Outdated
Comment thread src/target/linux/software_breakpoint.rs Outdated
Comment thread src/target/linux/software_breakpoint.rs
Comment thread tests/runtime_breakpoint.rs
Comment thread tests/runtime_breakpoint.rs Outdated
Comment thread tests/runtime_breakpoint.rs
Comment thread tests/runtime_breakpoint.rs Outdated
Comment thread tests/test_utils.rs Outdated
@bjorn3
bjorn3 requested a review from nbaksalyar September 14, 2020 12:51

@blitzerr blitzerr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You tackled an involved issue (by my standards) as your first PR. kudos to you @Arthamys

Comment thread examples/repl.rs Outdated
Comment thread examples/repl.rs Outdated
Comment thread src/target/linux.rs Outdated
Comment thread src/target/linux.rs Outdated
Comment thread tests/runtime_breakpoint.rs Outdated
Comment thread tests/runtime_breakpoint.rs Outdated
Comment thread src/target/linux/software_breakpoint.rs Outdated
Comment thread src/target/linux.rs Outdated
@bjorn3

bjorn3 commented Sep 30, 2020

Copy link
Copy Markdown
Contributor

This hit the spurious #116. The good news is that all other tests pass!

Comment thread examples/repl.rs Outdated
Comment thread examples/repl.rs Outdated
Comment thread tests/runtime_breakpoint.rs
Comment thread tests/testees/loop.rs Outdated
Comment thread tests/runtime_breakpoint.rs Outdated
Comment thread src/target/linux/software_breakpoint.rs Outdated

@nbaksalyar nbaksalyar left a comment

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.

Great work @Arthamys, thank you!

I've added a couple of general comments about future work, and there is a couple of minor typos.
Would you prefer to address them in this PR, or raise a separate one?

Comment thread src/target/linux.rs
self.breakpoints.borrow_mut().insert(addr, bp.clone());
bp
}
// If there is already a breakpoint set, we give back the existing one

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.

In this case, we might need to support multiple breakpoints set in one place. For example, for breakpoints with different conditions (watching variables), and for the case of 'internal' breakpoints (i.e. the ones set by the debugger itself). I believe that's a separate issue, though, and should be tackled with a separate PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Watching variables could be handled by a wrapper around LinuxTarget. The code should be relatively platform independent. Setting multiple breakpoints could also be handled by such wrapper.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Having more involved types of breakpoints is of course something that we should tackle, but as you suggested, it should probably be part of another PR once we have breakpoints support on another platform than Linux.

Comment thread src/target/linux/software_breakpoint.rs Outdated
Comment thread src/target/linux/software_breakpoint.rs Outdated
Comment thread src/target/linux/software_breakpoint.rs Outdated

@nbaksalyar nbaksalyar left a comment

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.

Thank you!

@bjorn3
bjorn3 merged commit e4eb3f3 into headcrab-rs:master Sep 30, 2020
@bjorn3

bjorn3 commented Sep 30, 2020

Copy link
Copy Markdown
Contributor

Thanks a lot! Do you want to make a follow up to remove the patch breakpoint function hack from the repl and tests?

@Arthamys

Copy link
Copy Markdown
Contributor Author

Yes, I'll get on that tomorrow!

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.

4 participants