Debugging of the C++ code on Mac and Unix can proceed as follows:
cd to your ImageJ directory that contains a self-starting Micro-Manager plugin:
Start gdb debugging java:
$ gdb -arch i386 java
Now tell java on gdb to run ImageJ:
(gdb) r -cp ij.jar ij.ImageJ
Control-C can interrupt execution.
Please refer to the gdb documentation for debugging commands.
Apple replaced gdb with lldb (around Mac OS X 10.9?). lldb commands are very similar to gdb, however, please have a look at this tutorial. Note that lldb will stop on every SIGSEGV signal generated by java (for an explanation, see 1. Press ‘c’ to continue (there may be a more efficient way of dealing with this).
Using NetBeans with gdb for C++ debugging
- Install NetBeans for C++ or install the C/C++ plugin for in your existing NetBeans installation.
- Choose File > New Project… . Select Categories=C/C++, Projects=C/C++ Project with Existing Sources.
- Specifiy the folder that contains existing sources (e.g., /projects/micromanager/) and press “Finish.”
- Right-click the new project and select “Properties”.
- Under Build…Make, set Build Command to “make all; make install”
and “Clean Command” to “make clean”. Set Build Result to
- Add the following option to the netbeans_default_options=”…“
line of /Applications/NetBeans/NetBeans
6.8.app/Contents/Resources/NetBeans/etc/netbeans.conf : -J-Dgdb.init.enable=true
- Create a .gdbinit file in ~ that informs gdb of the directories of all .cpp and .h source files you might wish to debug: directory /projects/micromanager/ directory /projects/micromanager/MMCore directory /projects/micromanager/MMDevice directory /projects/micromanager/DeviceAdapters/DemoCamera
- Restart Netbeans.
- Launch ImageJ (the target of make install from your micromanager source).
- Select Debug…Attach debugger.