Skip to content

Commit 1cede08

Browse files
authored
Merge pull request #17 from roblabla/use-upstream-gimli
Use upstream gimli
2 parents 1a8bc08 + eaef772 commit 1cede08

File tree

5 files changed

+27
-42
lines changed

5 files changed

+27
-42
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ debug = true
88
members = ["unwind"]
99

1010
#[patch.crates-io]
11-
#gimli = { git = 'https://github.com/main--/gimli.git?branch=unwind-patches' }
11+
#gimli = { git = 'https://github.com/roblabla/gimli.git?branch=lookup_and_parse' }
1212
[replace]
13-
"gimli:0.14.0" = { git = 'https://github.com/main--/gimli.git', branch = 'unwind-patches' }
13+
"gimli:0.16.0" = { git = 'https://github.com/roblabla/gimli.git', branch = 'lookup_and_parse' }

unwind/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
authors = ["main() <[email protected]>"]
55

66
[dependencies]
7-
gimli = "0.14"
7+
gimli = "0.16"
88
libc = "0.2"
99
fallible-iterator = "0.1"
1010
log = "0.4"

unwind/examples/demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn foo() {
1919
}
2020

2121
fn main() {
22-
env_logger::init().unwrap();
22+
env_logger::init();
2323

2424
foo();
2525
println!("down");

unwind/examples/trace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn foo() {
2020
}
2121

2222
fn main() {
23-
env_logger::init().unwrap();
23+
env_logger::init();
2424

2525
foo();
2626
println!("down");

unwind/src/lib.rs

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -115,47 +115,32 @@ impl ObjectRecord {
115115
..
116116
} = self;
117117

118-
let fdeptr = eh_frame_hdr.table().unwrap().lookup(address, bases).unwrap();
119-
let fdeptr = match fdeptr {
120-
Pointer::Direct(x) => x,
121-
_ => unreachable!(),
122-
};
123-
124-
let entry = gimli::parse_cfi_entry(bases, *sel, &mut EndianBuf::new(unsafe { std::slice::from_raw_parts(fdeptr as *const u8, 0x1000000) }, NativeEndian)).unwrap().unwrap();
125-
let target_fde = match entry {
126-
CieOrFde::Fde(fde) => Some(fde.parse(|offset| sel.cie_from_offset(bases, offset))?),
127-
CieOrFde::Cie(_) => unimplemented!(), // return error here probably
128-
};
129-
130-
131-
if let Some(fde) = target_fde {
132-
trace!("fde {:x} - {:x}", fde.initial_address(), fde.len());
133-
assert!(fde.contains(address));
134-
let mut result_row = None;
135-
let mut ctx = ctx.initialize(fde.cie()).unwrap();
136-
137-
{
138-
let mut table = UnwindTable::new(&mut ctx, &fde);
139-
while let Some(row) = table.next_row()? {
140-
if row.contains(address) {
141-
result_row = Some(row.clone());
142-
break;
143-
}
118+
let fde = eh_frame_hdr.table().unwrap()
119+
.lookup_and_parse(address, bases, sel.clone(), |offset| sel.cie_from_offset(bases, offset))?;
120+
121+
let mut result_row = None;
122+
let mut ctx = ctx.initialize(fde.cie()).unwrap();
123+
124+
{
125+
let mut table = UnwindTable::new(&mut ctx, &fde);
126+
while let Some(row) = table.next_row()? {
127+
if row.contains(address) {
128+
result_row = Some(row.clone());
129+
break;
144130
}
145131
}
146-
147-
if let Some(row) = result_row {
148-
return Ok(UnwindInfo {
149-
row,
150-
ctx: ctx.reset(),
151-
personality: fde.personality(),
152-
lsda: fde.lsda(),
153-
initial_address: fde.initial_address(),
154-
});
155-
}
156132
}
157133

158-
Err(gimli::Error::NoUnwindInfoForAddress)
134+
match result_row {
135+
Some(row) => Ok(UnwindInfo {
136+
row,
137+
ctx: ctx.reset(),
138+
personality: fde.personality(),
139+
lsda: fde.lsda(),
140+
initial_address: fde.initial_address(),
141+
}),
142+
None => Err(gimli::Error::NoUnwindInfoForAddress)
143+
}
159144
}
160145
}
161146

0 commit comments

Comments
 (0)