title: Cannot step into MEX function
body: <p><strong>Question:</strong></p>
  
  <p>I cannot step into my MEX function.  What am I doing wrong?  The obvious answer is the <code>SEGSEGV</code> and <code>SIGUSR1</code> but it would be good to get an insight on why that is.  Atleast for the <code>SIGUSR1</code>   </p>
  
  <p>Environment - x86_64 linux
  Software - Matlab 2012a
  Debugger - GDB</p>
  
  <p>There is a bit of preface since I think it is relevant to answering the question and knowing the holes in my understanding.</p>
  
  <p>Compiled mex file with debug flag</p>
  
  <p>start gdb with matlab as the executable and with -Dgdb (gdb set as debugger)</p>
  
  <pre><code>bash:&gt;matlab -Dgdb
  </code></pre>
  
  <p>run matlab in command line </p>
  
  <pre><code>(gdb) run -nojvm
  </code></pre>
  
  <p>In the course of starting up Matlab I see a bunch of "Missing separate debuginfo for ...*.so" and also hits a handful of segmentation faults (SIGSEGV)</p>
  
  <p>I set gdb segmentation fault signal handling to print but don't stop.</p>
  
  <pre><code>gdb&gt;handle SIGSEGV nostop print pass
  gdb&gt;handle SIGUSR1 nostop print pass
  
  Signal       Stop    Print     Pass     Description
  SIGSEGV       No     Yes        Yes     Segmentation fault
  SIGUSR1       No     Yes        Yes     User defined signal 1
  </code></pre>
  
  <p>After disable SIGSEGV i'm able to get to the Matlab command line where all seems to be good and Matlab appears to be operational.</p>
  
  <p>Enable mex debugging</p>
  
  <pre><code>matlab&gt;&gt;dbmex on
  matlab&gt;&gt;yprime(1,[1,2,3,4])
  
  
  Program received signal SIGUSR1, User defined signal 1.
  
  MEX FILE: /home/user/test/prime/yprime.mexa64 entry point located 
  at address 0xde5e3a60
  Add breakpoints at the debugger prompt and issue a "continue" to resume 
  execution of MATLAB.
  
  
  ans =
  
      2.0000    8.9685    4.0000   -1.0947
  </code></pre>
  
  <p>Based on the output <code>ans</code> we have already passed through <code>yprime()</code> mex routine and returned the result back to Matlab.</p>
  
  <p>What happens if I don't bypass SIGUSR1?</p>
  
  <p>If I don't bypass the SIGUSR1 I get the following output:</p>
  
  <pre><code>&gt;&gt; yprime(1,[1,2,3,4])         
  
  Program received signal SIGUSR1, User defined signal 1.
  0x0000003c83c0b5bc in pthread_cond_wait@@GLIBC_2.3.2 () from    /lib64/libpthread.so.0
  Missing separate debuginfos, use: debuginfo-install 
  glibc-2.12-1.149.el6_6.5.x86_64 libICE-1.0.6-1.el6.x86_64 
  libSM-1.2.1-2.el6.x86_64 libX11-1.6.0-2.2.el6.x86_64 
  libXau-1.0.6-4.el6.x86_64 libXcursor-1.1.14-2.1.el6.x86_64 
  libXext-1.3.2-2.1.el6.x86_64 libXfixes-5.0.1-2.1.el6.x86_64 
  libXmu-1.1.1-2.el6.x86_64 libXrender-0.9.8-2.1.el6.x86_64 
  libXt-1.1.4-6.1.el6.x86_64 libuuid-2.17.2-12.18.el6.x86_64 
  libxcb-1.9.1-2.el6.x86_64 ncurses-libs-5.7-3.20090208.el6.x86_64 
  nss-softokn-freebl-3.14.3-22.el6_6.x86_64 zlib-1.2.3-29.el6.x86_64
  
  
  (gdb) bt
  #0  0x0000003c83c0b5bc in pthread_cond_wait@@GLIBC_2.3.2 () 
             from /lib64/libpthread.so.0
  #1  0x00007f2440f10774 in mcr_run_main(...l) ()
             from /opt/matlab_2012a/bin/glnxa64/libmwmcr.so
  #2  0x00000000004026e0 in ?? ()
  #3  0x0000003c8381ed5d in __libc_start_main () from /lib64/libc.so.6
  #4  0x0000000000402579 in ?? ()
  #5  0x00007ffffc6f3678 in ?? ()
  #6  0x000000000000001c in ?? ()
  #7  0x0000000000000002 in ?? ()
  #8  0x00007ffffc6f4a9b in ?? ()
  #9  0x00007ffffc6f4ac0 in ?? ()
  #10 0x0000000000000000 in ?? ()
  </code></pre>