| ... | @@ -1071,7 +1071,7 @@ pub const File = struct { | ... | @@ -1071,7 +1071,7 @@ pub const File = struct { |
| 1071 | }, | 1071 | }, |
| 1072 | } | 1072 | } |
| 1073 | // Write the form for the compile unit, which must match the abbrev table above. | 1073 | // Write the form for the compile unit, which must match the abbrev table above. |
| 1074 | const name_strp = try self.makeDebugString(self.base.options.root_name); | 1074 | const name_strp = try self.makeDebugString(self.base.options.root_pkg.root_src_path); |
| 1075 | const comp_dir_strp = try self.makeDebugString(self.base.options.root_pkg.root_src_dir_path); | 1075 | const comp_dir_strp = try self.makeDebugString(self.base.options.root_pkg.root_src_dir_path); |
| 1076 | const producer_strp = try self.makeDebugString("zig (TODO version here)"); | 1076 | const producer_strp = try self.makeDebugString("zig (TODO version here)"); |
| 1077 | // Currently only one compilation unit is supported, so the address range is simply | 1077 | // Currently only one compilation unit is supported, so the address range is simply |
| ... | @@ -1225,11 +1225,7 @@ pub const File = struct { | ... | @@ -1225,11 +1225,7 @@ pub const File = struct { |
| 1225 | }, | 1225 | }, |
| 1226 | } | 1226 | } |
| 1227 | | 1227 | |
| 1228 | mem.writeInt(u16, di_buf.addManyAsArrayAssumeCapacity(2), 5, target_endian); // version | 1228 | mem.writeInt(u16, di_buf.addManyAsArrayAssumeCapacity(2), 4, target_endian); // version |
| 1229 | di_buf.appendSliceAssumeCapacity(&[_]u8{ | | |
| 1230 | ptr_width_bytes, // address_size | | |
| 1231 | 0, // segment_selector_size | | |
| 1232 | }); | | |
| 1233 | | 1229 | |
| 1234 | // Empirically, debug info consumers do not respect this field, or otherwise | 1230 | // Empirically, debug info consumers do not respect this field, or otherwise |
| 1235 | // consider it to be an error when it does not point exactly to the end of the header. | 1231 | // consider it to be an error when it does not point exactly to the end of the header. |
| ... | @@ -1263,39 +1259,17 @@ pub const File = struct { | ... | @@ -1263,39 +1259,17 @@ pub const File = struct { |
| 1263 | 0, // `DW.LNS_set_epilogue_begin` | 1259 | 0, // `DW.LNS_set_epilogue_begin` |
| 1264 | 1, // `DW.LNS_set_isa` | 1260 | 1, // `DW.LNS_set_isa` |
| 1265 | | 1261 | |
| 1266 | 1, // directory_entry_format_count | 1262 | 0, // include_directories (none except the compilation unit cwd) |
| 1267 | DW.LNCT_path, DW.FORM_string, // directory_entry_format | | |
| 1268 | | | |
| 1269 | // For now we only support one compilation unit, which has one directory. | | |
| 1270 | 1, // directories_count (this is a ULEB128) | | |
| 1271 | }); | 1263 | }); |
| 1272 | // Empirically, some tools do not understand DW.FORM_strp yet. readelf 2.31.1 gives the bogus | 1264 | // file_names[0] |
| 1273 | // error <no .debug_str section> and gdb 8.3.1 crashes. Both programs seem to work fine with | 1265 | di_buf.appendSliceAssumeCapacity(self.base.options.root_pkg.root_src_path); // relative path name |
| 1274 | // DW.FORM_string however. | | |
| 1275 | di_buf.appendSliceAssumeCapacity(self.base.options.root_pkg.root_src_dir_path); | | |
| 1276 | di_buf.appendAssumeCapacity(0); | | |
| 1277 | | | |
| 1278 | di_buf.appendSliceAssumeCapacity(&[_]u8{ | 1266 | di_buf.appendSliceAssumeCapacity(&[_]u8{ |
| 1279 | 2, // file_name_entry_format_count | 1267 | 0, // null byte for the relative path name |
| 1280 | DW.LNCT_path, DW.FORM_string, // file_name_entry_format[0] | 1268 | 0, // directory_index |
| 1281 | DW.LNCT_directory_index, DW.FORM_data1, // file_name_entry_format[1] | 1269 | 0, // mtime (TODO supply this) |
| 1282 | // TODO Look into adding the file size here. Maybe even the mtime and MD5. | 1270 | 0, // file size bytes (TODO supply this) |
| 1283 | //DW.LNCT_size, DW.FORM_udata, // file_name_entry_format[2] | 1271 | 0, // file_names sentinel |
| 1284 | | | |
| 1285 | // For now we only put the root file name here. Once more source files | | |
| 1286 | // are supported, this will need to be improved. | | |
| 1287 | 2, // file_names_count (this is a ULEB128) | | |
| 1288 | }); | 1272 | }); |
| 1289 | // See note above with directories about why we use DW.FORM_string here. | | |
| 1290 | di_buf.appendSliceAssumeCapacity(self.base.options.root_pkg.root_src_path); | | |
| 1291 | di_buf.appendAssumeCapacity(0); | | |
| 1292 | di_buf.appendAssumeCapacity(0); // LNCT_directory_index, FORM_data1 | | |
| 1293 | | | |
| 1294 | // We add the root file twice because according to DWARF, the state machine | | |
| 1295 | // starts out with file index 1. | | |
| 1296 | di_buf.appendSliceAssumeCapacity(self.base.options.root_pkg.root_src_path); | | |
| 1297 | di_buf.appendAssumeCapacity(0); | | |
| 1298 | di_buf.appendAssumeCapacity(0); // LNCT_directory_index, FORM_data1 | | |
| 1299 | | 1273 | |
| 1300 | const header_len = di_buf.items.len - after_header_len; | 1274 | const header_len = di_buf.items.len - after_header_len; |
| 1301 | switch (self.ptr_width) { | 1275 | switch (self.ptr_width) { |