pull/3205/head
yann300 2 years ago committed by Aniket
parent 5acf4105d7
commit 4f7ffce311
  1. 9
      libs/remix-debug/src/code/breakpointManager.ts
  2. 11
      libs/remix-debug/test/debugger.ts

@ -22,13 +22,12 @@ export class BreakpointManager {
* @param {Object} _debugger - type of EthDebugger
* @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location
*/
constructor ({ traceManager, callTree, solidityProxy, locationToRowConverter }) {
constructor ({ traceManager, callTree, solidityProxy }) {
this.event = new EventManager()
this.traceManager = traceManager
this.callTree = callTree
this.solidityProxy = solidityProxy
this.breakpoints = {}
this.locationToRowConverter = locationToRowConverter
}
setManagers ({ traceManager, callTree, solidityProxy }) {
@ -43,7 +42,7 @@ export class BreakpointManager {
*
*/
async jumpNextBreakpoint (fromStep, defaultToLimit) {
if (!this.locationToRowConverter) {
if (!this.callTree.locationAndOpcodePerVMTraceIndex[fromStep]) {
return console.log('row converter not provided')
}
this.jump(fromStep || 0, 1, defaultToLimit, this.traceManager.trace)
@ -55,7 +54,7 @@ export class BreakpointManager {
*
*/
async jumpPreviousBreakpoint (fromStep, defaultToLimit) {
if (!this.locationToRowConverter) {
if (!this.callTree.locationAndOpcodePerVMTraceIndex[fromStep]) {
return console.log('row converter not provided')
}
this.jump(fromStep || 0, -1, defaultToLimit, this.traceManager.trace)
@ -97,7 +96,7 @@ export class BreakpointManager {
while (currentStep > 0 && currentStep < trace.length) {
try {
previousSourceLocation = sourceLocation
const stepInfo = await this.callTree.locationAndOpcodePerVMTraceIndex[currentStep]
const stepInfo = this.callTree.locationAndOpcodePerVMTraceIndex[currentStep]
sourceLocation = stepInfo.sourceLocation
lineColumn = stepInfo.lineColumnPos
} catch (e) {

@ -168,7 +168,12 @@ contract Ballot {
compilationResult: function () {
return { data: output }
},
web3: web3
web3: web3,
offsetToLineColumnConverter: {
offsetToLineColumn: async (rawLocation) => {
return sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, sourceMappingDecoder.getLinebreakPositions(ballot))
}
}
})
debugManager.callTree.event.register('callTreeReady', () => {
@ -273,9 +278,7 @@ function testDebugging (debugManager) {
tape('breakPointManager', (t) => {
t.plan(2)
const {traceManager, callTree, solidityProxy} = debugManager
var breakPointManager = new BreakpointManager({traceManager, callTree, solidityProxy, locationToRowConverter: async (rawLocation) => {
return sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, sourceMappingDecoder.getLinebreakPositions(ballot))
}})
var breakPointManager = new BreakpointManager({traceManager, callTree, solidityProxy})
breakPointManager.add({fileName: 'test.sol', row: 39})

Loading…
Cancel
Save