MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / load_dwp

Function load_dwp

crates/cranelift/src/debug/transform/mod.rs:43–95  ·  view source on GitHub ↗
(
    translation: ModuleTranslation<'data>,
    buffer: &'data [u8],
)

Source from the content-addressed store, hash-verified

41}
42
43fn load_dwp<'data>(
44 translation: ModuleTranslation<'data>,
45 buffer: &'data [u8],
46) -> Result<DwarfPackage<gimli::EndianSlice<'data, gimli::LittleEndian>>> {
47 let endian_slice = gimli::EndianSlice::new(buffer, LittleEndian);
48
49 let dwarf_package = DwarfPackage::load(
50 |id| -> Result<_> {
51 let slice = match id {
52 gimli::SectionId::DebugAbbrev => {
53 translation.debuginfo.dwarf.debug_abbrev.reader().slice()
54 }
55 gimli::SectionId::DebugInfo => {
56 translation.debuginfo.dwarf.debug_info.reader().slice()
57 }
58 gimli::SectionId::DebugLine => {
59 translation.debuginfo.dwarf.debug_line.reader().slice()
60 }
61 gimli::SectionId::DebugStr => {
62 translation.debuginfo.dwarf.debug_str.reader().slice()
63 }
64 gimli::SectionId::DebugStrOffsets => translation
65 .debuginfo
66 .dwarf
67 .debug_str_offsets
68 .reader()
69 .slice(),
70 gimli::SectionId::DebugLoc => translation.debuginfo.debug_loc.reader().slice(),
71 gimli::SectionId::DebugLocLists => {
72 translation.debuginfo.debug_loclists.reader().slice()
73 }
74 gimli::SectionId::DebugRngLists => {
75 translation.debuginfo.debug_rnglists.reader().slice()
76 }
77 gimli::SectionId::DebugTypes => {
78 translation.debuginfo.dwarf.debug_types.reader().slice()
79 }
80 gimli::SectionId::DebugCuIndex => {
81 translation.debuginfo.debug_cu_index.reader().slice()
82 }
83 gimli::SectionId::DebugTuIndex => {
84 translation.debuginfo.debug_tu_index.reader().slice()
85 }
86 _ => &buffer,
87 };
88
89 Ok(gimli::EndianSlice::new(slice, gimli::LittleEndian))
90 },
91 endian_slice,
92 )?;
93
94 Ok(dwarf_package)
95}
96
97/// Attempts to load a DWARF package using the passed bytes.
98fn read_dwarf_package_from_bytes<'data>(

Callers 1

Calls 4

OkFunction · 0.85
newFunction · 0.50
loadFunction · 0.50
sliceMethod · 0.45

Tested by

no test coverage detected