Commit cccfc472 authored by chriseth's avatar chriseth Committed by GitHub

Merge pull request #186 from ethereum/fixvarsinstorage

Fix decode locals from storage
parents 22859590 9fc9344c
...@@ -254,12 +254,12 @@ function getStructMembers (type, stateDefinitions, contractName, location) { ...@@ -254,12 +254,12 @@ function getStructMembers (type, stateDefinitions, contractName, location) {
* @return {String} returns the token type (used to instanciate the right decoder) (uint[2] storage ref[2] will return 'array', uint256 will return uintX) * @return {String} returns the token type (used to instanciate the right decoder) (uint[2] storage ref[2] will return 'array', uint256 will return uintX)
*/ */
function typeClass (fullType) { function typeClass (fullType) {
if (fullType.indexOf(']') !== -1) {
return 'array'
}
if (fullType.indexOf('mapping') === 0) { if (fullType.indexOf('mapping') === 0) {
return 'mapping' return 'mapping'
} }
if (fullType.indexOf(']') !== -1) {
return 'array'
}
if (fullType.indexOf(' ') !== -1) { if (fullType.indexOf(' ') !== -1) {
fullType = fullType.split(' ')[0] fullType = fullType.split(' ')[0]
} }
......
'use strict' 'use strict'
function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory) { function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory, storage) {
var scope = internalTreeCall.findScope(vmtraceIndex) var scope = internalTreeCall.findScope(vmtraceIndex)
if (!scope) { if (!scope) {
var error = { 'message': 'Can\'t display locals. reason: compilation result might not have been provided' } 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) { ...@@ -11,7 +11,7 @@ function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory) {
for (var local in scope.locals) { for (var local in scope.locals) {
let variable = scope.locals[local] let variable = scope.locals[local]
if (variable.stackDepth < stack.length) { if (variable.stackDepth < stack.length) {
locals[variable.name] = variable.type.decodeFromStack(variable.stackDepth, stack, memory) locals[variable.name] = variable.type.decodeFromStack(variable.stackDepth, stack, memory, storage)
} }
} }
return locals return locals
......
'use strict' 'use strict'
var util = require('./util')
class RefType { class RefType {
constructor (storageSlots, storageBytes, typeName, location) { constructor (storageSlots, storageBytes, typeName, location) {
...@@ -29,10 +30,11 @@ class RefType { ...@@ -29,10 +30,11 @@ class RefType {
storage = {} // TODO this is a fallback, should manage properly locals store in storage storage = {} // TODO this is a fallback, should manage properly locals store in storage
} }
var offset = stack[stack.length - 1 - stackDepth] var offset = stack[stack.length - 1 - stackDepth]
offset = parseInt(offset, 16)
if (this.isInStorage()) { if (this.isInStorage()) {
offset = util.toBN(offset)
return this.decodeFromStorage({ offset: 0, slot: offset }, storage) return this.decodeFromStorage({ offset: 0, slot: offset }, storage)
} else if (this.isInMemory()) { } else if (this.isInMemory()) {
offset = parseInt(offset, 16)
return this.decodeFromMemoryInternal(offset, memory) return this.decodeFromMemoryInternal(offset, memory)
} else { } else {
return { return {
......
...@@ -47,8 +47,12 @@ class SolidityLocals { ...@@ -47,8 +47,12 @@ class SolidityLocals {
var stack = result[0].value var stack = result[0].value
var memory = result[1].value var memory = result[1].value
try { try {
var locals = localDecoder.solidityLocals(index, this.internalTreeCall, stack, memory) this.traceManager.getStorageAt(index, this.parent.tx, (error, storage) => {
this.basicPanel.update(locals) if (!error) {
var locals = localDecoder.solidityLocals(index, this.internalTreeCall, stack, memory, storage)
this.basicPanel.update(locals)
}
})
} catch (e) { } catch (e) {
warningDiv.innerHTML = e.message warningDiv.innerHTML = e.message
} }
......
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