Skip to content

Commit 9ee0ba1

Browse files
committed
Update gimli to 0.33
1 parent 484846c commit 9ee0ba1

3 files changed

Lines changed: 25 additions & 17 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ default-run = "klint"
1313
rusqlite = "0.37"
1414
home = "0.5"
1515
object = "0.38.0"
16-
gimli = "0.32.3"
16+
gimli = "0.33"
1717
iced-x86 = { version = "1.21.0", default-features = false, features = ["std", "decoder", "gas"] }
1818

1919
[dev-dependencies]

src/binary_analysis/dwarf.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,12 @@ impl<'file, 'data> DwarfLoader<'file, 'data> {
298298
fn linkage_name(
299299
&self,
300300
unit: &Unit<ReaderTy<'_>>,
301-
die: &DebuggingInformationEntry<'_, '_, ReaderTy<'_>>,
301+
die: &DebuggingInformationEntry<ReaderTy<'_>>,
302302
) -> Result<String, Error> {
303-
let mut attrs = die.attrs();
304303
let mut name = None;
305304
let mut deleg = None;
306305

307-
while let Some(attr) = attrs.next()? {
306+
for attr in die.attrs() {
308307
match attr.name() {
309308
gimli::DW_AT_linkage_name => {
310309
return Ok(self
@@ -347,6 +346,7 @@ impl<'file, 'data> DwarfLoader<'file, 'data> {
347346
let mut entries = unit.entries_at_offset(offset)?;
348347
entries
349348
.next_entry()?
349+
.then_some(())
350350
.ok_or(Error::UnexpectedDwarf("Referenced entry not found"))?;
351351

352352
let next_die = entries.current().unwrap();
@@ -361,19 +361,18 @@ impl<'file, 'data> DwarfLoader<'file, 'data> {
361361
fn ranges(
362362
&self,
363363
unit: &Unit<ReaderTy<'_>>,
364-
die: &DebuggingInformationEntry<'_, '_, ReaderTy<'_>>,
364+
die: &DebuggingInformationEntry<ReaderTy<'_>>,
365365
) -> Result<(SectionIndex, Vec<Range<i64>>), Error> {
366366
let mut ranges = Vec::new();
367367

368-
let mut attrs = die.attrs();
369-
while let Some(attr) = attrs.next()? {
368+
for attr in die.attrs() {
370369
match attr.name() {
371370
gimli::DW_AT_low_pc => {
372371
let Some(low_pc) = self.dwarf().attr_address(unit, attr.value())? else {
373372
Err(Error::UnexpectedDwarf("DW_AT_low_pc is not an address"))?
374373
};
375374

376-
let Some(high_pc) = die.attr_value(gimli::DW_AT_high_pc)? else {
375+
let Some(high_pc) = die.attr_value(gimli::DW_AT_high_pc) else {
377376
Err(Error::UnexpectedDwarf(
378377
"DW_AT_high_pc not found at DW_TAG_inlined_subroutine",
379378
))?
@@ -437,9 +436,9 @@ impl<'file, 'data> DwarfLoader<'file, 'data> {
437436
fn call_location(
438437
&self,
439438
unit: &Unit<ReaderTy<'_>>,
440-
die: &DebuggingInformationEntry<'_, '_, ReaderTy<'_>>,
439+
die: &DebuggingInformationEntry<ReaderTy<'_>>,
441440
) -> Result<Option<Location>, Error> {
442-
let Some(file) = die.attr(gimli::DW_AT_call_file)? else {
441+
let Some(file) = die.attr(gimli::DW_AT_call_file) else {
443442
// This may happen when two calls from different files are merged.
444443
return Ok(None);
445444
};
@@ -454,15 +453,15 @@ impl<'file, 'data> DwarfLoader<'file, 'data> {
454453
.ok_or(Error::UnexpectedDwarf("file number is not udata"))?,
455454
)?;
456455

457-
let Some(line) = die.attr(gimli::DW_AT_call_line)? else {
456+
let Some(line) = die.attr(gimli::DW_AT_call_line) else {
458457
// This may happen when two calls from different lines are merged.
459458
return Ok(None);
460459
};
461460
let line = line
462461
.udata_value()
463462
.ok_or(Error::UnexpectedDwarf("line number is not udata"))?;
464463

465-
let column = match die.attr(gimli::DW_AT_call_column)? {
464+
let column = match die.attr(gimli::DW_AT_call_column) {
466465
None => 0,
467466
Some(column) => column
468467
.udata_value()
@@ -485,10 +484,12 @@ impl<'file, 'data> DwarfLoader<'file, 'data> {
485484

486485
let mut stack = Vec::new();
487486
let mut entries = unit.entries();
488-
while let Some((depth, die)) = entries.next_dfs()? {
489-
for _ in depth..=0 {
487+
let mut prev_depth = 0;
488+
while let Some(die) = entries.next_dfs()? {
489+
for _ in die.depth()..=prev_depth {
490490
stack.pop();
491491
}
492+
prev_depth = die.depth;
492493

493494
if matches!(
494495
die.tag(),

0 commit comments

Comments
 (0)