Skip to content

debuginfo: Make names of types in debuginfo reliable and omit source locations from debug info type descriptions. #15199

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

Merged
merged 1 commit into from
Jul 3, 2014

Conversation

michaelwoerister
Copy link
Member

So far, type names generated for debuginfo where a bit sketchy. It was not clearly defined when a name should be fully qualified and when not, if region parameters should be shown or not, and other things like that.
This commit makes the debuginfo module responsible for creating type names instead of using ppaux::ty_to_str() and brings type names (as they show up in the DWARF information) in line with GCC and Clang:

  • The name of the type being described is unqualified. It's path is defined by its position in the namespace hierarchy.
  • Type arguments are always fully qualified, no matter if they would actually be in scope at the type definition location.

Care is also taken to make type names consistent across crate boundaries. That is, the code now tries make the type name the same, regardless if the type is in the local crate or reconstructed from metadata. Otherwise LLVM will complain about violating the one-definition-rule when using link-time-optimization.

This commit also removes all source location information from type descriptions because these cannot be reconstructed for types instantiated from metadata. Again, with LTO enabled, this can lead to two versions of the debuginfo type description, one with and one without source location information, which then triggers the LLVM ODR assertion.
Fortunately, source location information about types is rarely used, so this has little impact. Once source location information is preserved in metadata (#1972) it can also be re-enabled for type descriptions.

RUSTFLAGS=-g make check no works again for me locally, including the LTO test cases (note that I've taken care of #15156 by reverting the change in LLVM that @luqmana identified as the culprit for that issue).

@michaelwoerister
Copy link
Member Author

Forgot to mention: This PR is in response to issue #15045.

@luqmana
Copy link
Member

luqmana commented Jun 28, 2014

@michaelwoerister What do you mean you've reverted the change in LLVM? I don't see any submodule changes.

@michaelwoerister
Copy link
Member Author

I just reverted the change just locally on my machine for testing. This PR does not include any change to LLVM.

On June 28, 2014 9:51:32 AM CEST, Luqman Aden notifications@github.com wrote:

@michaelwoerister What do you mean you've reverted the change in LLVM?
I don't see any submodule changes.


Reply to this email directly or view it on GitHub:
#15199 (comment)

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@luqmana
Copy link
Member

luqmana commented Jun 30, 2014

@michaelwoerister So then, just to be clear, these changes also fix that issue (#15156)?

@michaelwoerister
Copy link
Member Author

No, this PR doesn't fix issue #15156. Sorry for phrasing that so ambiguously. I just had to circumvent the segfault, so I could properly test that LTO + debuginfo now correctly work together. Otherwise the segfaulting issue is not related to this PR or the issue it fixes.

fn push_debuginfo_type_name(cx: &CrateContext,
t: ty::t,
qualified: bool,
output:&mut String) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: line these 2 up with the other arguments.

@michaelwoerister
Copy link
Member Author

I'll add a test case for checking type names. It's not good that these pop_char() errors just slipped through.

@michaelwoerister
Copy link
Member Author

I've added test cases for type names in src/test/debuginfo/type-names.rs but this isn't quite finished yet, so please hold off with any reviewing for now.

…locations from debug info type descriptions.

So far, type names generated for debuginfo where a bit sketchy. It was not clearly defined when a name should be fully qualified and when not, if region parameters should be shown or not, and other things like that.
This commit makes the debuginfo module responsible for creating type names instead of using ppaux::ty_to_str() and brings type names, as they show up in the DWARF information, in line with GCC and Clang:

* The name of the type being described is unqualified. It's path is defined by its position in the namespace hierarchy.
* Type arguments are always fully qualified, no matter if they would actually be in scope at the type definition location.

Care is also taken to reliably make type names consistent across crate boundaries. That is, the code now tries make the type name the same, regardless if the type is in the local crate or reconstructed from metadata. Otherwise LLVM will complain about violating the one-definition-rule when using link-time-optimization.

This commit also removes all source location information from type descriptions because these cannot be reconstructed for types instantiated from metadata. Again, with LTO enabled, this can lead to two versions of the debuginfo type description, one with and one without source location information, which then triggers the LLVM ODR assertion.
Fortunately, source location information about types is rarely used, so this has little impact. Once source location information is preserved in metadata (rust-lang#1972) it can also be reenabled for type descriptions.
@michaelwoerister
Copy link
Member Author

OK, this should be done now. I've added some much needed test cases and fixed an issue with traits in the process. I've also addressed the problems pointed out by @luqmana.

.find_metadata_for_unique_id(unique_type_id) {
Some(metadata) => return metadata,
None => { /* proceed normally */ }
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this what return_if_created_in_meantime! does?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is but I removed the macro in the form that is needed here (returning a DIType) and added another form returning a MetadataCreationResult, because it is used much more often in the other functions. Only two occurences of the "raw metadata" form were left and it competed for a good name with the more often used form, so I decided to get rid of it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok.

@luqmana
Copy link
Member

luqmana commented Jul 2, 2014

@michaelwoerister Just that one last nit, otherwise r=me. Thanks for all your work on this!

bors added a commit that referenced this pull request Jul 3, 2014
…=luqmana

So far, type names generated for debuginfo where a bit sketchy. It was not clearly defined when a name should be fully qualified and when not, if region parameters should be shown or not, and other things like that.
This commit makes the debuginfo module responsible for creating type names instead of using `ppaux::ty_to_str()` and brings type names (as they show up in the DWARF information) in line with GCC and Clang:

* The name of the type being described is unqualified. It's path is defined by its position in the namespace hierarchy.
* Type arguments are always fully qualified, no matter if they would actually be in scope at the type definition location.

Care is also taken to make type names consistent across crate boundaries. That is, the code now tries make the type name the same, regardless if the type is in the local crate or reconstructed from metadata. Otherwise LLVM will complain about violating the one-definition-rule when using link-time-optimization.

This commit also removes all source location information from type descriptions because these cannot be reconstructed for types instantiated from metadata. Again, with LTO enabled, this can lead to two versions of the debuginfo type description, one with and one without source location information, which then triggers the LLVM ODR assertion.
Fortunately, source location information about types is rarely used, so this has little impact. Once source location information is preserved in metadata (#1972) it can also be re-enabled for type descriptions.

`RUSTFLAGS=-g make check` no works again for me locally, including the LTO test cases (note that I've taken care of #15156 by reverting the change in LLVM that @luqmana identified as the culprit for that issue).
@bors bors closed this Jul 3, 2014
@bors bors merged commit 40e0541 into rust-lang:master Jul 3, 2014
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 17, 2023
Revert "Support `#[rustc_coinductive]`"

Reverts rust-lang#15125, addresses rust-lang/rust-analyzer#15125 (comment)

I'll add the support again once I figure out the problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants