| ... | ... | @@ -79,8 +79,8 @@ pub const Abbrev = struct { |
| 79 | 79 | has_children: bool, |
| 80 | 80 | attrs: []Attr, |
| 81 | 81 | |
| 82 | | fn deinit(abbrev: *Abbrev, allocator: Allocator) void { |
| 83 | | allocator.free(abbrev.attrs); |
| 82 | fn deinit(abbrev: *Abbrev, gpa: Allocator) void { |
| 83 | gpa.free(abbrev.attrs); |
| 84 | 84 | abbrev.* = undefined; |
| 85 | 85 | } |
| 86 | 86 | |
| ... | ... | @@ -96,11 +96,11 @@ pub const Abbrev = struct { |
| 96 | 96 | offset: u64, |
| 97 | 97 | abbrevs: []Abbrev, |
| 98 | 98 | |
| 99 | | fn deinit(table: *Table, allocator: Allocator) void { |
| 99 | fn deinit(table: *Table, gpa: Allocator) void { |
| 100 | 100 | for (table.abbrevs) |*abbrev| { |
| 101 | | abbrev.deinit(allocator); |
| 101 | abbrev.deinit(gpa); |
| 102 | 102 | } |
| 103 | | allocator.free(table.abbrevs); |
| 103 | gpa.free(table.abbrevs); |
| 104 | 104 | table.* = undefined; |
| 105 | 105 | } |
| 106 | 106 | |
| ... | ... | @@ -213,8 +213,8 @@ pub const Die = struct { |
| 213 | 213 | value: FormValue, |
| 214 | 214 | }; |
| 215 | 215 | |
| 216 | | fn deinit(self: *Die, allocator: Allocator) void { |
| 217 | | allocator.free(self.attrs); |
| 216 | fn deinit(self: *Die, gpa: Allocator) void { |
| 217 | gpa.free(self.attrs); |
| 218 | 218 | self.* = undefined; |
| 219 | 219 | } |
| 220 | 220 | |
| ... | ... | @@ -368,7 +368,7 @@ pub const ScanError = error{ |
| 368 | 368 | StreamTooLong, |
| 369 | 369 | } || Allocator.Error; |
| 370 | 370 | |
| 371 | | fn scanAllFunctions(di: *Dwarf, allocator: Allocator, endian: Endian) ScanError!void { |
| 371 | fn scanAllFunctions(di: *Dwarf, gpa: Allocator, endian: Endian) ScanError!void { |
| 372 | 372 | var fr: Reader = .fixed(di.section(.debug_info).?); |
| 373 | 373 | var this_unit_offset: u64 = 0; |
| 374 | 374 | |
| ... | ... | @@ -394,7 +394,7 @@ fn scanAllFunctions(di: *Dwarf, allocator: Allocator, endian: Endian) ScanError! |
| 394 | 394 | address_size = try fr.takeByte(); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | | const abbrev_table = try di.getAbbrevTable(allocator, debug_abbrev_offset); |
| 397 | const abbrev_table = try di.getAbbrevTable(gpa, debug_abbrev_offset); |
| 398 | 398 | |
| 399 | 399 | var max_attrs: usize = 0; |
| 400 | 400 | var zig_padding_abbrev_code: u7 = 0; |
| ... | ... | @@ -409,8 +409,8 @@ fn scanAllFunctions(di: *Dwarf, allocator: Allocator, endian: Endian) ScanError! |
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | | const attrs_buf = try allocator.alloc(Die.Attr, max_attrs * 3); |
| 413 | | defer allocator.free(attrs_buf); |
| 412 | const attrs_buf = try gpa.alloc(Die.Attr, max_attrs * 3); |
| 413 | defer gpa.free(attrs_buf); |
| 414 | 414 | var attrs_bufs: [3][]Die.Attr = undefined; |
| 415 | 415 | for (&attrs_bufs, 0..) |*buf, index| buf.* = attrs_buf[index * max_attrs ..][0..max_attrs]; |
| 416 | 416 | |
| ... | ... | @@ -510,7 +510,7 @@ fn scanAllFunctions(di: *Dwarf, allocator: Allocator, endian: Endian) ScanError! |
| 510 | 510 | else => return bad(), |
| 511 | 511 | }; |
| 512 | 512 | |
| 513 | | try di.func_list.append(allocator, .{ |
| 513 | try di.func_list.append(gpa, .{ |
| 514 | 514 | .name = fn_name, |
| 515 | 515 | .pc_range = .{ |
| 516 | 516 | .start = low_pc, |
| ... | ... | @@ -535,7 +535,7 @@ fn scanAllFunctions(di: *Dwarf, allocator: Allocator, endian: Endian) ScanError! |
| 535 | 535 | |
| 536 | 536 | while (try iter.next()) |range| { |
| 537 | 537 | range_added = true; |
| 538 | | try di.func_list.append(allocator, .{ |
| 538 | try di.func_list.append(gpa, .{ |
| 539 | 539 | .name = fn_name, |
| 540 | 540 | .pc_range = .{ |
| 541 | 541 | .start = range.start, |
| ... | ... | @@ -546,7 +546,7 @@ fn scanAllFunctions(di: *Dwarf, allocator: Allocator, endian: Endian) ScanError! |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | if (fn_name != null and !range_added) { |
| 549 | | try di.func_list.append(allocator, .{ |
| 549 | try di.func_list.append(gpa, .{ |
| 550 | 550 | .name = fn_name, |
| 551 | 551 | .pc_range = null, |
| 552 | 552 | }); |
| ... | ... | @@ -560,11 +560,11 @@ fn scanAllFunctions(di: *Dwarf, allocator: Allocator, endian: Endian) ScanError! |
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | | fn scanAllCompileUnits(di: *Dwarf, allocator: Allocator, endian: Endian) ScanError!void { |
| 563 | fn scanAllCompileUnits(di: *Dwarf, gpa: Allocator, endian: Endian) ScanError!void { |
| 564 | 564 | var fr: Reader = .fixed(di.section(.debug_info).?); |
| 565 | 565 | var this_unit_offset: u64 = 0; |
| 566 | 566 | |
| 567 | | var attrs_buf = std.array_list.Managed(Die.Attr).init(allocator); |
| 567 | var attrs_buf = std.array_list.Managed(Die.Attr).init(gpa); |
| 568 | 568 | defer attrs_buf.deinit(); |
| 569 | 569 | |
| 570 | 570 | while (this_unit_offset < fr.buffer.len) { |
| ... | ... | @@ -589,7 +589,7 @@ fn scanAllCompileUnits(di: *Dwarf, allocator: Allocator, endian: Endian) ScanErr |
| 589 | 589 | address_size = try fr.takeByte(); |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | | const abbrev_table = try di.getAbbrevTable(allocator, debug_abbrev_offset); |
| 592 | const abbrev_table = try di.getAbbrevTable(gpa, debug_abbrev_offset); |
| 593 | 593 | |
| 594 | 594 | var max_attrs: usize = 0; |
| 595 | 595 | for (abbrev_table.abbrevs) |abbrev| { |
| ... | ... | @@ -608,7 +608,7 @@ fn scanAllCompileUnits(di: *Dwarf, allocator: Allocator, endian: Endian) ScanErr |
| 608 | 608 | |
| 609 | 609 | if (compile_unit_die.tag_id != DW.TAG.compile_unit) return bad(); |
| 610 | 610 | |
| 611 | | compile_unit_die.attrs = try allocator.dupe(Die.Attr, compile_unit_die.attrs); |
| 611 | compile_unit_die.attrs = try gpa.dupe(Die.Attr, compile_unit_die.attrs); |
| 612 | 612 | |
| 613 | 613 | var compile_unit: CompileUnit = .{ |
| 614 | 614 | .version = version, |
| ... | ... | @@ -645,7 +645,7 @@ fn scanAllCompileUnits(di: *Dwarf, allocator: Allocator, endian: Endian) ScanErr |
| 645 | 645 | } |
| 646 | 646 | }; |
| 647 | 647 | |
| 648 | | try di.compile_unit_list.append(allocator, compile_unit); |
| 648 | try di.compile_unit_list.append(gpa, compile_unit); |
| 649 | 649 | |
| 650 | 650 | this_unit_offset += next_offset; |
| 651 | 651 | } |
| ... | ... | @@ -855,32 +855,32 @@ pub fn findCompileUnit(di: *const Dwarf, endian: Endian, target_address: u64) !* |
| 855 | 855 | |
| 856 | 856 | /// Gets an already existing AbbrevTable given the abbrev_offset, or if not found, |
| 857 | 857 | /// seeks in the stream and parses it. |
| 858 | | fn getAbbrevTable(di: *Dwarf, allocator: Allocator, abbrev_offset: u64) !*const Abbrev.Table { |
| 858 | fn getAbbrevTable(di: *Dwarf, gpa: Allocator, abbrev_offset: u64) !*const Abbrev.Table { |
| 859 | 859 | for (di.abbrev_table_list.items) |*table| { |
| 860 | 860 | if (table.offset == abbrev_offset) { |
| 861 | 861 | return table; |
| 862 | 862 | } |
| 863 | 863 | } |
| 864 | 864 | try di.abbrev_table_list.append( |
| 865 | | allocator, |
| 866 | | try di.parseAbbrevTable(allocator, abbrev_offset), |
| 865 | gpa, |
| 866 | try di.parseAbbrevTable(gpa, abbrev_offset), |
| 867 | 867 | ); |
| 868 | 868 | return &di.abbrev_table_list.items[di.abbrev_table_list.items.len - 1]; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | | fn parseAbbrevTable(di: *Dwarf, allocator: Allocator, offset: u64) !Abbrev.Table { |
| 871 | fn parseAbbrevTable(di: *Dwarf, gpa: Allocator, offset: u64) !Abbrev.Table { |
| 872 | 872 | var fr: Reader = .fixed(di.section(.debug_abbrev).?); |
| 873 | 873 | fr.seek = cast(usize, offset) orelse return bad(); |
| 874 | 874 | |
| 875 | | var abbrevs = std.array_list.Managed(Abbrev).init(allocator); |
| 875 | var abbrevs = std.array_list.Managed(Abbrev).init(gpa); |
| 876 | 876 | defer { |
| 877 | 877 | for (abbrevs.items) |*abbrev| { |
| 878 | | abbrev.deinit(allocator); |
| 878 | abbrev.deinit(gpa); |
| 879 | 879 | } |
| 880 | 880 | abbrevs.deinit(); |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | | var attrs = std.array_list.Managed(Abbrev.Attr).init(allocator); |
| 883 | var attrs = std.array_list.Managed(Abbrev.Attr).init(gpa); |
| 884 | 884 | defer attrs.deinit(); |
| 885 | 885 | |
| 886 | 886 | while (true) { |
| ... | ... | @@ -1446,7 +1446,7 @@ fn getStringGeneric(opt_str: ?[]const u8, offset: u64) ![:0]const u8 { |
| 1446 | 1446 | return str[casted_offset..last :0]; |
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | | pub fn getSymbol(di: *Dwarf, allocator: Allocator, endian: Endian, address: u64) !std.debug.Symbol { |
| 1449 | pub fn getSymbol(di: *Dwarf, gpa: Allocator, endian: Endian, address: u64) !std.debug.Symbol { |
| 1450 | 1450 | const compile_unit = di.findCompileUnit(endian, address) catch |err| switch (err) { |
| 1451 | 1451 | error.MissingDebugInfo, error.InvalidDebugInfo => return .unknown, |
| 1452 | 1452 | else => return err, |
| ... | ... | @@ -1456,7 +1456,7 @@ pub fn getSymbol(di: *Dwarf, allocator: Allocator, endian: Endian, address: u64) |
| 1456 | 1456 | .compile_unit_name = compile_unit.die.getAttrString(di, endian, std.dwarf.AT.name, di.section(.debug_str), compile_unit) catch |err| switch (err) { |
| 1457 | 1457 | error.MissingDebugInfo, error.InvalidDebugInfo => null, |
| 1458 | 1458 | }, |
| 1459 | | .source_location = di.getLineNumberInfo(allocator, endian, compile_unit, address) catch |err| switch (err) { |
| 1459 | .source_location = di.getLineNumberInfo(gpa, endian, compile_unit, address) catch |err| switch (err) { |
| 1460 | 1460 | error.MissingDebugInfo, error.InvalidDebugInfo => null, |
| 1461 | 1461 | else => return err, |
| 1462 | 1462 | }, |