Skip to content

Commit 984d95c

Browse files
committed
Update to the latest version of addr2line and address breaking changes
1 parent d7ef525 commit 984d95c

File tree

3 files changed

+69
-14
lines changed

3 files changed

+69
-14
lines changed

Cargo.lock

Lines changed: 54 additions & 4 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
@@ -24,7 +24,7 @@ path = "./src/bin/espflash.rs"
2424
required-features = ["cli"]
2525

2626
[dependencies]
27-
addr2line = { version = "0.19.0", optional = true }
27+
addr2line = { version = "0.20.0", optional = true }
2828
base64 = "0.21.0"
2929
binread = "2.2.0"
3030
bytemuck = { version = "1.12.3", features = ["derive"] }

espflash/src/cli/monitor/symbols.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::error::Error;
33
use addr2line::{
44
gimli::{EndianRcSlice, RunTimeEndian},
55
object::{read::File, Object},
6-
Context,
6+
Context, LookupResult,
77
};
88

99
// Wrapper around addr2line that allows to look up function names and
@@ -20,6 +20,7 @@ impl<'sym> Symbols<'sym> {
2020

2121
Ok(Self { file, ctx })
2222
}
23+
2324
/// Returns the name of the function at the given address, if one can be found.
2425
pub fn get_name(&self, addr: u64) -> Option<String> {
2526
// The basic steps here are:
@@ -28,15 +29,19 @@ impl<'sym> Symbols<'sym> {
2829
// 3. if no function name is found, try to look it up in the object file
2930
// directly
3031
// 4. return a demangled function name, if one was found
31-
self.ctx
32-
.find_frames(addr)
32+
let mut frames = match self.ctx.find_frames(addr) {
33+
LookupResult::Output(result) => result.unwrap(),
34+
LookupResult::Load { .. } => unimplemented!(),
35+
};
36+
37+
frames
38+
.next()
3339
.ok()
34-
.and_then(|mut frames| {
35-
frames.next().ok().flatten().and_then(|frame| {
36-
frame
37-
.function
38-
.and_then(|name| name.demangle().map(|s| s.into_owned()).ok())
39-
})
40+
.flatten()
41+
.and_then(|frame| {
42+
frame
43+
.function
44+
.and_then(|name| name.demangle().map(|s| s.into_owned()).ok())
4045
})
4146
.or_else(|| {
4247
self.file

0 commit comments

Comments
 (0)