-
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
Include column info in debuginfo #42921
Comments
We don't ship a GDB - just a wrapper that loads some python scripts into the system GDB. |
Output column number info when panicking Outputs the column number when panicking. Useful when you e.g. have code like `foo[i] = bar[k] + bar[l]` and you get a panic with index out of bounds, or when you have an expression like `a = b + c + d + e` and the addition overflows. Now you know which operation to blame! The format is `file:line:column`, just like for compiler errors. Example output with the patch: ``` thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 8', src/main.rs:3:8 ``` As some of the API between the compiler and the library landscape gets broken, this is a bit hackier than I'd originally wanted it to be. * `panic` and `panic_bounds_check` lang items got an additional column param, on stage0 I still have to use the previous version. After a SNAP this should be resolved. * For `#[derive(RustcDeserialze)]`, stage0 requires a fixed signature for `std::rt::begin_panic`, so we can't change it right away. What we need to do instead is to keep the signature, and add a `begin_panic_new` function that we use in later stages instead. After a SNAP we can change the `begin_panic` function and rely on it instead of `begin_panic_new`, and one SNAP later we can remove `begin_panic_new`. * Fortunately I didn't have to break anything about the panic hook API, I could easily extend it. Note that debuginfo remains unchanged, so RUST_BACKTRACE output won't contain any column info. See issue #42921 for discussion on including the column in debuginfo.
Does |
I don't think gdb should have any particular problem with columns -- it currently just ignores them. |
I've dug a little and it seems that Visual Studio expects column info to be in ranges, and otherwise is buggy... That's why it was apparently disabled for clang+msvc: https://reviews.llvm.org/rL279765 . LLVM seems to have no way of sending column ranges, so we can't improve on clang here unless we want to patch LLVM. However, for other targets it should work... at least worth a try. |
Sooo I've had another look and it seems that clang outputs col info by default while gcc does not, at least for the x86_64-unknown-linux-gnu target family. Test setup a.c source code: #include<stdio.h>
int main() {
printf("Hello World0\n"); printf("Hello World1\n"); printf("Hello World2\n");
printf("Hello World3\n");
return 0;
} Both compiled with I got this for gcc:
I got this for clang:
|
Emit column info in debuginfo for non msvc like targets Fixes rust-lang#42921 everywhere except MSVC. This mimics clang behaviour.
Emit column info in debuginfo for non msvc like targets Fixes rust-lang#42921 everywhere except MSVC. This mimics clang behaviour.
I think that we should include column info in debuginfo, so that backtraces become more informative.
Often you do multiple function calls on a line, like
ctr = ctr.inc().inc();
orlet foo = wrap((), wrap((),()))
.If one of these function calls generates a panic or something else that causes a backtrace, you can't know immediately which of the function calls actually caused the issue.
Apparently, right now we are setting the column number to zero: ae66285
The reason seems to be that GCC/Clang don't emit column numbers either and apparently GDB had issues with it. See #9641 and #10966. However, the change was from 2013, and maybe GDB support has changed since. Also, maybe if we ask kindly, GDB could consider adding support. AFAIK we already ship our copy of GDB so we might not even have to wait for a release to enable this per default.
Note that this is separate from panic locations, which doesn't use the LLVM debug info system but uses our own system instead. I'm preparing a PR to add line number info for panic's (without the RUST_BACKTRACE input) and want to file it soon. EDIT: #42938
cc @eddyb @michaelwoerister
The text was updated successfully, but these errors were encountered: