0

I'm building an open source Node.js debugger that is an electron app and uses the built in debugger in the render process. Full source: https://github.com/fijiwebdesign/electron-scope/

In the main process I want to launch the script to debug and set a breakpoint on the first line.

I'm following the tests in Electron for chrome debugger api: https://github.com/electron/electron/blob/702352804239f58e5abcd0b96dbd748b68ab0278/spec/api-debugger-spec.js#L77

My code:

win.webContents.debugger.sendCommand(
        'Debugger.setBreakpointByUrl', {
            lineNumber: 0,
            url: './test.js'
        },
        function (err, result){
            if(err){
                console.error('Error:', err)
            }
            console.log('Breakpoint Result: ', result)
        })

Full ref: https://github.com/fijiwebdesign/electron-scope/blob/setBreakpoint/index.js#L51

This logs: Result: { breakpointId: './test.js:0:0', locations: [] }

However, no breakpoint is set. I'm assuming if there were then locations would hold the information.

You can find the branch where I'm trying to set a breakpoint here: https://github.com/fijiwebdesign/electron-scope/tree/setBreakpoint

bucabay
  • 5,235
  • 2
  • 26
  • 37

1 Answers1

1

I think you might need to run Debugger.enable to activate the debugger so that subsequent debugger commands work. However, I'm not familiar with Electron's API, so it's possible that it inherently does.

win.debugger.sendCommand('Debugger.enable', {}, function() {
    setBreakpoint(win);
});
Gideon Pyzer
  • 22,610
  • 7
  • 62
  • 68