don't print source automatically; has to be required instead

pull/7/head
Iuri Matias 6 years ago
parent 3d2dbb461f
commit 5d5fcae465
  1. 69
      remix-debug/src/cmdline/index.js
  2. 7
      remix-debug/src/debugger/solidityState.js

@ -1,10 +1,13 @@
var Web3 = require('web3')
var Debugger = require('../debugger/debugger.js')
var ContextManager = require('./contextManager.js')
var EventManager = require('events')
class CmdLine {
constructor () {
this.events = new EventManager()
this.lineColumnPos = null
}
connect (providerType, url) {
@ -36,35 +39,53 @@ class CmdLine {
this.contextManager.switchProvider('debugger_web3')
}
getSource() {
const self = this
console.dir("getSource")
console.dir(this.lineColumnPos)
console.dir(this.filename)
let lineColumnPos = this.lineColumnPos
if (!lineColumnPos || !lineColumnPos.start) return;
let content = self.compilation.lastCompilationResult.source.sources[this.filename].content.split("\n")
let source = []
let line
line = content[lineColumnPos.start.line - 2]
if ( line !== undefined) {
source.push(" " + (lineColumnPos.start.line - 1) + ": " + line)
}
line = content[lineColumnPos.start.line - 1]
if ( line !== undefined) {
source.push(" " + lineColumnPos.start.line + ": " + line)
}
let currentLineNumber = lineColumnPos.start.line
let currentLine = content[currentLineNumber]
source.push("=> " + (currentLineNumber + 1) + ": " + currentLine)
let startLine = lineColumnPos.start.line
for (var i=1; i < 4; i++) {
let line = content[startLine + i]
source.push(" " + (startLine + i + 1) + ": " + line)
}
return source
}
// TODO: is filename really necessary?
startDebug(txNumber, filename) {
const self = this
this.filename = filename
this.debugger.debug(null, txNumber, null, () => {
self.debugger.event.register('newSourceLocation', function (lineColumnPos, rawLocation) {
if (!lineColumnPos || !lineColumnPos.start) return;
let content = self.compilation.lastCompilationResult.source.sources[filename].content.split("\n")
let line
line = content[lineColumnPos.start.line - 2]
if ( line !== undefined) {
console.dir(" " + (lineColumnPos.start.line - 1) + ": " + line)
}
line = content[lineColumnPos.start.line - 1]
if ( line !== undefined) {
console.dir(" " + lineColumnPos.start.line + ": " + line)
}
let currentLineNumber = lineColumnPos.start.line
let currentLine = content[currentLineNumber]
console.dir("=> " + (currentLineNumber + 1) + ": " + currentLine)
let startLine = lineColumnPos.start.line
for (var i=1; i < 4; i++) {
let line = content[startLine + i]
console.dir(" " + (startLine + i + 1) + ": " + line)
}
self.debugger.event.register('newSourceLocation', function (lineColumnPos, _rawLocation) {
self.lineColumnPos = lineColumnPos
self.events.emit("source")
});
self.debugger.vmDebuggerLogic.event.register('solidityState', (data) => {

@ -36,7 +36,12 @@ class DebuggerSolidityState {
}
self.event.trigger('solidityStateUpdating')
decodeTimeout = setTimeout(function () {
self.decode(index)
// necessary due to some states that can crash the debugger
try {
self.decode(index)
} catch(err) {
}
}, 500)
}

Loading…
Cancel
Save