我正在构建一个开源的Node.js调试器,它是一个电子应用程序,并在渲染过程中使用内置调试器。完整来源:https://github.com/fijiwebdesign/electron-scope/
在主进程中,我希望启动脚本进行调试,并在第一行设置断点。
下面是Electron for chrome调试器api中的测试:https://github.com/electron/electron/blob/702352804239f58e5abcd0b96dbd748b68ab0278/spec/api-debugger-spec.js#L77
我的代码:
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)
})
参考文献:https://github.com/fijiwebdesign/electron-scope/blob/setBreakpoint/index.js#L51
此日志:Result: { breakpointId: './test.js:0:0', locations: [] }
但是,没有设置断点。我猜想如果有的话,地点就会保存这些信息。
您可以在此处找到我尝试设置断点的分支:https://github.com/fijiwebdesign/electron-scope/tree/setBreakpoint
发布于 2017-02-03 20:13:31
我认为您可能需要运行Debugger.enable
来激活调试器,以便后续的调试器命令能够工作。然而,我对Electron的API并不熟悉,所以它有可能天生就熟悉。
win.debugger.sendCommand('Debugger.enable', {}, function() {
setBreakpoint(win);
});
https://stackoverflow.com/questions/42015863
复制相似问题