使用 XCode 进行调试
使用 XCode 进行调试
¥Debugging with XCode
生成用于调试源的 xcode 项目(无法从 xcode 构建代码)
¥Generate xcode project for debugging sources (cannot build code from xcode)
使用 --ide=xcode 参数运行 gn gen
。
¥Run gn gen
with the --ide=xcode argument.
$ gn gen out/Testing --ide=xcode
这将生成 electro.ninja.xcworkspace。你必须打开此工作区才能设置断点并进行检查。
¥This will generate the electron.ninja.xcworkspace. You will have to open this workspace to set breakpoints and inspect.
有关使用 GN 生成 IDE 项目的更多信息,请参阅 gn help gen
。
¥See gn help gen
for more information on generating IDE projects with GN.
调试和断点
¥Debugging and breakpoints
构建后启动 Electron 应用。现在,你可以打开上面创建的 xcode 工作区,并通过“调试”>“附加到进程”>“Electron 调试”菜单附加到 Electron 进程。[注意:如果你想调试渲染器进程,你还需要附加到 Electron Helper。]
¥Launch Electron app after build. You can now open the xcode workspace created above and attach to the Electron process through the Debug > Attach To Process > Electron debug menu. [Note: If you want to debug the renderer process, you need to attach to the Electron Helper as well.]
你现在可以在任何索引文件中设置断点。但是,你将无法直接在 Chromium 源中设置断点。要在 Chromium 源中设置断点,可以选择“调试”>“断点”>“创建符号断点”,然后将任意函数名称设置为符号。这将为所有具有该名称的函数(如果有多个类)设置断点。你还可以在附加调试器之前执行设置断点的步骤,但是,在调试器附加到应用之前,符号断点函数的实际断点可能不会显示。
¥You can now set breakpoints in any of the indexed files. However, you will not be able to set breakpoints directly in the Chromium source. To set break points in the Chromium source, you can choose Debug > Breakpoints > Create Symbolic Breakpoint and set any function name as the symbol. This will set the breakpoint for all functions with that name, from all the classes if there are more than one. You can also do this step of setting break points prior to attaching the debugger, however, actual breakpoints for symbolic breakpoint functions may not show up until the debugger is attached to the app.