Skip to content

Commit 7219386

Browse files
committed
std: remove TODOs for rejected proposal #1403
I also moved `ncmd` into a shorter scope.
1 parent fcf0ea0 commit 7219386

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

lib/std/debug.zig

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,16 +1083,18 @@ fn openSelfDebugInfoMacOs(allocator: *mem.Allocator) !DebugInfo {
10831083

10841084
const hdr_base = @ptrCast([*]u8, hdr);
10851085
var ptr = hdr_base + @sizeOf(macho.mach_header_64);
1086-
var ncmd: u32 = hdr.ncmds;
1087-
const symtab = while (ncmd != 0) : (ncmd -= 1) {
1088-
const lc = @ptrCast(*std.macho.load_command, ptr);
1089-
switch (lc.cmd) {
1090-
std.macho.LC_SYMTAB => break @ptrCast(*std.macho.symtab_command, ptr),
1091-
else => {},
1086+
const symtab = blk: {
1087+
var ncmd = hdr.ncmds;
1088+
while (ncmd != 0) : (ncmd -= 1) {
1089+
const lc = @ptrCast(*std.macho.load_command, ptr);
1090+
switch (lc.cmd) {
1091+
std.macho.LC_SYMTAB => break :blk @ptrCast(*std.macho.symtab_command, ptr),
1092+
else => {},
1093+
}
1094+
ptr += lc.cmdsize;
1095+
} else {
1096+
return error.MissingDebugInfo;
10921097
}
1093-
ptr += lc.cmdsize; // TODO https://github.com/ziglang/zig/issues/1403
1094-
} else {
1095-
return error.MissingDebugInfo;
10961098
};
10971099
const syms = @ptrCast([*]macho.nlist_64, @alignCast(@alignOf(macho.nlist_64), hdr_base + symtab.symoff))[0..symtab.nsyms];
10981100
const strings = @ptrCast([*]u8, hdr_base + symtab.stroff)[0..symtab.strsize];
@@ -2074,16 +2076,18 @@ fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: u
20742076

20752077
const hdr_base = @ptrCast([*]const u8, hdr);
20762078
var ptr = hdr_base + @sizeOf(macho.mach_header_64);
2077-
var ncmd: u32 = hdr.ncmds;
2078-
const segcmd = while (ncmd != 0) : (ncmd -= 1) {
2079-
const lc = @ptrCast(*const std.macho.load_command, ptr);
2080-
switch (lc.cmd) {
2081-
std.macho.LC_SEGMENT_64 => break @ptrCast(*const std.macho.segment_command_64, @alignCast(@alignOf(std.macho.segment_command_64), ptr)),
2082-
else => {},
2079+
const segcmd = blk: {
2080+
var ncmd = hdr.ncmds;
2081+
while (ncmd != 0) : (ncmd -= 1) {
2082+
const lc = @ptrCast(*const std.macho.load_command, ptr);
2083+
switch (lc.cmd) {
2084+
std.macho.LC_SEGMENT_64 => break :blk @ptrCast(*const std.macho.segment_command_64, @alignCast(@alignOf(std.macho.segment_command_64), ptr)),
2085+
else => {},
2086+
}
2087+
ptr += lc.cmdsize;
2088+
} else {
2089+
return error.MissingDebugInfo;
20832090
}
2084-
ptr += lc.cmdsize; // TODO https://github.com/ziglang/zig/issues/1403
2085-
} else {
2086-
return error.MissingDebugInfo;
20872091
};
20882092
const sections = @ptrCast([*]const macho.section_64, @alignCast(@alignOf(macho.section_64), ptr + @sizeOf(std.macho.segment_command_64)))[0..segcmd.nsects];
20892093
for (sections) |*sect| {

0 commit comments

Comments
 (0)