-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Debuginfo: Source lines for fail! invocations are incorrect #9232
Comments
Do you have an example of where this goes wrong as well? I may have broken usage through nested macros recently, but normal vanilla usage should be ok I thought. |
fn foo() {
fail!("whoops");
}
fn main() {
foo();
}
|
oh you mean with debug-info! I thought you meant what it actually printed to the console. Don't mind me... |
This is still incorrect... but in a different way; everything is now listed as being at the
|
I suspect that the line 6 is coming from line 6 of the definition of fail here: https://github.com/mozilla/rust/blob/master/src/libstd/macros.rs#L48. Each macro is individually serialized which is why the line count shifted. I think the issue before and now is that the debug info infrastructure needs to do something special with spans that point to autogenerated "files" like "". |
Triage time! To reproduce today, source code:
compile:
use gdb:
notably: hello::foo () at :3 and hello::main () at hello.rs:6 Is this wrong? should it say |
Yes, the output in frame 3 is not as useful as it could be, since you really want to know what line the macro was invoke on, rather than which line of the macro called begin_unwind. |
Just ran into this with a custom macro - one function contains multiple expansion of the macro, which calls another function, which panics. The backtrace doesn't make it easy to tell which expansion was involved. Not sure how this would be fixed, since the only obvious alternative would be emitting line info for the expansion site instead, which would cause the opposite problem, not being able to tell where in the macro the call came from. (This is what you get in C, and it's awful for sufficiently long macros.) Maybe rustc could fake an inline function call somehow? |
Triage: you need to use |
Now I see:
Frames 3 and 4 look fine to me. I don't know whether there is a test for this or not; but if so, I think it could be closed. |
I am going to close this since I don't think a test here is super helpful. |
When I set a breakpoint in rust_begin_unwind and hit a fail! somewhere, the stack frame containing the fail! call shows the right file but the wrong line. It shows me line 66, which I suspect comes from injecting the std_macros (including fail!) into every file, since the fail! definition occurs on line 60 of that block (see syntax/etx/expand.rs).
The text was updated successfully, but these errors were encountered: