in src/line.rs [186:222]
fn compute_len(&mut self, sym_rva: u32, sym_len: u32) {
// The length (in the binary) of the line is not in the pdb but we can infer it
// based on the rva of the next line. For the last line, we can infer it because
// we know the length of the function symbol, and we are only concerned with the
// line records of a single function here:
//
// RVA LINE NUMBER
// 0x0001 10 <= the size of line 10 is 0x000B - 0x0001
// 0x000B 11
// ...
// 0x002A 15 <= the size of line 15 is (0x0001 + sym length) - 0x002A
if self.lines.is_empty() {
return;
}
assert!(
self.are_lines_sorted,
"Call ensure_order() before calling compute_len()"
);
let lens: Vec<u32> = self.lines.windows(2).map(|w| w[1].rva - w[0].rva).collect();
// Cannot fail since self.lines isn't empty
let (last, lines) = self.lines.split_last_mut().unwrap();
lines
.iter_mut()
.zip(lens.iter())
.for_each(|(line, len)| line.len = *len);
if let Some(function_end_rva) = sym_rva.checked_add(sym_len) {
if last.rva < function_end_rva {
last.len = function_end_rva - last.rva;
}
}
}