]> git.lizzy.rs Git - rust.git/commit
Add basic backtrace functionality
authorAlex Crichton <alex@alexcrichton.com>
Wed, 5 Feb 2014 23:19:40 +0000 (15:19 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 13 Mar 2014 07:24:20 +0000 (00:24 -0700)
commit829df69f9f7a0dd0adbf072a47fd7c7600e75211
tree74d6759c446dadbd121d2ae9470a9b173045be0e
parent9a21b9007775343b7ca59245380b38d5b41a2e2b
Add basic backtrace functionality

Whenever a failure happens, if a program is run with
`RUST_LOG=std::rt::backtrace` a backtrace will be printed to the task's stderr
handle. Stack traces are uncondtionally printed on double-failure and
rtabort!().

This ended up having a nontrivial implementation, and here's some highlights of
it:

* We're bundling libbacktrace for everything but OSX and Windows
* We use libgcc_s and its libunwind apis to get a backtrace of instruction
  pointers
* On OSX we use dladdr() to go from an instruction pointer to a symbol
* On unix that isn't OSX, we use libbacktrace to get symbols
* Windows, as usual, has an entirely separate implementation

Lots more fun details and comments can be found in the source itself.

Closes #10128
mk/crates.mk
mk/rt.mk
mk/tests.mk
src/libstd/rt/backtrace.rs [new file with mode: 0644]
src/libstd/rt/libunwind.rs [new file with mode: 0644]
src/libstd/rt/mod.rs
src/libstd/rt/unwind.rs
src/libstd/rt/util.rs
src/test/run-pass/backtrace.rs [new file with mode: 0644]