Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Improved breakpoint functionality #1306

Merged
merged 4 commits into from
Sep 28, 2018
Merged

Improved breakpoint functionality #1306

merged 4 commits into from
Sep 28, 2018

Conversation

haltman-at
Copy link
Contributor

This branch expands the functionality of breakpoints as requested in #1276. Breakpoints can now be set on a line of the user's choice in a source file of their choice; they can also be set at the current location as before. Breakpoints are no longer toggled with b but rather set with b and cleared with B. A breakpoint set with b with no arguments is set at the current location; this is the current location within the line, like the old breakpoints. Breakpoints may also be set at a given line (including in another source file), which may also be specified relative to the current line; these breakpoints will stop execution at the first encountered location within that line. Breakpoints in another source file need only have enough of the filename specified to unambiguously identify it; if what's given is ambiguous, the user will be prompted with a list of possibilities.

This branch does not include expanded functionality for ?.

@haltman-at haltman-at changed the title Breakpoints Improved breakpoint functionality Sep 27, 2018
@coveralls
Copy link

coveralls commented Sep 27, 2018

Pull Request Test Coverage Report for Build 1431

  • 32 of 124 (25.81%) changed or added relevant lines in 8 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.8%) to 68.699%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/truffle-debugger/lib/session/index.js 2 3 66.67%
packages/truffle-debugger/lib/controller/actions/index.js 5 6 83.33%
packages/truffle-debugger/lib/controller/sagas/index.js 12 14 85.71%
packages/truffle-debugger/lib/controller/reducers.js 9 15 60.0%
packages/truffle-core/lib/commands/debug.js 0 82 0.0%
Files with Coverage Reduction New Missed Lines %
packages/truffle-core/lib/commands/debug.js 1 0.52%
Totals Coverage Status
Change from base Build 1425: -0.8%
Covered Lines: 4527
Relevant Lines: 6314

💛 - Coveralls

Copy link
Contributor

@gnidan gnidan left a comment

Choose a reason for hiding this comment

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

Nice! The truffle-debugger stuff is rather clean!

Approving this but I would like to strongly encourage you to split Session.setOrClearBreakpoint into two methods. (I just think it looks better for the interface)

else
{
return this.dispatch(controller.removeBreakpoint(breakpoint));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I kinda think this should be two separate methods

{
config.logger.log(`Breakpoint removed at ${locationMessage}.`);
}
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for later: you might consider splitting this up into multiple functions that could live in debug-utils. But no need to do it now; I think you'll find yourself naturally wanting that in the course of any follow-up work.

splitArgs=cmd.trim().split(/ +/).slice(1);
debug("splitArgs %O",splitArgs);

//warning: this bit *alters* cmd!
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't that kind of annoying?

else
{
config.logger.log(`Breakpoint removed at ${locationMessage}.`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah so I just tried this feature out and realized something that might be nice: an extra blank line after these added/removed messages.

This looks a bit cluttered:

debug(develop:0x91c817a1...)> b SquareLib:5
Breakpoint added at line 5 in SquareLib.sol.
debug(develop:0x91c817a1...)> b +10
Breakpoint added at line 23.
debug(develop:0x91c817a1...)> B +10
Breakpoint removed at line 23.

Compared with:

debug(develop:0x91c817a1...)> b SquareLib:5
Breakpoint added at line 5 in SquareLib.sol.

debug(develop:0x91c817a1...)> b +10
Breakpoint added at line 23.

debug(develop:0x91c817a1...)> B +10
Breakpoint removed at line 23.

};

session.continueUntil(breakpoint);
session.setOrClearBreakpoint(breakpoint,true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed this!

let breakpointStopped = false;

session.setOrClearBreakpoint(breakpoint,true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants