Skip to content

Commit

Permalink
fix(debugger): fix and improve console commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jrainville authored and iurimatias committed Dec 7, 2018
1 parent 5b6b582 commit 37c28b9
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/lib/modules/debugger/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import DebuggerManager from "./debugger_manager";

const NO_DEBUG_SESSION = __("No debug session active. Activate one with `debug`");

interface Events {
on: any;
request: any;
Expand Down Expand Up @@ -249,15 +251,21 @@ class TransactionDebugger {
return {
match: () => (cmd === "next" || cmd === "n"),
process: (cb: any) => {
if (!this.cmdDebugger) {
this.embark.logger.warn(NO_DEBUG_SESSION);
return cb();
}
if (!this.cmdDebugger.canGoNext()) {
return;
return cb();
}
if (!this.cmdDebugger.currentStep()) {
this.embark.logger.info("end of execution reached");
return this.cmdDebugger.unload();
this.cmdDebugger.unload();
return cb();
}
this.cmdDebugger.stepOverForward(true);
this.displayStepInfo();
cb();
},
};
});
Expand All @@ -266,15 +274,20 @@ class TransactionDebugger {
return {
match: () => (cmd === "previous" || cmd === "p"),
process: (cb: any) => {
if (!this.cmdDebugger) {
this.embark.logger.warn(NO_DEBUG_SESSION);
return cb();
}
if (!this.cmdDebugger.canGoPrevious()) {
return;
return cb();
}
if (!this.cmdDebugger.currentStep()) {
this.embark.logger.info("end of execution reached");
return this.cmdDebugger.unload();
}
this.cmdDebugger.stepOverBack(true);
this.displayStepInfo();
cb();
},
};
});
Expand All @@ -283,7 +296,12 @@ class TransactionDebugger {
return {
match: () => (cmd === "var local" || cmd === "v l" || cmd === "vl"),
process: (cb: any) => {
if (!this.cmdDebugger) {
this.embark.logger.warn(NO_DEBUG_SESSION);
return cb();
}
this.cmdDebugger.displayLocals();
cb();
},
};
});
Expand All @@ -292,7 +310,12 @@ class TransactionDebugger {
return {
match: () => (cmd === "var global" || cmd === "v g" || cmd === "vg"),
process: (cb: any) => {
if (!this.cmdDebugger) {
this.embark.logger.warn(NO_DEBUG_SESSION);
return cb();
}
this.cmdDebugger.displayGlobals();
cb();
},
};
});
Expand All @@ -301,9 +324,17 @@ class TransactionDebugger {
return {
match: () => (cmd === "var all" || cmd === "v a" || cmd === "va"),
process: (cb: any) => {
if (!this.cmdDebugger) {
this.embark.logger.warn(NO_DEBUG_SESSION);
return cb();
}
this.getGlobals(this.currentCmdTxHash, (err: any, globals: any) => {
if (err) { return this.embark.logger.error(err); }
if (err) {
this.embark.logger.error(err);
return cb();
}
this.embark.logger.info(globals);
cb();
});
},
};
Expand Down

0 comments on commit 37c28b9

Please sign in to comment.