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

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

Loading…
Cancel
Save