Skip to content

Instantly share code, notes, and snippets.

@hongry18
Last active February 11, 2019 08:26
Show Gist options
  • Save hongry18/528f10a6e00371d458e6f3a065e3d81e to your computer and use it in GitHub Desktop.
Save hongry18/528f10a6e00371d458e6f3a065e3d81e to your computer and use it in GitHub Desktop.

gdb install in osx

download source

https://ftp.gnu.org/gnu/gdb/gdb-8.0.1.tar.xz
8.2에 codesign 문제가 있어 8.0.1 로 다운그레이드 해서 사용.

crash

reference : https://stackoverflow.com/posts/52995622/revisions

BFD: test: unknown load command 0x32
BFD: test: unknown load command 0x32
File: not in executable format: file format not recognized

./bfd/mach-o.c

case BFD_MACH_O_LC_VERSION_MIN_WATCHOS:
...
/* add */
case BFD_MACH_O_LC_BUILD_VERSION:
break;

./include/mach-o/loader.h

BFD_MACH_O_LC_VERSION_MIN_WATCHOS = 0x30
/* add */
BFD_MACH_O_LC_BUILD_VERSION = 0x32
./configure
make
make install

add keychain

reference : [https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d]

If you are getting this in gdb on macOS while trying to run a program:

Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
  1. Open Keychain Accessmm
  2. In menu, open Keychain Access > Certificate Assistant > Create a certificate
  3. Give it a name (e.g. gdbc)
  • Identity type: Self Signed Root
  • Certificate type: Code Signing
  • Check: let me override defaults
  1. Continue until "specify a location for..."
  2. Set Keychain location to System
  3. Create certificate and close Certificate Assistant.
  4. Find certificate in System keychain.
  5. Double click certificate
  6. Expand Trust, set Code signing to always trust
  7. Restart taskgated in terminal: killall taskgated
  8. Codesign gdb using your certificate: codesign -fs gdbc /usr/local/bin/gdb
  9. Shut down your mac and restart in recovery mode (hold down command-R until apple logo appears)
  10. Open terminal window
  11. Modify System Integrity Protection to allow debugging: csrutil enable --without debug
  12. Reboot your Mac. Debugging with gdb should now work as expected.
Set Keychain location to System 선택후 
unknown error = -2.147.414.007 메세지가 나올때
로그인 항목으로 재 생성하여 시스템항목으로 다시 가져오면 된다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment