gdb on mac 10.9 fails with “not in executable format: File format not recognized” for 32+64 arch

前端 未结 2 755
予麋鹿
予麋鹿 2021-02-07 08:23
$ file app
app: Mach-O universal binary with 2 architectures
app (for architecture i386):    Mach-O executable i386
app (for architecture x86_64):  Mach-O 64-bit executa         


        
2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-07 09:14

    As OP commented, using Apple's gdb will fix the problem.

    Here are instructions to build Apple gdb 6.3.50.20050815-cvs from source on OS 10.9:

    NOTE: You will need to install Xcode and set up a build environment. If you have Homebrew installed, run brew doctor to see if "Your system is ready to brew."

    1. Download the gdb-1822 source tarball from: http://opensource.apple.com/tarballs/gdb/gdb-1822.tar.gz

    2. Extract this into a temporary directory. Open a terminal and cd into gdb-1822/src.

    3. Run the configure script:

      ./configure --prefix="$HOME/.local/stow/gdb-1822" --disable-debug --disable-dependency-tracking --with-system-readline
      

      (The last three configure arguments are from the homebrew-dupes formula: https://github.com/Homebrew/homebrew-dupes/blob/master/gdb.rb )

    4. Run make:

      make
      make install
      
    5. Follow the instructions at https://sourceware.org/gdb/wiki/BuildingOnDarwin#Creating_a_certificate to create a gdb-cert code signing certificate.

    6. cd into $HOME/.local/stow/gdb-1822/bin and sign the gdb executable:

      codesign -s gdb-cert gdb
      
    7. cd into $HOME/.local/stow and stow the gdb-1822 folder:

      stow gdb-1822
      
    8. Add $HOME/.local/bin to your PATH and either restart the terminal or clear Bash's cache to the location of gdb:

      hash -d gdb
      

提交回复
热议问题