remove need of using extractValidSourceLocation

pull/3068/head
yann300 2 years ago
parent cf0cf0ea18
commit 42fe88df86
  1. 19
      libs/remix-debug/src/solidity-decoder/internalCallTree.ts
  2. 12
      libs/remix-debug/src/solidity-decoder/solidityProxy.ts
  3. 6
      libs/remix-debug/src/source/sourceLocationTracker.ts

@ -219,20 +219,26 @@ async function buildTree (tree, step, scopeId, isExternalCall, isCreation, funct
let currentSourceLocation = { start: -1, length: -1, file: -1, jump: '-' }
let previousSourceLocation = currentSourceLocation
let previousValidSourceLocation = currentSourceLocation
while (step < tree.traceManager.trace.length) {
let sourceLocation
let validSourceLocation
let newLocation = false
let address
try {
const address = tree.traceManager.getCurrentCalledAddressAt(step)
address = tree.traceManager.getCurrentCalledAddressAt(step)
sourceLocation = await tree.extractSourceLocation(step, address)
validSourceLocation = await tree.extractValidSourceLocation(step, address)
if (!includedSource(sourceLocation, currentSourceLocation)) {
tree.reducedTrace.push(step)
currentSourceLocation = sourceLocation
newLocation = true
}
const amountOfSources = tree.sourceLocationTracker.getTotalAmountOfSources(address, tree.solidityProxy.contracts)
if (tree.sourceLocationTracker.isInvalidSourceLocation(currentSourceLocation, amountOfSources)) { // file is -1 or greater than amount of sources
validSourceLocation = previousValidSourceLocation
} else
validSourceLocation = currentSourceLocation
} catch (e) {
return { outStep: step, error: 'InternalCallTree - Error resolving source location. ' + step + ' ' + e }
}
@ -261,7 +267,7 @@ async function buildTree (tree, step, scopeId, isExternalCall, isCreation, funct
}
}
const contractObj = await tree.solidityProxy.contractObjectAt(step)
const contractObj = await tree.solidityProxy.contractObjectAtAddress(address)
const generatedSources = getGeneratedSources(tree, scopeId, contractObj)
const functionDefinition = resolveFunctionDefinition(tree, sourceLocation, generatedSources)
@ -292,6 +298,7 @@ async function buildTree (tree, step, scopeId, isExternalCall, isCreation, funct
await includeVariableDeclaration(tree, step, sourceLocation, scopeId, contractObj, generatedSources)
}
previousSourceLocation = sourceLocation
previousValidSourceLocation = validSourceLocation
step++
}
}

@ -47,8 +47,18 @@ export class SolidityProxy {
* @param {Int} vmTraceIndex - index in the vm trave where to resolve the executed contract name
* @param {Function} cb - callback returns (error, contractName)
*/
async contractObjectAt (vmTraceIndex) {
async contractObjectAt (vmTraceIndex: number) {
const address = this.getCurrentCalledAddressAt(vmTraceIndex)
return this.contractObjectAtAddress(address)
}
/**
* retrieve the compiled contract name at the @arg vmTraceIndex (cached)
*
* @param {Int} vmTraceIndex - index in the vm trave where to resolve the executed contract name
* @param {Function} cb - callback returns (error, contractName)
*/
async contractObjectAtAddress (address: string) {
if (this.cache.contractObjectByAddress[address]) {
return this.cache.contractObjectByAddress[address]
}

@ -87,13 +87,17 @@ export class SourceLocationTracker {
(map.file > amountOfSources - 1) this indicates the current file index exceed the total number of files.
this happens when generated sources should not be considered.
*/
while (vmtraceStepIndex >= 0 && (map.file === -1 || map.file > amountOfSources - 1)) {
while (vmtraceStepIndex >= 0 && this.isInvalidSourceLocation(map, amountOfSources)) {
map = await this.getSourceLocationFromVMTraceIndex(address, vmtraceStepIndex, contracts)
vmtraceStepIndex = vmtraceStepIndex - 1
}
return map
}
isInvalidSourceLocation (sourceLocation, amountOfSources) {
return sourceLocation.file === -1 || sourceLocation.file > amountOfSources - 1
}
async getValidSourceLocationFromVMTraceIndexFromCache (address: string, vmtraceStepIndex: number, contracts: any, cache: Map<number, any>) {
const amountOfSources = this.getTotalAmountOfSources(address, contracts)
let map: any = { file: -1 }

Loading…
Cancel
Save