top bar

Difference between revisions of "Debugging MM on MacOSX and Unix"

(New page: 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: cd ~/ImageJ Start gdb debugging jav...)
 
(Using LLDB)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
==Using gdb==
 +
 
Debugging of the C++ code on Mac and Unix can proceed as follows:
 
Debugging of the C++ code on Mac and Unix can proceed as follows:
  
Line 11: Line 13:
 
Now tell java on gdb to run ImageJ:
 
Now tell java on gdb to run ImageJ:
  
   (gdb) r -cp ij.jar ImageJ
+
   (gdb) r -cp ij.jar ij.ImageJ
  
 
Control-C can interrupt execution.
 
Control-C can interrupt execution.
  
 
Please refer to the [http://sourceware.org/gdb/current/onlinedocs/gdb_toc.html gdb documentation] for debugging commands.
 
Please refer to the [http://sourceware.org/gdb/current/onlinedocs/gdb_toc.html gdb documentation] for debugging commands.
 +
 +
 +
==Using lldb==
 +
 +
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 [http://lldb.llvm.org/tutorial.html tutorial].  Note that lldb will stop on every SIGSEGV signal generated by java (for an explanation, see [http://fusionsecurity.blogspot.com/2011/10/why-am-i-seeing-sigsegv-when-i-strace.html].  Press 'c' to continue (there may be a more efficient way of dealing with this).
 +
 +
==Using NetBeans with gdb for C++ debugging==
 +
 +
<ol>
 +
<li>Install NetBeans for C++ or install the C/C++ plugin for in your existing NetBeans installation.</li>
 +
<li>Choose File > New Project... . Select Categories=C/C++, Projects=C/C++ Project with Existing Sources.</li>
 +
<li>Specifiy the folder that contains existing sources (e.g., '''/projects/micromanager/''') and press "Finish."</li>
 +
<li>Right-click the new project and select "Properties".</li>
 +
<li>Under Build...Make, set Build Command to "make all; make install" and "Clean Command" to "make clean". Set Build Result to "<your_ImageJ_directory>/ImageJ.app/Contents/MacOS/JavaApplicationStub" .</li>
 +
<li>Add the following option to the '''netbeans_default_options="..."''' line of '''/Applications/NetBeans/NetBeans\ 6.8.app/Contents/Resources/NetBeans/etc/netbeans.conf''' :<pre>-J-Dgdb.init.enable=true</pre></li>
 +
<li> Create a '''.gdbinit''' file in '''~''' that informs gdb of the directories of all '''.cpp''' and '''.h''' source files you might wish to debug:<pre>directory /projects/micromanager/
 +
directory /projects/micromanager/MMCore
 +
directory /projects/micromanager/MMDevice
 +
directory /projects/micromanager/DeviceAdapters/DemoCamera
 +
</pre></li>
 +
<li>Restart Netbeans.</li>
 +
<li>Launch ImageJ (the target of make install from your micromanager source).</li>
 +
<li>Select Debug...Attach debugger.</li>
 +
</ol>
 +
{{Programming_Sidebar}}

Latest revision as of 12:27, 2 July 2015

Using gdb

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:

   cd ~/ImageJ

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.


Using lldb

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

  1. Install NetBeans for C++ or install the C/C++ plugin for in your existing NetBeans installation.
  2. Choose File > New Project... . Select Categories=C/C++, Projects=C/C++ Project with Existing Sources.
  3. Specifiy the folder that contains existing sources (e.g., /projects/micromanager/) and press "Finish."
  4. Right-click the new project and select "Properties".
  5. Under Build...Make, set Build Command to "make all; make install" and "Clean Command" to "make clean". Set Build Result to "<your_ImageJ_directory>/ImageJ.app/Contents/MacOS/JavaApplicationStub" .
  6. 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
  7. 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
    
  8. Restart Netbeans.
  9. Launch ImageJ (the target of make install from your micromanager source).
  10. Select Debug...Attach debugger.
© Micro-Manager : Vale Lab, UCSF 2006-2011 | All Rights Reserved | Contact