Merge pull request #188 from ethereum/hidelocalsiffuncscope

don't display local var if not declared
pull/7/head
yann300 8 years ago committed by GitHub
commit 84dc68463c
  1. 4
      src/solidity/localDecoder.js
  2. 8
      src/ui/Ethdebugger.js
  3. 15
      src/ui/SolidityLocals.js
  4. 3
      src/util/internalCallTree.js
  5. 2
      test/solidity/localsTests/helper.js

@ -1,6 +1,6 @@
'use strict'
function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory, storage) {
function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory, storage, currentSourceLocation) {
var scope = internalTreeCall.findScope(vmtraceIndex)
if (!scope) {
var error = { 'message': 'Can\'t display locals. reason: compilation result might not have been provided' }
@ -11,7 +11,7 @@ function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory, storage)
var anonymousIncr = 1
for (var local in scope.locals) {
let variable = scope.locals[local]
if (variable.stackDepth < stack.length) {
if (variable.stackDepth < stack.length && variable.sourceLocation.start <= currentSourceLocation.start) {
var name = variable.name
if (name === '') {
name = '<' + anonymousIncr + '>'

@ -52,6 +52,14 @@ function Ethdebugger () {
self.stepChanged(stepIndex)
})
this.vmDebugger = new VmDebugger(this, this.traceManager, this.codeManager, this.solidityProxy, callTree)
this.codeManager.event.register('changed', this, (code, address, instIndex) => {
this.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, this.currentStepIndex, this.solidityProxy.contracts, (error, sourceLocation) => {
if (!error) {
this.event.trigger('sourceLocationChanged', [sourceLocation])
}
})
})
}
Ethdebugger.prototype.web3 = function () {

@ -28,28 +28,21 @@ class SolidityLocals {
}
init () {
this.parent.event.register('indexChanged', this, (index) => {
this.parent.event.register('sourceLocationChanged', this, (sourceLocation) => {
var warningDiv = this.view.querySelector('#warning')
warningDiv.innerHTML = ''
if (index < 0) {
warningDiv.innerHTML = 'invalid step index'
return
}
if (this.parent.currentStepIndex !== index) return
this.traceManager.waterfall([
this.traceManager.getStackAt,
this.traceManager.getMemoryAt],
index,
this.parent.currentStepIndex,
(error, result) => {
if (!error) {
var stack = result[0].value
var memory = result[1].value
try {
this.traceManager.getStorageAt(index, this.parent.tx, (error, storage) => {
this.traceManager.getStorageAt(this.parent.currentStepIndex, this.parent.tx, (error, storage) => {
if (!error) {
var locals = localDecoder.solidityLocals(index, this.internalTreeCall, stack, memory, storage)
var locals = localDecoder.solidityLocals(this.parent.currentStepIndex, this.internalTreeCall, stack, memory, storage, sourceLocation)
this.basicPanel.update(locals)
}
})

@ -132,7 +132,8 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId) {
tree.scopes[scopeId].locals[variableDeclaration.attributes.name] = {
name: variableDeclaration.attributes.name,
type: decodeInfo.parseType(variableDeclaration.attributes.type, states, contractName),
stackDepth: stack.length
stackDepth: stack.length,
sourceLocation: sourceLocation
}
}
})

@ -12,7 +12,7 @@ function decodeLocal (st, index, traceManager, callTree, verifier) {
index,
function (error, result) {
if (!error) {
var locals = localDecoder.solidityLocals(index, callTree, result[0].value, result[1].value)
var locals = localDecoder.solidityLocals(index, callTree, result[0].value, result[1].value, {}, {start: 5000})
verifier(locals)
} else {
st.fail(error)

Loading…
Cancel
Save