Commit b87ae778 authored by Iuri Matias's avatar Iuri Matias Committed by aniket-engg

refactor getCurrentStep

parent 68b4b822
...@@ -113,9 +113,12 @@ class VmDebuggerLogic { ...@@ -113,9 +113,12 @@ class VmDebuggerLogic {
} catch (error) { } catch (error) {
} }
this._traceManager.getCurrentStep(index, (error, step) => { try {
this.event.trigger('traceCurrentStepUpdate', [error, step]) const step = this._traceManager.getCurrentStep(index)
}) this.event.trigger('traceCurrentStepUpdate', [null, step])
} catch (error) {
this.event.trigger('traceCurrentStepUpdate', [error])
}
try { try {
const addmem = this._traceManager.getMemExpand(index) const addmem = this._traceManager.getMemExpand(index)
......
...@@ -200,13 +200,13 @@ TraceManager.prototype.getReturnValue = function (stepIndex) { ...@@ -200,13 +200,13 @@ TraceManager.prototype.getReturnValue = function (stepIndex) {
return this.traceCache.returnValues[stepIndex] return this.traceCache.returnValues[stepIndex]
} }
TraceManager.prototype.getCurrentStep = function (stepIndex, callback) { TraceManager.prototype.getCurrentStep = function (stepIndex) {
try { try {
this.checkRequestedStep(stepIndex) this.checkRequestedStep(stepIndex)
} catch (check) { } catch (check) {
return callback(check, null) throw new Error(check)
} }
callback(null, this.traceCache.steps[stepIndex]) return this.traceCache.steps[stepIndex]
} }
TraceManager.prototype.getMemExpand = function (stepIndex) { TraceManager.prototype.getMemExpand = function (stepIndex) {
......
...@@ -209,16 +209,15 @@ tape('TraceManager', function (t) { ...@@ -209,16 +209,15 @@ tape('TraceManager', function (t) {
}) })
t.test('TraceManager.getCurrentStep', function (st) { t.test('TraceManager.getCurrentStep', function (st) {
traceManager.getCurrentStep(66, function (error, result) { try {
const result = traceManager.getCurrentStep(66)
console.log(result) console.log(result)
if (error) {
st.fail(error)
} else {
st.ok(result === 2) st.ok(result === 2)
st.end() st.end()
} catch (error) {
st.fail(error)
} }
}) })
})
t.test('TraceManager.getMemExpand', function (st) { t.test('TraceManager.getMemExpand', function (st) {
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment