Commit 3ef2e631 authored by yann300's avatar yann300

fix debugging with source location

parent 4afd5e6f
......@@ -12,20 +12,23 @@ function Debugger (options) {
this.event = new EventManager()
this.executionContext = options.executionContext
// dependencies
this.offsetToLineColumnConverter = options.offsetToLineColumnConverter
this.compiler = options.compiler
this.compilerArtefacts = options.compilersArtefacts
this.compilersArtefacts = options.compilersArtefacts
this.debugger = new Ethdebugger({
executionContext: options.executionContext,
compilationResult: () => {
if (this.options.compilersArtefacts['__last']) return this.options.compilersArtefacts['__last'].getData()
if (this.compilersArtefacts['__last']) return this.compilersArtefacts['__last'].getData()
return null
}
})
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)
if (!this.compilersArtefacts['__last']) return null
let compilationData = this.compilersArtefacts['__last'].getData()
if (!compilationData) return null
return self.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, compilationData.sources, compilationData.sources)
}, (step) => {
self.event.trigger('breakpointStep', [step])
})
......@@ -57,12 +60,16 @@ function Debugger (options) {
Debugger.prototype.registerAndHighlightCodeItem = function (index) {
const self = this
// register selected code item, highlight the corresponding source location
if (!self._deps.compilersArtefacts['__last']) return
if (!self.compilersArtefacts['__last']) {
self.event.trigger('newSourceLocation', [null])
return
}
var compilerData = self.compilersArtefacts['__last'].getData()
self.debugger.traceManager.getCurrentCalledAddressAt(index, (error, address) => {
if (error) return console.log(error)
self.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, index, self.compiler.lastCompilationResult.data.contracts, function (error, rawLocation) {
self.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, index, compilerData.contracts, function (error, rawLocation) {
if (!error) {
var lineColumnPos = self.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, compilerData.source.sources, compilerData.data.sources)
var lineColumnPos = self.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, compilerData.sources, compilerData.sources)
self.event.trigger('newSourceLocation', [lineColumnPos, rawLocation])
} else {
self.event.trigger('newSourceLocation', [null])
......
......@@ -34,7 +34,8 @@ class DebuggerUI {
this.debugger = new Debugger({
executionContext: executionContext,
offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api,
compiler: this.registry.get('compiler').api
compiler: this.registry.get('compiler').api,
compilersArtefacts: this.registry.get('compilersartefacts').api
})
this.isActive = false
......
......@@ -25,7 +25,6 @@ class DebuggerTab {
self._view = { el: null }
self.data = {}
self._components = {}
// TODO: what is this used for? is repated in debugger.js
self._components.registry = localRegistry || globalRegistry
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment