在 macOS 中调试

    • Xcode: In addition to Xcode, you should also install the Xcode command line tools. They include , the default debugger in Xcode on macOS. It supports debugging C, Objective-C and C++ on the desktop and iOS devices and simulator.

    • .lldbinit: Create or edit ~/.lldbinit to allow Chromium code to be properly source-mapped.

    附加并调试 Electron

    To start a debugging session, open up Terminal and start lldb, passing a non-release build of Electron as a parameter.

    1. $ lldb ./out/Testing/Electron.app
    2. (lldb) target create "./out/Testing/Electron.app"

    Relevant code files can be found in ./shell/.

    让我们假设你想调试 app.setName(), 在 browser.cc 中定义为 . 使用 breakpoint 命令进行断点,指定文件和断点位置:

    然后, 启动 Electron:

    1. (lldb) run

    应用程式会立即暂停,因为 Electron 会在启动时设定应用程序名称:

    1. (lldb) frame variable
    2. (atom::Browser *) this = 0x0000000108b14f20
    3. (const string &) name = "Electron": {

    在当前选择的线程中执行源级单步执行, 执行 step (或 s). 这将带你进入 name_override_.empty()。 继续前进,步过,运行 next (或 n).

    NOTE: If you don’t see source code when you think you should, you may not have added the ~/.lldbinit file above.

    要完成此时的调试,运行 process continue。 你也可以继续,直到这个线程中的某一行被命中(线程直到100)。 此命令将在当前帧中运行线程,直到它到达此帧中的行100,或者如果它离开当前帧,则停止。

    现在,如果你打开 Electron 的开发工具并调用 ,你将再次命中断点。

    进一步阅读

    You can also check out LLDB’s fantastic , which will explain more complex debugging scenarios.