-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic backtrace functionality #10128
Comments
+1 |
I played around with this for a bit using the Not entirely sure how useful this would be in light of this, and it also turns out that |
Firefox has stackwalking code that might be worth investigating: http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsStackWalk.cpp |
However, it appears that the production stackwalker code for our in-app profiler that runs on release builds is built on top of Breakpad. |
cc me |
In a toy example in C on Mac OS X, it seems like the backtrace functionality works, sort of, for a compiled executable. (I say "sort of" because once I start marking functions in my toy example as static, gcc starts emitting tail calls, so of course that means those frames get left off the stack, so my toy example isn't as full an illustration as I'd like it to be.) |
cc me |
The ruby implementation looks like this: https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L679-L705 |
Most recent Gecko work for use by the built-in profiler: https://bugzilla.mozilla.org/show_bug.cgi?id=938157 |
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. Currently this is not an exported interface because it's only supported on osx/linux. I found that windows/freebsd/android all required extra libraries which are not necessarily present by default. cc rust-lang#10128
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 rust-lang#10128
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 rust-lang#10128
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
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
There are a number of locations where it would be really nice if we had some very simple support for backtraces. By simple I just mean the ability to know the name of the function and possibly the instruction pointer inside the function.
Some possible use case:
This is obviously a tricky thing to do, and I don't think that we should bring in libunwind for just this (it's pretty simple), but it appears that each platform has their own solution for acquiring a simple backtrace, and we can take the least common denominator of all of them:
This would probably be a module in
std::unstable
like the waydynamic_lib
is a module. This isn't really a high priority, but it would certainly be something nice to have!The text was updated successfully, but these errors were encountered: