MCPcopy Index your code
hub / github.com/encounter/objdiff / parse_line_info_dwarf1

Function parse_line_info_dwarf1

objdiff-core/src/obj/read.rs:734–763  ·  view source on GitHub ↗

Parse .line section from DWARF 1.1 format.

(obj_file: &object::File, sections: &mut [Section])

Source from the content-addressed store, hash-verified

732
733/// Parse .line section from DWARF 1.1 format.
734fn parse_line_info_dwarf1(obj_file: &object::File, sections: &mut [Section]) -> Result<()> {
735 if let Some(section) = obj_file.section_by_name(".line") {
736 let data = section.uncompressed_data()?;
737 let mut reader: &[u8] = data.as_ref();
738
739 let mut text_sections = sections.iter_mut().filter(|s| s.kind == SectionKind::Code);
740 while !reader.is_empty() {
741 let mut section_data = reader;
742 let size = read_u32(obj_file, &mut section_data)? as usize;
743 if size > reader.len() {
744 bail!("Line info size {size} exceeds remaining size {}", reader.len());
745 }
746 (section_data, reader) = reader.split_at(size);
747
748 section_data = &section_data[4..]; // Skip the size field
749 let base_address = read_u32(obj_file, &mut section_data)? as u64;
750 let out_section = text_sections.next().context("No text section for line info")?;
751 while !section_data.is_empty() {
752 let line_number = read_u32(obj_file, &mut section_data)?;
753 let statement_pos = read_u16(obj_file, &mut section_data)?;
754 if statement_pos != 0xFFFF {
755 log::warn!("Unhandled statement pos {statement_pos}");
756 }
757 let address_delta = read_u32(obj_file, &mut section_data)? as u64;
758 out_section.line_info.insert(base_address + address_delta, line_number);
759 }
760 }
761 }
762 Ok(())
763}
764
765fn parse_line_info_coff(
766 coff: &object::coff::CoffFile,

Callers 1

parse_line_infoFunction · 0.85

Calls 4

iter_mutMethod · 0.80
nextMethod · 0.80
read_u32Function · 0.70
read_u16Function · 0.70

Tested by

no test coverage detected