Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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. Private Function

parseAbbrevTable

Private Function
std.debug.Dwarf.parseAbbrevTable
fn parseAbbrevTable(di: *Dwarf, gpa: Allocator, offset: u64) !Abbrev.Table

Params

File

debug/Dwarf.zig:883
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
fn parseAbbrevTable(di: *Dwarf, gpa: Allocator, offset: u64) !Abbrev.Table {
    var fr: Reader = .fixed(di.section(.debug_abbrev).?);
    fr.seek = cast(usize, offset) orelse return bad();

    var abbrevs: std.ArrayList(Abbrev) = .empty;
    defer {
        for (abbrevs.items) |*abbrev| {
            abbrev.deinit(gpa);
        }
        abbrevs.deinit(gpa);
    }

    var attrs: std.ArrayList(Abbrev.Attr) = .empty;
    defer attrs.deinit(gpa);

    while (true) {
        const code = try fr.takeLeb128(u64);
        if (code == 0) break;
        const tag_id = try fr.takeLeb128(u64);
        const has_children = (try fr.takeByte()) == DW.CHILDREN.yes;

        while (true) {
            const attr_id = try fr.takeLeb128(u64);
            const form_id = try fr.takeLeb128(u64);
            if (attr_id == 0 and form_id == 0) break;
            try attrs.append(gpa, .{
                .id = attr_id,
                .form_id = form_id,
                .payload = switch (form_id) {
                    FORM.implicit_const => try fr.takeLeb128(i64),
                    else => undefined,
                },
            });
        }
        try abbrevs.ensureUnusedCapacity(gpa, 1);
        abbrevs.appendAssumeCapacity(.{
            .code = code,
            .tag_id = tag_id,
            .has_children = has_children,
            .attrs = try attrs.toOwnedSlice(gpa),
        });
    }

    return .{
        .offset = offset,
        .abbrevs = try abbrevs.toOwnedSlice(gpa),
    };
}