-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Improve debugging experience for enums on windows-msvc #85292
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f353cbf
Generate better debuginfo for directly tagged enums
wesleywiser b644f06
Resolve EnumTagInfo FIXME
wesleywiser 2a025c1
Remove fallback for containing scopes
wesleywiser 141546c
Generate better debuginfo for niche-layout enums
wesleywiser 2a9fa20
Add/update tests
wesleywiser d650091
Make tidy happy
wesleywiser d2d6fa8
Respond to review feedback
wesleywiser ef053fd
Change the type name from `_enum<..>` to `enum$<..>`
wesleywiser 3127419
Respond to review feedback
wesleywiser 94c45ef
Update generator tests
wesleywiser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
251 changes: 149 additions & 102 deletions
251
compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// only-cdb | ||
// ignore-tidy-linelength | ||
// compile-flags:-g | ||
|
||
// cdb-command: g | ||
|
||
// Note: The natvis used to visualize niche-layout enums don't work correctly in cdb | ||
// so the best we can do is to make sure we are generating the right debuginfo | ||
|
||
// cdb-command: dx -r2 a,! | ||
// cdb-check:a,! [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>] | ||
// cdb-check: [+0x000] dataful_variant [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>::Some] | ||
// cdb-check: [+0x000] __0 : Low (0x2) [Type: msvc_pretty_enums::CStyleEnum] | ||
// cdb-check: [+0x000] discriminant : 0x2 [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>::Discriminant$] | ||
|
||
// cdb-command: dx -r2 b,! | ||
// cdb-check:b,! [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>] | ||
// cdb-check: [+0x000] dataful_variant [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>::Some] | ||
// cdb-check: [+0x000] __0 : 0x11 [Type: msvc_pretty_enums::CStyleEnum] | ||
// cdb-check: [+0x000] discriminant : None (0x11) [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>::Discriminant$] | ||
|
||
// cdb-command: dx -r2 c,! | ||
// cdb-check:c,! [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>] | ||
// cdb-check: [+0x000] dataful_variant [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Data] | ||
// cdb-check: [+0x000] my_data : 0x11 [Type: msvc_pretty_enums::CStyleEnum] | ||
// cdb-check: [+0x000] discriminant : Tag1 (0x11) [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Discriminant$] | ||
|
||
// cdb-command: dx -r2 d,! | ||
// cdb-check:d,! [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>] | ||
// cdb-check: [+0x000] dataful_variant [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Data] | ||
// cdb-check: [+0x000] my_data : High (0x10) [Type: msvc_pretty_enums::CStyleEnum] | ||
// cdb-check: [+0x000] discriminant : 0x10 [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Discriminant$] | ||
|
||
// cdb-command: dx -r2 e,! | ||
// cdb-check:e,! [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>] | ||
// cdb-check: [+0x000] dataful_variant [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Data] | ||
// cdb-check: [+0x000] my_data : 0x13 [Type: msvc_pretty_enums::CStyleEnum] | ||
// cdb-check: [+0x000] discriminant : Tag2 (0x13) [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Discriminant$] | ||
|
||
// cdb-command: dx -r2 f,! | ||
// cdb-check:f,! [Type: enum$<core::option::Option<u32*>, 1, [...], Some>] | ||
// cdb-check: [+0x000] dataful_variant [Type: enum$<core::option::Option<u32*>, 1, [...], Some>::Some] | ||
// cdb-check: [+0x000] __0 : 0x[...] : 0x1 [Type: unsigned int *] | ||
// cdb-check: [+0x000] discriminant : 0x[...] [Type: enum$<core::option::Option<u32*>, 1, [...], Some>::Discriminant$] | ||
|
||
// cdb-command: dx -r2 g,! | ||
// cdb-check:g,! [Type: enum$<core::option::Option<u32*>, 1, [...], Some>] | ||
// cdb-check: [+0x000] dataful_variant [Type: enum$<core::option::Option<u32*>, 1, [...], Some>::Some] | ||
// cdb-check: [+0x000] __0 : 0x0 [Type: unsigned int *] | ||
// cdb-check: [+0x000] discriminant : None (0x0) [Type: enum$<core::option::Option<u32*>, 1, [...], Some>::Discriminant$] | ||
|
||
// cdb-command: dx h | ||
// cdb-check:h : Some [Type: enum$<core::option::Option<u32>>] | ||
// cdb-check: [+0x000] variant$ : Some (0x1) [Type: core::option::Option] | ||
// cdb-check: [+0x004] __0 : 0xc [Type: unsigned int] | ||
|
||
// cdb-command: dx i | ||
// cdb-check:i : None [Type: enum$<core::option::Option<u32>>] | ||
// cdb-check: [+0x000] variant$ : None (0x0) [Type: core::option::Option] | ||
|
||
// cdb-command: dx j | ||
// cdb-check:j : High (0x10) [Type: msvc_pretty_enums::CStyleEnum] | ||
|
||
// cdb-command: dx -r2 k,! | ||
// cdb-check:k,! [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>] | ||
// cdb-check: [+0x000] dataful_variant [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>::Some] | ||
// cdb-check: [+0x000] __0 [Type: alloc::string::String] | ||
// cdb-check: [+0x000] discriminant : 0x[...] [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>::Discriminant$] | ||
|
||
pub enum CStyleEnum { | ||
Low = 2, | ||
High = 16, | ||
} | ||
|
||
pub enum NicheLayoutEnum { | ||
Tag1, | ||
Data { my_data: CStyleEnum }, | ||
Tag2, | ||
} | ||
|
||
fn main() { | ||
let a = Some(CStyleEnum::Low); | ||
let b = Option::<CStyleEnum>::None; | ||
let c = NicheLayoutEnum::Tag1; | ||
let d = NicheLayoutEnum::Data { my_data: CStyleEnum::High }; | ||
let e = NicheLayoutEnum::Tag2; | ||
let f = Some(&1u32); | ||
let g = Option::<&'static u32>::None; | ||
let h = Some(12u32); | ||
let i = Option::<u32>::None; | ||
let j = CStyleEnum::High; | ||
let k = Some("IAMA optional string!".to_string()); | ||
|
||
zzz(); // #break | ||
} | ||
|
||
fn zzz() { () } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.