@zigc/lib 0.17.0-dev.644 → 0.17.0-dev.667

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/compiler/Maker/ScannedConfig.zig +4 -3
  2. package/compiler/Maker/Step/FindProgram.zig +2 -2
  3. package/compiler/Maker/Watch/FsEvents.zig +3 -2
  4. package/compiler/Maker.zig +2 -2
  5. package/compiler/aro/aro/Attribute.zig +52 -51
  6. package/compiler/aro/aro/Compilation.zig +5 -5
  7. package/compiler/aro/aro/Diagnostics.zig +7 -7
  8. package/compiler/aro/aro/Parser.zig +2 -2
  9. package/compiler/aro/aro/Tree.zig +11 -11
  10. package/compiler/aro/aro/features.zig +4 -4
  11. package/compiler/aro/aro/text_literal.zig +2 -2
  12. package/compiler/aro/backend/Interner.zig +14 -13
  13. package/compiler/configurer.zig +2 -2
  14. package/compiler/resinator/bmp.zig +3 -2
  15. package/compiler/resinator/code_pages.zig +14 -12
  16. package/compiler/resinator/cvtres.zig +11 -10
  17. package/compiler/resinator/errors.zig +18 -22
  18. package/compiler/resinator/lang.zig +7 -7
  19. package/compiler/resinator/parse.zig +1 -1
  20. package/compiler/translate-c/ast.zig +6 -6
  21. package/docs/wasm/markdown/Document.zig +3 -3
  22. package/docs/wasm/markdown/Parser.zig +3 -3
  23. package/libc/include/powerpc-linux-gnu/bits/struct_mutex.h +2 -2
  24. package/libc/include/s390x-linux-gnu/bits/fenv.h +2 -2
  25. package/libc/include/s390x-linux-gnu/bits/struct_mutex.h +2 -2
  26. package/libc/include/x86-linux-gnu/bits/struct_mutex.h +2 -2
  27. package/package.json +1 -1
  28. package/std/Build/Cache.zig +2 -2
  29. package/std/Build/Configuration.zig +19 -16
  30. package/std/Build/Step/ConfigHeader.zig +3 -2
  31. package/std/Build/Step/Options.zig +28 -22
  32. package/std/Build.zig +52 -53
  33. package/std/Io/Kqueue.zig +2 -2
  34. package/std/Io/Reader.zig +1 -1
  35. package/std/Io/Threaded.zig +18 -15
  36. package/std/Io/Uring.zig +2 -2
  37. package/std/Io/Writer.zig +18 -18
  38. package/std/Io/net.zig +3 -1
  39. package/std/Io.zig +7 -6
  40. package/std/Progress.zig +2 -2
  41. package/std/Target/aarch64.zig +2 -2
  42. package/std/Target/alpha.zig +2 -2
  43. package/std/Target/amdgcn.zig +2 -2
  44. package/std/Target/arc.zig +2 -2
  45. package/std/Target/arm.zig +2 -2
  46. package/std/Target/avr.zig +2 -2
  47. package/std/Target/bpf.zig +2 -2
  48. package/std/Target/csky.zig +2 -2
  49. package/std/Target/hexagon.zig +2 -2
  50. package/std/Target/hppa.zig +2 -2
  51. package/std/Target/kvx.zig +2 -2
  52. package/std/Target/lanai.zig +2 -2
  53. package/std/Target/loongarch.zig +2 -2
  54. package/std/Target/m68k.zig +2 -2
  55. package/std/Target/mips.zig +2 -2
  56. package/std/Target/msp430.zig +2 -2
  57. package/std/Target/nvptx.zig +2 -2
  58. package/std/Target/powerpc.zig +2 -2
  59. package/std/Target/propeller.zig +2 -2
  60. package/std/Target/riscv.zig +2 -2
  61. package/std/Target/s390x.zig +2 -2
  62. package/std/Target/sparc.zig +2 -2
  63. package/std/Target/spirv.zig +2 -2
  64. package/std/Target/ve.zig +2 -2
  65. package/std/Target/wasm.zig +2 -2
  66. package/std/Target/x86.zig +2 -2
  67. package/std/Target/xcore.zig +2 -2
  68. package/std/Target/xtensa.zig +2 -2
  69. package/std/Target.zig +4 -4
  70. package/std/c/darwin.zig +1 -1
  71. package/std/coff.zig +1 -1
  72. package/std/crypto/aes/aesni.zig +1 -1
  73. package/std/crypto/aes/armcrypto.zig +4 -4
  74. package/std/crypto/aes/soft.zig +4 -4
  75. package/std/crypto/aes.zig +12 -0
  76. package/std/crypto/codecs/asn1/Oid.zig +8 -8
  77. package/std/crypto/codecs/asn1/der/Decoder.zig +7 -7
  78. package/std/crypto/codecs/asn1/der/Encoder.zig +10 -8
  79. package/std/crypto/phc_encoding.zig +23 -20
  80. package/std/crypto/timing_safe.zig +1 -1
  81. package/std/crypto/tls/Client.zig +3 -3
  82. package/std/crypto/tls.zig +1 -1
  83. package/std/debug/Dwarf/Unwind/VirtualMachine.zig +11 -5
  84. package/std/debug/ElfFile.zig +12 -8
  85. package/std/debug/MachOFile.zig +2 -2
  86. package/std/debug/SelfInfo/MachO.zig +44 -17
  87. package/std/debug/SelfInfo/Windows.zig +2 -2
  88. package/std/elf.zig +7 -7
  89. package/std/enums.zig +66 -67
  90. package/std/gpu.zig +1 -1
  91. package/std/hash/auto_hash.zig +8 -8
  92. package/std/hash/verify.zig +3 -3
  93. package/std/http/Client.zig +2 -2
  94. package/std/json/Stringify.zig +14 -14
  95. package/std/json/static.zig +47 -31
  96. package/std/lang.zig +65 -97
  97. package/std/math.zig +2 -2
  98. package/std/mem/Allocator.zig +9 -9
  99. package/std/mem.zig +86 -102
  100. package/std/meta/trailer_flags.zig +26 -19
  101. package/std/meta.zig +131 -171
  102. package/std/multi_array_list.zig +49 -57
  103. package/std/os/uefi/protocol/device_path.zig +8 -7
  104. package/std/os/uefi/tables/boot_services.zig +1 -1
  105. package/std/os/windows.zig +9 -15
  106. package/std/sort/pdq.zig +22 -5
  107. package/std/start.zig +6 -6
  108. package/std/testing/Smith.zig +35 -21
  109. package/std/testing.zig +15 -15
  110. package/std/zig/Ast.zig +4 -4
  111. package/std/zig/AstGen.zig +42 -42
  112. package/std/zig/ErrorBundle.zig +16 -13
  113. package/std/zig/LibCInstallation.zig +11 -11
  114. package/std/zig/Parse.zig +6 -6
  115. package/std/zig/Zir.zig +10 -10
  116. package/std/zig/c_translation/helpers.zig +2 -2
  117. package/std/zig/llvm/BitcodeReader.zig +3 -3
  118. package/std/zig/llvm/Builder.zig +124 -93
  119. package/std/zig/llvm/bitcode_writer.zig +4 -4
  120. package/std/zig/system/windows.zig +11 -11
  121. package/std/zig/system.zig +4 -4
  122. package/std/zig.zig +4 -4
  123. package/std/zon/Serializer.zig +28 -23
  124. package/std/zon/parse.zig +83 -61
