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

Commit

Permalink
Merge pull request #1174 from trufflesuite/debug-skip-unknown-locations
Browse files Browse the repository at this point in the history
Make debugger fail less hard
  • Loading branch information
gnidan authored Aug 10, 2018
2 parents 1eb8cee + d1a4615 commit ba5165f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
7 changes: 6 additions & 1 deletion packages/truffle-debugger/lib/controller/sagas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ function* stepNext () {
yield* advance();

// and check the next source range
upcoming = yield select(controller.current.location);
try {
upcoming = yield select(controller.current.location);
} catch (e) {
upcoming = null;
}

// if the next step's source range is still the same, keep going
} while (
!upcoming ||
!upcoming.node ||
SKIPPED_TYPES.has(upcoming.node.nodeType) ||

Expand Down
3 changes: 3 additions & 0 deletions packages/truffle-debugger/lib/evm/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ const evm = createSelectorTree({
let record;
if (address) {
record = instances[address];
if (!record) {
return { address };
}
binary = record.binary
} else {
record = search(binary);
Expand Down
18 changes: 10 additions & 8 deletions packages/truffle-debugger/lib/solidity/sagas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@ export function *addSourceMap(binary, sourceMap) {
yield put(actions.addSourceMap(binary, sourceMap));
}

function* functionDepthSaga () {
function *tickSaga() {
while (true) {
yield take(TICK);
debug("got TICK");
let instruction = yield select(solidity.current.instruction);
debug("instruction: %o", instruction);

if (yield select(solidity.current.willJump)) {
let jumpDirection = yield select(solidity.current.jumpDirection);
yield *functionDepthSaga();
}
}

function* functionDepthSaga () {
if (yield select(solidity.current.willJump)) {
let jumpDirection = yield select(solidity.current.jumpDirection);


yield put(actions.jump(jumpDirection));
}
yield put(actions.jump(jumpDirection));
}
}

export function* saga () {
yield call(functionDepthSaga);
yield call(tickSaga);
}

export default prefixName("solidity", saga);
4 changes: 4 additions & 0 deletions packages/truffle-debugger/lib/solidity/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ let solidity = createSelectorTree({
["/info/sources", evm.current.context, "./sourceMap"],

(sources, {binary}, {sourceMap}) => {
if (!binary) {
return [];
}

let instructions = CodeUtils.parseCode(binary);

if (!sourceMap) {
Expand Down

0 comments on commit ba5165f

Please sign in to comment.