Skip to content
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'd source has all debug/error line numbers attributed to !include statement #36382

Closed
vvuk opened this issue Sep 10, 2016 · 13 comments
Closed
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@vvuk
Copy link
Contributor

vvuk commented Sep 10, 2016

as in https://github.com/servo/ipc-channel/blob/master/src/platform/mod.rs#L18

Tested on nightly-x86_64-pc-windows-gnu rustc 1.13.0-nightly (497d67d 2016-09-01), and with mingw64 gdb.

@sfackler sfackler added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Sep 10, 2016
@vvuk
Copy link
Contributor Author

vvuk commented Sep 10, 2016

Note: if I build with "-Z debug-macros" line numbers get properly attributed to the included source; not sure if this is intentional behaviour in this case?

@vvuk
Copy link
Contributor Author

vvuk commented Sep 11, 2016

Or.. not completely. With -Z debug-macros:

vladimir@grizzly[2334]$ cargo build
   Compiling ipc-channel v0.5.1 (file:///C:/proj/r/ipc-channel)
error[E0308]: mismatched types
  --> src\platform/mod.rs:18:5
   |
18 |     include!("windows/mod.rs");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected &str, found struct `std::string::String`
   |
   = note: expected type `&str`
   = note:    found type `std::string::String`
   = note: this error originates in a macro from the standard library

error: aborting due to previous error

error: Could not compile `ipc-channel`.

@vvuk
Copy link
Contributor Author

vvuk commented Sep 11, 2016

For the record, the error line was:

                return Err(WinError::last(format!("WaitForMultipleObjectsEx returned {}", index)));

with last() wanting a &str. If I changed this to cause another error, it was reported to the right line properly.

@vvuk vvuk changed the title !include'd source has all debug line numbers attributed to !include statement !include'd source has all debug/error line numbers attributed to !include statement Sep 13, 2016
@raphaelcohn
Copy link

I'm not sure if this is related, but I've noticed include! has a different path when invoked from inside a macro.

For example, if I have mod linux_like_syscall, and linux_like_syscall/mod.rs, then if mod.rs does include!("code.rs")';, code.rs is found in linux_like_syscall/ and all's well. If I have the include! inside a macro, eg conditionally compiling using cfg_if!, then code.rs is searched for in ..

@Manishearth Manishearth added the A-diagnostics Area: Messages for errors, warnings, and lints label Sep 20, 2016
@vadimcn
Copy link
Contributor

vadimcn commented Oct 7, 2016

Note: if I build with "-Z debug-macros" line numbers get properly attributed to the included source; not sure if this is intentional behaviour in this case?

Yes, this is intentional: #35238. Most of the time you want to step over macros. But if not, that's what -Z debug-macros is was intended for.

@vvuk
Copy link
Contributor Author

vvuk commented Oct 8, 2016

include! seems like it should be special though. Is it even implementable via macro_rules!?

@vadimcn
Copy link
Contributor

vadimcn commented Oct 9, 2016

The debug info emission code treats all macros uniformly, whether they are MBEs or procedural. Singling out include! would be... hacky.
Regarding your case, is there a reason you've avoided the usual "conditionally compiled module" approach?

@vvuk
Copy link
Contributor Author

vvuk commented Oct 11, 2016

Hacky, but perhaps a lot less unexpected. No reason; legacy code that did it this way. I may do a PR to change it.

@comex
Copy link
Contributor

comex commented Dec 11, 2016

Just ran into this. It's not possible to avoid include! when using code generated at build time, like with syntex: can't use a path attribute on a mod declaration because of the concat!(env("OUT_DIR") bit. (I tried to work around this by include!-ing a generated rs file that just consists of a mod decl, but somewhat counterintuitively to me, that doesn't change anything: everything in the module has debug info pointing to the include!.)

@jdm
Copy link
Contributor

jdm commented Jan 16, 2017

Servo is in a similar bind to the previous comment - we generate a lot of code in the out directory, and there's no way to reference it without using env!("OUT_DIR").

@vadimcn
Copy link
Contributor

vadimcn commented Jan 19, 2017

If we hardcode an exclusion for include!, would that solve everybody problems?

cc @michaelwoerister

@vvuk
Copy link
Contributor Author

vvuk commented Jan 19, 2017 via email

frewsxcv added a commit to frewsxcv/rust that referenced this issue Feb 9, 2017
…erister

Exclude top-level macro expansions from source location override.

It occurred to me that a simple heuristic can address the issue rust-lang#36382: any macros that expand into items (including `include!()`) don't need to be stepped over because there's not code to step through above a function scope level.

r? @michaelwoerister
@vadimcn
Copy link
Contributor

vadimcn commented Feb 28, 2017

Should be fixed in the current nightly.

@vadimcn vadimcn closed this as completed Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

7 participants