Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › debug › Dwarf › SelfUnwinder › computeRules Public Function computeRules Doc Source Public Function std.debug.Dwarf.SelfUnwinder.computeRules
pub fn computeRules (
unwinder : *SelfUnwinder ,
gpa : Allocator ,
unwind : *const Dwarf .Unwind ,
load_offset : usize ,
explicit_fde_offset : ?usize ,
) !CacheEntry Params File debug/Dwarf/SelfUnwinder.zig: 74
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 pub fn computeRules (
unwinder : *SelfUnwinder ,
gpa : Allocator ,
unwind : *const Dwarf .Unwind ,
load_offset : usize ,
explicit_fde_offset : ?usize ,
) !CacheEntry {
assert (unwinder .pc != 0 );
const pc_vaddr = unwinder .pc - load_offset ;
const fde_offset = explicit_fde_offset orelse try unwind .lookupPc (
pc_vaddr ,
@sizeOf (usize ),
native_endian ,
) orelse return error .MissingDebugInfo ;
const cie , const fde = try unwind .getFde (fde_offset , native_endian );
// `lookupPc` can return false positives, so check if the FDE *actually* includes the pc
if (pc_vaddr < fde .pc_begin or pc_vaddr >= fde .pc_begin + fde .pc_range ) {
return error .MissingDebugInfo ;
}
unwinder .cfi_vm .reset ();
const row = try unwinder .cfi_vm .runTo (gpa , pc_vaddr , cie , &fde , @sizeOf (usize ), native_endian );
var entry : CacheEntry = .{
.pc = unwinder .pc ,
.cie = cie ,
.cfa_rule = row .cfa ,
.num_rules = undefined ,
.rules_regs = undefined ,
.rules = undefined ,
};
var i : usize = 0 ;
for (unwinder .cfi_vm .rowColumns (&row )) |col | {
if (i == CacheEntry .max_rules ) return error .UnsupportedDebugInfo ;
_ = unwinder .cpu_state .dwarfRegisterBytes (col .register ) catch |err | switch (err ) {
// Reading an unsupported register during unwinding will result in an error, so there is
// no point wasting a rule slot in the cache entry for it.
error .UnsupportedRegister => continue ,
error .InvalidRegister => return error .InvalidDebugInfo ,
};
entry .rules_regs [i ] = col .register ;
entry .rules [i ] = col .rule ;
i += 1 ;
}
entry .num_rules = @intCast (i );
return entry ;
}
Compute the rule set for the address
unwinder.pcfrom the information inunwind. The caller may store the returned rule set in a simple fixed-size cache keyed on thepcfield to avoid frequently recomputing register rules when unwinding many times.To actually apply the computed rules, see
next.