当前位置:首页 > 操作系统 > MacOs

mac上eclipse用gdb调试(转)

  • For the remainder of the tutorial, use /opt/local/bin/gdb-apple as the GDB executable
  • Remember if you want breakpoints in template functions to work, you‘ll need to change your compiler to g++-apple-4.2 instead of g++! This can be done in your Makefiles or in your IDE settings.
  • Install with Homebrew

    1. Install Xcode and Homebrew, if not already installed.
    2. Now install GDB from Homebrew: $ brew tap homebrew/dupes
      $ brew install gdb
    3. For the remainder of the tutorial, use /usr/local/bin/gdb as the GDB executable

    If that worked, then lucky you! Getting it compiled is where many people seem to have trouble. Now you just need to sign it to give it permission to control OS X processes.

    Certifying GDB

    Open up the Keychain Access application (/Applications/Utilities/Keychain Access.app). Navigate via the menu to Keychain Access > Certificate Assistant > Create Certificate...

    mac上eclipse用gdb调试(转) - 文章图片

    Enter a name for the certificate. For this how-to, I‘ll call it "gdb-cert". Set the fields exactly as shown below.

    mac上eclipse用gdb调试(转) - 文章图片

    The maximum validity period is 999 days. I don‘t really want to deal with this again, so I‘m going to max it out.

    mac上eclipse用gdb调试(转) - 文章图片

    Keep clicking the "Continue" button until you are asked for a location. Set it to "System".3

    mac上eclipse用gdb调试(转) - 文章图片

    Success!

    mac上eclipse用gdb调试(转) - 文章图片

    Now make sure the cert is always trusted. Right-click the new certificate and select Get Info. Under the Trust section, set Code Signing to Always Trust.

    mac上eclipse用gdb调试(转) - 文章图片

    mac上eclipse用gdb调试(转) - 文章图片

    Now that we have a certificate, we need to use it to sign GDB. First, we‘ll restart the taskgatedprocess to make sure it picks up the new certificate. Quit Keychain Access (you must quit Keychain Access!) and return to the Terminal for these final commands.

    Find the taskgated process.

    ps -e grep taskgated
    56822 ??         0:03.11 /usr/libexec/taskgated -s
    60944 ttys002    0:00.00 grep --color=auto taskgated

    The first number in the above output is the PID. Use this to kill the process (it will immediately restart itself).

    sudo kill -9 56822

    Now you can finally code sign GDB.

    # MacPorts version
    $ codesign -s gdb-cert $(which gdb-apple)
    # Homebrew version
    $ codesign -s gdb-cert $(which gdb)

    Now you should be all set! The OS X Keychain may ask for your password the first time you attempt to debug a program, but it should work!

    Getting it to Work with Eclipse

    There‘s one more step for Eclipse users. You need to specify where Eclipse can find the new GDB. Specify the path to GDB in Preferences > C/C++ > Debug > GDB:

    mac上eclipse用gdb调试(转) - 文章图片

    If you already have some debug configurations, you may need to edit them individually to point to the correct place (under Run > Debug Configurations...):

    mac上eclipse用gdb调试(转) - 文章图片


      1. The CDT developers are planning to support LLDB, but they will have to write a whole new interface, and I think most of them only work on Eclipse in their spare time, so it will likely be at least some months before LLDB support is there.
      2. The procedure is derived from this StackOverflow post and this GDB Wiki page.
      3. If you are unable to save it to the System keychain, then save it to the login keychain. You can later export the cert, and then import it into the System keychain. I didn‘t have to do this, so comment if you have any problem.

    mac上eclipse用gdb调试(转)

    标签:

    本文系统来源:http://www.cnblogs.com/yaoliang11/p/4521895.html


    【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

    相关教程推荐

    其他课程推荐