From 77d6d4ec3b82b46cf6f5d1238948d77341465586 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 12:42:02 -0400 Subject: [PATCH 001/170] move debugger UI to its own module --- src/app/debugger/debugger.js | 1 + src/app/debugger/debuggerUI.js | 20 ++++++++++++++++++ src/app/tabs/debugger-tab.js | 38 +++++++++++++++++----------------- 3 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 src/app/debugger/debuggerUI.js diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index 9d547a5319..b63294b800 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -12,6 +12,7 @@ function Debugger (container, sourceHighlighter, localRegistry) { this._components = { sourceHighlighter: sourceHighlighter } + // TODO: localRegistry doesn't seem to be actually used anywhere this._components.registry = localRegistry || globlalRegistry // dependencies this._deps = { diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js new file mode 100644 index 0000000000..e570e7a566 --- /dev/null +++ b/src/app/debugger/debuggerUI.js @@ -0,0 +1,20 @@ +var Debugger = require('../debugger/debugger') +var executionContext = require('../../execution-context') +var SourceHighlighter = require('../editor/sourceHighlighter') + +class DebuggerUI { + + constructor (container) { + this.transactionDebugger = new Debugger(container, new SourceHighlighter()) + this.transactionDebugger.addProvider('vm', executionContext.vm()) + this.transactionDebugger.addProvider('injected', executionContext.internalWeb3()) + this.transactionDebugger.addProvider('web3', executionContext.internalWeb3()) + this.transactionDebugger.switchProvider(executionContext.getProvider()) + } + + view () { + return this.transactionDebugger + } +} + +module.exports = DebuggerUI diff --git a/src/app/tabs/debugger-tab.js b/src/app/tabs/debugger-tab.js index 45b1ea193b..bbe4738dfb 100644 --- a/src/app/tabs/debugger-tab.js +++ b/src/app/tabs/debugger-tab.js @@ -2,24 +2,33 @@ var yo = require('yo-yo') var csjs = require('csjs-inject') var remixLib = require('remix-lib') -var Debugger = require('../debugger/debugger') -var SourceHighlighter = require('../editor/sourceHighlighter') - -var executionContext = require('../../execution-context') +var DebuggerUI = require('../debugger/debuggerUI') var globalRegistry = require('../../global/registry') var EventManager = remixLib.EventManager var styles = require('../ui/styles-guide/theme-chooser').chooser() -module.exports = class DebuggerTab { +const css = csjs` + .debuggerTabView { + padding: 2%; + } + .debugger { + margin-bottom: 1%; + ${styles.rightPanel.debuggerTab.box_Debugger} + } +` + +class DebuggerTab { constructor (localRegistry) { const self = this self.event = new EventManager() self._view = { el: null } self.data = {} self._components = {} + // TODO: what is this used for? is repated in debugger.js self._components.registry = localRegistry || globalRegistry } + render () { const self = this if (self._view.el) return self._view.el @@ -29,23 +38,14 @@ module.exports = class DebuggerTab {
` - self._view.transactionDebugger = new Debugger(self._view.el.querySelector('#debugger'), new SourceHighlighter()) - self._view.transactionDebugger.addProvider('vm', executionContext.vm()) - self._view.transactionDebugger.addProvider('injected', executionContext.internalWeb3()) - self._view.transactionDebugger.addProvider('web3', executionContext.internalWeb3()) - self._view.transactionDebugger.switchProvider(executionContext.getProvider()) + let debuggerUI = new DebuggerUI(self._view.el.querySelector('#debugger')) + self._view.transactionDebugger = debuggerUI.view() return self._view.el } + debugger () { return this._view.transactionDebugger } } -const css = csjs` - .debuggerTabView { - padding: 2%; - } - .debugger { - margin-bottom: 1%; - ${styles.rightPanel.debuggerTab.box_Debugger} - } -` + +module.exports = DebuggerTab From 5367933bd523dd353fc4379bc450161e3d66de26 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 13:05:00 -0400 Subject: [PATCH 002/170] move active events --- src/app.js | 2 +- src/app/debugger/debugger.js | 10 ---------- src/app/debugger/debuggerUI.js | 20 ++++++++++++++++++++ src/app/tabs/debugger-tab.js | 7 ++++--- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/app.js b/src/app.js index 4077ae1846..fe3f6b1c08 100644 --- a/src/app.js +++ b/src/app.js @@ -230,7 +230,7 @@ class App { } runCompiler () { const self = this - if (self._components.righthandpanel.debugger().isActive) return + if (self._components.righthandpanel.debugger().isDebuggerActive()) return self._components.fileManager.saveCurrentFile() self._components.editorpanel.getEditor().clearAnnotations() diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index b63294b800..4c38613bde 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -35,7 +35,6 @@ function Debugger (container, sourceHighlighter, localRegistry) { // TODO: render doesn't exist anymore container.appendChild(this.debugger_ui.render()) // - this.isActive = false this.breakPointManager = new remixLib.code.BreakpointManager(this.debugger, (sourceLocation) => { return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, this._deps.compiler.lastCompilationResult.source.sources, this._deps.compiler.lastCompilationResult.data.sources) @@ -58,15 +57,6 @@ function Debugger (container, sourceHighlighter, localRegistry) { self.switchProvider(context) }) - this.debugger.event.register('newTraceLoaded', this, function () { - self.isActive = true - }) - - this.debugger.event.register('traceUnloaded', this, function () { - self._components.sourceHighlighter.currentSourceLocation(null) - self.isActive = false - }) - // unload if a file has changed (but not if tabs were switched) self._deps.editor.event.register('contentChanged', function () { self.debugger.unLoad() diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index e570e7a566..1bfc11279c 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -10,11 +10,31 @@ class DebuggerUI { this.transactionDebugger.addProvider('injected', executionContext.internalWeb3()) this.transactionDebugger.addProvider('web3', executionContext.internalWeb3()) this.transactionDebugger.switchProvider(executionContext.getProvider()) + + this.isActive = false + + this.listenToEvents() + } + + listenToEvents () { + const self = this + this.transactionDebugger.debugger.event.register('newTraceLoaded', this, function () { + self.isActive = true + }) + + this.transactionDebugger.debugger.event.register('traceUnloaded', this, function () { + self._components.sourceHighlighter.currentSourceLocation(null) + self.isActive = false + }) } view () { return this.transactionDebugger } + + isDebuggerActive () { + return this.isActive + } } module.exports = DebuggerUI diff --git a/src/app/tabs/debugger-tab.js b/src/app/tabs/debugger-tab.js index bbe4738dfb..9d9ed3b7b8 100644 --- a/src/app/tabs/debugger-tab.js +++ b/src/app/tabs/debugger-tab.js @@ -38,13 +38,14 @@ class DebuggerTab {
` - let debuggerUI = new DebuggerUI(self._view.el.querySelector('#debugger')) - self._view.transactionDebugger = debuggerUI.view() + this.debuggerUI = new DebuggerUI(self._view.el.querySelector('#debugger')) + self._view.transactionDebugger = this.debuggerUI.view() return self._view.el } debugger () { - return this._view.transactionDebugger + // return this._view.transactionDebugger + return this.debuggerUI } } From ec08df83e54b013299a29fa7d1478d0d8835695e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 13:31:44 -0400 Subject: [PATCH 003/170] create event for debugger state; add debug method --- src/app/debugger/debugger.js | 14 +++++++++++++- src/app/debugger/debuggerUI.js | 13 ++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index 4c38613bde..8f8f00c318 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -2,6 +2,7 @@ var EthdebuggerUI = require('./remix-debugger/src/ui/EthdebuggerUI') var Ethdebugger = require('remix-debug').EthDebugger var remixLib = require('remix-lib') +var EventManager = remixLib.EventManager var executionContext = require('../../execution-context') var globlalRegistry = require('../../global/registry') @@ -9,6 +10,9 @@ var globlalRegistry = require('../../global/registry') * Manage remix and source highlighting */ function Debugger (container, sourceHighlighter, localRegistry) { + var self = this + this.event = new EventManager() + this._components = { sourceHighlighter: sourceHighlighter } @@ -44,7 +48,6 @@ function Debugger (container, sourceHighlighter, localRegistry) { this.debugger.setBreakpointManager(this.breakPointManager) - var self = this self._deps.editor.event.register('breakpointCleared', (fileName, row) => { this.breakPointManager.remove({fileName: fileName, row: row}) }) @@ -78,6 +81,15 @@ function Debugger (container, sourceHighlighter, localRegistry) { }) } }) + + this.debugger.event.register('newTraceLoaded', this, function () { + self.event.trigger('debuggerStatus', [true]) + }) + + this.debugger.event.register('traceUnloaded', this, function () { + self._components.sourceHighlighter.currentSourceLocation(null) + self.event.trigger('debuggerStatus', [false]) + }) } /** diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index 1bfc11279c..afd8743ee1 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -18,13 +18,8 @@ class DebuggerUI { listenToEvents () { const self = this - this.transactionDebugger.debugger.event.register('newTraceLoaded', this, function () { - self.isActive = true - }) - - this.transactionDebugger.debugger.event.register('traceUnloaded', this, function () { - self._components.sourceHighlighter.currentSourceLocation(null) - self.isActive = false + this.transactionDebugger.event.register('debuggerStatus', function (isActive) { + self.isActive = isActive }) } @@ -35,6 +30,10 @@ class DebuggerUI { isDebuggerActive () { return this.isActive } + + debug(txHash) { + this.transactionDebugger.debug(txHash) + } } module.exports = DebuggerUI From 84ba99111765ca39a97007fdaf53ac3df0e7f98b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 13:43:55 -0400 Subject: [PATCH 004/170] move provider set into debugger class --- src/app/debugger/debugger.js | 45 ++++++++++++++++++++-------------- src/app/debugger/debuggerUI.js | 9 +------ 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index 8f8f00c318..e140cbc47b 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -82,6 +82,8 @@ function Debugger (container, sourceHighlighter, localRegistry) { } }) + // ==================== + // listen to events this.debugger.event.register('newTraceLoaded', this, function () { self.event.trigger('debuggerStatus', [true]) }) @@ -90,6 +92,13 @@ function Debugger (container, sourceHighlighter, localRegistry) { self._components.sourceHighlighter.currentSourceLocation(null) self.event.trigger('debuggerStatus', [false]) }) + + // ==================== + // add providers + this.debugger.addProvider('vm', executionContext.vm()) + this.debugger.addProvider('injected', executionContext.internalWeb3()) + this.debugger.addProvider('web3', executionContext.internalWeb3()) + this.debugger.switchProvider(executionContext.getProvider()) } /** @@ -107,24 +116,24 @@ Debugger.prototype.debug = function (txHash) { }) } -/** - * add a new web3 provider to remix - * - * @param {String} type - type/name of the provider to add - * @param {Object} obj - provider - */ -Debugger.prototype.addProvider = function (type, obj) { - this.debugger.addProvider(type, obj) -} - -/** - * switch the provider - * - * @param {String} type - type/name of the provider to use - */ -Debugger.prototype.switchProvider = function (type) { - this.debugger.switchProvider(type) -} +// /** +// * add a new web3 provider to remix +// * +// * @param {String} type - type/name of the provider to add +// * @param {Object} obj - provider +// */ +// Debugger.prototype.addProvider = function (type, obj) { +// this.debugger.addProvider(type, obj) +// } + +// /** +// * switch the provider +// * +// * @param {String} type - type/name of the provider to use +// */ +// Debugger.prototype.switchProvider = function (type) { +// this.debugger.switchProvider(type) +// } /** * get the current provider diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index afd8743ee1..397ba14c93 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -1,18 +1,11 @@ var Debugger = require('../debugger/debugger') -var executionContext = require('../../execution-context') var SourceHighlighter = require('../editor/sourceHighlighter') class DebuggerUI { constructor (container) { this.transactionDebugger = new Debugger(container, new SourceHighlighter()) - this.transactionDebugger.addProvider('vm', executionContext.vm()) - this.transactionDebugger.addProvider('injected', executionContext.internalWeb3()) - this.transactionDebugger.addProvider('web3', executionContext.internalWeb3()) - this.transactionDebugger.switchProvider(executionContext.getProvider()) - this.isActive = false - this.listenToEvents() } @@ -31,7 +24,7 @@ class DebuggerUI { return this.isActive } - debug(txHash) { + debug (txHash) { this.transactionDebugger.debug(txHash) } } From 3ae1a7504e6b84d4cb7c5f03ad6306d19d362626 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 13:44:08 -0400 Subject: [PATCH 005/170] remove unused code --- src/app/debugger/debugger.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index e140cbc47b..6d122d22c1 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -116,25 +116,6 @@ Debugger.prototype.debug = function (txHash) { }) } -// /** -// * add a new web3 provider to remix -// * -// * @param {String} type - type/name of the provider to add -// * @param {Object} obj - provider -// */ -// Debugger.prototype.addProvider = function (type, obj) { -// this.debugger.addProvider(type, obj) -// } - -// /** -// * switch the provider -// * -// * @param {String} type - type/name of the provider to use -// */ -// Debugger.prototype.switchProvider = function (type) { -// this.debugger.switchProvider(type) -// } - /** * get the current provider */ From 1937b1efe1c8623e3bacebc7ff4201b827ca38b0 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 13:44:23 -0400 Subject: [PATCH 006/170] fix typo --- src/app/debugger/debugger.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index 6d122d22c1..1577597a06 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -4,7 +4,7 @@ var Ethdebugger = require('remix-debug').EthDebugger var remixLib = require('remix-lib') var EventManager = remixLib.EventManager var executionContext = require('../../execution-context') -var globlalRegistry = require('../../global/registry') +var globalRegistry = require('../../global/registry') /** * Manage remix and source highlighting @@ -17,7 +17,7 @@ function Debugger (container, sourceHighlighter, localRegistry) { sourceHighlighter: sourceHighlighter } // TODO: localRegistry doesn't seem to be actually used anywhere - this._components.registry = localRegistry || globlalRegistry + this._components.registry = localRegistry || globalRegistry // dependencies this._deps = { offsetToLineColumnConverter: this._components.registry.get('offsettolinecolumnconverter').api, From 56591612b6d090a3f3eb378597bcc458e4208a67 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 14:01:34 -0400 Subject: [PATCH 007/170] remove unused code --- src/app/debugger/debugger.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index 1577597a06..75a0059cab 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -116,11 +116,4 @@ Debugger.prototype.debug = function (txHash) { }) } -/** - * get the current provider - */ -Debugger.prototype.web3 = function (type) { - return this.debugger.web3 -} - module.exports = Debugger From e96f879efbf2f8289011300c6215665ab7f56b00 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 15:19:46 -0400 Subject: [PATCH 008/170] move debugger UI; out of debugger class --- src/app/debugger/debugger.js | 58 +++++++++++++++------------------- src/app/debugger/debuggerUI.js | 21 +++++++++++- 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index 75a0059cab..dbec8b6114 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -1,5 +1,5 @@ 'use strict' -var EthdebuggerUI = require('./remix-debugger/src/ui/EthdebuggerUI') +// var EthdebuggerUI = require('./remix-debugger/src/ui/EthdebuggerUI') var Ethdebugger = require('remix-debug').EthDebugger var remixLib = require('remix-lib') var EventManager = remixLib.EventManager @@ -33,17 +33,15 @@ function Debugger (container, sourceHighlighter, localRegistry) { return null } }) - this.debugger_ui = new EthdebuggerUI({debugger: this.debugger}) + // this.debugger_ui = new EthdebuggerUI({debugger: this.debugger}) this.sourceMappingDecoder = new remixLib.SourceMappingDecoder() - // - // TODO: render doesn't exist anymore - container.appendChild(this.debugger_ui.render()) - // + // container.appendChild(this.debugger_ui.render()) this.breakPointManager = new remixLib.code.BreakpointManager(this.debugger, (sourceLocation) => { return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, this._deps.compiler.lastCompilationResult.source.sources, this._deps.compiler.lastCompilationResult.data.sources) }, (step) => { - this.debugger_ui.stepManager.jumpTo(step) + self.event.trigger('breakpointStep', [step]) + // this.debugger_ui.stepManager.jumpTo(step) }) this.debugger.setBreakpointManager(this.breakPointManager) @@ -65,23 +63,7 @@ function Debugger (container, sourceHighlighter, localRegistry) { self.debugger.unLoad() }) - // register selected code item, highlight the corresponding source location - this.debugger_ui.event.register('indexChanged', function (index) { - if (self._deps.compiler.lastCompilationResult) { - self.debugger.traceManager.getCurrentCalledAddressAt(index, (error, address) => { - if (error) return console.log(error) - self.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, index, self._deps.compiler.lastCompilationResult.data.contracts, function (error, rawLocation) { - if (!error && self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { - var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) - self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation) - } else { - self._components.sourceHighlighter.currentSourceLocation(null) - } - }) - }) - } - }) - + // // ==================== // listen to events this.debugger.event.register('newTraceLoaded', this, function () { @@ -101,19 +83,31 @@ function Debugger (container, sourceHighlighter, localRegistry) { this.debugger.switchProvider(executionContext.getProvider()) } +Debugger.prototype.registerAndHighlightCodeItem = function (index) { + const self = this + // register selected code item, highlight the corresponding source location + if (self._deps.compiler.lastCompilationResult) { + self.debugger.traceManager.getCurrentCalledAddressAt(index, (error, address) => { + if (error) return console.log(error) + self.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, index, self._deps.compiler.lastCompilationResult.data.contracts, function (error, rawLocation) { + if (!error && self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { + var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources) + self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation) + } else { + self._components.sourceHighlighter.currentSourceLocation(null) + } + }) + }) + } +} + /** * Start debugging using Remix * * @param {String} txHash - hash of the transaction */ -Debugger.prototype.debug = function (txHash) { - var self = this - - this.debugger.web3.eth.getTransaction(txHash, function (error, tx) { - if (!error) { - self.debugger_ui.debug(tx) - } - }) +Debugger.prototype.debug = function (txHash, cb) { + this.debugger.web3.eth.getTransaction(txHash, cb) } module.exports = Debugger diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index 397ba14c93..2fb6c987a6 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -1,3 +1,4 @@ +var OldEthdebuggerUI = require('./remix-debugger/src/ui/EthdebuggerUI') var Debugger = require('../debugger/debugger') var SourceHighlighter = require('../editor/sourceHighlighter') @@ -6,6 +7,10 @@ class DebuggerUI { constructor (container) { this.transactionDebugger = new Debugger(container, new SourceHighlighter()) this.isActive = false + + this.debugger_ui = new OldEthdebuggerUI({debugger: this.transactionDebugger.debugger}) + container.appendChild(this.debugger_ui.render()) + this.listenToEvents() } @@ -14,6 +19,14 @@ class DebuggerUI { this.transactionDebugger.event.register('debuggerStatus', function (isActive) { self.isActive = isActive }) + + this.transactionDebugger.event.register('breakpointStep', function (step) { + self.debugger_ui.stepManager.jumpTo(step) + }) + + this.debugger_ui.event.register('indexChanged', function (index) { + self.transactionDebugger.registerAndHighlightCodeItem(index) + }) } view () { @@ -25,7 +38,13 @@ class DebuggerUI { } debug (txHash) { - this.transactionDebugger.debug(txHash) + const self = this + this.transactionDebugger.debug(txHash, (error, tx) => { + if (error) { + return console.error("coudn't get txHash: " + error) + } + self.debugger_ui.debug(tx) + }) } } From 5166dd85f47b2c3a755d2d8c2b637dbf29bf2aeb Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 15:20:12 -0400 Subject: [PATCH 009/170] remove unused code --- src/app/debugger/debugger.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index dbec8b6114..4a8c3c1859 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -1,5 +1,4 @@ 'use strict' -// var EthdebuggerUI = require('./remix-debugger/src/ui/EthdebuggerUI') var Ethdebugger = require('remix-debug').EthDebugger var remixLib = require('remix-lib') var EventManager = remixLib.EventManager @@ -33,15 +32,12 @@ function Debugger (container, sourceHighlighter, localRegistry) { return null } }) - // this.debugger_ui = new EthdebuggerUI({debugger: this.debugger}) this.sourceMappingDecoder = new remixLib.SourceMappingDecoder() - // container.appendChild(this.debugger_ui.render()) this.breakPointManager = new remixLib.code.BreakpointManager(this.debugger, (sourceLocation) => { return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, this._deps.compiler.lastCompilationResult.source.sources, this._deps.compiler.lastCompilationResult.data.sources) }, (step) => { self.event.trigger('breakpointStep', [step]) - // this.debugger_ui.stepManager.jumpTo(step) }) this.debugger.setBreakpointManager(this.breakPointManager) From ba7efb0820df0a5a1741b12afefd104d58933639 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 15:28:20 -0400 Subject: [PATCH 010/170] remove unused parameters --- src/app/debugger/debugger.js | 5 ++--- src/app/debugger/debuggerUI.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index 4a8c3c1859..5a132bf361 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -8,15 +8,14 @@ var globalRegistry = require('../../global/registry') /** * Manage remix and source highlighting */ -function Debugger (container, sourceHighlighter, localRegistry) { +function Debugger (sourceHighlighter) { var self = this this.event = new EventManager() this._components = { sourceHighlighter: sourceHighlighter } - // TODO: localRegistry doesn't seem to be actually used anywhere - this._components.registry = localRegistry || globalRegistry + this._components.registry = globalRegistry // dependencies this._deps = { offsetToLineColumnConverter: this._components.registry.get('offsettolinecolumnconverter').api, diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index 2fb6c987a6..2a3434fef8 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -5,7 +5,7 @@ var SourceHighlighter = require('../editor/sourceHighlighter') class DebuggerUI { constructor (container) { - this.transactionDebugger = new Debugger(container, new SourceHighlighter()) + this.transactionDebugger = new Debugger(new SourceHighlighter()) this.isActive = false this.debugger_ui = new OldEthdebuggerUI({debugger: this.transactionDebugger.debugger}) From dd9edcf379d6c1d7a60e5b6c61cfabdf414b2eba Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 16:59:30 -0400 Subject: [PATCH 011/170] use new tx browser; move code to upper class --- src/app/debugger/debuggerUI.js | 39 +++- src/app/debugger/debuggerUI/TxBrowser.js | 206 ++++++++++++++++++ src/app/debugger/remix-debugger/index.js | 1 + .../remix-debugger/src/ui/EthdebuggerUI.js | 49 ++--- 4 files changed, 264 insertions(+), 31 deletions(-) create mode 100644 src/app/debugger/debuggerUI/TxBrowser.js diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index 2a3434fef8..33bfd698c6 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -1,6 +1,9 @@ var OldEthdebuggerUI = require('./remix-debugger/src/ui/EthdebuggerUI') var Debugger = require('../debugger/debugger') var SourceHighlighter = require('../editor/sourceHighlighter') +var TxBrowser = require('./debuggerUI/TxBrowser') +var remixLib = require('remix-lib') +var executionContext = remixLib.execution.executionContext class DebuggerUI { @@ -8,7 +11,12 @@ class DebuggerUI { this.transactionDebugger = new Debugger(new SourceHighlighter()) this.isActive = false - this.debugger_ui = new OldEthdebuggerUI({debugger: this.transactionDebugger.debugger}) + this.debugger_ui = new OldEthdebuggerUI({ + debugger: this.transactionDebugger.debugger + }) + + this.startTxBrowser() + container.appendChild(this.debugger_ui.render()) this.listenToEvents() @@ -29,6 +37,25 @@ class DebuggerUI { }) } + startTxBrowser () { + const self = this + + let txBrowser = new TxBrowser(this.debugger_ui, {displayConnectionSetting: false, web3: executionContext.web3()}) + this.debugger_ui.txBrowser = txBrowser + + txBrowser.event.register('newTxLoading', this, function () { + self.debugger_ui.unLoad() + }) + txBrowser.event.register('newTraceRequested', this, function (blockNumber, txIndex, tx) { + self.debugger_ui.startDebugging(blockNumber, txIndex, tx) + }) + txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) { + self.debugger_ui.unLoad() + }) + + this.txBrowser = this.debugger_ui.txBrowser + } + view () { return this.transactionDebugger } @@ -43,7 +70,15 @@ class DebuggerUI { if (error) { return console.error("coudn't get txHash: " + error) } - self.debugger_ui.debug(tx) + self.transactionDebugger.debugger.solidityProxy.reset({}) + + if (tx instanceof Object) { + self.txBrowser.load(tx.hash, tx) + } else if (tx instanceof String) { + self.txBrowser.load(tx) + } + + // self.debugger_ui.debug(tx) }) } } diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js new file mode 100644 index 0000000000..5e9213c28e --- /dev/null +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -0,0 +1,206 @@ +var remixLib = require('remix-lib') +var EventManager = remixLib.EventManager +var traceHelper = remixLib.helpers.trace +var yo = require('yo-yo') +var init = remixLib.init +var csjs = require('csjs-inject') +var styleGuide = require('../../ui/styles-guide/theme-chooser') +var styles = styleGuide.chooser() + +var css = csjs` + .container { + display: flex; + flex-direction: column; + } + .txContainer { + display: flex; + flex-direction: column; + } + .txinputs { + width: 100%; + display: flex; + justify-content: center; + } + .txinput { + ${styles.rightPanel.debuggerTab.input_Debugger} + margin: 3px; + width: inherit; + } + .txbuttons { + width: 100%; + display: flex; + justify-content: center; + } + .txbutton { + ${styles.rightPanel.debuggerTab.button_Debugger} + width: inherit; + } + .txbuttonstart { + ${styles.rightPanel.debuggerTab.button_Debugger} + } + .txbutton:hover { + color: ${styles.rightPanel.debuggerTab.button_Debugger_icon_HoverColor}; + } + .vmargin { + margin-top: 10px; + margin-bottom: 10px; + } +` +function TxBrowser (_parent, opts) { + this.event = new EventManager() + + this.blockNumber + this.txNumber + this.view + this.displayConnectionSetting = opts.displayConnectionSetting + this.web3 = opts.web3 + var self = this + _parent.event.register('providerChanged', this, function (provider) { + self.setDefaultValues() + if (self.view) { + yo.update(self.view, self.render()) + } + }) +} + +// creation 0xa9619e1d0a35b2c1d686f5b661b3abd87f998d2844e8e9cc905edb57fc9ce349 +// invokation 0x71a6d583d16d142c5c3e8903060e8a4ee5a5016348a9448df6c3e63b68076ec4 0xcda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff +// test: +// creation: 0x72908de76f99fca476f9e3a3b5d352f350a98cd77d09cebfc59ffe32a6ecaa0b +// invokation: 0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51 + +TxBrowser.prototype.setDefaultValues = function () { + this.connectInfo = '' + if (this.view) { + yo.update(this.view, this.render()) + } +} + +TxBrowser.prototype.submit = function (tx) { + var self = this + self.event.trigger('newTxLoading', [this.blockNumber, this.txNumber]) + if (tx) { + return self.update(null, tx) + } + if (!this.txNumber) { + self.update('no tx index or tx hash to look for') + return + } + try { + if (this.txNumber.indexOf('0x') !== -1) { + self.web3.eth.getTransaction(this.txNumber, function (error, result) { + self.update(error, result) + }) + } else { + self.web3.eth.getTransactionFromBlock(this.blockNumber, this.txNumber, function (error, result) { + self.update(error, result) + }) + } + } catch (e) { + self.update(e.message) + } +} + +TxBrowser.prototype.update = function (error, tx) { + var info = {} + if (error) { + this.view.querySelector('#error').innerHTML = error + } else { + if (tx) { + this.view.querySelector('#error').innerHTML = '' + if (!tx.to) { + tx.to = traceHelper.contractCreationToken('0') + } + info.from = tx.from + info.to = tx.to + info.hash = tx.hash + this.event.trigger('newTraceRequested', [this.blockNumber, this.txNumber, tx]) + } else { + var mes = '' + info.from = mes + info.to = mes + info.hash = mes + this.view.querySelector('#error').innerHTML = 'Cannot find transaction with reference. Block number: ' + this.blockNumber + '. Transaction index/hash: ' + this.txNumber + } + } +} + +TxBrowser.prototype.updateWeb3Url = function (newhost) { + init.setProvider(global.web3, newhost) + var self = this + this.checkWeb3(function (error, block) { + if (!error) { + self.connectInfo = 'Connected to ' + global.web3.currentProvider.host + '. Current block number: ' + block + } else { + self.connectInfo = 'Unable to connect to ' + global.web3.currentProvider.host + '. ' + error.message + } + yo.update(self.view, self.render()) + }) +} + +TxBrowser.prototype.checkWeb3 = function (callback) { + try { + global.web3.eth.getBlockNumber(function (error, block) { + callback(error, block) + }) + } catch (e) { + console.log(e) + callback(e.message, null) + } +} + +TxBrowser.prototype.updateBlockN = function (ev) { + this.blockNumber = ev.target.value +} + +TxBrowser.prototype.updateTxN = function (ev) { + this.txNumber = ev.target.value +} + +TxBrowser.prototype.load = function (txHash, tx) { + this.txNumber = txHash + this.submit(tx) +} + +TxBrowser.prototype.unload = function (txHash) { + this.event.trigger('unloadRequested') + this.init() +} + +TxBrowser.prototype.init = function (ev) { + this.setDefaultValues() +} + +TxBrowser.prototype.connectionSetting = function () { + if (this.displayConnectionSetting) { + var self = this + return yo`
Node URL: + ${this.connectInfo}
` + } else { + return '' + } +} + +TxBrowser.prototype.render = function () { + var self = this + var view = yo`
+ ${this.connectionSetting()} +
+
+ + +
+
+ + +
+
+ +
` + if (!this.view) { + this.view = view + } + return view +} + +module.exports = TxBrowser diff --git a/src/app/debugger/remix-debugger/index.js b/src/app/debugger/remix-debugger/index.js index 380808018f..1e8e7ed6dd 100644 --- a/src/app/debugger/remix-debugger/index.js +++ b/src/app/debugger/remix-debugger/index.js @@ -1,4 +1,5 @@ 'use strict' +// TODO: this file doesn't seem to be used any more and can be removed var VMDebugger = require('./src/ui/VmDebugger') var Debugger = require('./src/ui/EthdebuggerUI') var DebuggerBackend = require('remix-debug').EthDebugger diff --git a/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js b/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js index 778370a2a2..aa7dfc6a67 100644 --- a/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js +++ b/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js @@ -1,5 +1,5 @@ 'use strict' -var TxBrowser = require('./TxBrowser') +// var TxBrowser = require('./TxBrowser') var StepManager = require('./StepManager') var VmDebugger = require('./VmDebugger') @@ -24,7 +24,7 @@ function EthdebuggerUI (opts) { this.opts = opts || {} this.debugger = opts.debugger - if (!this.opts.compilationResult) this.opts.compilationResult = () => { return null } + // if (!this.opts.compilationResult) this.opts.compilationResult = () => { return null } var self = this this.event = new EventManager() @@ -42,17 +42,6 @@ function EthdebuggerUI (opts) { executionContext.event.register('contextChanged', this, function () { self.updateWeb3Reference() }) - - this.txBrowser = new TxBrowser(this, {displayConnectionSetting: false, web3: executionContext.web3()}) - this.txBrowser.event.register('newTxLoading', this, function () { - self.unLoad() - }) - this.txBrowser.event.register('newTraceRequested', this, function (blockNumber, txIndex, tx) { - self.startDebugging(blockNumber, txIndex, tx) - }) - this.txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) { - self.unLoad() - }) } EthdebuggerUI.prototype.setBreakpointManager = function (breakpointManager) { @@ -68,22 +57,24 @@ EthdebuggerUI.prototype.updateWeb3Reference = function (web3) { this.txBrowser.web3 = web3 || executionContext.web3() } -EthdebuggerUI.prototype.setCompilationResult = function (compilationResult) { - if (compilationResult && compilationResult.sources && compilationResult.contracts) { - this.debugger.solidityProxy.reset(compilationResult) - } else { - this.debugger.solidityProxy.reset({}) - } -} - -EthdebuggerUI.prototype.debug = function (tx) { - this.setCompilationResult(this.opts.compilationResult()) - if (tx instanceof Object) { - this.txBrowser.load(tx.hash, tx) - } else if (tx instanceof String) { - this.txBrowser.load(tx) - } -} +// EthdebuggerUI.prototype.setCompilationResult = function (compilationResult) { +// if (compilationResult && compilationResult.sources && compilationResult.contracts) { +// this.debugger.solidityProxy.reset(compilationResult) +// } else { +// this.debugger.solidityProxy.reset({}) +// } +// } + +// EthdebuggerUI.prototype.debug = function (tx) { +// // this.setCompilationResult(this.opts.compilationResult()) +// +// this.debugger.solidityProxy.reset({}) +// if (tx instanceof Object) { +// this.txBrowser.load(tx.hash, tx) +// } else if (tx instanceof String) { +// this.txBrowser.load(tx) +// } +// } EthdebuggerUI.prototype.render = function () { this.debuggerPanelsView = yo`
` From 2cef4760e75088b64c8c1aed8a44eae3cc7bd2bc Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 16:59:55 -0400 Subject: [PATCH 012/170] remove unused code --- .../remix-debugger/src/ui/EthdebuggerUI.js | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js b/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js index aa7dfc6a67..fa0d3b300c 100644 --- a/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js +++ b/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js @@ -24,8 +24,6 @@ function EthdebuggerUI (opts) { this.opts = opts || {} this.debugger = opts.debugger - // if (!this.opts.compilationResult) this.opts.compilationResult = () => { return null } - var self = this this.event = new EventManager() @@ -57,25 +55,6 @@ EthdebuggerUI.prototype.updateWeb3Reference = function (web3) { this.txBrowser.web3 = web3 || executionContext.web3() } -// EthdebuggerUI.prototype.setCompilationResult = function (compilationResult) { -// if (compilationResult && compilationResult.sources && compilationResult.contracts) { -// this.debugger.solidityProxy.reset(compilationResult) -// } else { -// this.debugger.solidityProxy.reset({}) -// } -// } - -// EthdebuggerUI.prototype.debug = function (tx) { -// // this.setCompilationResult(this.opts.compilationResult()) -// -// this.debugger.solidityProxy.reset({}) -// if (tx instanceof Object) { -// this.txBrowser.load(tx.hash, tx) -// } else if (tx instanceof String) { -// this.txBrowser.load(tx) -// } -// } - EthdebuggerUI.prototype.render = function () { this.debuggerPanelsView = yo`
` this.debuggerHeadPanelsView = yo`
` From c83162098a6c1566618310645c8a48bf48efadda Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 17:00:32 -0400 Subject: [PATCH 013/170] remove unused code --- src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js b/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js index fa0d3b300c..26c258edd9 100644 --- a/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js +++ b/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js @@ -46,10 +46,6 @@ EthdebuggerUI.prototype.setBreakpointManager = function (breakpointManager) { this.breakpointManager = breakpointManager } -EthdebuggerUI.prototype.get_web3 = function () { - return this.web3 -} - EthdebuggerUI.prototype.updateWeb3Reference = function (web3) { if (!this.txBrowser) return this.txBrowser.web3 = web3 || executionContext.web3() From 538cb4b59e3febd4d1390f377d054b875fafb629 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 17:49:59 -0400 Subject: [PATCH 014/170] cleanup --- src/app/debugger/debuggerUI/TxBrowser.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js index 5e9213c28e..65e36cb9b7 100644 --- a/src/app/debugger/debuggerUI/TxBrowser.js +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -46,6 +46,7 @@ var css = csjs` margin-bottom: 10px; } ` + function TxBrowser (_parent, opts) { this.event = new EventManager() @@ -63,12 +64,6 @@ function TxBrowser (_parent, opts) { }) } -// creation 0xa9619e1d0a35b2c1d686f5b661b3abd87f998d2844e8e9cc905edb57fc9ce349 -// invokation 0x71a6d583d16d142c5c3e8903060e8a4ee5a5016348a9448df6c3e63b68076ec4 0xcda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff -// test: -// creation: 0x72908de76f99fca476f9e3a3b5d352f350a98cd77d09cebfc59ffe32a6ecaa0b -// invokation: 0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51 - TxBrowser.prototype.setDefaultValues = function () { this.connectInfo = '' if (this.view) { @@ -176,9 +171,8 @@ TxBrowser.prototype.connectionSetting = function () { var self = this return yo`
Node URL: ${this.connectInfo}
` - } else { - return '' } + return '' } TxBrowser.prototype.render = function () { From bbfb0aa500908faa7fd8ca84be22c9cf9c537ea8 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 17:58:51 -0400 Subject: [PATCH 015/170] remove all code related to displayConnectionSetting since it's always false --- src/app/debugger/debuggerUI.js | 2 +- src/app/debugger/debuggerUI/TxBrowser.js | 37 +----------------------- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index 33bfd698c6..ecdd1923cd 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -40,7 +40,7 @@ class DebuggerUI { startTxBrowser () { const self = this - let txBrowser = new TxBrowser(this.debugger_ui, {displayConnectionSetting: false, web3: executionContext.web3()}) + let txBrowser = new TxBrowser(this.debugger_ui, {web3: executionContext.web3()}) this.debugger_ui.txBrowser = txBrowser txBrowser.event.register('newTxLoading', this, function () { diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js index 65e36cb9b7..9205bace02 100644 --- a/src/app/debugger/debuggerUI/TxBrowser.js +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -2,7 +2,6 @@ var remixLib = require('remix-lib') var EventManager = remixLib.EventManager var traceHelper = remixLib.helpers.trace var yo = require('yo-yo') -var init = remixLib.init var csjs = require('csjs-inject') var styleGuide = require('../../ui/styles-guide/theme-chooser') var styles = styleGuide.chooser() @@ -53,11 +52,11 @@ function TxBrowser (_parent, opts) { this.blockNumber this.txNumber this.view - this.displayConnectionSetting = opts.displayConnectionSetting this.web3 = opts.web3 var self = this _parent.event.register('providerChanged', this, function (provider) { self.setDefaultValues() + // TODO: looks redudant since setDefaultValues already re-renders if (self.view) { yo.update(self.view, self.render()) } @@ -120,30 +119,6 @@ TxBrowser.prototype.update = function (error, tx) { } } -TxBrowser.prototype.updateWeb3Url = function (newhost) { - init.setProvider(global.web3, newhost) - var self = this - this.checkWeb3(function (error, block) { - if (!error) { - self.connectInfo = 'Connected to ' + global.web3.currentProvider.host + '. Current block number: ' + block - } else { - self.connectInfo = 'Unable to connect to ' + global.web3.currentProvider.host + '. ' + error.message - } - yo.update(self.view, self.render()) - }) -} - -TxBrowser.prototype.checkWeb3 = function (callback) { - try { - global.web3.eth.getBlockNumber(function (error, block) { - callback(error, block) - }) - } catch (e) { - console.log(e) - callback(e.message, null) - } -} - TxBrowser.prototype.updateBlockN = function (ev) { this.blockNumber = ev.target.value } @@ -166,19 +141,9 @@ TxBrowser.prototype.init = function (ev) { this.setDefaultValues() } -TxBrowser.prototype.connectionSetting = function () { - if (this.displayConnectionSetting) { - var self = this - return yo`
Node URL: - ${this.connectInfo}
` - } - return '' -} - TxBrowser.prototype.render = function () { var self = this var view = yo`
- ${this.connectionSetting()}
From 076bd377b5567d882b68e55d5633c3cf04da148f Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 18:05:33 -0400 Subject: [PATCH 016/170] move provider change event out of tx browser; simplify set default values --- src/app/debugger/debuggerUI.js | 4 ++++ src/app/debugger/debuggerUI/TxBrowser.js | 21 +++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index ecdd1923cd..57fba2347c 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -53,6 +53,10 @@ class DebuggerUI { self.debugger_ui.unLoad() }) + this.debugger_ui.event.register('providerChanged', this, function (provider) { + txBrowser.setDefaultValues() + }) + this.txBrowser = this.debugger_ui.txBrowser } diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js index 9205bace02..a3dae4fa76 100644 --- a/src/app/debugger/debuggerUI/TxBrowser.js +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -53,14 +53,15 @@ function TxBrowser (_parent, opts) { this.txNumber this.view this.web3 = opts.web3 - var self = this - _parent.event.register('providerChanged', this, function (provider) { - self.setDefaultValues() - // TODO: looks redudant since setDefaultValues already re-renders - if (self.view) { - yo.update(self.view, self.render()) - } - }) + this.setDefaultValues() + // var self = this + // _parent.event.register('providerChanged', this, function (provider) { + // self.setDefaultValues() + // // TODO: looks redudant since setDefaultValues already re-renders + // if (self.view) { + // yo.update(self.view, self.render()) + // } + // }) } TxBrowser.prototype.setDefaultValues = function () { @@ -134,10 +135,6 @@ TxBrowser.prototype.load = function (txHash, tx) { TxBrowser.prototype.unload = function (txHash) { this.event.trigger('unloadRequested') - this.init() -} - -TxBrowser.prototype.init = function (ev) { this.setDefaultValues() } From 13b3aebad1dc2b8d2988d37afd1580ac1846ec85 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 18:07:23 -0400 Subject: [PATCH 017/170] cleanup --- src/app/debugger/debuggerUI/TxBrowser.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js index a3dae4fa76..3239e1de8e 100644 --- a/src/app/debugger/debuggerUI/TxBrowser.js +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -54,14 +54,6 @@ function TxBrowser (_parent, opts) { this.view this.web3 = opts.web3 this.setDefaultValues() - // var self = this - // _parent.event.register('providerChanged', this, function (provider) { - // self.setDefaultValues() - // // TODO: looks redudant since setDefaultValues already re-renders - // if (self.view) { - // yo.update(self.view, self.render()) - // } - // }) } TxBrowser.prototype.setDefaultValues = function () { From c371e04925c52b9c4a831e76fe5bebe7b52e761f Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 18:11:28 -0400 Subject: [PATCH 018/170] clean up; remove unnecessary else's --- src/app/debugger/debuggerUI/TxBrowser.js | 43 ++++++++++++------------ 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js index 3239e1de8e..6b5486bb32 100644 --- a/src/app/debugger/debuggerUI/TxBrowser.js +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -75,14 +75,13 @@ TxBrowser.prototype.submit = function (tx) { } try { if (this.txNumber.indexOf('0x') !== -1) { - self.web3.eth.getTransaction(this.txNumber, function (error, result) { - self.update(error, result) - }) - } else { - self.web3.eth.getTransactionFromBlock(this.blockNumber, this.txNumber, function (error, result) { + return self.web3.eth.getTransaction(this.txNumber, function (error, result) { self.update(error, result) }) } + self.web3.eth.getTransactionFromBlock(this.blockNumber, this.txNumber, function (error, result) { + self.update(error, result) + }) } catch (e) { self.update(e.message) } @@ -92,23 +91,23 @@ TxBrowser.prototype.update = function (error, tx) { var info = {} if (error) { this.view.querySelector('#error').innerHTML = error - } else { - if (tx) { - this.view.querySelector('#error').innerHTML = '' - if (!tx.to) { - tx.to = traceHelper.contractCreationToken('0') - } - info.from = tx.from - info.to = tx.to - info.hash = tx.hash - this.event.trigger('newTraceRequested', [this.blockNumber, this.txNumber, tx]) - } else { - var mes = '' - info.from = mes - info.to = mes - info.hash = mes - this.view.querySelector('#error').innerHTML = 'Cannot find transaction with reference. Block number: ' + this.blockNumber + '. Transaction index/hash: ' + this.txNumber + return + } + if (tx) { + this.view.querySelector('#error').innerHTML = '' + if (!tx.to) { + tx.to = traceHelper.contractCreationToken('0') } + info.from = tx.from + info.to = tx.to + info.hash = tx.hash + this.event.trigger('newTraceRequested', [this.blockNumber, this.txNumber, tx]) + } else { + var mes = '' + info.from = mes + info.to = mes + info.hash = mes + this.view.querySelector('#error').innerHTML = 'Cannot find transaction with reference. Block number: ' + this.blockNumber + '. Transaction index/hash: ' + this.txNumber } } @@ -145,9 +144,11 @@ TxBrowser.prototype.render = function () {
` + if (!this.view) { this.view = view } + return view } From 62f12a78c57c8ba7d2b2df58449cb16db2a19127 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 18:15:38 -0400 Subject: [PATCH 019/170] remove local variable not used anywhere --- src/app/debugger/debuggerUI/TxBrowser.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js index 6b5486bb32..6a28589a1e 100644 --- a/src/app/debugger/debuggerUI/TxBrowser.js +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -88,7 +88,6 @@ TxBrowser.prototype.submit = function (tx) { } TxBrowser.prototype.update = function (error, tx) { - var info = {} if (error) { this.view.querySelector('#error').innerHTML = error return @@ -98,15 +97,8 @@ TxBrowser.prototype.update = function (error, tx) { if (!tx.to) { tx.to = traceHelper.contractCreationToken('0') } - info.from = tx.from - info.to = tx.to - info.hash = tx.hash this.event.trigger('newTraceRequested', [this.blockNumber, this.txNumber, tx]) } else { - var mes = '' - info.from = mes - info.to = mes - info.hash = mes this.view.querySelector('#error').innerHTML = 'Cannot find transaction with reference. Block number: ' + this.blockNumber + '. Transaction index/hash: ' + this.txNumber } } From 65b84b37aa2d096b00f47261d2f80630db67a084 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 18:16:46 -0400 Subject: [PATCH 020/170] simplify update method --- src/app/debugger/debuggerUI/TxBrowser.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js index 6a28589a1e..eade3ea5d5 100644 --- a/src/app/debugger/debuggerUI/TxBrowser.js +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -92,15 +92,17 @@ TxBrowser.prototype.update = function (error, tx) { this.view.querySelector('#error').innerHTML = error return } - if (tx) { - this.view.querySelector('#error').innerHTML = '' - if (!tx.to) { - tx.to = traceHelper.contractCreationToken('0') - } - this.event.trigger('newTraceRequested', [this.blockNumber, this.txNumber, tx]) - } else { + + if (!tx) { this.view.querySelector('#error').innerHTML = 'Cannot find transaction with reference. Block number: ' + this.blockNumber + '. Transaction index/hash: ' + this.txNumber + return + } + + this.view.querySelector('#error').innerHTML = '' + if (!tx.to) { + tx.to = traceHelper.contractCreationToken('0') } + this.event.trigger('newTraceRequested', [this.blockNumber, this.txNumber, tx]) } TxBrowser.prototype.updateBlockN = function (ev) { From a95f1ba4c3521737696e5c96d96b8d06bc981f35 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 07:31:35 -0400 Subject: [PATCH 021/170] move logic out of txbrowser ui into parent --- src/app/debugger/debuggerUI.js | 40 ++++++++++++++++--- src/app/debugger/debuggerUI/TxBrowser.js | 50 ++++++++++++------------ 2 files changed, 59 insertions(+), 31 deletions(-) diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index 57fba2347c..94ff67b028 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -4,6 +4,7 @@ var SourceHighlighter = require('../editor/sourceHighlighter') var TxBrowser = require('./debuggerUI/TxBrowser') var remixLib = require('remix-lib') var executionContext = remixLib.execution.executionContext +var traceHelper = remixLib.helpers.trace class DebuggerUI { @@ -39,16 +40,45 @@ class DebuggerUI { startTxBrowser () { const self = this + let web3 = executionContext.web3() - let txBrowser = new TxBrowser(this.debugger_ui, {web3: executionContext.web3()}) + let txBrowser = new TxBrowser(this.debugger_ui, {web3: web3}) this.debugger_ui.txBrowser = txBrowser - txBrowser.event.register('newTxLoading', this, function () { + txBrowser.event.register('requestDebug', function (blockNumber, txNumber, tx) { self.debugger_ui.unLoad() + + if (tx) { + if (!tx.to) { + tx.to = traceHelper.contractCreationToken('0') + } + return self.debugger_ui.startDebugging(blockNumber, txNumber, tx) + } + + try { + if (txNumber.indexOf('0x') !== -1) { + return web3.eth.getTransaction(txNumber, function (error, result) { + let tx = result + txBrowser.update(error, result) + self.debugger_ui.startDebugging(blockNumber, txNumber, tx) + }) + } + web3.eth.getTransactionFromBlock(blockNumber, txNumber, function (error, result) { + let tx = result + txBrowser.update(error, result) + self.debugger_ui.startDebugging(blockNumber, txNumber, tx) + }) + } catch (e) { + self.update(e.message) + } }) - txBrowser.event.register('newTraceRequested', this, function (blockNumber, txIndex, tx) { - self.debugger_ui.startDebugging(blockNumber, txIndex, tx) - }) + + // txBrowser.event.register('newTxLoading', this, function () { + // self.debugger_ui.unLoad() + // }) + // txBrowser.event.register('newTraceRequested', this, function (blockNumber, txIndex, tx) { + // self.debugger_ui.startDebugging(blockNumber, txIndex, tx) + // }) txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) { self.debugger_ui.unLoad() }) diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js index eade3ea5d5..e8f7395502 100644 --- a/src/app/debugger/debuggerUI/TxBrowser.js +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -1,6 +1,5 @@ var remixLib = require('remix-lib') var EventManager = remixLib.EventManager -var traceHelper = remixLib.helpers.trace var yo = require('yo-yo') var csjs = require('csjs-inject') var styleGuide = require('../../ui/styles-guide/theme-chooser') @@ -64,27 +63,29 @@ TxBrowser.prototype.setDefaultValues = function () { } TxBrowser.prototype.submit = function (tx) { - var self = this - self.event.trigger('newTxLoading', [this.blockNumber, this.txNumber]) - if (tx) { - return self.update(null, tx) - } - if (!this.txNumber) { - self.update('no tx index or tx hash to look for') - return - } - try { - if (this.txNumber.indexOf('0x') !== -1) { - return self.web3.eth.getTransaction(this.txNumber, function (error, result) { - self.update(error, result) - }) - } - self.web3.eth.getTransactionFromBlock(this.blockNumber, this.txNumber, function (error, result) { - self.update(error, result) - }) - } catch (e) { - self.update(e.message) - } + this.event.trigger('requestDebug', [this.blockNumber, this.txNumber, tx]) + + // var self = this + // self.event.trigger('newTxLoading', [this.blockNumber, this.txNumber]) + // if (tx) { + // return self.update(null, tx) + // } + // if (!this.txNumber) { + // self.update('no tx index or tx hash to look for') + // return + // } + // try { + // if (this.txNumber.indexOf('0x') !== -1) { + // return self.web3.eth.getTransaction(this.txNumber, function (error, result) { + // self.update(error, result) + // }) + // } + // self.web3.eth.getTransactionFromBlock(this.blockNumber, this.txNumber, function (error, result) { + // self.update(error, result) + // }) + // } catch (e) { + // self.update(e.message) + // } } TxBrowser.prototype.update = function (error, tx) { @@ -99,10 +100,7 @@ TxBrowser.prototype.update = function (error, tx) { } this.view.querySelector('#error').innerHTML = '' - if (!tx.to) { - tx.to = traceHelper.contractCreationToken('0') - } - this.event.trigger('newTraceRequested', [this.blockNumber, this.txNumber, tx]) + // this.event.trigger('newTraceRequested', [this.blockNumber, this.txNumber, tx]) } TxBrowser.prototype.updateBlockN = function (ev) { From 5271cc7dbad236a058cdf2030a43847859defcf2 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 07:34:41 -0400 Subject: [PATCH 022/170] cleanup --- src/app/debugger/debuggerUI.js | 6 ------ src/app/debugger/debuggerUI/TxBrowser.js | 23 ----------------------- 2 files changed, 29 deletions(-) diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index 94ff67b028..98f1d118c0 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -73,12 +73,6 @@ class DebuggerUI { } }) - // txBrowser.event.register('newTxLoading', this, function () { - // self.debugger_ui.unLoad() - // }) - // txBrowser.event.register('newTraceRequested', this, function (blockNumber, txIndex, tx) { - // self.debugger_ui.startDebugging(blockNumber, txIndex, tx) - // }) txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) { self.debugger_ui.unLoad() }) diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js index e8f7395502..3ea0805de5 100644 --- a/src/app/debugger/debuggerUI/TxBrowser.js +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -64,28 +64,6 @@ TxBrowser.prototype.setDefaultValues = function () { TxBrowser.prototype.submit = function (tx) { this.event.trigger('requestDebug', [this.blockNumber, this.txNumber, tx]) - - // var self = this - // self.event.trigger('newTxLoading', [this.blockNumber, this.txNumber]) - // if (tx) { - // return self.update(null, tx) - // } - // if (!this.txNumber) { - // self.update('no tx index or tx hash to look for') - // return - // } - // try { - // if (this.txNumber.indexOf('0x') !== -1) { - // return self.web3.eth.getTransaction(this.txNumber, function (error, result) { - // self.update(error, result) - // }) - // } - // self.web3.eth.getTransactionFromBlock(this.blockNumber, this.txNumber, function (error, result) { - // self.update(error, result) - // }) - // } catch (e) { - // self.update(e.message) - // } } TxBrowser.prototype.update = function (error, tx) { @@ -100,7 +78,6 @@ TxBrowser.prototype.update = function (error, tx) { } this.view.querySelector('#error').innerHTML = '' - // this.event.trigger('newTraceRequested', [this.blockNumber, this.txNumber, tx]) } TxBrowser.prototype.updateBlockN = function (ev) { From d48a550ba101c8c9c980cfd49ad61d962e963905 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 09:14:46 -0400 Subject: [PATCH 023/170] add new stepmanager and related files; move step manager out of old ui --- src/app/debugger/debuggerUI.js | 31 ++- .../debugger/debuggerUI/ButtonNavigator.js | 184 ++++++++++++++++ src/app/debugger/debuggerUI/Slider.js | 75 +++++++ src/app/debugger/debuggerUI/StepManager.js | 205 ++++++++++++++++++ .../remix-debugger/src/ui/EthdebuggerUI.js | 15 +- 5 files changed, 497 insertions(+), 13 deletions(-) create mode 100644 src/app/debugger/debuggerUI/ButtonNavigator.js create mode 100644 src/app/debugger/debuggerUI/Slider.js create mode 100644 src/app/debugger/debuggerUI/StepManager.js diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index 98f1d118c0..b5713aa225 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -2,6 +2,7 @@ var OldEthdebuggerUI = require('./remix-debugger/src/ui/EthdebuggerUI') var Debugger = require('../debugger/debugger') var SourceHighlighter = require('../editor/sourceHighlighter') var TxBrowser = require('./debuggerUI/TxBrowser') +var StepManager = require('./debuggerUI/StepManager') var remixLib = require('remix-lib') var executionContext = remixLib.execution.executionContext var traceHelper = remixLib.helpers.trace @@ -17,6 +18,8 @@ class DebuggerUI { }) this.startTxBrowser() + // this.startStepManager() + this.stepManager = null container.appendChild(this.debugger_ui.render()) @@ -30,7 +33,7 @@ class DebuggerUI { }) this.transactionDebugger.event.register('breakpointStep', function (step) { - self.debugger_ui.stepManager.jumpTo(step) + self.stepManager.jumpTo(step) }) this.debugger_ui.event.register('indexChanged', function (index) { @@ -38,6 +41,10 @@ class DebuggerUI { }) } + // startStepManager () { + // this.stepManager = null + // } + startTxBrowser () { const self = this let web3 = executionContext.web3() @@ -52,7 +59,7 @@ class DebuggerUI { if (!tx.to) { tx.to = traceHelper.contractCreationToken('0') } - return self.debugger_ui.startDebugging(blockNumber, txNumber, tx) + return self.startDebugging(blockNumber, txNumber, tx) } try { @@ -60,13 +67,13 @@ class DebuggerUI { return web3.eth.getTransaction(txNumber, function (error, result) { let tx = result txBrowser.update(error, result) - self.debugger_ui.startDebugging(blockNumber, txNumber, tx) + self.startDebugging(blockNumber, txNumber, tx) }) } web3.eth.getTransactionFromBlock(blockNumber, txNumber, function (error, result) { let tx = result txBrowser.update(error, result) - self.debugger_ui.startDebugging(blockNumber, txNumber, tx) + self.startDebugging(blockNumber, txNumber, tx) }) } catch (e) { self.update(e.message) @@ -92,6 +99,22 @@ class DebuggerUI { return this.isActive } + startDebugging (blockNumber, txNumber, tx) { + const self = this + let shouldOpenDebugger = this.debugger_ui.startDebugging(blockNumber, txNumber, tx) + if (!shouldOpenDebugger) return + + this.stepManager = new StepManager(this.debugger_ui, this.transactionDebugger.debugger.traceManager) + this.stepManager.event.register('stepChanged', this, function (stepIndex) { + self.debugger_ui.stepChanged(stepIndex) + }) + + this.debugger_ui.stepManager = this.stepManager + + this.debugger_ui.createAndAddVmDebugger() + this.transactionDebugger.debugger.debug(tx) + } + debug (txHash) { const self = this this.transactionDebugger.debug(txHash, (error, tx) => { diff --git a/src/app/debugger/debuggerUI/ButtonNavigator.js b/src/app/debugger/debuggerUI/ButtonNavigator.js new file mode 100644 index 0000000000..12c9e4fa54 --- /dev/null +++ b/src/app/debugger/debuggerUI/ButtonNavigator.js @@ -0,0 +1,184 @@ +'use strict' +var remixLib = require('remix-lib') +var EventManager = remixLib.EventManager +var yo = require('yo-yo') + +var csjs = require('csjs-inject') +var styleGuide = require('../../ui/styles-guide/theme-chooser') +var styles = styleGuide.chooser() + +var css = csjs` + .buttons { + display: flex; + flex-wrap: wrap; + } + .stepButtons { + width: 100%; + display: flex; + justify-content: center; + } + .stepButton { + ${styles.rightPanel.debuggerTab.button_Debugger} + } + .jumpButtons { + width: 100%; + display: flex; + justify-content: center; + } + .jumpButton { + ${styles.rightPanel.debuggerTab.button_Debugger} + } + .navigator { + color: ${styles.rightPanel.debuggerTab.text_Primary}; + } + .navigator:hover { + color: ${styles.rightPanel.debuggerTab.button_Debugger_icon_HoverColor}; + } +` + +function ButtonNavigator (_parent, _traceManager) { + this.event = new EventManager() + this.intoBackDisabled = true + this.overBackDisabled = true + this.intoForwardDisabled = true + this.overForwardDisabled = true + this.jumpOutDisabled = true + this.jumpNextBreakpointDisabled = true + this.jumpPreviousBreakpointDisabled = true + + this.traceManager = _traceManager + this.currentCall = null + this.revertionPoint = null + + _parent.event.register('indexChanged', this, (index) => { + if (!this.view) return + if (index < 0) return + if (_parent.currentStepIndex !== index) return + + this.traceManager.buildCallPath(index, (error, callsPath) => { + if (error) { + console.log(error) + resetWarning(this) + } else { + this.currentCall = callsPath[callsPath.length - 1] + if (this.currentCall.reverted) { + this.revertionPoint = this.currentCall.return + this.view.querySelector('#reverted').style.display = 'block' + this.view.querySelector('#reverted #outofgas').style.display = this.currentCall.outOfGas ? 'inline' : 'none' + this.view.querySelector('#reverted #parenthasthrown').style.display = 'none' + } else { + var k = callsPath.length - 2 + while (k >= 0) { + var parent = callsPath[k] + if (parent.reverted) { + this.revertionPoint = parent.return + this.view.querySelector('#reverted').style.display = 'block' + this.view.querySelector('#reverted #parenthasthrown').style.display = parent ? 'inline' : 'none' + this.view.querySelector('#reverted #outofgas').style.display = 'none' + return + } + k-- + } + resetWarning(this) + } + } + }) + }) + + this.view +} + +module.exports = ButtonNavigator + +ButtonNavigator.prototype.render = function () { + var self = this + var view = yo`
+
+ + + + +
+ +
+ + + +
+ +
` + if (!this.view) { + this.view = view + } + return view +} + +ButtonNavigator.prototype.reset = function () { + this.intoBackDisabled = true + this.overBackDisabled = true + this.intoForwardDisabled = true + this.overForwardDisabled = true + this.jumpOutDisabled = true + this.jumpNextBreakpointDisabled = true + this.jumpPreviousBreakpointDisabled = true + resetWarning(this) +} + +ButtonNavigator.prototype.stepChanged = function (step) { + this.intoBackDisabled = step <= 0 + this.overBackDisabled = step <= 0 + if (!this.traceManager) { + this.intoForwardDisabled = true + this.overForwardDisabled = true + } else { + var self = this + this.traceManager.getLength(function (error, length) { + if (error) { + self.reset() + console.log(error) + } else { + self.jumpNextBreakpointDisabled = step >= length - 1 + self.jumpPreviousBreakpointDisabled = step <= 0 + self.intoForwardDisabled = step >= length - 1 + self.overForwardDisabled = step >= length - 1 + var stepOut = self.traceManager.findStepOut(step) + self.jumpOutDisabled = stepOut === step + } + self.updateAll() + }) + } + this.updateAll() +} + +ButtonNavigator.prototype.updateAll = function () { + this.updateDisabled('intoback', this.intoBackDisabled) + this.updateDisabled('overback', this.overBackDisabled) + this.updateDisabled('overforward', this.overForwardDisabled) + this.updateDisabled('intoforward', this.intoForwardDisabled) + this.updateDisabled('jumpout', this.jumpOutDisabled) + this.updateDisabled('jumptoexception', this.jumpOutDisabled) + this.updateDisabled('jumpnextbreakpoint', this.jumpNextBreakpointDisabled) + this.updateDisabled('jumppreviousbreakpoint', this.jumpPreviousBreakpointDisabled) +} + +ButtonNavigator.prototype.updateDisabled = function (id, disabled) { + if (disabled) { + document.getElementById(id).setAttribute('disabled', true) + } else { + document.getElementById(id).removeAttribute('disabled') + } +} + +function resetWarning (self) { + self.view.querySelector('#reverted #outofgas').style.display = 'none' + self.view.querySelector('#reverted #parenthasthrown').style.display = 'none' + self.view.querySelector('#reverted').style.display = 'none' +} + +module.exports = ButtonNavigator diff --git a/src/app/debugger/debuggerUI/Slider.js b/src/app/debugger/debuggerUI/Slider.js new file mode 100644 index 0000000000..10ca255d81 --- /dev/null +++ b/src/app/debugger/debuggerUI/Slider.js @@ -0,0 +1,75 @@ +'use strict' +var remixLib = require('remix-lib') +var EventManager = remixLib.EventManager +var yo = require('yo-yo') + +class Slider { + constructor (_traceManager, _stepOverride) { + this.event = new EventManager() + this.traceManager = _traceManager + this.max + this.disabled = true + this.view + this.solidityMode = false + this.stepOverride = _stepOverride + + this.previousValue = null + } + + render () { + var self = this + var view = yo`
+ +
` + if (!this.view) { + this.view = view + } + return view + } + + init (length) { + var slider = this.view.querySelector('#slider') + slider.setAttribute('max', length - 1) + this.max = length - 1 + this.updateDisabled(length === 0) + this.disabled = length === 0 + this.setValue(0) + } + + onChange (event) { + var value = parseInt(this.view.querySelector('#slider').value) + if (this.stepOverride) { + var correctedValue = this.stepOverride(value) + if (correctedValue !== value) { + this.setValue(correctedValue) + value = correctedValue + } + } + if (value === this.previousValue) return + this.previousValue = value + this.event.trigger('moved', [value]) + } + + setValue (value) { + this.view.querySelector('#slider').value = value + } + + updateDisabled (disabled) { + if (disabled) { + this.view.querySelector('#slider').setAttribute('disabled', true) + } else { + this.view.querySelector('#slider').removeAttribute('disabled') + } + } +} + +module.exports = Slider diff --git a/src/app/debugger/debuggerUI/StepManager.js b/src/app/debugger/debuggerUI/StepManager.js new file mode 100644 index 0000000000..d464b292cc --- /dev/null +++ b/src/app/debugger/debuggerUI/StepManager.js @@ -0,0 +1,205 @@ +'use strict' +var ButtonNavigator = require('./ButtonNavigator') +var Slider = require('./Slider') +var remixLib = require('remix-lib') +var EventManager = remixLib.EventManager +var yo = require('yo-yo') +var util = remixLib.util + +function StepManager (_parent, _traceManager) { + this.event = new EventManager() + this.parent = _parent.debugger + this.traceManager = _traceManager + this.sourceMapByAddress = {} + this.solidityMode = false + + var self = this + this.parent.event.register('newTraceLoaded', this, function () { + if (!this.slider) return + self.traceManager.getLength(function (error, length) { + if (error) { + console.log(error) + } else { + self.slider.init(length) + self.init() + } + }) + }) + + this.slider = new Slider(this.traceManager, (step) => { + return this.solidityMode ? this.resolveToReducedTrace(step, 0) : step + }) + this.slider.event.register('moved', this, function (step) { + self.sliderMoved(step) + }) + + this.parent.callTree.event.register('callTreeReady', () => { + if (!this.slider) return + if (this.parent.callTree.functionCallStack.length) { + this.jumpTo(this.parent.callTree.functionCallStack[0]) + } + }) + + this.buttonNavigator = new ButtonNavigator(_parent, this.traceManager) + this.buttonNavigator.event.register('stepIntoBack', this, function () { + self.stepIntoBack() + }) + this.buttonNavigator.event.register('stepIntoForward', this, function () { + self.stepIntoForward() + }) + this.buttonNavigator.event.register('stepOverBack', this, function () { + self.stepOverBack() + }) + this.buttonNavigator.event.register('stepOverForward', this, function () { + self.stepOverForward() + }) + this.buttonNavigator.event.register('jumpOut', this, function () { + self.jumpOut() + }) + this.buttonNavigator.event.register('jumpToException', this, function (exceptionIndex) { + self.jumpTo(exceptionIndex) + }) + this.buttonNavigator.event.register('jumpNextBreakpoint', (exceptionIndex) => { + self.parent.breakpointManager.jumpNextBreakpoint(_parent.currentStepIndex, true) + }) + this.buttonNavigator.event.register('jumpPreviousBreakpoint', (exceptionIndex) => { + self.parent.breakpointManager.jumpPreviousBreakpoint(_parent.currentStepIndex, true) + }) +} + +StepManager.prototype.remove = function () { + // used to stop listenning on event. bad and should be "refactored" + this.slider.view = null + this.slider = null + this.buttonNavigator.view = null + this.buttonNavigator = null +} + +StepManager.prototype.resolveToReducedTrace = function (value, incr) { + if (this.parent.callTree.reducedTrace.length) { + var nextSource = util.findClosestIndex(value, this.parent.callTree.reducedTrace) + nextSource = nextSource + incr + if (nextSource <= 0) { + nextSource = 0 + } else if (nextSource > this.parent.callTree.reducedTrace.length) { + nextSource = this.parent.callTree.reducedTrace.length - 1 + } + return this.parent.callTree.reducedTrace[nextSource] + } + return value +} + +StepManager.prototype.render = function () { + return yo`
+ ${this.slider.render()} + ${this.buttonNavigator.render()} +
` +} + +StepManager.prototype.reset = function () { + this.slider.setValue(0) + this.currentStepIndex = 0 + this.buttonNavigator.reset() +} + +StepManager.prototype.init = function () { + this.slider.setValue(0) + this.changeState(0) +} + +StepManager.prototype.newTraceAvailable = function () { + this.init() +} + +StepManager.prototype.jumpTo = function (step) { + if (!this.traceManager.inRange(step)) { + return + } + this.slider.setValue(step) + this.changeState(step) +} + +StepManager.prototype.sliderMoved = function (step) { + if (!this.traceManager.inRange(step)) { + return + } + this.changeState(step) +} + +StepManager.prototype.stepIntoForward = function () { + if (!this.traceManager.isLoaded()) { + return + } + var step = this.currentStepIndex + if (this.solidityMode) { + step = this.resolveToReducedTrace(step, 1) + } else { + step += 1 + } + if (!this.traceManager.inRange(step)) { + return + } + this.slider.setValue(step) + this.changeState(step) +} + +StepManager.prototype.stepIntoBack = function () { + if (!this.traceManager.isLoaded()) { + return + } + var step = this.currentStepIndex + if (this.solidityMode) { + step = this.resolveToReducedTrace(step, -1) + } else { + step -= 1 + } + if (!this.traceManager.inRange(step)) { + return + } + this.slider.setValue(step) + this.changeState(step) +} + +StepManager.prototype.stepOverForward = function () { + if (!this.traceManager.isLoaded()) { + return + } + var step = this.traceManager.findStepOverForward(this.currentStepIndex) + if (this.solidityMode) { + step = this.resolveToReducedTrace(step, 1) + } + this.slider.setValue(step) + this.changeState(step) +} + +StepManager.prototype.stepOverBack = function () { + if (!this.traceManager.isLoaded()) { + return + } + var step = this.traceManager.findStepOverBack(this.currentStepIndex) + if (this.solidityMode) { + step = this.resolveToReducedTrace(step, -1) + } + this.slider.setValue(step) + this.changeState(step) +} + +StepManager.prototype.jumpOut = function () { + if (!this.traceManager.isLoaded()) { + return + } + var step = this.traceManager.findStepOut(this.currentStepIndex) + if (this.solidityMode) { + step = this.resolveToReducedTrace(step, 0) + } + this.slider.setValue(step) + this.changeState(step) +} + +StepManager.prototype.changeState = function (step) { + this.currentStepIndex = step + this.buttonNavigator.stepChanged(step) + this.event.trigger('stepChanged', [step]) +} + +module.exports = StepManager diff --git a/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js b/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js index 26c258edd9..7988addddf 100644 --- a/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js +++ b/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js @@ -1,6 +1,6 @@ 'use strict' // var TxBrowser = require('./TxBrowser') -var StepManager = require('./StepManager') +// var StepManager = require('./StepManager') var VmDebugger = require('./VmDebugger') var yo = require('yo-yo') @@ -91,16 +91,11 @@ EthdebuggerUI.prototype.stepChanged = function (stepIndex) { EthdebuggerUI.prototype.startDebugging = function (blockNumber, txIndex, tx) { const self = this if (this.debugger.traceManager.isLoading) { - return + return false } this.tx = tx - this.stepManager = new StepManager(this, this.debugger.traceManager) - this.stepManager.event.register('stepChanged', this, function (stepIndex) { - self.stepChanged(stepIndex) - }) - this.debugger.codeManager.event.register('changed', this, (code, address, instIndex) => { self.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, this.currentStepIndex, this.debugger.solidityProxy.contracts, (error, sourceLocation) => { if (!error) { @@ -109,12 +104,14 @@ EthdebuggerUI.prototype.startDebugging = function (blockNumber, txIndex, tx) { }) }) + return true +} + +EthdebuggerUI.prototype.createAndAddVmDebugger = function () { this.vmDebugger = new VmDebugger(this, this.debugger.traceManager, this.debugger.codeManager, this.debugger.solidityProxy, this.debugger.callTree) yo.update(this.debuggerHeadPanelsView, this.vmDebugger.renderHead()) yo.update(this.debuggerPanelsView, this.vmDebugger.render()) yo.update(this.stepManagerView, this.stepManager.render()) - - this.debugger.debug(tx) } module.exports = EthdebuggerUI From b6f0f8c62f5e5ceeeaa473e2090460b2a538d155 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 09:22:43 -0400 Subject: [PATCH 024/170] remove unused method --- src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js b/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js index 7988addddf..af50bcb465 100644 --- a/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js +++ b/src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js @@ -42,10 +42,6 @@ function EthdebuggerUI (opts) { }) } -EthdebuggerUI.prototype.setBreakpointManager = function (breakpointManager) { - this.breakpointManager = breakpointManager -} - EthdebuggerUI.prototype.updateWeb3Reference = function (web3) { if (!this.txBrowser) return this.txBrowser.web3 = web3 || executionContext.web3() From 55afb5c4b731cacee80275ef31f4b891b358e5b4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 09:31:48 -0400 Subject: [PATCH 025/170] remove unused parameter --- src/app/debugger/debuggerUI/Slider.js | 3 +-- src/app/debugger/debuggerUI/StepManager.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/app/debugger/debuggerUI/Slider.js b/src/app/debugger/debuggerUI/Slider.js index 10ca255d81..b89e78034a 100644 --- a/src/app/debugger/debuggerUI/Slider.js +++ b/src/app/debugger/debuggerUI/Slider.js @@ -4,9 +4,8 @@ var EventManager = remixLib.EventManager var yo = require('yo-yo') class Slider { - constructor (_traceManager, _stepOverride) { + constructor (_stepOverride) { this.event = new EventManager() - this.traceManager = _traceManager this.max this.disabled = true this.view diff --git a/src/app/debugger/debuggerUI/StepManager.js b/src/app/debugger/debuggerUI/StepManager.js index d464b292cc..4c818252d2 100644 --- a/src/app/debugger/debuggerUI/StepManager.js +++ b/src/app/debugger/debuggerUI/StepManager.js @@ -26,7 +26,7 @@ function StepManager (_parent, _traceManager) { }) }) - this.slider = new Slider(this.traceManager, (step) => { + this.slider = new Slider((step) => { return this.solidityMode ? this.resolveToReducedTrace(step, 0) : step }) this.slider.event.register('moved', this, function (step) { From 9e2f69c3588838d1acd6fb802a3ad32766967e88 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 10:08:35 -0400 Subject: [PATCH 026/170] remove unused variable --- src/app/debugger/debuggerUI/Slider.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/debugger/debuggerUI/Slider.js b/src/app/debugger/debuggerUI/Slider.js index b89e78034a..f3b1a0383d 100644 --- a/src/app/debugger/debuggerUI/Slider.js +++ b/src/app/debugger/debuggerUI/Slider.js @@ -9,7 +9,6 @@ class Slider { this.max this.disabled = true this.view - this.solidityMode = false this.stepOverride = _stepOverride this.previousValue = null From 1c8c01121d3a3cce8a50fdeededd1f08b436f927 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 10:14:28 -0400 Subject: [PATCH 027/170] remove method/simplify --- src/app/debugger/debuggerUI/Slider.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/app/debugger/debuggerUI/Slider.js b/src/app/debugger/debuggerUI/Slider.js index f3b1a0383d..f030d77e67 100644 --- a/src/app/debugger/debuggerUI/Slider.js +++ b/src/app/debugger/debuggerUI/Slider.js @@ -38,8 +38,14 @@ class Slider { var slider = this.view.querySelector('#slider') slider.setAttribute('max', length - 1) this.max = length - 1 - this.updateDisabled(length === 0) - this.disabled = length === 0 + this.disabled = (length === 0) + + if (this.disabled) { + this.view.querySelector('#slider').setAttribute('disabled', true) + } else { + this.view.querySelector('#slider').removeAttribute('disabled') + } + this.setValue(0) } @@ -61,13 +67,6 @@ class Slider { this.view.querySelector('#slider').value = value } - updateDisabled (disabled) { - if (disabled) { - this.view.querySelector('#slider').setAttribute('disabled', true) - } else { - this.view.querySelector('#slider').removeAttribute('disabled') - } - } } module.exports = Slider From fdc2864fed8e409d86a3cb1bcd64c8dbb5090600 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 10:28:47 -0400 Subject: [PATCH 028/170] rename method --- src/app/debugger/debuggerUI/Slider.js | 5 ++++- src/app/debugger/debuggerUI/StepManager.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/debugger/debuggerUI/Slider.js b/src/app/debugger/debuggerUI/Slider.js index f030d77e67..b3f84c7fce 100644 --- a/src/app/debugger/debuggerUI/Slider.js +++ b/src/app/debugger/debuggerUI/Slider.js @@ -34,7 +34,7 @@ class Slider { return view } - init (length) { + setSliderLength (length) { var slider = this.view.querySelector('#slider') slider.setAttribute('max', length - 1) this.max = length - 1 @@ -51,6 +51,7 @@ class Slider { onChange (event) { var value = parseInt(this.view.querySelector('#slider').value) + if (this.stepOverride) { var correctedValue = this.stepOverride(value) if (correctedValue !== value) { @@ -58,8 +59,10 @@ class Slider { value = correctedValue } } + if (value === this.previousValue) return this.previousValue = value + this.event.trigger('moved', [value]) } diff --git a/src/app/debugger/debuggerUI/StepManager.js b/src/app/debugger/debuggerUI/StepManager.js index 4c818252d2..7e223e1e7a 100644 --- a/src/app/debugger/debuggerUI/StepManager.js +++ b/src/app/debugger/debuggerUI/StepManager.js @@ -20,7 +20,7 @@ function StepManager (_parent, _traceManager) { if (error) { console.log(error) } else { - self.slider.init(length) + self.slider.setSliderLength(length) self.init() } }) From 44b05c06c6ee0266a9706fa10ea47dbdc9439a28 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 11:45:52 -0400 Subject: [PATCH 029/170] button navigator step changed --- .../debugger/debuggerUI/ButtonNavigator.js | 58 +++++++++++-------- src/app/debugger/debuggerUI/Slider.js | 2 +- src/app/debugger/debuggerUI/StepManager.js | 21 ++++++- 3 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/app/debugger/debuggerUI/ButtonNavigator.js b/src/app/debugger/debuggerUI/ButtonNavigator.js index 12c9e4fa54..5710dc1f53 100644 --- a/src/app/debugger/debuggerUI/ButtonNavigator.js +++ b/src/app/debugger/debuggerUI/ButtonNavigator.js @@ -88,8 +88,6 @@ function ButtonNavigator (_parent, _traceManager) { this.view } -module.exports = ButtonNavigator - ButtonNavigator.prototype.render = function () { var self = this var view = yo`
@@ -130,29 +128,43 @@ ButtonNavigator.prototype.reset = function () { resetWarning(this) } -ButtonNavigator.prototype.stepChanged = function (step) { +ButtonNavigator.prototype.stepChanged = function (stepState, jumpOutDisabled) { + if (stepState === 'invalid') { + // TODO: probably not necessary, already implicit done in the next steps + this.reset() + this.updateAll() + return + } + + this.intoBackDisabled = (stepState === 'initial') + this.overBackDisabled = (stepState === 'initial') + this.jumpPreviousBreakpointDisabled = (stepState === 'initial') + this.jumpNextBreakpointDisabled = (stepState === 'end') + this.intoForwardDisabled = (stepState === 'end') + this.overForwardDisabled = (stepState === 'end') + this.jumpNextBreakpointDisabled = jumpOutDisabled + + this.updateAll() +} + +ButtonNavigator.prototype.old_stepChanged = function (step) { + var self = this this.intoBackDisabled = step <= 0 this.overBackDisabled = step <= 0 - if (!this.traceManager) { - this.intoForwardDisabled = true - this.overForwardDisabled = true - } else { - var self = this - this.traceManager.getLength(function (error, length) { - if (error) { - self.reset() - console.log(error) - } else { - self.jumpNextBreakpointDisabled = step >= length - 1 - self.jumpPreviousBreakpointDisabled = step <= 0 - self.intoForwardDisabled = step >= length - 1 - self.overForwardDisabled = step >= length - 1 - var stepOut = self.traceManager.findStepOut(step) - self.jumpOutDisabled = stepOut === step - } - self.updateAll() - }) - } + this.traceManager.getLength(function (error, length) { + if (error) { + console.log(error) + self.reset() + } else { + self.jumpNextBreakpointDisabled = step >= length - 1 + self.jumpPreviousBreakpointDisabled = step <= 0 + self.intoForwardDisabled = step >= length - 1 + self.overForwardDisabled = step >= length - 1 + var stepOut = self.traceManager.findStepOut(step) + self.jumpOutDisabled = stepOut === step + } + self.updateAll() + }) this.updateAll() } diff --git a/src/app/debugger/debuggerUI/Slider.js b/src/app/debugger/debuggerUI/Slider.js index b3f84c7fce..3ca7eb8ffc 100644 --- a/src/app/debugger/debuggerUI/Slider.js +++ b/src/app/debugger/debuggerUI/Slider.js @@ -63,7 +63,7 @@ class Slider { if (value === this.previousValue) return this.previousValue = value - this.event.trigger('moved', [value]) + this.event.trigger('sliderMoved', [value]) } setValue (value) { diff --git a/src/app/debugger/debuggerUI/StepManager.js b/src/app/debugger/debuggerUI/StepManager.js index 7e223e1e7a..ed8edafb68 100644 --- a/src/app/debugger/debuggerUI/StepManager.js +++ b/src/app/debugger/debuggerUI/StepManager.js @@ -29,7 +29,7 @@ function StepManager (_parent, _traceManager) { this.slider = new Slider((step) => { return this.solidityMode ? this.resolveToReducedTrace(step, 0) : step }) - this.slider.event.register('moved', this, function (step) { + this.slider.event.register('sliderMoved', this, function (step) { self.sliderMoved(step) }) @@ -197,8 +197,25 @@ StepManager.prototype.jumpOut = function () { } StepManager.prototype.changeState = function (step) { + const self = this this.currentStepIndex = step - this.buttonNavigator.stepChanged(step) + + this.traceManager.getLength(function (error, length) { + let stepState = 'valid' + + if (error) { + stepState = 'invalid' + } else if (step <= 0) { + stepState = 'initial' + } else if (step >= length - 1) { + stepState = 'end' + } + + let jumpOutDisabled = (step === self.traceManager.findStepOut(step)) + + self.buttonNavigator.stepChanged(stepState, jumpOutDisabled) + }) + this.event.trigger('stepChanged', [step]) } From 3d351d5404f9c0c2917c3a08dc9e9fd41261cec9 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 11:46:07 -0400 Subject: [PATCH 030/170] remove unused code --- .../debugger/debuggerUI/ButtonNavigator.js | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/src/app/debugger/debuggerUI/ButtonNavigator.js b/src/app/debugger/debuggerUI/ButtonNavigator.js index 5710dc1f53..884880e617 100644 --- a/src/app/debugger/debuggerUI/ButtonNavigator.js +++ b/src/app/debugger/debuggerUI/ButtonNavigator.js @@ -147,27 +147,6 @@ ButtonNavigator.prototype.stepChanged = function (stepState, jumpOutDisabled) { this.updateAll() } -ButtonNavigator.prototype.old_stepChanged = function (step) { - var self = this - this.intoBackDisabled = step <= 0 - this.overBackDisabled = step <= 0 - this.traceManager.getLength(function (error, length) { - if (error) { - console.log(error) - self.reset() - } else { - self.jumpNextBreakpointDisabled = step >= length - 1 - self.jumpPreviousBreakpointDisabled = step <= 0 - self.intoForwardDisabled = step >= length - 1 - self.overForwardDisabled = step >= length - 1 - var stepOut = self.traceManager.findStepOut(step) - self.jumpOutDisabled = stepOut === step - } - self.updateAll() - }) - this.updateAll() -} - ButtonNavigator.prototype.updateAll = function () { this.updateDisabled('intoback', this.intoBackDisabled) this.updateDisabled('overback', this.overBackDisabled) From a7598b68b6c1f29ede03ce8dd805397ee9e2ecfc Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 13:20:22 -0400 Subject: [PATCH 031/170] remove logic to set revertPoint and reason from button navigator into caller --- .../debugger/debuggerUI/ButtonNavigator.js | 53 +++++-------------- src/app/debugger/debuggerUI/StepManager.js | 39 ++++++++++++++ 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/src/app/debugger/debuggerUI/ButtonNavigator.js b/src/app/debugger/debuggerUI/ButtonNavigator.js index 884880e617..59e09a5328 100644 --- a/src/app/debugger/debuggerUI/ButtonNavigator.js +++ b/src/app/debugger/debuggerUI/ButtonNavigator.js @@ -49,42 +49,6 @@ function ButtonNavigator (_parent, _traceManager) { this.traceManager = _traceManager this.currentCall = null this.revertionPoint = null - - _parent.event.register('indexChanged', this, (index) => { - if (!this.view) return - if (index < 0) return - if (_parent.currentStepIndex !== index) return - - this.traceManager.buildCallPath(index, (error, callsPath) => { - if (error) { - console.log(error) - resetWarning(this) - } else { - this.currentCall = callsPath[callsPath.length - 1] - if (this.currentCall.reverted) { - this.revertionPoint = this.currentCall.return - this.view.querySelector('#reverted').style.display = 'block' - this.view.querySelector('#reverted #outofgas').style.display = this.currentCall.outOfGas ? 'inline' : 'none' - this.view.querySelector('#reverted #parenthasthrown').style.display = 'none' - } else { - var k = callsPath.length - 2 - while (k >= 0) { - var parent = callsPath[k] - if (parent.reverted) { - this.revertionPoint = parent.return - this.view.querySelector('#reverted').style.display = 'block' - this.view.querySelector('#reverted #parenthasthrown').style.display = parent ? 'inline' : 'none' - this.view.querySelector('#reverted #outofgas').style.display = 'none' - return - } - k-- - } - resetWarning(this) - } - } - }) - }) - this.view } @@ -125,7 +89,7 @@ ButtonNavigator.prototype.reset = function () { this.jumpOutDisabled = true this.jumpNextBreakpointDisabled = true this.jumpPreviousBreakpointDisabled = true - resetWarning(this) + this.resetWarning('') } ButtonNavigator.prototype.stepChanged = function (stepState, jumpOutDisabled) { @@ -166,10 +130,17 @@ ButtonNavigator.prototype.updateDisabled = function (id, disabled) { } } -function resetWarning (self) { - self.view.querySelector('#reverted #outofgas').style.display = 'none' - self.view.querySelector('#reverted #parenthasthrown').style.display = 'none' - self.view.querySelector('#reverted').style.display = 'none' +ButtonNavigator.prototype.resetAndCheckRevertionPoint = function (revertedReason, revertionPoint) { + if (revertionPoint) { + this.revertionPoint = revertionPoint + } + this.resetWarning(revertedReason) +} + +ButtonNavigator.prototype.resetWarning = function (revertedReason) { + this.view.querySelector('#reverted #outofgas').style.display = (revertedReason === 'outofgas') ? 'inline' : 'none' + this.view.querySelector('#reverted #parenthasthrown').style.display = (revertedReason === 'parenthasthrown') ? 'inline' : 'none' + this.view.querySelector('#reverted').style.display = (revertedReason === '') ? 'none' : 'block' } module.exports = ButtonNavigator diff --git a/src/app/debugger/debuggerUI/StepManager.js b/src/app/debugger/debuggerUI/StepManager.js index ed8edafb68..f0d0df3738 100644 --- a/src/app/debugger/debuggerUI/StepManager.js +++ b/src/app/debugger/debuggerUI/StepManager.js @@ -41,6 +41,45 @@ function StepManager (_parent, _traceManager) { }) this.buttonNavigator = new ButtonNavigator(_parent, this.traceManager) + + _parent.event.register('indexChanged', this, (index) => { + // if (!this.view) return + if (index < 0) return + if (_parent.currentStepIndex !== index) return + + self.traceManager.buildCallPath(index, (error, callsPath) => { + if (error) { + console.log(error) + if (self.buttonNavigator) { + self.buttonNavigator.resetWarning('') + } + } else { + self.currentCall = callsPath[callsPath.length - 1] + if (self.currentCall.reverted) { + let revertedReason = self.currentCall.outofgas ? 'outofgas' : '' + if (self.buttonNavigator) { + self.buttonNavigator.resetAndCheckRevertionPoint(revertedReason, self.currentCall.return) + } + } else { + var k = callsPath.length - 2 + while (k >= 0) { + var parent = callsPath[k] + if (parent.reverted) { + let revertedReason = parent ? 'parenthasthrown' : '' + if (self.buttonNavigator) { + return self.buttonNavigator.resetAndCheckRevertionPoint(revertedReason, parent.return) + } + } + k-- + } + if (self.buttonNavigator) { + self.buttonNavigator.resetWarning('') + } + } + } + }) + }) + this.buttonNavigator.event.register('stepIntoBack', this, function () { self.stepIntoBack() }) From d2c791dcbb26679166f3cbbc645e616d963753dd Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 13:23:29 -0400 Subject: [PATCH 032/170] cleanup --- src/app/debugger/debuggerUI/ButtonNavigator.js | 5 ++--- src/app/debugger/debuggerUI/StepManager.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/debugger/debuggerUI/ButtonNavigator.js b/src/app/debugger/debuggerUI/ButtonNavigator.js index 59e09a5328..afd2b03560 100644 --- a/src/app/debugger/debuggerUI/ButtonNavigator.js +++ b/src/app/debugger/debuggerUI/ButtonNavigator.js @@ -36,7 +36,7 @@ var css = csjs` } ` -function ButtonNavigator (_parent, _traceManager) { +function ButtonNavigator () { this.event = new EventManager() this.intoBackDisabled = true this.overBackDisabled = true @@ -46,8 +46,6 @@ function ButtonNavigator (_parent, _traceManager) { this.jumpNextBreakpointDisabled = true this.jumpPreviousBreakpointDisabled = true - this.traceManager = _traceManager - this.currentCall = null this.revertionPoint = null this.view } @@ -131,6 +129,7 @@ ButtonNavigator.prototype.updateDisabled = function (id, disabled) { } ButtonNavigator.prototype.resetAndCheckRevertionPoint = function (revertedReason, revertionPoint) { + // TODO: since this is only used for the jump, this value should instead be outside of the view if (revertionPoint) { this.revertionPoint = revertionPoint } diff --git a/src/app/debugger/debuggerUI/StepManager.js b/src/app/debugger/debuggerUI/StepManager.js index f0d0df3738..4b09398803 100644 --- a/src/app/debugger/debuggerUI/StepManager.js +++ b/src/app/debugger/debuggerUI/StepManager.js @@ -40,7 +40,7 @@ function StepManager (_parent, _traceManager) { } }) - this.buttonNavigator = new ButtonNavigator(_parent, this.traceManager) + this.buttonNavigator = new ButtonNavigator() _parent.event.register('indexChanged', this, (index) => { // if (!this.view) return From 6afca782dad6a63b3bc2bbd5ae1c58d527d48689 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 7 Sep 2018 10:48:03 -0400 Subject: [PATCH 033/170] remove tracking of revertion point out of button navigator --- src/app/debugger/debuggerUI/ButtonNavigator.js | 10 +--------- src/app/debugger/debuggerUI/StepManager.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/app/debugger/debuggerUI/ButtonNavigator.js b/src/app/debugger/debuggerUI/ButtonNavigator.js index afd2b03560..fb20442d43 100644 --- a/src/app/debugger/debuggerUI/ButtonNavigator.js +++ b/src/app/debugger/debuggerUI/ButtonNavigator.js @@ -66,7 +66,7 @@ ButtonNavigator.prototype.render = function () {