Skip to content

Commit 7ee620a

Browse files
Update gimli and addr2line dependencies (#12424)
* Update gimli and addr2line dependencies gimli has a significant number of breaking changes to adapt to. * Add vets --------- Co-authored-by: Alex Crichton <[email protected]>
1 parent 17bff9d commit 7ee620a

File tree

14 files changed

+135
-132
lines changed

14 files changed

+135
-132
lines changed

Cargo.lock

Lines changed: 23 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ backtrace = "0.3.75"
363363
mutatis = "0.3.2"
364364
cc = "1.2.41"
365365
object = { version = "0.37.3", default-features = false, features = ['read_core', 'elf'] }
366-
gimli = { version = "0.32.3", default-features = false, features = ['read'] }
367-
addr2line = { version = "0.25.1", default-features = false }
366+
gimli = { version = "0.33.0", default-features = false, features = ['read'] }
367+
addr2line = { version = "0.26.0", default-features = false }
368368
anyhow = { version = "1.0.100", default-features = false }
369369
anyhow-for-testing = { package = "anyhow", version = "1.0.100", default-features = false }
370370
windows-sys = "0.61.2"

crates/cranelift/src/debug/gc.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ fn has_die_back_edge(die: &read::DebuggingInformationEntry<Reader<'_>>) -> read:
137137
| constants::DW_TAG_imported_declaration
138138
| constants::DW_TAG_imported_module
139139
| constants::DW_TAG_module => false,
140-
constants::DW_TAG_subprogram => die.attr(constants::DW_AT_declaration)?.is_some(),
140+
constants::DW_TAG_subprogram => die.attr(constants::DW_AT_declaration).is_some(),
141141
_ => true,
142142
};
143143
Ok(result)
@@ -150,14 +150,14 @@ fn has_valid_code_range(
150150
) -> read::Result<bool> {
151151
match die.tag() {
152152
constants::DW_TAG_subprogram => {
153-
if let Some(ranges_attr) = die.attr_value(constants::DW_AT_ranges)? {
153+
if let Some(ranges_attr) = die.attr_value(constants::DW_AT_ranges) {
154154
let offset = match ranges_attr {
155155
read::AttributeValue::RangeListsRef(val) => unit.ranges_offset_from_raw(val),
156156
read::AttributeValue::DebugRngListsIndex(index) => unit.ranges_offset(index)?,
157157
_ => return Ok(false),
158158
};
159159
let mut has_valid_base = if let Some(read::AttributeValue::Addr(low_pc)) =
160-
die.attr_value(constants::DW_AT_low_pc)?
160+
die.attr_value(constants::DW_AT_low_pc)
161161
{
162162
Some(at.can_translate_address(low_pc))
163163
} else {
@@ -200,7 +200,7 @@ fn has_valid_code_range(
200200
}
201201
}
202202
return Ok(false);
203-
} else if let Some(low_pc) = die.attr_value(constants::DW_AT_low_pc)? {
203+
} else if let Some(low_pc) = die.attr_value(constants::DW_AT_low_pc) {
204204
if let read::AttributeValue::Addr(a) = low_pc {
205205
return Ok(at.can_translate_address(a));
206206
} else if let read::AttributeValue::DebugAddrIndex(i) = low_pc {
@@ -222,9 +222,8 @@ fn build_die_dependencies(
222222
) -> read::Result<()> {
223223
let entry = die.entry();
224224
let offset = entry.offset().to_unit_section_offset(&unit);
225-
let mut attrs = entry.attrs();
226-
while let Some(attr) = attrs.next()? {
227-
build_attr_dependencies(&attr, offset, unit, at, deps)?;
225+
for attr in entry.attrs() {
226+
build_attr_dependencies(attr, offset, unit, at, deps)?;
228227
}
229228

230229
let mut children = die.children();
@@ -256,7 +255,7 @@ fn build_attr_dependencies(
256255
deps.add_edge(offset, ref_offset);
257256
}
258257
read::AttributeValue::DebugInfoRef(val) => {
259-
let ref_offset = UnitSectionOffset::DebugInfoOffset(val);
258+
let ref_offset = UnitSectionOffset(val.0);
260259
deps.add_edge(offset, ref_offset);
261260
}
262261
_ => (),

crates/cranelift/src/debug/transform/attr.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ pub(crate) fn clone_die_attributes<'a>(
7676
let mut is_obj_ptr = false;
7777
prepare_die_context(unit, entry, &mut attr_context, &mut is_obj_ptr)?;
7878

79-
let mut attrs = entry.attrs();
80-
while let Some(attr) = attrs.next()? {
79+
for attr in entry.attrs() {
8180
match attr.name() {
8281
gimli::DW_AT_low_pc | gimli::DW_AT_high_pc | gimli::DW_AT_ranges => {
8382
// Handled by RangeInfoBuilder.
@@ -420,13 +419,13 @@ fn is_obj_ptr_param<'a>(
420419
// why do we need this heuristic as well?
421420
// A: Declarations do not include DW_AT_object_pointer.
422421
if param_num == 0
423-
&& entry.attr_value(gimli::DW_AT_artificial)? == Some(AttributeValue::Flag(true))
422+
&& entry.attr_value(gimli::DW_AT_artificial) == Some(AttributeValue::Flag(true))
424423
{
425424
// Either this has no name (declarations omit them), or its explicitly "this".
426-
let name = entry.attr_value(gimli::DW_AT_name)?;
425+
let name = entry.attr_value(gimli::DW_AT_name);
427426
if name.is_none() || unit.attr_string(name.unwrap())?.slice().eq(b"this") {
428427
// Finally, a type check. We expect a pointer.
429-
if let Some(type_attr) = entry.attr_value(gimli::DW_AT_type)? {
428+
if let Some(type_attr) = entry.attr_value(gimli::DW_AT_type) {
430429
if let Some(type_die) = resolve_die_ref(unit, &type_attr)? {
431430
return Ok(type_die.tag() == gimli::DW_TAG_pointer_type);
432431
}

crates/cranelift/src/debug/transform/debug_transform_logging.rs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
use crate::{debug::Reader, translate::get_vmctx_value_label};
22
use core::fmt;
33
use cranelift_codegen::{LabelValueLoc, ValueLabelsRanges, ir::ValueLabel, isa::TargetIsa};
4-
use gimli::{
5-
AttributeValue, DebuggingInformationEntry, LittleEndian, UnitOffset, UnitRef,
6-
UnitSectionOffset, write,
7-
};
4+
use gimli::{AttributeValue, DebuggingInformationEntry, LittleEndian, UnitOffset, UnitRef, write};
85

96
macro_rules! dbi_log_enabled {
107
() => {
@@ -29,8 +26,7 @@ pub struct CompileUnitSummary<'a, 'r> {
2926
impl<'a, 'r> fmt::Debug for CompileUnitSummary<'a, 'r> {
3027
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3128
let unit = self.unit;
32-
let offs = get_offset_value(unit.header.offset());
33-
write!(f, "0x{offs:08x} [")?;
29+
write!(f, "0x{:08x} [", unit.header.offset().0)?;
3430
let comp_dir = match unit.comp_dir {
3531
Some(dir) => &dir.to_string_lossy(),
3632
None => "None",
@@ -56,8 +52,7 @@ pub struct DieRefSummary<'a, 'r> {
5652
impl<'a, 'r> fmt::Debug for DieRefSummary<'a, 'r> {
5753
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5854
let section_offs = self.unit_ref.to_unit_section_offset(&self.unit);
59-
let offs = get_offset_value(section_offs);
60-
write!(f, "0x{offs:08x}")
55+
write!(f, "0x{:08x}", section_offs.0)
6156
}
6257
}
6358

@@ -70,7 +65,7 @@ pub fn log_get_die_ref<'a, 'r>(
7065

7166
struct DieDetailedSummary<'a, 'r> {
7267
unit: UnitRef<'a, Reader<'r>>,
73-
die: &'a DebuggingInformationEntry<'a, 'a, Reader<'r>>,
68+
die: &'a DebuggingInformationEntry<Reader<'r>>,
7469
}
7570

7671
pub fn log_begin_input_die<'r>(
@@ -92,8 +87,7 @@ impl<'a, 'r> fmt::Debug for DieDetailedSummary<'a, 'r> {
9287
let unit = self.unit;
9388
write!(f, "{}\n", die.tag())?;
9489

95-
let mut attrs = die.attrs();
96-
while let Some(attr) = attrs.next().unwrap_or(None) {
90+
for attr in die.attrs() {
9791
write!(f, " {} (", attr.name())?;
9892
let attr_value = attr.value();
9993
match attr_value {
@@ -150,8 +144,7 @@ impl<'a, 'r> fmt::Debug for DieDetailedSummary<'a, 'r> {
150144
AttributeValue::Inline(value) => write!(f, "{value}"),
151145
AttributeValue::Ordering(value) => write!(f, "{value}"),
152146
AttributeValue::UnitRef(offset) => {
153-
let section_offset = offset.to_unit_section_offset(&unit);
154-
write!(f, "0x{:08x}", get_offset_value(section_offset))
147+
write!(f, "0x{:08x}", offset.to_unit_section_offset(&unit).0)
155148
}
156149
AttributeValue::DebugInfoRef(offset) => write!(f, "0x{:08x}", offset.0),
157150
unexpected_attr => write!(f, "<unexpected attr: {unexpected_attr:?}>"),
@@ -226,8 +219,8 @@ impl<'a> fmt::Debug for OutDieDetailedSummary<'a> {
226219
write::AttributeValue::Ordering(value) => write!(f, "{value}"),
227220
write::AttributeValue::UnitRef(unit_ref) => write!(f, "{unit_ref:?}>"),
228221
write::AttributeValue::DebugInfoRef(reference) => match reference {
229-
write::Reference::Symbol(index) => write!(f, "symbol #{index}>"),
230-
write::Reference::Entry(unit_id, die_id) => {
222+
write::DebugInfoRef::Symbol(index) => write!(f, "symbol #{index}>"),
223+
write::DebugInfoRef::Entry(unit_id, die_id) => {
231224
write!(f, "{die_id:?} in {unit_id:?}>")
232225
}
233226
},
@@ -273,13 +266,6 @@ pub fn log_end_output_die_skipped(
273266
);
274267
}
275268

276-
fn get_offset_value(offset: UnitSectionOffset) -> usize {
277-
match offset {
278-
UnitSectionOffset::DebugInfoOffset(offs) => offs.0,
279-
UnitSectionOffset::DebugTypesOffset(offs) => offs.0,
280-
}
281-
}
282-
283269
pub fn log_get_value_name(value: ValueLabel) -> ValueNameSummary {
284270
ValueNameSummary { value }
285271
}

crates/cranelift/src/debug/transform/expression.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,9 @@ where
647647
| Operation::ImplicitValue { .. }
648648
| Operation::ImplicitPointer { .. }
649649
| Operation::EntryValue { .. }
650-
| Operation::ParameterRef { .. } => {
650+
| Operation::ParameterRef { .. }
651+
| Operation::VariableValue { .. }
652+
| Operation::Uninitialized => {
651653
return Ok(None);
652654
}
653655
Operation::WasmGlobal { index: _ } | Operation::WasmStack { index: _ } => {

0 commit comments

Comments
 (0)