-
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
Port repr128-dwarf run-make test to rmake #124280
Merged
Merged
Changes from all commits
Commits
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
This file contains 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 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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,75 @@ | ||
//@ ignore-windows | ||
// This test should be replaced with one in tests/debuginfo once GDB or LLDB support 128-bit enums. | ||
Noratrieb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
extern crate run_make_support; | ||
|
||
use gimli::{AttributeValue, Dwarf, EndianRcSlice, Reader, RunTimeEndian}; | ||
use object::{Object, ObjectSection}; | ||
use run_make_support::{gimli, object, rustc, tmp_dir}; | ||
use std::borrow::Cow; | ||
use std::collections::HashMap; | ||
use std::rc::Rc; | ||
|
||
fn main() { | ||
let output = tmp_dir().join("repr128"); | ||
rustc().input("main.rs").arg("-o").arg(&output).arg("-Cdebuginfo=2").run(); | ||
// Mach-O uses packed debug info | ||
let dsym_location = output | ||
.with_extension("dSYM") | ||
.join("Contents") | ||
.join("Resources") | ||
.join("DWARF") | ||
.join("repr128"); | ||
let output = | ||
std::fs::read(if dsym_location.try_exists().unwrap() { dsym_location } else { output }) | ||
.unwrap(); | ||
let obj = object::File::parse(output.as_slice()).unwrap(); | ||
let endian = if obj.is_little_endian() { RunTimeEndian::Little } else { RunTimeEndian::Big }; | ||
let dwarf = gimli::Dwarf::load(|section| -> Result<_, ()> { | ||
let data = obj.section_by_name(section.name()).map(|s| s.uncompressed_data().unwrap()); | ||
Ok(EndianRcSlice::new(Rc::from(data.unwrap_or_default().as_ref()), endian)) | ||
}) | ||
.unwrap(); | ||
let mut iter = dwarf.units(); | ||
let mut still_to_find = HashMap::from([ | ||
("U128A", 0_u128), | ||
("U128B", 1_u128), | ||
("U128C", u64::MAX as u128 + 1), | ||
("U128D", u128::MAX), | ||
("I128A", 0_i128 as u128), | ||
("I128B", (-1_i128) as u128), | ||
("I128C", i128::MIN as u128), | ||
("I128D", i128::MAX as u128), | ||
]); | ||
while let Some(header) = iter.next().unwrap() { | ||
let unit = dwarf.unit(header).unwrap(); | ||
let mut cursor = unit.entries(); | ||
while let Some((_, entry)) = cursor.next_dfs().unwrap() { | ||
if entry.tag() == gimli::constants::DW_TAG_enumerator { | ||
let name = dwarf | ||
.attr_string( | ||
&unit, | ||
entry.attr(gimli::constants::DW_AT_name).unwrap().unwrap().value(), | ||
) | ||
.unwrap(); | ||
let name = name.to_string().unwrap(); | ||
if let Some(expected) = still_to_find.remove(name.as_ref()) { | ||
match entry.attr(gimli::constants::DW_AT_const_value).unwrap().unwrap().value() | ||
{ | ||
AttributeValue::Block(value) => { | ||
assert_eq!( | ||
value.to_slice().unwrap(), | ||
expected.to_le_bytes().as_slice(), | ||
"{name}" | ||
); | ||
} | ||
value => panic!("{name}: unexpected DW_AT_const_value of {value:?}"), | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if !still_to_find.is_empty() { | ||
panic!("Didn't find debug entries for {still_to_find:?}"); | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, do we want to force edition 2021 for every rmake test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why not. The
rmake
test files are “developer-facing” after all unlike the Rust files found in e.g.tests/ui
. They are test runners, not “test subjects”. Lol, lacking the proper words rn. Similarly,compiler/
/rustc_*
crates all default to Rust 2021.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense yeah, I was just wondering if where was any weird edge cases I have not considered