Skip to content

Commit 49addc0

Browse files
author
ci-bot
committed
rollback previous change and check locals on DUP
1 parent 504d33d commit 49addc0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

libs/remix-debug/src/solidity-decoder/helpers/callTreeHelper.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ export async function includeVariableDeclaration (tree: InternalCallTree, step,
194194
for (const variableDeclaration of variableDeclarations) {
195195
if (variableDeclaration) {
196196
try {
197+
// check if already processed
198+
if (tree.scopes[scopeId] && tree.scopes[scopeId].locals && tree.scopes[scopeId].locals[variableDeclaration.name]) continue
199+
197200
const stack = tree.traceManager.getStackAt(step)
198201
// the stack length at this point is where the value of the new local variable will be stored.
199202
// so, either this is the direct value, or the offset in memory. That depends on the type.
@@ -253,21 +256,22 @@ export async function includeVariableDeclaration (tree: InternalCallTree, step,
253256
Without the fix below the second PUSH will register the var at index 4.
254257
That isn't a really good way of fixing this, need to find a better solution.
255258
*/
259+
/*
256260
try {
257261
const symbolicStack = tree.symbolicStackManager.getStackAtStep(step)
258262
if (symbolicStack && symbolicStack.length && symbolicStack[symbolicStack.length - 1] &&
259263
symbolicStack && symbolicStack.length && symbolicStack[symbolicStack.length - 2]) {
260264
const testDup = symbolicStack[symbolicStack.length - 1]
261265
const testPush = symbolicStack[symbolicStack.length - 2]
262266
if (testDup.originOp && testDup.kind && testDup.kind === 'intermediate' && testDup.originOp.startsWith('DUP') &&
263-
testPush.kind && testPush.kind === 'variable' && testPush.originStep === step - 2) {
267+
testPush.kind && (testPush.kind === 'variable' || testPush.kind === 'return_value')) {
264268
console.warn('applying stack fix', step, symbolicStack)
265269
stackIndex = stack.length - 1
266270
}
267271
}
268272
} catch (e) {
269273
console.warn(e)
270-
}
274+
}*/
271275

272276
// Bind variable to symbolic stack with appropriate lifecycle
273277
const variable = isReturnParamDeclaration ? existingReturnParam : newVar

libs/remix-debug/src/solidity-decoder/internalCallTree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ async function buildTree (tree: InternalCallTree, step, scopeId, isCreation, sou
913913
tree.scopes[scopeId].endExecutionLine = lineColumnPos && lineColumnPos.end ? lineColumnPos.end.line + 1 : undefined
914914
return { outStep: step + 1 }
915915
} else {
916-
if (tree.includeLocalVariables && stepDetail.op && stepDetail.op.startsWith('PUSH')) {
916+
if (tree.includeLocalVariables && stepDetail.op && (stepDetail.op.startsWith('PUSH') || stepDetail.op.startsWith('DUP'))) {
917917
try {
918918
await includeVariableDeclaration(tree, step, sourceLocation, scopeId, contractObj, generatedSources, address, blocksDefinition)
919919
} catch (e) {

0 commit comments

Comments
 (0)