@@ -29,16 +29,18 @@ fn anyTag(self: *Encoder, tag_: Tag, val: anytype) !void {
29
29
 
30
30
  switch (@typeInfo(T)) {
31
31
  .@"struct" => |info| {
32
- inline for (0..info.fields.len) |i| {
33
- const f = info.fields[info.fields.len - i - 1];
34
- const field_val = @field(val, f.name);
35
- const field_tag = FieldTag.fromContainer(T, f.name);
32
+ inline for (0..info.field_names.len) |i| {
33
+ const f_idx = info.field_names.len - i - 1;
34
+ const f_name = info.field_names[f_idx];
35
+ const f_type = info.field_types[f_idx];
36
+ const f_attrs = info.field_attrs[f_idx];
37
+ const field_val = @field(val, f_name);
38
+ const field_tag = FieldTag.fromContainer(T, f_name);
36
39
 
37
40
  // > The encoding of a set value or sequence value shall not include an encoding for any
38
41
  // > component value which is equal to its default value.
39
- const is_default = if (f.is_comptime) false else if (f.default_value_ptr) |v| brk: {
40
- const default_val: *const f.type = @ptrCast(@alignCast(v));
41
- break :brk std.mem.eql(u8, std.mem.asBytes(default_val), std.mem.asBytes(&field_val));
42
+ const is_default = if (f_attrs.@"comptime") false else if (f_attrs.defaultValue(f_type)) |default_val| brk: {
43
+ break :brk std.mem.eql(u8, std.mem.asBytes(&default_val), std.mem.asBytes(&field_val));
42
44
  } else false;
43
45
 
44
46
  if (!is_default) {
@@ -46,7 +48,7 @@ fn anyTag(self: *Encoder, tag_: Tag, val: anytype) !void {
46
48
  self.field_tag = field_tag;
47
49
  // will merge with self.field_tag.
48
50
  // may mutate self.field_tag.
49
- try self.anyTag(Tag.fromZig(f.type), field_val);
51
+ try self.anyTag(Tag.fromZig(f_type), field_val);
50
52
  if (field_tag) |ft| {
51
53
  if (ft.explicit) {
52
54
  try self.length(self.buffer.data.len - start2);
@@ -115,22 +115,23 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
115
115
  while (it_params.next()) |params| {
116
116
  const param = kvSplit(params) catch break;
117
117
  var found = false;
118
- inline for (comptime meta.fields(HashResult)) |p| {
119
- if (mem.eql(u8, p.name, param.key)) {
120
- switch (@typeInfo(p.type)) {
121
- .int => @field(out, p.name) = fmt.parseUnsigned(
122
- p.type,
118
+ const info = @typeInfo(HashResult).@"struct";
119
+ inline for (info.field_names, info.field_types) |p_name, p_type| {
120
+ if (mem.eql(u8, p_name, param.key)) {
121
+ switch (@typeInfo(p_type)) {
122
+ .int => @field(out, p_name) = fmt.parseUnsigned(
123
+ p_type,
123
124
  param.value,
124
125
  10,
125
126
  ) catch return Error.InvalidEncoding,
126
127
  .pointer => |ptr| {
127
- if (!ptr.is_const) @compileError("Value slice must be constant");
128
- @field(out, p.name) = param.value;
128
+ if (!ptr.attrs.@"const") @compileError("Value slice must be constant");
129
+ @field(out, p_name) = param.value;
129
130
  },
130
- .@"struct" => try @field(out, p.name).fromB64(param.value),
131
+ .@"struct" => try @field(out, p_name).fromB64(param.value),
131
132
  else => std.debug.panic(
132
133
  "Value for [{s}] must be an integer, a constant slice or a BinValue",
133
- .{p.name},
134
+ .{p_name},
134
135
  ),
135
136
  }
136
137
  set_fields += 1;
@@ -167,8 +168,9 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
167
168
  // Check that all the required fields have been set, excluding optional values and parameters
168
169
  // with default values
169
170
  var expected_fields: usize = 0;
170
- inline for (comptime meta.fields(HashResult)) |p| {
171
- if (@typeInfo(p.type) != .optional and p.default_value_ptr == null) {
171
+ const info = @typeInfo(HashResult).@"struct";
172
+ inline for (info.field_types, info.field_attrs) |p_type, p_attrs| {
173
+ if (@typeInfo(p_type) != .optional and p_attrs.default_value_ptr == null) {
172
174
  expected_fields += 1;
173
175
  }
174
176
  }
@@ -228,21 +230,22 @@ fn serializeTo(params: anytype, out: *std.Io.Writer) !void {
228
230
  }
229
231
 
230
232
  var has_params = false;
231
- inline for (comptime meta.fields(HashResult)) |p| {
232
- if (comptime !(mem.eql(u8, p.name, "alg_id") or
233
- mem.eql(u8, p.name, "alg_version") or
234
- mem.eql(u8, p.name, "hash") or
235
- mem.eql(u8, p.name, "salt")))
233
+ const info = @typeInfo(HashResult).@"struct";
234
+ inline for (info.field_names, info.field_types) |p_name, p_type| {
235
+ if (comptime !(mem.eql(u8, p_name, "alg_id") or
236
+ mem.eql(u8, p_name, "alg_version") or
237
+ mem.eql(u8, p_name, "hash") or
238
+ mem.eql(u8, p_name, "salt")))
236
239
  {
237
- const value = @field(params, p.name);
240
+ const value = @field(params, p_name);
238
241
  try out.writeAll(if (has_params) params_delimiter else fields_delimiter);
239
- if (@typeInfo(p.type) == .@"struct") {
242
+ if (@typeInfo(p_type) == .@"struct") {
240
243
  var buf: [@TypeOf(value).max_encoded_length]u8 = undefined;
241
- try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) });
244
+ try out.print("{s}{s}{s}", .{ p_name, kv_delimiter, try value.toB64(&buf) });
242
245
  } else {
243
246
  try out.print(
244
247
  if (@typeInfo(@TypeOf(value)) == .pointer) "{s}{s}{s}" else "{s}{s}{}",
245
- .{ p.name, kv_delimiter, value },
248
+ .{ p_name, kv_delimiter, value },
246
249
  );
247
250
  }
248
251
  has_params = true;
@@ -135,7 +135,7 @@ fn markSecret(ptr: anytype, comptime action: enum { classify, declassify }) void
135
135
  const t = @typeInfo(@TypeOf(ptr));
136
136
  if (t != .pointer) @compileError("Pointer expected - Found: " ++ @typeName(@TypeOf(ptr)));
137
137
  const p = t.pointer;
138
- if (p.is_allowzero) @compileError("A nullable pointer is always assumed to leak information via side channels");
138
+ if (p.attrs.@"allowzero") @compileError("A nullable pointer is always assumed to leak information via side channels");
139
139
  const child = @typeInfo(p.child);
140
140
 
141
141
  switch (child) {
@@ -1338,11 +1338,11 @@ fn failRead(c: *Client, err: ReadError) error{ReadFailed} {
1338
1338
  }
1339
1339
 
1340
1340
  fn logSecrets(w: *Writer, context: anytype, secrets: anytype) void {
1341
- inline for (@typeInfo(@TypeOf(secrets)).@"struct".fields) |field| w.print("{s}" ++
1342
- (if (@hasField(@TypeOf(context), "counter")) "_{d}" else "") ++ " {x} {x}\n", .{field.name} ++
1341
+ inline for (@typeInfo(@TypeOf(secrets)).@"struct".field_names) |field_name| w.print("{s}" ++
1342
+ (if (@hasField(@TypeOf(context), "counter")) "_{d}" else "") ++ " {x} {x}\n", .{field_name} ++
1343
1343
  (if (@hasField(@TypeOf(context), "counter")) .{context.counter} else .{}) ++ .{
1344
1344
  context.client_random,
1345
- @field(secrets, field.name),
1345
+ @field(secrets, field_name),
1346
1346
  }) catch {};
1347
1347
  }
1348
1348
 
@@ -710,7 +710,7 @@ pub const Decoder = struct {
710
710
  else => @compileError("unsupported int type: " ++ @typeName(T)),
711
711
  },
712
712
  .@"enum" => |info| {
713
- if (info.is_exhaustive) @compileError("exhaustive enum cannot be used");
713
+ if (info.mode == .exhaustive) @compileError("exhaustive enum cannot be used");
714
714
  return @enumFromInt(d.decode(info.tag_type));
715
715
  },
716
716
  else => @compileError("unsupported type: " ++ @typeName(T)),
@@ -247,10 +247,15 @@ fn evalInstructions(
247
247
  .val_expr => |len| .{ .val_expression = try takeExprBlock(&fr, len) },
248
248
  };
249
249
  },
250
- .def_cfa => |cfa| vm.current_row.cfa = .{ .reg_off = .{
251
- .register = cfa.register,
252
- .offset = @intCast(cfa.offset),
253
- } },
250
+ .def_cfa => |cfa| vm.current_row.cfa = .{
251
+ .reg_off = .{
252
+ .register = cfa.register,
253
+ // Unfortunately, LLVM emits negative CFI directives as their unsigned variants
254
+ // rather than the signed variants that DWARF has for exactly that purpose, hence
255
+ // `@bitCast` instead of `@intCast`.
256
+ .offset = @bitCast(cfa.offset),
257
+ },
258
+ },
254
259
  .def_cfa_sf => |cfa| vm.current_row.cfa = .{ .reg_off = .{
255
260
  .register = cfa.register,
256
261
  .offset = cfa.offset_sf * cie.data_alignment_factor,
@@ -272,7 +277,8 @@ fn evalInstructions(
272
277
  },
273
278
  .def_cfa_offset => |offset| switch (vm.current_row.cfa) {
274
279
  .none, .expression => return error.InvalidOperation,
275
- .reg_off => |*ro| ro.offset = @intCast(offset),
280
+ // See the comment for `def_cfa` above.
281
+ .reg_off => |*ro| ro.offset = @bitCast(offset),
276
282
  },
277
283
  .def_cfa_offset_sf => |offset_sf| switch (vm.current_row.cfa) {
278
284
  .none, .expression => return error.InvalidOperation,
@@ -219,9 +219,10 @@ pub fn load(
219
219
  break :dwarf null; // debug info not present
220
220
  }
221
221
  var sections: Dwarf.SectionArray = @splat(null);
222
- inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields) |f| {
223
- if (result.sections.get(@field(Section.Id, f.name))) |s| {
224
- sections[f.value] = .{ .data = s.bytes, .owned = false };
222
+ const info = @typeInfo(Dwarf.Section.Id).@"enum";
223
+ inline for (info.field_names, info.field_values) |f_name, f_value| {
224
+ if (result.sections.get(@field(Section.Id, f_name))) |s| {
225
+ sections[f_value] = .{ .data = s.bytes, .owned = false };
225
226
  }
226
227
  }
227
228
  break :dwarf .{ .sections = sections };
@@ -408,8 +409,8 @@ fn loadSeparateDebugFile(
408
409
  return null;
409
410
  }
410
411
 
411
- inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields) |f| {
412
- const id = @field(Section.Id, f.name);
412
+ inline for (@typeInfo(Dwarf.Section.Id).@"enum".field_names) |f_name| {
413
+ const id = @field(Section.Id, f_name);
413
414
  if (main_loaded.sections.get(id) == null) {
414
415
  main_loaded.sections.set(id, result.sections.get(id));
415
416
  }
@@ -498,9 +499,12 @@ fn loadInner(
498
499
  if (shdr.sh_name > shstrtab.len) return error.TruncatedElfFile;
499
500
  const name = std.mem.sliceTo(shstrtab[@intCast(shdr.sh_name)..], 0);
500
501
 
501
- const section_id: Section.Id = inline for (@typeInfo(Section.Id).@"enum".fields) |s| {
502
- if (std.mem.eql(u8, "." ++ s.name, name)) {
503
- break @enumFromInt(s.value);
502
+ const section_id: Section.Id = inline for (
503
+ @typeInfo(Section.Id).@"enum".field_names,
504
+ @typeInfo(Section.Id).@"enum".field_values,
505
+ ) |s_name, s_value| {
506
+ if (std.mem.eql(u8, "." ++ s_name, name)) {
507
+ break @enumFromInt(s_value);
504
508
  }
505
509
  } else continue;
506
510
 
@@ -504,8 +504,8 @@ fn loadOFile(gpa: Allocator, io: Io, o_file_name: []const u8) !OFile {
504
504
 
505
505
  if (!std.mem.eql(u8, "__DWARF", sect.segName())) continue;
506
506
 
507
- const section_index: usize = inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |section, i| {
508
- if (mem.eql(u8, "__" ++ section.name, sect.sectName())) break i;
507
+ const section_index: usize = inline for (@typeInfo(Dwarf.Section.Id).@"enum".field_names, 0..) |section_name, i| {
508
+ if (mem.eql(u8, "__" ++ section_name, sect.sectName())) break i;
509
509
  } else continue;
510
510
 
511
511
  if (mapped_ofile.len < sect.offset + sect.size) return error.InvalidMachO;
@@ -93,12 +93,28 @@ pub fn getSymbols(
93
93
  pub fn getModuleName(si: *SelfInfo, io: Io, address: usize) Error![]const u8 {
94
94
  _ = si;
95
95
  _ = io;
96
- // This function is marked as deprecated; however, it is significantly more
97
- // performant than `dladdr` (since the latter also does a very slow symbol
98
- // lookup), so let's use it since it's still available.
99
- return std.mem.span(std.c.dyld_image_path_containing_address(
100
- @ptrFromInt(address),
101
- ) orelse return error.MissingDebugInfo);
96
+ return getModuleNameInner(address) orelse return error.MissingDebugInfo;
97
+ }
98
+ fn getModuleNameInner(address: usize) ?[]const u8 {
99
+ switch (builtin.target.os.tag) {
100
+ .macos => {
101
+ // This function is marked as deprecated; however, it is significantly more performant
102
+ // than `dladdr` (since the latter also does a very slow symbol lookup), so let's just
103
+ // use it for the better performance since it's still available.
104
+ return std.mem.span(std.c.dyld_image_path_containing_address(
105
+ @ptrFromInt(address),
106
+ ) orelse return null);
107
+ },
108
+ else => {
109
+ // On other Darwin systems, the function used above is entirely unavailable, so we have
110
+ // no choice but to use the slow `dladdr`.
111
+ var info: std.c.dl_info = undefined;
112
+ if (std.c.dladdr(@ptrFromInt(address), &info) == 0) {
113
+ return null;
114
+ }
115
+ return std.mem.span(info.fname);
116
+ },
117
+ }
102
118
  }
103
119
  pub fn getModuleSlide(si: *SelfInfo, io: Io, address: usize) Error!usize {
104
120
  const gpa = std.debug.getDebugInfoAllocator();
@@ -408,8 +424,8 @@ fn unwindFrameInner(si: *SelfInfo, io: Io, context: *UnwindContext) !usize {
408
424
  const ip_ptr = fp + @sizeOf(usize);
409
425
 
410
426
  var reg_addr = fp - @sizeOf(usize);
411
- inline for (@typeInfo(@TypeOf(frame.x_reg_pairs)).@"struct".fields, 0..) |field, i| {
412
- if (@field(frame.x_reg_pairs, field.name) != 0) {
427
+ inline for (@typeInfo(@TypeOf(frame.x_reg_pairs)).@"struct".field_names, 0..) |field_name, i| {
428
+ if (@field(frame.x_reg_pairs, field_name) != 0) {
413
429
  (try dwarfRegNative(&context.cpu_state, 19 + i)).* = @as(*const usize, @ptrFromInt(reg_addr)).*;
414
430
  reg_addr += @sizeOf(usize);
415
431
  (try dwarfRegNative(&context.cpu_state, 20 + i)).* = @as(*const usize, @ptrFromInt(reg_addr)).*;
@@ -446,12 +462,25 @@ fn unwindFrameInner(si: *SelfInfo, io: Io, context: *UnwindContext) !usize {
446
462
 
447
463
  /// Acquires the mutex on success.
448
464
  fn findModule(si: *SelfInfo, gpa: Allocator, io: Io, address: usize) Error!*Module {
449
- // This function is marked as deprecated; however, it is significantly more
450
- // performant than `dladdr` (since the latter also does a very slow symbol
451
- // lookup), so let's use it since it's still available.
452
- const text_base = std.c._dyld_get_image_header_containing_address(
453
- @ptrFromInt(address),
454
- ) orelse return error.MissingDebugInfo;
465
+ const text_base: *anyopaque = switch (builtin.target.os.tag) {
466
+ .macos => base: {
467
+ // This function is marked as deprecated; however, it is significantly more performant
468
+ // than `dladdr` (since the latter also does a very slow symbol lookup), so let's just
469
+ // use it for the better performance since it's still available.
470
+ break :base std.c._dyld_get_image_header_containing_address(
471
+ @ptrFromInt(address),
472
+ ) orelse return error.MissingDebugInfo;
473
+ },
474
+ else => base: {
475
+ // On other Darwin systems, the function used above is entirely unavailable, so we have
476
+ // no choice but to use the slow `dladdr`.
477
+ var info: std.c.dl_info = undefined;
478
+ if (std.c.dladdr(@ptrFromInt(address), &info) == 0) {
479
+ return error.MissingDebugInfo;
480
+ }
481
+ break :base info.fbase;
482
+ },
483
+ };
455
484
  try si.mutex.lock(io);
456
485
  errdefer si.mutex.unlock(io);
457
486
  const gop = try si.modules.getOrPutAdapted(gpa, @intFromPtr(text_base), Module.Adapter{});
@@ -563,9 +592,7 @@ const Module = struct {
563
592
 
564
593
  fn getFile(module: *Module, gpa: Allocator, io: Io) Error!*MachOFile {
565
594
  if (module.file == null) {
566
- const path = std.mem.span(
567
- std.c.dyld_image_path_containing_address(@ptrFromInt(module.text_base)).?,
568
- );
595
+ const path = getModuleNameInner(module.text_base).?;
569
596
  module.file = MachOFile.load(gpa, io, path, builtin.cpu.arch) catch |err| switch (err) {
570
597
  error.InvalidMachO, error.InvalidDwarf => error.InvalidDebugInfo,
571
598
  error.MissingDebugInfo, error.OutOfMemory, error.UnsupportedDebugInfo, error.ReadFailed => |e| e,
@@ -513,8 +513,8 @@ const Module = struct {
513
513
  if (coff_obj.getSectionByName(".debug_info") == null) break :dwarf null;
514
514
 
515
515
  var sections: Dwarf.SectionArray = undefined;
516
- inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |section, i| {
517
- sections[i] = if (coff_obj.getSectionByName("." ++ section.name)) |section_header| .{
516
+ inline for (@typeInfo(Dwarf.Section.Id).@"enum".field_names, 0..) |section_name, i| {
517
+ sections[i] = if (coff_obj.getSectionByName("." ++ section_name)) |section_header| .{
518
518
  .data = try coff_obj.getSectionDataAlloc(section_header, arena),
519
519
  .owned = false,
520
520
  } else null;
package/std/elf.zig CHANGED
@@ -484,7 +484,7 @@ pub const PT = enum(Word) {
484
484
  _,
485
485
 
486
486
  /// Number of defined types
487
- pub const NUM = @typeInfo(PT).@"enum".fields.len;
487
+ pub const NUM = @typeInfo(PT).@"enum".field_names.len;
488
488
 
489
489
  /// Start of OS-specific
490
490
  pub const LOOS: PT = @enumFromInt(0x60000000);
@@ -552,7 +552,7 @@ pub const SHT = enum(Word) {
552
552
  _,
553
553
 
554
554
  /// Number of defined types
555
- pub const NUM = @typeInfo(SHT).@"enum".fields.len;
555
+ pub const NUM = @typeInfo(SHT).@"enum".field_names.len;
556
556
 
557
557
  /// Start of OS-specific
558
558
  pub const LOOS: SHT = @enumFromInt(0x60000000);
@@ -595,7 +595,7 @@ pub const STB = enum(u4) {
595
595
  _,
596
596
 
597
597
  /// Number of defined types
598
- pub const NUM = @typeInfo(STB).@"enum".fields.len;
598
+ pub const NUM = @typeInfo(STB).@"enum".field_names.len;
599
599
 
600
600
  /// Start of OS-specific
601
601
  pub const LOOS: STB = @enumFromInt(10);
@@ -631,7 +631,7 @@ pub const STT = enum(u4) {
631
631
  _,
632
632
 
633
633
  /// Number of defined types
634
- pub const NUM = @typeInfo(STT).@"enum".fields.len;
634
+ pub const NUM = @typeInfo(STT).@"enum".field_names.len;
635
635
 
636
636
  /// Start of OS-specific
637
637
  pub const LOOS: STT = @enumFromInt(10);
@@ -815,7 +815,7 @@ pub const Header = struct {
815
815
 
816
816
  pub fn init(hdr: anytype, endian: Endian) Header {
817
817
  // Converting integers to exhaustive enums using `@enumFromInt` could cause a panic.
818
- comptime assert(!@typeInfo(OSABI).@"enum".is_exhaustive);
818
+ comptime assert(@typeInfo(OSABI).@"enum".mode == .nonexhaustive);
819
819
  return .{
820
820
  .is_64 = switch (@TypeOf(hdr)) {
821
821
  Elf32_Ehdr => false,
@@ -1642,7 +1642,7 @@ pub const CLASS = enum(u8) {
1642
1642
  @"64" = 2,
1643
1643
  _,
1644
1644
 
1645
- pub const NUM = @typeInfo(CLASS).@"enum".fields.len;
1645
+ pub const NUM = @typeInfo(CLASS).@"enum".field_names.len;
1646
1646
 
1647
1647
  pub fn ElfN(comptime class: CLASS) type {
1648
1648
  return switch (class) {
@@ -1667,7 +1667,7 @@ pub const DATA = enum(u8) {
1667
1667
  @"2MSB" = 2,
1668
1668
  _,
1669
1669
 
1670
- pub const NUM = @typeInfo(DATA).@"enum".fields.len;
1670
+ pub const NUM = @typeInfo(DATA).@"enum".field_names.len;
1671
1671
  };
1672
1672
 
1673
1673
  pub const OSABI = enum(u8) {