Skip to content

Commit

Permalink
fix debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed Aug 22, 2018
1 parent a252ab7 commit ca47914
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 53 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"npm-run-all": "^4.0.2",
"onchange": "^3.2.1",
"remix-analyzer": "latest",
"remix-lib": "../remix/remix-lib",
"remix-lib": "./remix/remix-lib",
"remix-solidity": "latest",
"remix-tests": "latest",
"remixd": "git+https://github.com/ethereum/remixd.git",
Expand All @@ -58,7 +58,7 @@
},
"dependencies": {
"http-server": "0.9.0",
"remix-debug": "../remix/remix-debug",
"remix-debug": "./remix/remix-debug",
"remixd": "git+https://github.com/ethereum/remixd.git"
},
"repository": {
Expand Down
19 changes: 11 additions & 8 deletions src/app/debugger/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,18 @@ function Debugger (container, sourceHighlighter, localRegistry) {
})

// register selected code item, highlight the corresponding source location
this.debugger.codeManager.event.register('changed', this, function (code, address, index) {
this.debugger_ui.event.register('indexChanged', function (index) {
if (self._deps.compiler.lastCompilationResult) {
self.debugger.callTree.sourceLocationTracker.getSourceLocationFromInstructionIndex(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)
}
self.debugger.traceManager.getCurrentCalledAddressAt(index, (error, address) => {
if (error) return console.log(error)
self.debugger.callTree.sourceLocationTracker.getSourceLocationFromInstructionIndex(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)
}
})
})
}
})
Expand Down
10 changes: 5 additions & 5 deletions src/app/debugger/remix-debugger/src/ui/CalldataPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
var DropdownPanel = require('./DropdownPanel')
var yo = require('yo-yo')

