fix debugging with source location

pull/1/head
yann300 6 years ago
parent 4afd5e6f00
commit 3ef2e631af
  1. 21
      src/app/debugger/debugger/debugger.js
  2. 3
      src/app/debugger/debuggerUI.js
  3. 1
      src/app/tabs/debugger-tab.js

@ -12,20 +12,23 @@ function Debugger (options) {
this.event = new EventManager() this.event = new EventManager()
this.executionContext = options.executionContext this.executionContext = options.executionContext
// dependencies
this.offsetToLineColumnConverter = options.offsetToLineColumnConverter this.offsetToLineColumnConverter = options.offsetToLineColumnConverter
this.compiler = options.compiler this.compilersArtefacts = options.compilersArtefacts
this.compilerArtefacts = options.compilersArtefacts
this.debugger = new Ethdebugger({ this.debugger = new Ethdebugger({
executionContext: options.executionContext, executionContext: options.executionContext,
compilationResult: () => { compilationResult: () => {
if (this.options.compilersArtefacts['__last']) return this.options.compilersArtefacts['__last'].getData() if (this.compilersArtefacts['__last']) return this.compilersArtefacts['__last'].getData()
return null return null
} }
}) })
this.breakPointManager = new remixLib.code.BreakpointManager(this.debugger, (sourceLocation) => { 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) => { }, (step) => {
self.event.trigger('breakpointStep', [step]) self.event.trigger('breakpointStep', [step])
}) })
@ -57,12 +60,16 @@ function Debugger (options) {
Debugger.prototype.registerAndHighlightCodeItem = function (index) { Debugger.prototype.registerAndHighlightCodeItem = function (index) {
const self = this const self = this
// register selected code item, highlight the corresponding source location // 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) => { self.debugger.traceManager.getCurrentCalledAddressAt(index, (error, address) => {
if (error) return console.log(error) 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) { 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]) self.event.trigger('newSourceLocation', [lineColumnPos, rawLocation])
} else { } else {
self.event.trigger('newSourceLocation', [null]) self.event.trigger('newSourceLocation', [null])

@ -34,7 +34,8 @@ class DebuggerUI {
this.debugger = new Debugger({ this.debugger = new Debugger({
executionContext: executionContext, executionContext: executionContext,
offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api, 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 this.isActive = false

@ -25,7 +25,6 @@ class DebuggerTab {
self._view = { el: null } self._view = { el: null }
self.data = {} self.data = {}
self._components = {} self._components = {}
// TODO: what is this used for? is repated in debugger.js
self._components.registry = localRegistry || globalRegistry self._components.registry = localRegistry || globalRegistry
} }

Loading…
Cancel
Save