Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRFC: Debuggable macro expansions #2117
Conversation
hsivonen
added some commits
Aug 18, 2017
withoutboats
added
the
T-compiler
label
Aug 18, 2017
This comment has been minimized.
This comment has been minimized.
michaelwoerister
commented
Aug 21, 2017
|
Thanks a lot for the RFC, @hsivonen! I think this is a good idea as proposed. Regarding the open questions:
cc @vadimcn and @rust-lang/compiler (and maybe @rust-lang/lang and @rust-lang/dev-tools should take a quick look at this too). |
This comment has been minimized.
This comment has been minimized.
|
For context, these issues are a problem for some of our production customers. It'd be good to get feedback from the compiler team soon. |
This comment has been minimized.
This comment has been minimized.
|
I think the behavior of fn f() { // 17
{ // 18
one(); // 18
{ // 18
two(); // 18
} // 18
{ // 18
three(); // 19 <--- retain line number if the statement comes from macro invocation
four(); // 20 <---
} // 18
} // 18
} // 22 |
nrc
added
the
T-dev-tools
label
Aug 23, 2017
This comment has been minimized.
This comment has been minimized.
|
Related, for error messages, we apply a same-crate heuristic, where if the macro is in the same crate, we give details from inside the macro, and if not we treat it as opaque. If we add an attribute like |
This comment has been minimized.
This comment has been minimized.
|
I think this proposal looks reasonable. Thanks for writing it up! Re unsolved questions: if code blocks passed as macro argument are not affected by #[collapse_debuginfo], it might break "step-over" functionality in debuggers, so this scenario needs to be tested if you decide to go this route. |
This comment has been minimized.
This comment has been minimized.
|
@michaelwoerister do you want to move toward FCP at this point, to land this ahead of the impl period? |
This comment has been minimized.
This comment has been minimized.
|
We discussed this in dev-tools meeting today. We approve of the RFC in principal, but would like to experiment with an implementation. Given the impl period, we'll not do anything with this RFC for now, but consider us approving a hypothetical 'experimental RFC' so that we can experiment with an unstable implementation. We'll revisit this RFC once we have some experience with the implementation. |
tromey
reviewed
Jan 25, 2018
| results for macros that are not assert-like and not print-like but that expand | ||
| to substantial code. The current approach of collapsing debug information by | ||
| default makes non-assert-like, non-print-like macro usage result in code that | ||
| is on debuggable, that doesn't get useful panic/crash stacks in CI or in the |
This comment has been minimized.
This comment has been minimized.
tromey
Jan 25, 2018
I think "on debuggable" should be changed "not debuggable" here, and "at that" should be changed to "and that" on the subsequent line.
petrochenkov
added
T-dev-tools
and removed
T-dev-tools
labels
Jan 30, 2018
This comment has been minimized.
This comment has been minimized.
|
@michaelwoerister @tromey @hsivonen @vadimcn is anyone interested in doing an initial implementation of this? I think that is the next step here. |
This comment has been minimized.
This comment has been minimized.
gbutler69
commented
Jun 6, 2018
Would it make sense to have an attribute that could annotate the call-site of the macro to select collapsed vs expanded debug info which overrides the setting made at the macro declaration site? |
This comment has been minimized.
This comment has been minimized.
For the use cases I've encountered so far, the choice has been something that'd belong better on the macro declaration than on the macro invocation. I don't know if others have use cases where being able to override the choice from the macro invocation site would make sense, but I'm pretty confident that at least the primary choice belongs in the macro declaration. |
hsivonen commentedAug 18, 2017
Improves debuggability of, panic stacks for and profiling attribution of code expanded from non-assert-like macros.
By default, annotate code expanded from a macro with debug location info corresponding to the macro definition (i.e. the behavior that's currently available on nightly via
-Zdebug-macros). Add an annotation#[collapse_debuginfo]to enable a particular macro definition to opt to have the expansion annotated with debug location info corresponding to the macro invocation (i.e. the current default behavior).Rust issue, PR that created the current behavior, Internals forum post
Rendered