function CalldataPanel (_parent, _traceManager) {
this.parent = _parent
function CalldataPanel (_parentUI, _traceManager) {
this._parentUI = _parentUI
this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Call Data', {json: true})
this.init()
Expand All @@ -15,15 +15,15 @@ CalldataPanel.prototype.render = function () {

CalldataPanel.prototype.init = function () {
var self = this
this.parent.event.register('indexChanged', this, function (index) {
this._parentUI.event.register('indexChanged', this, function (index) {
if (index < 0) return
if (self.parent.currentStepIndex !== index) return
if (self._parentUI.currentStepIndex !== index) return

self.traceManager.getCallDataAt(index, function (error, calldata) {
if (error) {
self.basicPanel.update({})
console.log(error)
} else if (self.parent.currentStepIndex === index) {
} else if (self._parentUI.currentStepIndex === index) {
self.basicPanel.update(calldata)
}
})
Expand Down
36 changes: 18 additions & 18 deletions src/app/debugger/remix-debugger/src/ui/EthdebuggerUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,7 @@ function EthdebuggerUI (opts) {
this.txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) {
self.unLoad()
})
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) {
self.event.trigger('sourceLocationChanged', [sourceLocation])
}
})
})
}

EthdebuggerUI.prototype.setManagers = function () {
Expand Down Expand Up @@ -186,11 +175,11 @@ EthdebuggerUI.prototype.debug = function (tx) {
}

EthdebuggerUI.prototype.render = function () {
var view = yo`<div>
<div class="${css.innerShift}">
this.browserView = yo`<div class="${css.innerShift}">
${this.txBrowser.render()}
${this.stepManager.render()}
</div>
</div>`
var view = yo`<div>
${this.browserView}
<div class="${css.statusMessage}" >${this.statusMessage}</div>
</div>`
if (!this.view) {
Expand Down Expand Up @@ -220,8 +209,6 @@ EthdebuggerUI.prototype.startDebugging = function (blockNumber, txIndex, tx) {
return
}

this.statusMessage = 'Loading trace...'
yo.update(this.view, this.render())
console.log('loading trace...')
this.tx = tx
//this.tx.hash = txIndex
Expand All @@ -232,8 +219,21 @@ EthdebuggerUI.prototype.startDebugging = function (blockNumber, txIndex, tx) {
//this.debugger.addProvider('web3', executionContext.web3())
//this.debugger.switchProvider('web3')

this.vmDebugger = new VmDebugger(this, this.debugger.traceManager, this.debugger.codeManager, this.debugger.solidityProxy, this.debugger.callTree)
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) {
self.event.trigger('sourceLocationChanged', [sourceLocation])
}
})
})

this.vmDebugger = new VmDebugger(this, this.debugger.traceManager, this.debugger.codeManager, this.debugger.solidityProxy, this.debugger.callTree)
this.browserView.appendChild(this.stepManager.render())
this.view.appendChild(this.vmDebugger.render())

this.debugger.debug(tx)
Expand Down
3 changes: 1 addition & 2 deletions src/app/debugger/remix-debugger/src/ui/SolidityState.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ var DropdownPanel = require('./DropdownPanel')
var remixDebug = require('remix-debug')
var stateDecoder = remixDebug.SolidityDecoder.stateDecoder
var solidityTypeFormatter = require('./SolidityTypeFormatter')
var remixLib = require('remix-lib')
var StorageViewer = remixLib.Storage.StorageViewer
var StorageViewer = remixDebug.storage.StorageViewer
var yo = require('yo-yo')

function SolidityState (_parent, _traceManager, _codeManager, _solidityProxy) {
Expand Down
11 changes: 6 additions & 5 deletions src/app/debugger/remix-debugger/src/ui/StepDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
var yo = require('yo-yo')
var DropdownPanel = require('./DropdownPanel')

function StepDetail (_parent, _traceManager) {
this.parent = _parent
function StepDetail (_parentUI, _traceManager) {
this.debugger = _parentUI.debugger
this.parentUI = _parentUI
this.traceManager = _traceManager

this.basicPanel = new DropdownPanel('Step detail', {json: true, displayContentOnly: true})
Expand All @@ -19,17 +20,17 @@ StepDetail.prototype.render = function () {

StepDetail.prototype.init = function () {
var self = this
this.parent.event.register('traceUnloaded', this, function () {
this.debugger.event.register('traceUnloaded', this, function () {
self.detail = initDetail()
self.basicPanel.update(self.detail)
})

this.parent.event.register('newTraceLoaded', this, function () {
this.debugger.event.register('newTraceLoaded', this, function () {
self.detail = initDetail()
self.basicPanel.update(self.detail)
})

this.parent.event.register('indexChanged', this, function (index) {
this.parentUI.event.register('indexChanged', this, function (index) {
if (index < 0) return

self.detail['vm trace step'] = index
Expand Down
4 changes: 1 addition & 3 deletions src/app/debugger/remix-debugger/src/ui/StepManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ StepManager.prototype.resolveToReducedTrace = function (value, incr) {
}

StepManager.prototype.render = function () {
return (
yo`<div>
return yo`<div>
${this.slider.render()}
${this.buttonNavigator.render()}
</div>`
)
}

StepManager.prototype.reset = function () {
Expand Down
4 changes: 2 additions & 2 deletions src/app/debugger/remix-debugger/src/ui/StoragePanel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'
var DropdownPanel = require('./DropdownPanel')
var remixLib = require('remix-lib')
var StorageViewer = remixLib.Storage.StorageViewer
var remixDebug = require('remix-debug')
var StorageViewer = remixDebug.storage.StorageViewer
var yo = require('yo-yo')

function StoragePanel (_parent, _traceManager) {
Expand Down
16 changes: 8 additions & 8 deletions src/app/debugger/remix-debugger/src/ui/VmDebugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ function VmDebugger (_parentUI, _traceManager, _codeManager, _solidityProxy, _ca
let _parent = _parentUI.debugger

this.asmCode = new CodeListView(_parent, _codeManager)
this.stackPanel = new StackPanel(_parent, _traceManager)
this.storagePanel = new StoragePanel(_parent, _traceManager)
this.memoryPanel = new MemoryPanel(_parent, _traceManager)
this.calldataPanel = new CalldataPanel(_parent, _traceManager)
this.callstackPanel = new CallstackPanel(_parent, _traceManager)
this.stepDetail = new StepDetail(_parent, _traceManager)
this.solidityState = new SolidityState(_parent, _traceManager, _codeManager, _solidityProxy)
this.solidityLocals = new SolidityLocals(_parent, _traceManager, _callTree)
this.stackPanel = new StackPanel(_parentUI, _traceManager)
this.storagePanel = new StoragePanel(_parentUI, _traceManager)
this.memoryPanel = new MemoryPanel(_parentUI, _traceManager)
this.calldataPanel = new CalldataPanel(_parentUI, _traceManager)
this.callstackPanel = new CallstackPanel(_parentUI, _traceManager)
this.stepDetail = new StepDetail(_parentUI, _traceManager)
this.solidityState = new SolidityState(_parentUI, _traceManager, _codeManager, _solidityProxy)
this.solidityLocals = new SolidityLocals(_parentUI, _traceManager, _callTree)

/* Return values - */
this.returnValuesPanel = new DropdownPanel('Return Value', {json: true})
Expand Down

0 comments on commit ca47914

Please sign in to comment.