Skip to content

Commit ddd123e

Browse files
committed
Auto merge of #44251 - kennytm:osx-backtrace, r=alexcrichton
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).
2 parents 18366f4 + aa6bd11 commit ddd123e

File tree

10 files changed

+1477
-24
lines changed

10 files changed

+1477
-24
lines changed

src/libbacktrace/configure

+3
Original file line numberDiff line numberDiff line change
@@ -11844,6 +11844,9 @@ elf*) FORMAT_FILE="elf.lo" ;;
1184411844
pecoff) FORMAT_FILE="pecoff.lo"
1184511845
backtrace_supports_data=no
1184611846
;;
11847+
macho*) FORMAT_FILE="macho.lo"
11848+
backtrace_supports_data=no
11849+
;;
1184711850
*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not determine output file type" >&5
1184811851
$as_echo "$as_me: WARNING: could not determine output file type" >&2;}
1184911852
FORMAT_FILE="unknown.lo"

src/libbacktrace/configure.ac

+3
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ elf*) FORMAT_FILE="elf.lo" ;;
231231
pecoff) FORMAT_FILE="pecoff.lo"
232232
backtrace_supports_data=no
233233
;;
234+
macho*) FORMAT_FILE="macho.lo"
235+
backtrace_supports_data=no
236+
;;
234237
*) AC_MSG_WARN([could not determine output file type])
235238
FORMAT_FILE="unknown.lo"
236239
backtrace_supported=no

src/libbacktrace/filetype.awk

+6
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
/\177ELF\002/ { if (NR == 1) { print "elf64"; exit } }
44
/\114\001/ { if (NR == 1) { print "pecoff"; exit } }
55
/\144\206/ { if (NR == 1) { print "pecoff"; exit } }
6+
/\xFE\xED\xFA\xCE/ { if (NR == 1) { print "macho32"; exit } }
7+
/\xCE\xFA\xED\xFE/ { if (NR == 1) { print "macho32"; exit } }
8+
/\xFE\xED\xFA\xCF/ { if (NR == 1) { print "macho64"; exit } }
9+
/\xCF\xFA\xED\xFE/ { if (NR == 1) { print "macho64"; exit } }
10+
/\xCA\xFE\xBA\xBE/ { if (NR == 1) { print "macho-fat"; exit } }
11+
/\xBE\xBA\xFE\xCA/ { if (NR == 1) { print "macho-fat"; exit } }

0 commit comments

Comments
 (0)