Skip to content

Commit 23c7419

Browse files
feat: Update addr2line (#946)
1 parent 1e34651 commit 23c7419

File tree

3 files changed

+68
-81
lines changed

3 files changed

+68
-81
lines changed

Cargo.lock

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

espflash/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ path = "./src/bin/espflash.rs"
2929
required-features = ["cli", "serialport"]
3030

3131
[dependencies]
32-
addr2line = { version = "=0.22.0", optional = true }
32+
addr2line = { version = "0.25", optional = true }
3333
base64 = "0.22"
3434
bitflags = "2.9"
3535
bytemuck = { version = "1.23", features = ["derive"] }

espflash/src/cli/monitor/symbols.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,32 @@ use std::error::Error;
33
use addr2line::{
44
Context,
55
LookupResult,
6-
gimli::{EndianRcSlice, RunTimeEndian},
7-
object::{Object, ObjectSegment, ObjectSymbol, read::File},
6+
gimli::{self, Dwarf, EndianSlice, LittleEndian, SectionId},
87
};
8+
use object::{Object, ObjectSection, ObjectSegment, ObjectSymbol, read::File};
99

1010
// Wrapper around addr2line that allows to look up function names and
1111
// locations from a given address.
1212
pub(crate) struct Symbols<'sym> {
1313
object: File<'sym, &'sym [u8]>,
14-
ctx: Context<EndianRcSlice<RunTimeEndian>>,
14+
ctx: Context<EndianSlice<'sym, LittleEndian>>,
1515
}
1616

1717
impl<'sym> Symbols<'sym> {
1818
/// Tries to create a new `Symbols` instance from the given ELF file bytes.
1919
pub fn try_from(bytes: &'sym [u8]) -> Result<Self, Box<dyn Error>> {
2020
let object = File::parse(bytes)?;
21-
let ctx = Context::new(&object)?;
21+
let dwarf = Dwarf::load(
22+
|id: SectionId| -> Result<EndianSlice<'sym, LittleEndian>, gimli::Error> {
23+
let data = object
24+
.section_by_name(id.name())
25+
.and_then(|section| section.data().ok())
26+
.unwrap_or(&[][..]);
27+
Ok(EndianSlice::new(data, LittleEndian))
28+
},
29+
)?;
30+
31+
let ctx = Context::from_dwarf(dwarf)?;
2232

2333
Ok(Self { object, ctx })
2434
}

0 commit comments

Comments
 (0)