1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:47:35 +00:00

HackStudio: Change singlestepping logic in the debugger

Previously, we did source-level singlestepping by inserting a
breakpoint at every source line and continued execution until we hit
a breakpoint. We did this because we used to not generate source
locations debug info for library code, and it allowed us to not single
step through lots of library code to get to the next source line
(which is super slow).

Since we now do generate source locations debug info for libraries
(-g1), we can improve the way we implement source level stepping by
stepping at the assembly level until we reach a different source code
location.
This commit is contained in:
Itamar 2020-08-15 10:58:11 +03:00 committed by Andreas Kling
parent b5f6a1a9e8
commit 311a355505
2 changed files with 52 additions and 25 deletions

View file

@ -70,6 +70,22 @@ public:
void reset_breakpoints() { m_breakpoints.clear(); }
private:
class DebuggingState {
public:
enum State {
Normal,
SingleStepping,
};
State get() const { return m_state; }
void set_normal();
void set_single_stepping(DebugInfo::SourcePosition original_source_position);
bool should_stop_single_stepping(const DebugInfo::SourcePosition& current_source_position) const;
private:
State m_state { Normal };
Optional<DebugInfo::SourcePosition> m_original_source_position; // The source position at which we started the current single step
};
explicit Debugger(
Function<HasControlPassedToUser(const PtraceRegisters&)> on_stop_callback,
Function<void()> on_continue_callback,