Commit 3f4965e0 authored by aniket-engg's avatar aniket-engg Committed by Aniket

breakpointManager, eventManager, traceHelper import export updated

parent eec30903
import Web3 from 'web3' import Web3 from 'web3'
const Debugger = require('../debugger/debugger.js') import { Debugger } from '../debugger/debugger.js'
import { EventEmitter } from 'events' import { EventEmitter } from 'events'
export class CmdLine { export class CmdLine {
...@@ -47,13 +47,9 @@ export class CmdLine { ...@@ -47,13 +47,9 @@ export class CmdLine {
getSource () { getSource () {
const lineColumnPos = this.lineColumnPos const lineColumnPos = this.lineColumnPos
if (!lineColumnPos || !lineColumnPos.start) return [] if (!lineColumnPos || !lineColumnPos.start) return []
const content = this.compilation.compilationResult.source.sources[this.filename].content.split('\n') const content = this.compilation.compilationResult.source.sources[this.filename].content.split('\n')
const source = [] const source = []
let line let line
line = content[lineColumnPos.start.line - 2] line = content[lineColumnPos.start.line - 2]
if (line !== undefined) { if (line !== undefined) {
......
'use strict' 'use strict'
const EventManager = require('../eventManager') import { EventManager } from '../eventManager'
const helper = require('../trace/traceHelper') import { isJumpDestInstruction } from '../trace/traceHelper'
/** /**
* allow to manage breakpoint * allow to manage breakpoint
...@@ -72,7 +72,7 @@ export class BreakpointManager { ...@@ -72,7 +72,7 @@ export class BreakpointManager {
// isJumpDestInstruction -> returning from a internal function call // isJumpDestInstruction -> returning from a internal function call
// depthChange -> returning from an external call // depthChange -> returning from an external call
// sourceLocation.start <= previousSourceLocation.start && ... -> previous src is contained in the current one // sourceLocation.start <= previousSourceLocation.start && ... -> previous src is contained in the current one
if ((helper.isJumpDestInstruction(trace[currentStep]) && previousSourceLocation.jump === 'o') || if ((isJumpDestInstruction(trace[currentStep]) && previousSourceLocation.jump === 'o') ||
this.depthChange(currentStep, trace) || this.depthChange(currentStep, trace) ||
(sourceLocation.start <= previousSourceLocation.start && (sourceLocation.start <= previousSourceLocation.start &&
sourceLocation.start + sourceLocation.length >= previousSourceLocation.start + previousSourceLocation.length)) { sourceLocation.start + sourceLocation.length >= previousSourceLocation.start + previousSourceLocation.length)) {
......
'use strict' 'use strict'
export class eventManager { export class EventManager {
registered registered
anonymous anonymous
......
'use strict' 'use strict'
const remixLib = require('@remix-project/remix-lib') import { helpers } from '@remix-project/remix-lib'
const ui = remixLib.helpers.ui const ui = helpers.ui
export = {
// vmTraceIndex has to point to a CALL, CODECALL, ... // vmTraceIndex has to point to a CALL, CODECALL, ...
resolveCalledAddress: function (vmTraceIndex, trace) { export function resolveCalledAddress (vmTraceIndex, trace) {
const step = trace[vmTraceIndex] const step = trace[vmTraceIndex]
if (this.isCreateInstruction(step)) { if (isCreateInstruction(step)) {
return this.contractCreationToken(vmTraceIndex) return contractCreationToken(vmTraceIndex)
} else if (this.isCallInstruction(step)) { } else if (isCallInstruction(step)) {
const stack = step.stack // callcode, delegatecall, ... const stack = step.stack // callcode, delegatecall, ...
return ui.normalizeHexAddress(stack[stack.length - 2]) return ui.normalizeHexAddress(stack[stack.length - 2])
} }
return undefined return undefined
}, }
isCallInstruction: function (step) { export function isCallInstruction (step) {
return step.op === 'CALL' || step.op === 'CALLCODE' || step.op === 'CREATE' || step.op === 'DELEGATECALL' return step.op === 'CALL' || step.op === 'CALLCODE' || step.op === 'CREATE' || step.op === 'DELEGATECALL'
}, }
isCreateInstruction: function (step) { export function isCreateInstruction (step) {
return step.op === 'CREATE' return step.op === 'CREATE'
}, }
isReturnInstruction: function (step) { export function isReturnInstruction (step) {
return step.op === 'RETURN' return step.op === 'RETURN'
}, }
isJumpDestInstruction: function (step) { export function isJumpDestInstruction (step) {
return step.op === 'JUMPDEST' return step.op === 'JUMPDEST'
}, }
isStopInstruction: function (step) { export function isStopInstruction (step) {
return step.op === 'STOP' return step.op === 'STOP'
}, }
isRevertInstruction: function (step) { export function isRevertInstruction (step) {
return step.op === 'REVERT' return step.op === 'REVERT'
}, }
isSSTOREInstruction: function (step) { export function isSSTOREInstruction (step) {
return step.op === 'SSTORE' return step.op === 'SSTORE'
}, }
isSHA3Instruction: function (step) { export function isSHA3Instruction (step) {
return step.op === 'SHA3' return step.op === 'SHA3'
}, }
newContextStorage: function (step) { export function newContextStorage (step) {
return step.op === 'CREATE' || step.op === 'CALL' return step.op === 'CREATE' || step.op === 'CALL'
}, }
isCallToPrecompiledContract: function (index, trace) { export function isCallToPrecompiledContract (index, trace) {
// if stack empty => this is not a precompiled contract // if stack empty => this is not a precompiled contract
const step = trace[index] const step = trace[index]
if (this.isCallInstruction(step)) { if (this.isCallInstruction(step)) {
return index + 1 < trace.length && trace[index + 1].stack.length !== 0 return index + 1 < trace.length && trace[index + 1].stack.length !== 0
} }
return false return false
}, }
contractCreationToken: function (index) { export function contractCreationToken (index) {
return '(Contract Creation - Step ' + index + ')' return '(Contract Creation - Step ' + index + ')'
}, }
isContractCreation: function (address) { export function isContractCreation (address) {
return address.indexOf('(Contract Creation - Step') !== -1 return address.indexOf('(Contract Creation - Step') !== -1
}
} }
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