| ... | @@ -148,11 +148,11 @@ pub const DeclState = struct { | ... | @@ -148,11 +148,11 @@ pub const DeclState = struct { |
| 148 | switch (ty.zigTypeTag()) { | 148 | switch (ty.zigTypeTag()) { |
| 149 | .NoReturn => unreachable, | 149 | .NoReturn => unreachable, |
| 150 | .Void => { | 150 | .Void => { |
| 151 | try dbg_info_buffer.append(abbrev_pad1); | 151 | try dbg_info_buffer.append(@enumToInt(AbbrevKind.pad1)); |
| 152 | }, | 152 | }, |
| 153 | .Bool => { | 153 | .Bool => { |
| 154 | try dbg_info_buffer.appendSlice(&[_]u8{ | 154 | try dbg_info_buffer.appendSlice(&[_]u8{ |
| 155 | abbrev_base_type, | 155 | @enumToInt(AbbrevKind.base_type), |
| 156 | DW.ATE.boolean, // DW.AT.encoding , DW.FORM.data1 | 156 | DW.ATE.boolean, // DW.AT.encoding , DW.FORM.data1 |
| 157 | 1, // DW.AT.byte_size, DW.FORM.data1 | 157 | 1, // DW.AT.byte_size, DW.FORM.data1 |
| 158 | 'b', 'o', 'o', 'l', 0, // DW.AT.name, DW.FORM.string | 158 | 'b', 'o', 'o', 'l', 0, // DW.AT.name, DW.FORM.string |
| ... | @@ -161,7 +161,7 @@ pub const DeclState = struct { | ... | @@ -161,7 +161,7 @@ pub const DeclState = struct { |
| 161 | .Int => { | 161 | .Int => { |
| 162 | const info = ty.intInfo(target); | 162 | const info = ty.intInfo(target); |
| 163 | try dbg_info_buffer.ensureUnusedCapacity(12); | 163 | try dbg_info_buffer.ensureUnusedCapacity(12); |
| 164 | dbg_info_buffer.appendAssumeCapacity(abbrev_base_type); | 164 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.base_type)); |
| 165 | // DW.AT.encoding, DW.FORM.data1 | 165 | // DW.AT.encoding, DW.FORM.data1 |
| 166 | dbg_info_buffer.appendAssumeCapacity(switch (info.signedness) { | 166 | dbg_info_buffer.appendAssumeCapacity(switch (info.signedness) { |
| 167 | .signed => DW.ATE.signed, | 167 | .signed => DW.ATE.signed, |
| ... | @@ -175,7 +175,7 @@ pub const DeclState = struct { | ... | @@ -175,7 +175,7 @@ pub const DeclState = struct { |
| 175 | .Optional => { | 175 | .Optional => { |
| 176 | if (ty.isPtrLikeOptional()) { | 176 | if (ty.isPtrLikeOptional()) { |
| 177 | try dbg_info_buffer.ensureUnusedCapacity(12); | 177 | try dbg_info_buffer.ensureUnusedCapacity(12); |
| 178 | dbg_info_buffer.appendAssumeCapacity(abbrev_base_type); | 178 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.base_type)); |
| 179 | // DW.AT.encoding, DW.FORM.data1 | 179 | // DW.AT.encoding, DW.FORM.data1 |
| 180 | dbg_info_buffer.appendAssumeCapacity(DW.ATE.address); | 180 | dbg_info_buffer.appendAssumeCapacity(DW.ATE.address); |
| 181 | // DW.AT.byte_size, DW.FORM.data1 | 181 | // DW.AT.byte_size, DW.FORM.data1 |
| ... | @@ -187,7 +187,7 @@ pub const DeclState = struct { | ... | @@ -187,7 +187,7 @@ pub const DeclState = struct { |
| 187 | var buf = try arena.create(Type.Payload.ElemType); | 187 | var buf = try arena.create(Type.Payload.ElemType); |
| 188 | const payload_ty = ty.optionalChild(buf); | 188 | const payload_ty = ty.optionalChild(buf); |
| 189 | // DW.AT.structure_type | 189 | // DW.AT.structure_type |
| 190 | try dbg_info_buffer.append(abbrev_struct_type); | 190 | try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); |
| 191 | // DW.AT.byte_size, DW.FORM.sdata | 191 | // DW.AT.byte_size, DW.FORM.sdata |
| 192 | const abi_size = ty.abiSize(target); | 192 | const abi_size = ty.abiSize(target); |
| 193 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); | 193 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); |
| ... | @@ -195,7 +195,7 @@ pub const DeclState = struct { | ... | @@ -195,7 +195,7 @@ pub const DeclState = struct { |
| 195 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(target)}); | 195 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(target)}); |
| 196 | // DW.AT.member | 196 | // DW.AT.member |
| 197 | try dbg_info_buffer.ensureUnusedCapacity(7); | 197 | try dbg_info_buffer.ensureUnusedCapacity(7); |
| 198 | dbg_info_buffer.appendAssumeCapacity(abbrev_struct_member); | 198 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); |
| 199 | // DW.AT.name, DW.FORM.string | 199 | // DW.AT.name, DW.FORM.string |
| 200 | dbg_info_buffer.appendSliceAssumeCapacity("maybe"); | 200 | dbg_info_buffer.appendSliceAssumeCapacity("maybe"); |
| 201 | dbg_info_buffer.appendAssumeCapacity(0); | 201 | dbg_info_buffer.appendAssumeCapacity(0); |
| ... | @@ -207,7 +207,7 @@ pub const DeclState = struct { | ... | @@ -207,7 +207,7 @@ pub const DeclState = struct { |
| 207 | try dbg_info_buffer.ensureUnusedCapacity(6); | 207 | try dbg_info_buffer.ensureUnusedCapacity(6); |
| 208 | dbg_info_buffer.appendAssumeCapacity(0); | 208 | dbg_info_buffer.appendAssumeCapacity(0); |
| 209 | // DW.AT.member | 209 | // DW.AT.member |
| 210 | dbg_info_buffer.appendAssumeCapacity(abbrev_struct_member); | 210 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); |
| 211 | // DW.AT.name, DW.FORM.string | 211 | // DW.AT.name, DW.FORM.string |
| 212 | dbg_info_buffer.appendSliceAssumeCapacity("val"); | 212 | dbg_info_buffer.appendSliceAssumeCapacity("val"); |
| 213 | dbg_info_buffer.appendAssumeCapacity(0); | 213 | dbg_info_buffer.appendAssumeCapacity(0); |
| ... | @@ -227,14 +227,14 @@ pub const DeclState = struct { | ... | @@ -227,14 +227,14 @@ pub const DeclState = struct { |
| 227 | // Slices are structs: struct { .ptr = *, .len = N } | 227 | // Slices are structs: struct { .ptr = *, .len = N } |
| 228 | // DW.AT.structure_type | 228 | // DW.AT.structure_type |
| 229 | try dbg_info_buffer.ensureUnusedCapacity(2); | 229 | try dbg_info_buffer.ensureUnusedCapacity(2); |
| 230 | dbg_info_buffer.appendAssumeCapacity(abbrev_struct_type); | 230 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_type)); |
| 231 | // DW.AT.byte_size, DW.FORM.sdata | 231 | // DW.AT.byte_size, DW.FORM.sdata |
| 232 | dbg_info_buffer.appendAssumeCapacity(@sizeOf(usize) * 2); | 232 | dbg_info_buffer.appendAssumeCapacity(@sizeOf(usize) * 2); |
| 233 | // DW.AT.name, DW.FORM.string | 233 | // DW.AT.name, DW.FORM.string |
| 234 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(target)}); | 234 | try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(target)}); |
| 235 | // DW.AT.member | 235 | // DW.AT.member |
| 236 | try dbg_info_buffer.ensureUnusedCapacity(5); | 236 | try dbg_info_buffer.ensureUnusedCapacity(5); |
| 237 | dbg_info_buffer.appendAssumeCapacity(abbrev_struct_member); | 237 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); |
| 238 | // DW.AT.name, DW.FORM.string | 238 | // DW.AT.name, DW.FORM.string |
| 239 | dbg_info_buffer.appendSliceAssumeCapacity("ptr"); | 239 | dbg_info_buffer.appendSliceAssumeCapacity("ptr"); |
| 240 | dbg_info_buffer.appendAssumeCapacity(0); | 240 | dbg_info_buffer.appendAssumeCapacity(0); |
| ... | @@ -248,7 +248,7 @@ pub const DeclState = struct { | ... | @@ -248,7 +248,7 @@ pub const DeclState = struct { |
| 248 | try dbg_info_buffer.ensureUnusedCapacity(6); | 248 | try dbg_info_buffer.ensureUnusedCapacity(6); |
| 249 | dbg_info_buffer.appendAssumeCapacity(0); | 249 | dbg_info_buffer.appendAssumeCapacity(0); |
| 250 | // DW.AT.member | 250 | // DW.AT.member |
| 251 | dbg_info_buffer.appendAssumeCapacity(abbrev_struct_member); | 251 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); |
| 252 | // DW.AT.name, DW.FORM.string | 252 | // DW.AT.name, DW.FORM.string |
| 253 | dbg_info_buffer.appendSliceAssumeCapacity("len"); | 253 | dbg_info_buffer.appendSliceAssumeCapacity("len"); |
| 254 | dbg_info_buffer.appendAssumeCapacity(0); | 254 | dbg_info_buffer.appendAssumeCapacity(0); |
| ... | @@ -263,7 +263,7 @@ pub const DeclState = struct { | ... | @@ -263,7 +263,7 @@ pub const DeclState = struct { |
| 263 | dbg_info_buffer.appendAssumeCapacity(0); | 263 | dbg_info_buffer.appendAssumeCapacity(0); |
| 264 | } else { | 264 | } else { |
| 265 | try dbg_info_buffer.ensureUnusedCapacity(5); | 265 | try dbg_info_buffer.ensureUnusedCapacity(5); |
| 266 | dbg_info_buffer.appendAssumeCapacity(abbrev_ptr_type); | 266 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.ptr_type)); |
| 267 | // DW.AT.type, DW.FORM.ref4 | 267 | // DW.AT.type, DW.FORM.ref4 |
| 268 | const index = dbg_info_buffer.items.len; | 268 | const index = dbg_info_buffer.items.len; |
| 269 | try dbg_info_buffer.resize(index + 4); | 269 | try dbg_info_buffer.resize(index + 4); |
| ... | @@ -272,7 +272,7 @@ pub const DeclState = struct { | ... | @@ -272,7 +272,7 @@ pub const DeclState = struct { |
| 272 | }, | 272 | }, |
| 273 | .Struct => blk: { | 273 | .Struct => blk: { |
| 274 | // DW.AT.structure_type | 274 | // DW.AT.structure_type |
| 275 | try dbg_info_buffer.append(abbrev_struct_type); | 275 | try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); |
| 276 | // DW.AT.byte_size, DW.FORM.sdata | 276 | // DW.AT.byte_size, DW.FORM.sdata |
| 277 | const abi_size = ty.abiSize(target); | 277 | const abi_size = ty.abiSize(target); |
| 278 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); | 278 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); |
| ... | @@ -285,7 +285,7 @@ pub const DeclState = struct { | ... | @@ -285,7 +285,7 @@ pub const DeclState = struct { |
| 285 | const fields = ty.tupleFields(); | 285 | const fields = ty.tupleFields(); |
| 286 | for (fields.types) |field, field_index| { | 286 | for (fields.types) |field, field_index| { |
| 287 | // DW.AT.member | 287 | // DW.AT.member |
| 288 | try dbg_info_buffer.append(abbrev_struct_member); | 288 | try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_member)); |
| 289 | // DW.AT.name, DW.FORM.string | 289 | // DW.AT.name, DW.FORM.string |
| 290 | try dbg_info_buffer.writer().print("{d}\x00", .{field_index}); | 290 | try dbg_info_buffer.writer().print("{d}\x00", .{field_index}); |
| 291 | // DW.AT.type, DW.FORM.ref4 | 291 | // DW.AT.type, DW.FORM.ref4 |
| ... | @@ -315,7 +315,7 @@ pub const DeclState = struct { | ... | @@ -315,7 +315,7 @@ pub const DeclState = struct { |
| 315 | const field = fields.get(field_name).?; | 315 | const field = fields.get(field_name).?; |
| 316 | // DW.AT.member | 316 | // DW.AT.member |
| 317 | try dbg_info_buffer.ensureUnusedCapacity(field_name.len + 2); | 317 | try dbg_info_buffer.ensureUnusedCapacity(field_name.len + 2); |
| 318 | dbg_info_buffer.appendAssumeCapacity(abbrev_struct_member); | 318 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); |
| 319 | // DW.AT.name, DW.FORM.string | 319 | // DW.AT.name, DW.FORM.string |
| 320 | dbg_info_buffer.appendSliceAssumeCapacity(field_name); | 320 | dbg_info_buffer.appendSliceAssumeCapacity(field_name); |
| 321 | dbg_info_buffer.appendAssumeCapacity(0); | 321 | dbg_info_buffer.appendAssumeCapacity(0); |
| ... | @@ -335,7 +335,7 @@ pub const DeclState = struct { | ... | @@ -335,7 +335,7 @@ pub const DeclState = struct { |
| 335 | }, | 335 | }, |
| 336 | .Enum => { | 336 | .Enum => { |
| 337 | // DW.AT.enumeration_type | 337 | // DW.AT.enumeration_type |
| 338 | try dbg_info_buffer.append(abbrev_enum_type); | 338 | try dbg_info_buffer.append(@enumToInt(AbbrevKind.enum_type)); |
| 339 | // DW.AT.byte_size, DW.FORM.sdata | 339 | // DW.AT.byte_size, DW.FORM.sdata |
| 340 | const abi_size = ty.abiSize(target); | 340 | const abi_size = ty.abiSize(target); |
| 341 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); | 341 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); |
| ... | @@ -355,7 +355,7 @@ pub const DeclState = struct { | ... | @@ -355,7 +355,7 @@ pub const DeclState = struct { |
| 355 | for (fields.keys()) |field_name, field_i| { | 355 | for (fields.keys()) |field_name, field_i| { |
| 356 | // DW.AT.enumerator | 356 | // DW.AT.enumerator |
| 357 | try dbg_info_buffer.ensureUnusedCapacity(field_name.len + 2 + @sizeOf(u64)); | 357 | try dbg_info_buffer.ensureUnusedCapacity(field_name.len + 2 + @sizeOf(u64)); |
| 358 | dbg_info_buffer.appendAssumeCapacity(abbrev_enum_variant); | 358 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.enum_variant)); |
| 359 | // DW.AT.name, DW.FORM.string | 359 | // DW.AT.name, DW.FORM.string |
| 360 | dbg_info_buffer.appendSliceAssumeCapacity(field_name); | 360 | dbg_info_buffer.appendSliceAssumeCapacity(field_name); |
| 361 | dbg_info_buffer.appendAssumeCapacity(0); | 361 | dbg_info_buffer.appendAssumeCapacity(0); |
| ... | @@ -385,7 +385,7 @@ pub const DeclState = struct { | ... | @@ -385,7 +385,7 @@ pub const DeclState = struct { |
| 385 | // for untagged unions. | 385 | // for untagged unions. |
| 386 | if (is_tagged) { | 386 | if (is_tagged) { |
| 387 | // DW.AT.structure_type | 387 | // DW.AT.structure_type |
| 388 | try dbg_info_buffer.append(abbrev_struct_type); | 388 | try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); |
| 389 | // DW.AT.byte_size, DW.FORM.sdata | 389 | // DW.AT.byte_size, DW.FORM.sdata |
| 390 | try leb128.writeULEB128(dbg_info_buffer.writer(), layout.abi_size); | 390 | try leb128.writeULEB128(dbg_info_buffer.writer(), layout.abi_size); |
| 391 | // DW.AT.name, DW.FORM.string | 391 | // DW.AT.name, DW.FORM.string |
| ... | @@ -395,7 +395,7 @@ pub const DeclState = struct { | ... | @@ -395,7 +395,7 @@ pub const DeclState = struct { |
| 395 | | 395 | |
| 396 | // DW.AT.member | 396 | // DW.AT.member |
| 397 | try dbg_info_buffer.ensureUnusedCapacity(9); | 397 | try dbg_info_buffer.ensureUnusedCapacity(9); |
| 398 | dbg_info_buffer.appendAssumeCapacity(abbrev_struct_member); | 398 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); |
| 399 | // DW.AT.name, DW.FORM.string | 399 | // DW.AT.name, DW.FORM.string |
| 400 | dbg_info_buffer.appendSliceAssumeCapacity("payload"); | 400 | dbg_info_buffer.appendSliceAssumeCapacity("payload"); |
| 401 | dbg_info_buffer.appendAssumeCapacity(0); | 401 | dbg_info_buffer.appendAssumeCapacity(0); |
| ... | @@ -408,7 +408,7 @@ pub const DeclState = struct { | ... | @@ -408,7 +408,7 @@ pub const DeclState = struct { |
| 408 | } | 408 | } |
| 409 | | 409 | |
| 410 | // DW.AT.union_type | 410 | // DW.AT.union_type |
| 411 | try dbg_info_buffer.append(abbrev_union_type); | 411 | try dbg_info_buffer.append(@enumToInt(AbbrevKind.union_type)); |
| 412 | // DW.AT.byte_size, DW.FORM.sdata, | 412 | // DW.AT.byte_size, DW.FORM.sdata, |
| 413 | try leb128.writeULEB128(dbg_info_buffer.writer(), layout.payload_size); | 413 | try leb128.writeULEB128(dbg_info_buffer.writer(), layout.payload_size); |
| 414 | // DW.AT.name, DW.FORM.string | 414 | // DW.AT.name, DW.FORM.string |
| ... | @@ -423,7 +423,7 @@ pub const DeclState = struct { | ... | @@ -423,7 +423,7 @@ pub const DeclState = struct { |
| 423 | const field = fields.get(field_name).?; | 423 | const field = fields.get(field_name).?; |
| 424 | if (!field.ty.hasRuntimeBits()) continue; | 424 | if (!field.ty.hasRuntimeBits()) continue; |
| 425 | // DW.AT.member | 425 | // DW.AT.member |
| 426 | try dbg_info_buffer.append(abbrev_struct_member); | 426 | try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_member)); |
| 427 | // DW.AT.name, DW.FORM.string | 427 | // DW.AT.name, DW.FORM.string |
| 428 | try dbg_info_buffer.writer().print("{s}\x00", .{field_name}); | 428 | try dbg_info_buffer.writer().print("{s}\x00", .{field_name}); |
| 429 | // DW.AT.type, DW.FORM.ref4 | 429 | // DW.AT.type, DW.FORM.ref4 |
| ... | @@ -439,7 +439,7 @@ pub const DeclState = struct { | ... | @@ -439,7 +439,7 @@ pub const DeclState = struct { |
| 439 | if (is_tagged) { | 439 | if (is_tagged) { |
| 440 | // DW.AT.member | 440 | // DW.AT.member |
| 441 | try dbg_info_buffer.ensureUnusedCapacity(5); | 441 | try dbg_info_buffer.ensureUnusedCapacity(5); |
| 442 | dbg_info_buffer.appendAssumeCapacity(abbrev_struct_member); | 442 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); |
| 443 | // DW.AT.name, DW.FORM.string | 443 | // DW.AT.name, DW.FORM.string |
| 444 | dbg_info_buffer.appendSliceAssumeCapacity("tag"); | 444 | dbg_info_buffer.appendSliceAssumeCapacity("tag"); |
| 445 | dbg_info_buffer.appendAssumeCapacity(0); | 445 | dbg_info_buffer.appendAssumeCapacity(0); |
| ... | @@ -471,7 +471,7 @@ pub const DeclState = struct { | ... | @@ -471,7 +471,7 @@ pub const DeclState = struct { |
| 471 | const payload_off = mem.alignForwardGeneric(u64, error_ty.abiSize(target), abi_align); | 471 | const payload_off = mem.alignForwardGeneric(u64, error_ty.abiSize(target), abi_align); |
| 472 | | 472 | |
| 473 | // DW.AT.structure_type | 473 | // DW.AT.structure_type |
| 474 | try dbg_info_buffer.append(abbrev_struct_type); | 474 | try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); |
| 475 | // DW.AT.byte_size, DW.FORM.sdata | 475 | // DW.AT.byte_size, DW.FORM.sdata |
| 476 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); | 476 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); |
| 477 | // DW.AT.name, DW.FORM.string | 477 | // DW.AT.name, DW.FORM.string |
| ... | @@ -480,7 +480,7 @@ pub const DeclState = struct { | ... | @@ -480,7 +480,7 @@ pub const DeclState = struct { |
| 480 | | 480 | |
| 481 | // DW.AT.member | 481 | // DW.AT.member |
| 482 | try dbg_info_buffer.ensureUnusedCapacity(7); | 482 | try dbg_info_buffer.ensureUnusedCapacity(7); |
| 483 | dbg_info_buffer.appendAssumeCapacity(abbrev_struct_member); | 483 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); |
| 484 | // DW.AT.name, DW.FORM.string | 484 | // DW.AT.name, DW.FORM.string |
| 485 | dbg_info_buffer.appendSliceAssumeCapacity("value"); | 485 | dbg_info_buffer.appendSliceAssumeCapacity("value"); |
| 486 | dbg_info_buffer.appendAssumeCapacity(0); | 486 | dbg_info_buffer.appendAssumeCapacity(0); |
| ... | @@ -493,7 +493,7 @@ pub const DeclState = struct { | ... | @@ -493,7 +493,7 @@ pub const DeclState = struct { |
| 493 | | 493 | |
| 494 | // DW.AT.member | 494 | // DW.AT.member |
| 495 | try dbg_info_buffer.ensureUnusedCapacity(5); | 495 | try dbg_info_buffer.ensureUnusedCapacity(5); |
| 496 | dbg_info_buffer.appendAssumeCapacity(abbrev_struct_member); | 496 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); |
| 497 | // DW.AT.name, DW.FORM.string | 497 | // DW.AT.name, DW.FORM.string |
| 498 | dbg_info_buffer.appendSliceAssumeCapacity("err"); | 498 | dbg_info_buffer.appendSliceAssumeCapacity("err"); |
| 499 | dbg_info_buffer.appendAssumeCapacity(0); | 499 | dbg_info_buffer.appendAssumeCapacity(0); |
| ... | @@ -509,7 +509,7 @@ pub const DeclState = struct { | ... | @@ -509,7 +509,7 @@ pub const DeclState = struct { |
| 509 | }, | 509 | }, |
| 510 | else => { | 510 | else => { |
| 511 | log.debug("TODO implement .debug_info for type '{}'", .{ty.fmtDebug()}); | 511 | log.debug("TODO implement .debug_info for type '{}'", .{ty.fmtDebug()}); |
| 512 | try dbg_info_buffer.append(abbrev_pad1); | 512 | try dbg_info_buffer.append(@enumToInt(AbbrevKind.pad1)); |
| 513 | }, | 513 | }, |
| 514 | } | 514 | } |
| 515 | } | 515 | } |
| ... | @@ -550,18 +550,21 @@ pub const SrcFn = struct { | ... | @@ -550,18 +550,21 @@ pub const SrcFn = struct { |
| 550 | | 550 | |
| 551 | pub const PtrWidth = enum { p32, p64 }; | 551 | pub const PtrWidth = enum { p32, p64 }; |
| 552 | | 552 | |
| 553 | pub const abbrev_compile_unit = 1; | 553 | pub const AbbrevKind = enum(u8) { |
| 554 | pub const abbrev_subprogram = 2; | 554 | compile_unit = 1, |
| 555 | pub const abbrev_subprogram_retvoid = 3; | 555 | subprogram, |
| 556 | pub const abbrev_base_type = 4; | 556 | subprogram_retvoid, |
| 557 | pub const abbrev_ptr_type = 5; | 557 | base_type, |
| 558 | pub const abbrev_struct_type = 6; | 558 | ptr_type, |
| 559 | pub const abbrev_struct_member = 7; | 559 | struct_type, |
| 560 | pub const abbrev_enum_type = 8; | 560 | struct_member, |
| 561 | pub const abbrev_enum_variant = 9; | 561 | enum_type, |
| 562 | pub const abbrev_union_type = 10; | 562 | enum_variant, |
| 563 | pub const abbrev_pad1 = 11; | 563 | union_type, |
| 564 | pub const abbrev_parameter = 12; | 564 | pad1, |
| | 565 | parameter, |
| | 566 | variable, |
| | 567 | }; |
| 565 | | 568 | |
| 566 | /// The reloc offset for the virtual address of a function in its Line Number Program. | 569 | /// The reloc offset for the virtual address of a function in its Line Number Program. |
| 567 | /// Size is a virtual address integer. | 570 | /// Size is a virtual address integer. |
| ... | @@ -670,9 +673,9 @@ pub fn initDeclState(self: *Dwarf, decl: *Module.Decl) !DeclState { | ... | @@ -670,9 +673,9 @@ pub fn initDeclState(self: *Dwarf, decl: *Module.Decl) !DeclState { |
| 670 | const fn_ret_type = decl.ty.fnReturnType(); | 673 | const fn_ret_type = decl.ty.fnReturnType(); |
| 671 | const fn_ret_has_bits = fn_ret_type.hasRuntimeBits(); | 674 | const fn_ret_has_bits = fn_ret_type.hasRuntimeBits(); |
| 672 | if (fn_ret_has_bits) { | 675 | if (fn_ret_has_bits) { |
| 673 | dbg_info_buffer.appendAssumeCapacity(abbrev_subprogram); | 676 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.subprogram)); |
| 674 | } else { | 677 | } else { |
| 675 | dbg_info_buffer.appendAssumeCapacity(abbrev_subprogram_retvoid); | 678 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.subprogram_retvoid)); |
| 676 | } | 679 | } |
| 677 | // These get overwritten after generating the machine code. These values are | 680 | // These get overwritten after generating the machine code. These values are |
| 678 | // "relocations" and have to be in this fixed place so that functions can be | 681 | // "relocations" and have to be in this fixed place so that functions can be |
| ... | @@ -926,7 +929,7 @@ pub fn commitDeclState( | ... | @@ -926,7 +929,7 @@ pub fn commitDeclState( |
| 926 | else => unreachable, | 929 | else => unreachable, |
| 927 | }; | 930 | }; |
| 928 | | 931 | |
| 929 | { | 932 | if (decl_state.abbrev_table.items.len > 0) { |
| 930 | // Now we emit the .debug_info types of the Decl. These will count towards the size of | 933 | // Now we emit the .debug_info types of the Decl. These will count towards the size of |
| 931 | // the buffer, so we have to do it before computing the offset, and we can't perform the actual | 934 | // the buffer, so we have to do it before computing the offset, and we can't perform the actual |
| 932 | // relocations yet. | 935 | // relocations yet. |
| ... | @@ -1244,14 +1247,14 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { | ... | @@ -1244,14 +1247,14 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { |
| 1244 | // These are LEB encoded but since the values are all less than 127 | 1247 | // These are LEB encoded but since the values are all less than 127 |
| 1245 | // we can simply append these bytes. | 1248 | // we can simply append these bytes. |
| 1246 | const abbrev_buf = [_]u8{ | 1249 | const abbrev_buf = [_]u8{ |
| 1247 | abbrev_compile_unit, DW.TAG.compile_unit, DW.CHILDREN.yes, // header | 1250 | @enumToInt(AbbrevKind.compile_unit), DW.TAG.compile_unit, DW.CHILDREN.yes, // header |
| 1248 | DW.AT.stmt_list, DW.FORM.sec_offset, DW.AT.low_pc, | 1251 | DW.AT.stmt_list, DW.FORM.sec_offset, DW.AT.low_pc, |
| 1249 | DW.FORM.addr, DW.AT.high_pc, DW.FORM.addr, | 1252 | DW.FORM.addr, DW.AT.high_pc, DW.FORM.addr, |
| 1250 | DW.AT.name, DW.FORM.strp, DW.AT.comp_dir, | 1253 | DW.AT.name, DW.FORM.strp, DW.AT.comp_dir, |
| 1251 | DW.FORM.strp, DW.AT.producer, DW.FORM.strp, | 1254 | DW.FORM.strp, DW.AT.producer, DW.FORM.strp, |
| 1252 | DW.AT.language, DW.FORM.data2, 0, | 1255 | DW.AT.language, DW.FORM.data2, 0, |
| 1253 | 0, // table sentinel | 1256 | 0, // table sentinel |
| 1254 | abbrev_subprogram, | 1257 | @enumToInt(AbbrevKind.subprogram), |
| 1255 | DW.TAG.subprogram, | 1258 | DW.TAG.subprogram, |
| 1256 | DW.CHILDREN.yes, // header | 1259 | DW.CHILDREN.yes, // header |
| 1257 | DW.AT.low_pc, | 1260 | DW.AT.low_pc, |
| ... | @@ -1262,15 +1265,15 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { | ... | @@ -1262,15 +1265,15 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { |
| 1262 | DW.FORM.ref4, | 1265 | DW.FORM.ref4, |
| 1263 | DW.AT.name, | 1266 | DW.AT.name, |
| 1264 | DW.FORM.string, | 1267 | DW.FORM.string, |
| 1265 | 0, 0, // table sentinel | 1268 | 0, 0, // table sentinel |
| 1266 | abbrev_subprogram_retvoid, | 1269 | @enumToInt(AbbrevKind.subprogram_retvoid), |
| 1267 | DW.TAG.subprogram, DW.CHILDREN.yes, // header | 1270 | DW.TAG.subprogram, DW.CHILDREN.yes, // header |
| 1268 | DW.AT.low_pc, DW.FORM.addr, | 1271 | DW.AT.low_pc, DW.FORM.addr, |
| 1269 | DW.AT.high_pc, DW.FORM.data4, | 1272 | DW.AT.high_pc, DW.FORM.data4, |
| 1270 | DW.AT.name, DW.FORM.string, | 1273 | DW.AT.name, DW.FORM.string, |
| 1271 | 0, | 1274 | 0, |
| 1272 | 0, // table sentinel | 1275 | 0, // table sentinel |
| 1273 | abbrev_base_type, | 1276 | @enumToInt(AbbrevKind.base_type), |
| 1274 | DW.TAG.base_type, | 1277 | DW.TAG.base_type, |
| 1275 | DW.CHILDREN.no, // header | 1278 | DW.CHILDREN.no, // header |
| 1276 | DW.AT.encoding, | 1279 | DW.AT.encoding, |
| ... | @@ -1281,14 +1284,14 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { | ... | @@ -1281,14 +1284,14 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { |
| 1281 | DW.FORM.string, | 1284 | DW.FORM.string, |
| 1282 | 0, | 1285 | 0, |
| 1283 | 0, // table sentinel | 1286 | 0, // table sentinel |
| 1284 | abbrev_ptr_type, | 1287 | @enumToInt(AbbrevKind.ptr_type), |
| 1285 | DW.TAG.pointer_type, | 1288 | DW.TAG.pointer_type, |
| 1286 | DW.CHILDREN.no, // header | 1289 | DW.CHILDREN.no, // header |
| 1287 | DW.AT.type, | 1290 | DW.AT.type, |
| 1288 | DW.FORM.ref4, | 1291 | DW.FORM.ref4, |
| 1289 | 0, | 1292 | 0, |
| 1290 | 0, // table sentinel | 1293 | 0, // table sentinel |
| 1291 | abbrev_struct_type, | 1294 | @enumToInt(AbbrevKind.struct_type), |
| 1292 | DW.TAG.structure_type, | 1295 | DW.TAG.structure_type, |
| 1293 | DW.CHILDREN.yes, // header | 1296 | DW.CHILDREN.yes, // header |
| 1294 | DW.AT.byte_size, | 1297 | DW.AT.byte_size, |
| ... | @@ -1297,7 +1300,7 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { | ... | @@ -1297,7 +1300,7 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { |
| 1297 | DW.FORM.string, | 1300 | DW.FORM.string, |
| 1298 | 0, | 1301 | 0, |
| 1299 | 0, // table sentinel | 1302 | 0, // table sentinel |
| 1300 | abbrev_struct_member, | 1303 | @enumToInt(AbbrevKind.struct_member), |
| 1301 | DW.TAG.member, | 1304 | DW.TAG.member, |
| 1302 | DW.CHILDREN.no, // header | 1305 | DW.CHILDREN.no, // header |
| 1303 | DW.AT.name, | 1306 | DW.AT.name, |
| ... | @@ -1308,7 +1311,7 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { | ... | @@ -1308,7 +1311,7 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { |
| 1308 | DW.FORM.sdata, | 1311 | DW.FORM.sdata, |
| 1309 | 0, | 1312 | 0, |
| 1310 | 0, // table sentinel | 1313 | 0, // table sentinel |
| 1311 | abbrev_enum_type, | 1314 | @enumToInt(AbbrevKind.enum_type), |
| 1312 | DW.TAG.enumeration_type, | 1315 | DW.TAG.enumeration_type, |
| 1313 | DW.CHILDREN.yes, // header | 1316 | DW.CHILDREN.yes, // header |
| 1314 | DW.AT.byte_size, | 1317 | DW.AT.byte_size, |
| ... | @@ -1317,7 +1320,7 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { | ... | @@ -1317,7 +1320,7 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { |
| 1317 | DW.FORM.string, | 1320 | DW.FORM.string, |
| 1318 | 0, | 1321 | 0, |
| 1319 | 0, // table sentinel | 1322 | 0, // table sentinel |
| 1320 | abbrev_enum_variant, | 1323 | @enumToInt(AbbrevKind.enum_variant), |
| 1321 | DW.TAG.enumerator, | 1324 | DW.TAG.enumerator, |
| 1322 | DW.CHILDREN.no, // header | 1325 | DW.CHILDREN.no, // header |
| 1323 | DW.AT.name, | 1326 | DW.AT.name, |
| ... | @@ -1326,7 +1329,7 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { | ... | @@ -1326,7 +1329,7 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { |
| 1326 | DW.FORM.data8, | 1329 | DW.FORM.data8, |
| 1327 | 0, | 1330 | 0, |
| 1328 | 0, // table sentinel | 1331 | 0, // table sentinel |
| 1329 | abbrev_union_type, | 1332 | @enumToInt(AbbrevKind.union_type), |
| 1330 | DW.TAG.union_type, | 1333 | DW.TAG.union_type, |
| 1331 | DW.CHILDREN.yes, // header | 1334 | DW.CHILDREN.yes, // header |
| 1332 | DW.AT.byte_size, | 1335 | DW.AT.byte_size, |
| ... | @@ -1335,18 +1338,25 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { | ... | @@ -1335,18 +1338,25 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void { |
| 1335 | DW.FORM.string, | 1338 | DW.FORM.string, |
| 1336 | 0, | 1339 | 0, |
| 1337 | 0, // table sentinel | 1340 | 0, // table sentinel |
| 1338 | abbrev_pad1, | 1341 | @enumToInt(AbbrevKind.pad1), |
| 1339 | DW.TAG.unspecified_type, | 1342 | DW.TAG.unspecified_type, |
| 1340 | DW.CHILDREN.no, // header | 1343 | DW.CHILDREN.no, // header |
| 1341 | 0, | 1344 | 0, |
| 1342 | 0, // table sentinel | 1345 | 0, // table sentinel |
| 1343 | abbrev_parameter, | 1346 | @enumToInt(AbbrevKind.parameter), |
| 1344 | DW.TAG.formal_parameter, DW.CHILDREN.no, // header | 1347 | DW.TAG.formal_parameter, DW.CHILDREN.no, // header |
| 1345 | DW.AT.location, DW.FORM.exprloc, | 1348 | DW.AT.location, DW.FORM.exprloc, |
| 1346 | DW.AT.type, DW.FORM.ref4, | 1349 | DW.AT.type, DW.FORM.ref4, |
| 1347 | DW.AT.name, DW.FORM.string, | 1350 | DW.AT.name, DW.FORM.string, |
| 1348 | 0, | 1351 | 0, |
| 1349 | 0, // table sentinel | 1352 | 0, // table sentinel |
| | 1353 | @enumToInt(AbbrevKind.variable), |
| | 1354 | DW.TAG.variable, DW.CHILDREN.no, // header |
| | 1355 | DW.AT.location, DW.FORM.exprloc, |
| | 1356 | DW.AT.type, DW.FORM.ref4, |
| | 1357 | DW.AT.name, DW.FORM.string, |
| | 1358 | 0, |
| | 1359 | 0, // table sentinel |
| 1350 | 0, | 1360 | 0, |
| 1351 | 0, | 1361 | 0, |
| 1352 | 0, // section sentinel | 1362 | 0, // section sentinel |
| ... | @@ -1459,7 +1469,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, file: *File, module: *Module, low_pc: u6 | ... | @@ -1459,7 +1469,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, file: *File, module: *Module, low_pc: u6 |
| 1459 | const comp_dir_strp = try self.makeString(module.root_pkg.root_src_directory.path orelse "."); | 1469 | const comp_dir_strp = try self.makeString(module.root_pkg.root_src_directory.path orelse "."); |
| 1460 | const producer_strp = try self.makeString(link.producer_string); | 1470 | const producer_strp = try self.makeString(link.producer_string); |
| 1461 | | 1471 | |
| 1462 | di_buf.appendAssumeCapacity(abbrev_compile_unit); | 1472 | di_buf.appendAssumeCapacity(@enumToInt(AbbrevKind.compile_unit)); |
| 1463 | if (self.tag == .macho) { | 1473 | if (self.tag == .macho) { |
| 1464 | mem.writeIntLittle(u32, di_buf.addManyAsArrayAssumeCapacity(4), 0); // DW.AT.stmt_list, DW.FORM.sec_offset | 1474 | mem.writeIntLittle(u32, di_buf.addManyAsArrayAssumeCapacity(4), 0); // DW.AT.stmt_list, DW.FORM.sec_offset |
| 1465 | mem.writeIntLittle(u64, di_buf.addManyAsArrayAssumeCapacity(8), low_pc); | 1475 | mem.writeIntLittle(u64, di_buf.addManyAsArrayAssumeCapacity(8), low_pc); |
| ... | @@ -1606,7 +1616,7 @@ fn pwriteDbgInfoNops( | ... | @@ -1606,7 +1616,7 @@ fn pwriteDbgInfoNops( |
| 1606 | const tracy = trace(@src()); | 1616 | const tracy = trace(@src()); |
| 1607 | defer tracy.end(); | 1617 | defer tracy.end(); |
| 1608 | | 1618 | |
| 1609 | const page_of_nops = [1]u8{abbrev_pad1} ** 4096; | 1619 | const page_of_nops = [1]u8{@enumToInt(AbbrevKind.pad1)} ** 4096; |
| 1610 | var vecs: [32]std.os.iovec_const = undefined; | 1620 | var vecs: [32]std.os.iovec_const = undefined; |
| 1611 | var vec_index: usize = 0; | 1621 | var vec_index: usize = 0; |
| 1612 | { | 1622 | { |
| ... | @@ -1673,7 +1683,7 @@ pub fn writeDbgAranges(self: *Dwarf, file: *File, addr: u64, size: u64) !void { | ... | @@ -1673,7 +1683,7 @@ pub fn writeDbgAranges(self: *Dwarf, file: *File, addr: u64, size: u64) !void { |
| 1673 | .p32 => @as(usize, 4), | 1683 | .p32 => @as(usize, 4), |
| 1674 | .p64 => 12, | 1684 | .p64 => 12, |
| 1675 | }; | 1685 | }; |
| 1676 | const ptr_width_bytes: u8 = self.ptrWidthBytes(); | 1686 | const ptr_width_bytes = self.ptrWidthBytes(); |
| 1677 | | 1687 | |
| 1678 | // Enough for all the data without resizing. When support for more compilation units | 1688 | // Enough for all the data without resizing. When support for more compilation units |
| 1679 | // is added, the size of this section will become more variable. | 1689 | // is added, the size of this section will become more variable. |
| ... | @@ -2040,7 +2050,7 @@ fn addDbgInfoErrorSet( | ... | @@ -2040,7 +2050,7 @@ fn addDbgInfoErrorSet( |
| 2040 | const target_endian = target.cpu.arch.endian(); | 2050 | const target_endian = target.cpu.arch.endian(); |
| 2041 | | 2051 | |
| 2042 | // DW.AT.enumeration_type | 2052 | // DW.AT.enumeration_type |
| 2043 | try dbg_info_buffer.append(abbrev_enum_type); | 2053 | try dbg_info_buffer.append(@enumToInt(AbbrevKind.enum_type)); |
| 2044 | // DW.AT.byte_size, DW.FORM.sdata | 2054 | // DW.AT.byte_size, DW.FORM.sdata |
| 2045 | const abi_size = ty.abiSize(target); | 2055 | const abi_size = ty.abiSize(target); |
| 2046 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); | 2056 | try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); |
| ... | @@ -2051,7 +2061,7 @@ fn addDbgInfoErrorSet( | ... | @@ -2051,7 +2061,7 @@ fn addDbgInfoErrorSet( |
| 2051 | // DW.AT.enumerator | 2061 | // DW.AT.enumerator |
| 2052 | const no_error = "(no error)"; | 2062 | const no_error = "(no error)"; |
| 2053 | try dbg_info_buffer.ensureUnusedCapacity(no_error.len + 2 + @sizeOf(u64)); | 2063 | try dbg_info_buffer.ensureUnusedCapacity(no_error.len + 2 + @sizeOf(u64)); |
| 2054 | dbg_info_buffer.appendAssumeCapacity(abbrev_enum_variant); | 2064 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.enum_variant)); |
| 2055 | // DW.AT.name, DW.FORM.string | 2065 | // DW.AT.name, DW.FORM.string |
| 2056 | dbg_info_buffer.appendSliceAssumeCapacity(no_error); | 2066 | dbg_info_buffer.appendSliceAssumeCapacity(no_error); |
| 2057 | dbg_info_buffer.appendAssumeCapacity(0); | 2067 | dbg_info_buffer.appendAssumeCapacity(0); |
| ... | @@ -2063,7 +2073,7 @@ fn addDbgInfoErrorSet( | ... | @@ -2063,7 +2073,7 @@ fn addDbgInfoErrorSet( |
| 2063 | const kv = module.getErrorValue(error_name) catch unreachable; | 2073 | const kv = module.getErrorValue(error_name) catch unreachable; |
| 2064 | // DW.AT.enumerator | 2074 | // DW.AT.enumerator |
| 2065 | try dbg_info_buffer.ensureUnusedCapacity(error_name.len + 2 + @sizeOf(u64)); | 2075 | try dbg_info_buffer.ensureUnusedCapacity(error_name.len + 2 + @sizeOf(u64)); |
| 2066 | dbg_info_buffer.appendAssumeCapacity(abbrev_enum_variant); | 2076 | dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.enum_variant)); |
| 2067 | // DW.AT.name, DW.FORM.string | 2077 | // DW.AT.name, DW.FORM.string |
| 2068 | dbg_info_buffer.appendSliceAssumeCapacity(error_name); | 2078 | dbg_info_buffer.appendSliceAssumeCapacity(error_name); |
| 2069 | dbg_info_buffer.appendAssumeCapacity(0); | 2079 | dbg_info_buffer.appendAssumeCapacity(0); |