Right, here's a series of steps that might help:
1) I find it easier to debug with GDB outside of Eclipse, but I have gotten CDT to work before.
2) Create a debug build of Xuggler (see the build instructions, and configure with --disable-optimizations). This will ensure your object files to have source line information and will aid in debugging. It will also build a DEBUG version of FFmpeg so you can step through line-by-line there.
3) Make sure your Eclipse set-up has the right environment variables set up in the process it launched in.
4) Install your debug build into your standard place (ant installer) to make sure it's picked up when you run Eclipse.
5) Restart Eclipse.
Now, this next step is tricky. How do you attach GDB to your running program. I'm going to show you all the steps assuming Linux (or MacOS). Windows debugging is an order of magnitude harder.
The first way is to create a Java program that has some sort of pausing BEFORE loading a Xuggler method. Make a stub program that doesn't actually begin running until you hit Enter on a console for example. Run that Java program, and then when it is paused waiting for enter, open a new shell and attach with gdb (or use CDT's "Attach to Running C/C++ Process" debug profile):
# find the Process ID for the java process
> ps -ef | grep java
# attach GDB to the java process. I assume the Process ID is 1234
> gdb `which java` 1234
# now you should be in GDB, set any breakpoints. GDB will complain
# about libraries not being loaded and ask if you want to break on
# load; say yes
#
# finally tell GDB to continue (but remaining attached)
> continue
Now, return to your Java window and hit Enter. Your breakpoints should hit.
Method two is if that approach doesn't work. Xuggler has a mechanism built in where it will wait in an infinite loop for a debugger to attach on the first library load if needed. To use that:
1) Run Java with the "com.xuggle.ferry.WaitForDebugger" property set to 1.
> java -Dcom.xuggle.ferry.WaitForDebugger=1 com.yourcompany.YourClass
2) Once the first Xuggler Jar is loaded, the following message will show up on your console:
> Waiting for debugger. Please attach...
3) The message will tell you the file (JNIHelper.cpp) and line number where the message appears in Xuggler's source. In a terminal, or using Eclipse's CDT "attach to process" find the Java process that is now stalled and attach
4) Using the GDB command "info threads", find the thread that is blocked in the JNIHelper::waitForDebugger method. In this example I'll assume it's thread 12
> info threads
> thread 12
5) Now, set any breakpoints you want in your code
6) Finally, tell Xuggler to stop waiting by setting the following variable to a non-zero value
> set sDebuggerAttached = 1
> continue
Now, your breakpoints should be hit, and you should be able to step through C/C++ code in Eclipse.
Hope that helps,
- Art
--
http://www.xuggle.com/xu‧ggle (zŭ' gl) v. To freely encode, decode, and experience audio and video.
Use Xuggle to get the power of FFmpeg in Java.