Skip to content

Commit

Permalink
Auto merge of #44251 - kennytm:osx-backtrace, r=alexcrichton
Browse files Browse the repository at this point in the history
Add libbacktrace support for Apple platforms (resubmitted)

Resubmitting #43422 rebased on the current master (cc @JohnColanduoni).

I have added an additional commit to fallback to `dladdr`-based `resolve_symbol` if `libbacktrace` returns `None`, otherwise the stack trace will be full of `<unknown>` when you forget to pass the `-g` flag (actually it seems — at least on macOS — the `dladdr` symbol is more accurate than the `libbacktrace` one).
  • Loading branch information
bors committed Sep 9, 2017
2 parents 18366f4 + aa6bd11 commit ddd123e
Show file tree
Hide file tree
Showing 10 changed files with 1,477 additions and 24 deletions.
3 changes: 3 additions & 0 deletions src/libbacktrace/configure
Original file line number Diff line number Diff line change
Expand Up @@ -11844,6 +11844,9 @@ elf*) FORMAT_FILE="elf.lo" ;;
pecoff) FORMAT_FILE="pecoff.lo"
backtrace_supports_data=no
;;
macho*) FORMAT_FILE="macho.lo"
backtrace_supports_data=no
;;
*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not determine output file type" >&5
$as_echo "$as_me: WARNING: could not determine output file type" >&2;}
FORMAT_FILE="unknown.lo"
Expand Down
3 changes: 3 additions & 0 deletions src/libbacktrace/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ elf*) FORMAT_FILE="elf.lo" ;;
pecoff) FORMAT_FILE="pecoff.lo"
backtrace_supports_data=no
;;
macho*) FORMAT_FILE="macho.lo"
backtrace_supports_data=no
;;
*) AC_MSG_WARN([could not determine output file type])
FORMAT_FILE="unknown.lo"
backtrace_supported=no
Expand Down
6 changes: 6 additions & 0 deletions src/libbacktrace/filetype.awk
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
/\177ELF\002/ { if (NR == 1) { print "elf64"; exit } }
/\114\001/ { if (NR == 1) { print "pecoff"; exit } }
/\144\206/ { if (NR == 1) { print "pecoff"; exit } }
/\xFE\xED\xFA\xCE/ { if (NR == 1) { print "macho32"; exit } }
/\xCE\xFA\xED\xFE/ { if (NR == 1) { print "macho32"; exit } }
/\xFE\xED\xFA\xCF/ { if (NR == 1) { print "macho64"; exit } }
/\xCF\xFA\xED\xFE/ { if (NR == 1) { print "macho64"; exit } }
/\xCA\xFE\xBA\xBE/ { if (NR == 1) { print "macho-fat"; exit } }
/\xBE\xBA\xFE\xCA/ { if (NR == 1) { print "macho-fat"; exit } }
Loading

0 comments on commit ddd123e

Please sign in to comment.