title: Eclipse GDB MacOSX Mavericks
body: <p>I have had terrible problems making an Application Debug using Eclipse C/C++ project with XCode 5.0 and I have finally made it. I have finally been able to successfully debug my application and that's why I decided to make this little tutorial hoping to save time to others.</p>
  
  <p>When trying to debug and application written in C/C++ on Eclipse on Mavericks OS it comes up with "Error gdb -- version".</p>
  
  <p>This is because Eclipse cannot find GDB debug on new Mac OSX because Apple discontinues GDB support in place of LLDB. To check if this is your case simply try to run from Terminal <code>gdb</code> and it will show up as file not found. </p>
  
  <p>The problem is that LLDB is not configured for Eclipse yet (or the other way around). So how to make your Eclipse debug the application again as in previous 10.8 OS?</p>
  
  <p>First get and compile the GDB. You have two possible options:</p>
  
  <ul>
  <li>Macports (Unfortunately, the Mavericks release got stuck in Building getext library) </li>
  <li>Homebrew</li>
  </ul>
  
  <p>My suggestion is to get it from Homebrew. Check on their web site the download link and install using</p>
  
  <pre><code>ruby -e "$(curl -fsSL https://raw.github.com/mxcl/hebrew/go)"
  </code></pre>
  
  <p>Let it install. After it successfully installed GDB you need to sign a certificate to make Eclipse able to use GDB otherwise it will show up the error: </p>
  
  <blockquote>
    <p>Unable to find Mach task port for process-id 28885: (os/kern) failure
    (0x5).  (please check gdb is codesigned - see taskgated(8))</p>
  </blockquote>
  
  <p>This means Eclipse can find the GDB now but cannot run it because of the Apple certificates issue.</p>
  
  <p>To sign the GDB application and make it possible that Eclipse runs it follow the guide here:</p>
  
  <p><a href="https://sourceware.org/gdb/wiki/BuildingOnDarwin">https://sourceware.org/gdb/wiki/BuildingOnDarwin</a></p>
  
  <p>which can be summarized in:</p>
  
  <ol>
  <li>Start Keychain Access application (/Applications/Utilities/Keychain Access.app) </li>
  <li><p>Open menu /Keychain Access/Certificate Assistant/Create a Certificate (TOP MENU BAR)</p></li>
  <li><p>Choose a name (gdb-cert in the example)
  3.1 Set "Identity Type" to "Self Signed Root" 
  3.2 Set "Certificate Type" to "Code Signing" 
  3.3 Check the flag "Let me override defaults" 
  3.4 Click several times on "Continue" until you get to the "Specify a Location For The Certificate screen" then set Keychain to "System"
  3.5 If you can't store the certificate in the "System" keychain, create it in the "login" keychain, then export it. You can then import it into the "System" keychain.
  3.6 Make sure you have the "gdb-cert" in your "System" (left top window)</p></li>
  <li><p>Select "Get Info" by pressing twice on the fresh made certificate (gdb-cert), </p></li>
  <li>Open the "Trus"t item, and set "Code Signing to Always Trust"</li>
  <li>Close Keychain Access application </li>
  <li>Restart "taskgated" application from activity monitor</li>
  </ol>
  
  <p>Now you need to sign the Certificated by doing from terminal</p>
  
  <pre><code>$ codesign -s gdb-cert ../path of GDB
  </code></pre>
  
  <p>Example:</p>
  
  <pre><code>$ codesign -s gdb-cert /usr/local/bin/gdb
  </code></pre>
  
  <p>You are all set now.... ready to debug you C/C++ application on Eclipse on MacOSX Mavericks</p>
  
  <p>Make sure you have all set properly once again double check on Eclipse Menu Run->Debug Configuration->Debugger the line : 
  GDB Debugger -> /usr/local/bin/gdb (or your local path, check it with "$ which gdb" to get the correct path)
  GDB Command file-> .gdbinit</p>
  
  <p>Apple let GDB installed on the Mavericks but they like people squash their heads on the wall before doing a simple Hallo World program. No comment.</p>
  
  <p>Have Fun and I hope to have saved you time!</p>