getAttrString
Function parameters
Parameters
- self:*const Die
- di:*Dwarf
- id:u64
- opt_str:?[]const u8
Type definitions in this namespace
Types
- ExceptionFrameHeader
- This represents the decoded .eh_frame_hdr header
Initialize DWARF info.
Functions
- open
- Initialize DWARF info.
- findCompileUnit
- TODO: change this to binary searching the sorted compile unit list
- scanAllUnwindInfo
- If `.eh_frame_hdr` is present, then only the header needs to be parsed.
- scanCieFdeInfo
- Scan `.eh_frame` and `.debug_frame` and build a sorted list of FDEs for binary searching during
- compactUnwindToDwarfRegNumber
- Returns the DWARF register number for an x86_64 register number found in compact unwind info
- bad
- This function is to make it handy to comment out the return and make it
Error sets in this namespace
Error Sets
= [_]?Section{null} ** num_sections
Values
- null_section_array
- = [_]?Section{null} ** num_sections
Source
Implementation
pub fn getAttrString(
self: *const Die,
di: *Dwarf,
id: u64,
opt_str: ?[]const u8,
compile_unit: CompileUnit,
) error{ InvalidDebugInfo, MissingDebugInfo }![]const u8 {
const form_value = self.getAttr(id) orelse return error.MissingDebugInfo;
switch (form_value.*) {
.string => |value| return value,
.strp => |offset| return di.getString(offset),
.strx => |index| {
const debug_str_offsets = di.section(.debug_str_offsets) orelse return bad();
if (compile_unit.str_offsets_base == 0) return bad();
switch (compile_unit.format) {
.@"32" => {
const byte_offset = compile_unit.str_offsets_base + 4 * index;
if (byte_offset + 4 > debug_str_offsets.len) return bad();
const offset = mem.readInt(u32, debug_str_offsets[byte_offset..][0..4], di.endian);
return getStringGeneric(opt_str, offset);
},
.@"64" => {
const byte_offset = compile_unit.str_offsets_base + 8 * index;
if (byte_offset + 8 > debug_str_offsets.len) return bad();
const offset = mem.readInt(u64, debug_str_offsets[byte_offset..][0..8], di.endian);
return getStringGeneric(opt_str, offset);
},
}
},
.line_strp => |offset| return di.getLineString(offset),
else => return bad(),
}
}