0

I tried to compile a 7.5 Version of gdb in emacs 24.3 but with unknown load command error.

Before this production deployment, the same setup is working on the OSX 10.6.8 Snow Leopard platform.

I do not find any issue for codesigned executables after following the guidelines (http://sourceware.org/gdb/wiki/BuildingOnDarwin).

But whenever I debug a simple temperature conversion program, it always had the following errors:

Current directory is /Users/xyz/Documents/C++....../CPP_Programs_mac/Chap01/Conversion/
BFD: /Users/xyz/Documents/C++......./CPP_Programs_mac/Chap01/Conversion/main.out: unknown load command 0x2
BFD: /Users/xyz/Documents/C++...../CPP_Programs_mac/Chap01/Conversion/main.out: unknown load command 0x29
BFD: /Users/xyz/Documents/C++...../CPP_Programs_mac/Chap01/Conversion/main.out: unknown load command 0x2b
GNU gdb (GDB) 7.5
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin12.3.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
BFD: /Users/xyz/Documents/C++...../CPP_Programs_mac/Chap01/Conversion/main.out: unknown load command 0x2a
BFD: /Users/xyz/Documents/C++..../CPP_Programs_mac/Chap01/Conversion/main.out: unknown load command 0x28
BFD: /Users/xyz/Documents/C++..../CPP_Programs_mac/Chap01/Conversion/main.out: unknown load command 0x29
BFD: /Users/xyz/Documents/C++..../CPP_Programs_mac/Chap01/Conversion/main.out: unknown load command 0x2b
Reading symbols from /Users/xyz/Documents/C++.../CPP_Programs_mac/Chap01/Conversion/main.out...(no debugging symbols found)...done.
(gdb)              

Even with those errors I can still "Go" (run) it and another buffer to execute the program. Then there are lots of errors in the gud screen:

BFD: /usr/lib/libstdc++.6.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/libstdc++.6.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/libSystem.B.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/libSystem.B.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/libc++abi.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/libc++abi.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libcache.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libcache.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libcommonCrypto.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libcommonCrypto.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libcompiler_rt.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libcompiler_rt.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libcopyfile.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libcopyfile.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libdispatch.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libdispatch.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libdnsinfo.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libdnsinfo.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libdyld.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libdyld.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libkeymgr.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libkeymgr.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/liblaunch.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/liblaunch.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libmacho.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libmacho.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libquarantine.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libquarantine.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libremovefile.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libremovefile.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libsystem_blocks.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libsystem_blocks.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libsystem_c.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libsystem_c.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libsystem_dnssd.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libsystem_dnssd.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libsystem_info.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libsystem_info.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libsystem_kernel.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libsystem_kernel.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libsystem_m.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libsystem_m.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libsystem_network.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libsystem_network.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libsystem_notify.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libsystem_notify.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libsystem_sandbox.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libsystem_sandbox.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libunc.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libunc.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libunwind.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libunwind.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libxpc.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libxpc.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/system/libcorecrypto.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/system/libcorecrypto.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/libobjc.A.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/libobjc.A.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/libauto.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/libauto.dylib(i386:x86-64): unknown load command 0x2b
BFD: /usr/lib/libc++.1.dylib(i386:x86-64): unknown load command 0x2a
BFD: /usr/lib/libc++.1.dylib(i386:x86-64): unknown load command 0x2b
(gdb)          

Running gdb in the terminal have the same errors. I tried very hard to google and found that those bugs are reported by many users last year. I wonder if those are resolved with the new version of gdb.

Has anyone been successful in gdb 7.5 on Mountain Lion? Or even tried gdb 7.6 at all?

Thanks

sshi
  • 11
  • 2
  • Seems similar to http://stackoverflow.com/questions/12050257/gdb-fails-on-mountain-lion – devnull May 02 '13 at 07:51
  • yes. but that post is deleted by the moderator. Not sure the reason. Anyway, I just install gdb 7.6 for Mountain Lion 10.8.3 and the BFD errors are gone. So just share with all other users here who may wonder if it is an good upgrade. cheers – sshi May 02 '13 at 18:18

1 Answers1

4

Binaries on Mac OS X have a series of load commands, instructions to the dynamic linker (dyld), about how to load/run the program. They start with a byte which indicates the type of load command. Some of them are critical for the debugger to understand to operate properly, some are not important for the debugger. There is a bit which indicates that they're considered "important" (LC_REQ_DYLD) but gdb will warn for every load command it doesn't recognize one way or the other. 0x2a is LC_SOURCE_VERSION and 0x2b is LC_DYLIB_CODE_SIGN_DRS, these load commands are new to Mac OS X 10.8 aka Mountain Lion. Neither is important for the debugger's correct operation.

When you installed a different gdb which worked correctly, someone probably updated the list of load commands it knew about.

I'd strongly recommend using the Apple supported debugger lldb. It's quite mature in Xcode 4.6 and most of the commands you use frequently in gdb will work as-is, or with small modifications, see http://lldb.llvm.org/lldb-gdb.html

Jason Molenda
  • 14,835
  • 1
  • 59
  • 61