gdb 8.2 can't recognized executable file on macOS Mojave 10.14

后端 未结 8 649
感情败类
感情败类 2020-11-30 19:05

I get gdb by brew install gdb.

The source file content is:

#include 
int main(){
    int a = 10;
    for(int i = 0; i<          


        
相关标签:
8条回答
  • 2020-11-30 20:03

    Upgrade to GDB version 8.3. Also see Issue 23728, binutils fail on macOS 10.14 (Mojave) due to unimpl in the Binutils bug tracker.

    From the bug report:

    I've found the root of the issue. binutils does not handle load command 0x32 LC_BUILD_VERSION (nor 0x31 LC_NOTE, actually). They are defined in recent LLVM versions: see https://github.com/llvm-mirror/llvm/blob/master/include/llvm/BinaryFormat/MachO.def#L77

    Looking at the output of objdump -private-headers there is one clear difference:

    @@ -56,16 +56,18 @@ attributes NO_TOC STRIP_STATIC_SYMS LIVE
      reserved1 0
      reserved2 0
     Load command 1
    -      cmd LC_VERSION_MIN_MACOSX
    -  cmdsize 16
    -  version 10.13
    -      sdk n/a
    +       cmd LC_BUILD_VERSION
    +   cmdsize 24
    +  platform macos
    +       sdk n/a
    +     minos 10.14
    +    ntools 0
     Load command 2
          cmd LC_SYMTAB
      cmdsize 24
    

    LC_VERSION_MIN_MACOSX is implemented in binutils, while LC_BUILD_VERSION is not. It is apparently new in Mojave.

    0 讨论(0)
  • 2020-11-30 20:03

    The answer by timotheecour above did work for me:

    brew install https://raw.githubusercontent.com/timotheecour/homebrew-timutil/master/gdb_tim.rb

    Then I had to generate a generate a self-signed certificate as in https://www.thomasvitale.com/how-to-setup-gdb-and-eclipse-to-debug-c-files-on-macos-sierra/

    0 讨论(0)
提交回复
热议问题