| author | |
| committer | |
| log | d98fc53b8fbe479f828114b0276d5290146cc2a3 |
| tree | 446b6e4a430ee44d10fca677af4add27a804614a |
| parent | b3277c893691c462ec2e82577a78e7baafb42bf6 |
3 files changed, 17 insertions(+), 25 deletions(-)
src/link/Dwarf.zig+6-14| ... | ... | @@ -18,8 +18,9 @@ const LinkBlock = File.LinkBlock; |
| 18 | 18 | const LinkFn = File.LinkFn; |
| 19 | 19 | const LinkerLoad = @import("../codegen.zig").LinkerLoad; |
| 20 | 20 | const Module = @import("../Module.zig"); |
| 21 | const Value = @import("../value.zig").Value; | |
| 21 | const StringTable = @import("strtab.zig").StringTable; | |
| 22 | 22 | const Type = @import("../type.zig").Type; |
| 23 | const Value = @import("../value.zig").Value; | |
| 23 | 24 | |
| 24 | 25 | allocator: Allocator, |
| 25 | 26 | bin_file: *File, |
| ... | ... | @@ -42,7 +43,7 @@ abbrev_table_offset: ?u64 = null, |
| 42 | 43 | |
| 43 | 44 | /// TODO replace with InternPool |
| 44 | 45 | /// Table of debug symbol names. |
| 45 | strtab: std.ArrayListUnmanaged(u8) = .{}, | |
| 46 | strtab: StringTable(.strtab) = .{}, | |
| 46 | 47 | |
| 47 | 48 | /// Quick lookup array of all defined source files referenced by at least one Decl. |
| 48 | 49 | /// They will end up in the DWARF debug_line header as two lists: |
| ... | ... | @@ -1770,11 +1771,11 @@ pub fn writeDbgInfoHeader(self: *Dwarf, module: *Module, low_pc: u64, high_pc: u |
| 1770 | 1771 | }, |
| 1771 | 1772 | } |
| 1772 | 1773 | // Write the form for the compile unit, which must match the abbrev table above. |
| 1773 | const name_strp = try self.makeString(module.root_pkg.root_src_path); | |
| 1774 | const name_strp = try self.strtab.insert(self.allocator, module.root_pkg.root_src_path); | |
| 1774 | 1775 | var compile_unit_dir_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; |
| 1775 | 1776 | const compile_unit_dir = resolveCompilationDir(module, &compile_unit_dir_buffer); |
| 1776 | const comp_dir_strp = try self.makeString(compile_unit_dir); | |
| 1777 | const producer_strp = try self.makeString(link.producer_string); | |
| 1777 | const comp_dir_strp = try self.strtab.insert(self.allocator, compile_unit_dir); | |
| 1778 | const producer_strp = try self.strtab.insert(self.allocator, link.producer_string); | |
| 1778 | 1779 | |
| 1779 | 1780 | di_buf.appendAssumeCapacity(@enumToInt(AbbrevKind.compile_unit)); |
| 1780 | 1781 | if (self.bin_file.tag == .macho) { |
| ... | ... | @@ -2435,15 +2436,6 @@ fn getRelocDbgInfoSubprogramHighPC(self: Dwarf) u32 { |
| 2435 | 2436 | return dbg_info_low_pc_reloc_index + self.ptrWidthBytes(); |
| 2436 | 2437 | } |
| 2437 | 2438 | |
| 2438 | /// TODO Improve this to use a table. | |
| 2439 | fn makeString(self: *Dwarf, bytes: []const u8) !u32 { | |
| 2440 | try self.strtab.ensureUnusedCapacity(self.allocator, bytes.len + 1); | |
| 2441 | const result = self.strtab.items.len; | |
| 2442 | self.strtab.appendSliceAssumeCapacity(bytes); | |
| 2443 | self.strtab.appendAssumeCapacity(0); | |
| 2444 | return @intCast(u32, result); | |
| 2445 | } | |
| 2446 | ||
| 2447 | 2439 | fn padToIdeal(actual_size: anytype) @TypeOf(actual_size) { |
| 2448 | 2440 | return actual_size +| (actual_size / ideal_factor); |
| 2449 | 2441 | } |
src/link/Elf.zig+5-5| ... | ... | @@ -688,8 +688,8 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 688 | 688 | // if (self.dwarf) |*dw| { |
| 689 | 689 | // if (self.debug_str_section_index == null) { |
| 690 | 690 | // self.debug_str_section_index = @intCast(u16, self.sections.slice().len); |
| 691 | // assert(dw.strtab.items.len == 0); | |
| 692 | // try dw.strtab.append(gpa, 0); | |
| 691 | // assert(dw.strtab.buffer.items.len == 0); | |
| 692 | // try dw.strtab.buffer.append(gpa, 0); | |
| 693 | 693 | // try self.sections.append(gpa, .{ |
| 694 | 694 | // .shdr = .{ |
| 695 | 695 | // .sh_name = try self.shstrtab.insert(gpa, ".debug_str"), |
| ... | ... | @@ -1164,10 +1164,10 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node |
| 1164 | 1164 | |
| 1165 | 1165 | // if (self.dwarf) |dwarf| { |
| 1166 | 1166 | // const shdr_index = self.debug_str_section_index.?; |
| 1167 | // if (self.debug_strtab_dirty or dwarf.strtab.items.len != self.sections.items(.shdr)[shdr_index].sh_size) { | |
| 1168 | // try self.growNonAllocSection(shdr_index, dwarf.strtab.items.len, 1, false); | |
| 1167 | // if (self.debug_strtab_dirty or dwarf.strtab.buffer.items.len != self.sections.items(.shdr)[shdr_index].sh_size) { | |
| 1168 | // try self.growNonAllocSection(shdr_index, dwarf.strtab.buffer.items.len, 1, false); | |
| 1169 | 1169 | // const debug_strtab_sect = self.sections.items(.shdr)[shdr_index]; |
| 1170 | // try self.base.file.?.pwriteAll(dwarf.strtab.items, debug_strtab_sect.sh_offset); | |
| 1170 | // try self.base.file.?.pwriteAll(dwarf.strtab.buffer.items, debug_strtab_sect.sh_offset); | |
| 1171 | 1171 | // self.debug_strtab_dirty = false; |
| 1172 | 1172 | // } |
| 1173 | 1173 | // } |
src/link/MachO/DebugSymbols.zig+6-6| ... | ... | @@ -82,11 +82,11 @@ pub fn populateMissingMetadata(self: *DebugSymbols) !void { |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | if (self.debug_str_section_index == null) { |
| 85 | assert(self.dwarf.strtab.items.len == 0); | |
| 86 | try self.dwarf.strtab.append(self.allocator, 0); | |
| 85 | assert(self.dwarf.strtab.buffer.items.len == 0); | |
| 86 | try self.dwarf.strtab.buffer.append(self.allocator, 0); | |
| 87 | 87 | self.debug_str_section_index = try self.allocateSection( |
| 88 | 88 | "__debug_str", |
| 89 | @intCast(u32, self.dwarf.strtab.items.len), | |
| 89 | @intCast(u32, self.dwarf.strtab.buffer.items.len), | |
| 90 | 90 | 0, |
| 91 | 91 | ); |
| 92 | 92 | self.debug_string_table_dirty = true; |
| ... | ... | @@ -291,10 +291,10 @@ pub fn flushModule(self: *DebugSymbols, macho_file: *MachO) !void { |
| 291 | 291 | |
| 292 | 292 | { |
| 293 | 293 | const sect_index = self.debug_str_section_index.?; |
| 294 | if (self.debug_string_table_dirty or self.dwarf.strtab.items.len != self.getSection(sect_index).size) { | |
| 295 | const needed_size = @intCast(u32, self.dwarf.strtab.items.len); | |
| 294 | if (self.debug_string_table_dirty or self.dwarf.strtab.buffer.items.len != self.getSection(sect_index).size) { | |
| 295 | const needed_size = @intCast(u32, self.dwarf.strtab.buffer.items.len); | |
| 296 | 296 | try self.growSection(sect_index, needed_size, false); |
| 297 | try self.file.pwriteAll(self.dwarf.strtab.items, self.getSection(sect_index).offset); | |
| 297 | try self.file.pwriteAll(self.dwarf.strtab.buffer.items, self.getSection(sect_index).offset); | |
| 298 | 298 | self.debug_string_table_dirty = false; |
| 299 | 299 | } |
| 300 | 300 | } |