How can I get Xcode / GDB to crack the Safari 5.1 NPAPI plugin?

I have an NPAPI plugin running on OS X 10.6.8 that I would like to debug. When I load it using FireFox 3.6.19, I can install the active executable in FF, run FF, connect using Xcode, and the breakpoint will fire at the expected time.

When using Safari 5.1, I see that the plugin is ending, so I created and activated the client executable for / System / Library / PrivateFrameworks / WebKit 2.framework / PluginProcess.app. Then I launch Safari, go to the page where the plug-in is located, attach to the plug-in, and then use the user interface, which should work at the breakpoint, but it is not. I can say that the user interface is definitely loaded. If you pause the process, I see:

(gdb) ib 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. I understand that the characters will be in the plugin, so I believe that gdb cannot find my source files.

Thanks in advance for your help, Dave

+4
source share
3 answers

One of the methods I used sometimes with FireBreath is this:

 #if WAIT_FOR_DEBUGGER static bool beingDebugged() { int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()}; size_t mib_size = 4; struct kinfo_proc kp; size_t kp_size = sizeof(kp); int result = sysctl(mib, mib_size, &kp, &kp_size, NULL, 0); return (0 == result) ? (P_TRACED & kp.kp_proc.p_flag) : false; } #endif 

Then at one of the entry points (for example, NP_Initialize) you will do:

 #if WAIT_FOR_DEBUGGER #warning "WILL BLOCK ON P_TRACED" while (!beingDebugged()) sleep(1); #endif 

My friend came up with this and it seems to work very well. However, you should be aware that in Safari 5.1 the browser will kill the plugin (send SIG_KILL) after a (rather short) time so as not to get a response from it. Because of this, it is almost impossible to debug with Safari 5.1; Because of this, I highly recommend that you debug Firefox or Chrome.

This will make the plugin wait for your debugger to connect. Note that in Safari 5.1 the name of the plugin process has changed; I forgot that it’s accurate now, but it’s definitely not in order, and it’s not Safari =]

The other day I’ll talk about this in the default Firebreath file np_mainmain.cpp ....

+3
source

Xcode has a Run β†’ Attach to process option. Use this to connect to the plugin process, not the browser. From here you can launch a debugging plugin running in a 64-bit browser

+2
source

The "with-dsym" part of dwarf-with-dsym means that the characters are in a separate character file, not in binary format.

Your options: - go to a simple dwarf - copy the .dsym package from the build directory next to the installed plugin - manually load dsym in gdb (at least I think it's possible, I really haven't done that, though)

0
source

All Articles