如何让 XCode / GDB 融入 Safari 5.1 NPAPI 插件?
我有一个在 OS X 10.6.8 上运行的 NPAPI 插件,我想对其进行调试。当我使用 FireFox 3.6.19 加载它时,我可以将活动可执行文件设置为 FF,启动 FF,使用 XCode 附加,并且断点将在预期时间触发。
使用 Safari 5.1 时,我发现插件在进程中运行,因此我为 /System/Library/PrivateFrameworks/WebKit2.framework/PluginProcess.app 创建并激活了客户可执行文件。然后,我启动 Safari,导航到托管插件的页面,附加到插件进程,然后使用 UI,这样断点应该触发,但它没有。我可以通过 UI 判断该插件已加载。如果暂停进程,我会看到:
(gdb) i b
Num Type Disp Enb Address What
1 breakpoint keep y <PENDING> "ADP_NPAPI_Interface.m":34
2 breakpoint keep y <PENDING> "ADP_NPAPI_Interface.m":34
3 breakpoint keep y <PENDING> "ADP_NPAPI_Interface.m":34
4 breakpoint keep y <PENDING> "plugin.cpp":244
5 breakpoint keep y <PENDING> "plugin.cpp":358
6 breakpoint keep y <PENDING> objc_exception_throw
(gdb) show directories
Source directories searched: $cdir:$cwd
(gdb) info sources
No symbol table is loaded. Use the "file" command.
(gdb) file sources
sources: No such file or directory
(gdb) info file
No registers.
No registers.
(gdb) show paths
Executable and object file path: /Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym。我的理解是符号将在插件中,所以,我相信gdb找不到我的源文件。
预先感谢您的帮助, 戴夫
I have an NPAPI plug in running on OS X 10.6.8 that I'd like to debug. When I load it using FireFox 3.6.19, I can set the active executable to FF, start FF, attach using XCode, and the breakpoint will fire at the expected time.
When using Safari 5.1, I see that the plug in runs out of process, so I created and activated a customer executable for /System/Library/PrivateFrameworks/WebKit2.framework/PluginProcess.app. I then start Safari, navigate to the page hosting the plug in, attach to the plug in process, and then use the UI such the breakpoint should fire, but it doesn't. I can tell by the UI that the plug in definately loaded. If the pause the process, I see:
(gdb) i b
Num Type Disp Enb Address What
1 breakpoint keep y <PENDING> "ADP_NPAPI_Interface.m":34
2 breakpoint keep y <PENDING> "ADP_NPAPI_Interface.m":34
3 breakpoint keep y <PENDING> "ADP_NPAPI_Interface.m":34
4 breakpoint keep y <PENDING> "plugin.cpp":244
5 breakpoint keep y <PENDING> "plugin.cpp":358
6 breakpoint keep y <PENDING> objc_exception_throw
(gdb) show directories
Source directories searched: $cdir:$cwd
(gdb) info sources
No symbol table is loaded. Use the "file" command.
(gdb) file sources
sources: No such file or directory
(gdb) info file
No registers.
No registers.
(gdb) show paths
Executable and object file path: /Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym. My understanding is that the symbols will be in the plug in, so, I believe that gdb can't find my source files.
Thanks in advance for your help,
Dave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我偶尔使用 FireBreath 插件的一种方法是:
然后在入口点之一(例如 NP_Initialize)中,您do:
我的一个朋友想出了这个,看起来效果不错。但是,您应该知道,在 Safari 5.1 中,浏览器将在(相当短暂的)一段时间没有收到插件响应后杀死该插件(发送 SIG_KILL)。因此,使用 Safari 5.1 进行调试几乎是不可能的;因此,我强烈建议您在 Firefox 或 Chrome 中进行调试。
这将导致插件等待调试器附加。请注意,在 Safari 5.1 中,插件进程的名称已更改;我忘记了它现在到底是什么,但它肯定不在进程中,而且不是 Safari =]
有一天我会抽出时间将其添加到默认的 FireBreath np_mainmain.cpp 文件....
One method that I have used occasionally with FireBreath plugins is this:
Then in one of the entrypoints (such as NP_Initialize) you do:
A friend of mine came up with this, and it seems to work pretty well. However, you should know that in Safari 5.1 the browser will kill the plugin (send a SIG_KILL) after a (fairly brief) time of not getting a response from it. Because of this, it's nearly impossible to debug with Safari 5.1; I highly recommend you debug in either Firefox or Chrome because of this.
This will cause the plugin to wait for your debugger to attach. Note that in Safari 5.1 the name of the plugin process has changed; I forget what it is now exactly, but it's definitely out of process and it's not Safari =]
One of these days I'll get around to adding this to the default FireBreath np_mainmain.cpp file....
Xcode 有一个选项 Run -> Attach to process。使用它附加到插件进程而不是浏览器。从这里您可以开始调试在 64 位浏览器中运行的插件
Xcode has an option to Run ->Attach to process. Use this to attach to plugin process and not the browser. From here you can start debugging plugin running in 64 bit browser
dwarf-with-dsym 的“with-dsym”部分意味着符号位于单独的符号文件中,而不是二进制文件中。
您的选择是:
- 切换到普通矮星
- 将 .dsym 包从构建目录复制到已安装插件旁边
- 在 gdb 中手动加载 dsym (至少,我相信这是可能的;但我实际上还没有这样做)
The "with-dsym" part of dwarf-with-dsym means that the symbols are in a separate symbol file, not in the binary.
Your options are:
- sWitch to plain dwarf
- copy the .dsym bundle from your build directory to next to the installed plugin
- manually load the dsym in gdb (at least, I believe this is possible; I haven't actually done it though)