authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-11-08 15:31:14-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-11-08 15:31:14-07:00
log4d75382452abd5e50e6f8ca9c82b67fbe0983456
treea8039aba1fac3e2ea38d9d58ad5bff528032d45b
parenta7d215759e93be971ba5e560578e7473655cdd82

tools/gen_stubs.zig: better error message on invalid input


1 files changed, 4 insertions(+), 1 deletions(-)

tools/gen_stubs.zig+4-1
...@@ -32,10 +32,13 @@ pub fn main() !void {...@@ -32,10 +32,13 @@ pub fn main() !void {
3232
33 // This is many times larger than any line objdump produces should ever be33 // This is many times larger than any line objdump produces should ever be
34 var buf: [4096]u8 = undefined;34 var buf: [4096]u8 = undefined;
35 var line_number: usize = 0;
3536
36 // Sample input line:37 // Sample input line:
37 // 00000000000241b0 g DF .text 000000000000001b copy_file_range38 // 00000000000241b0 g DF .text 000000000000001b copy_file_range
38 while (try stdin.readUntilDelimiterOrEof(&buf, '\n')) |line| {39 while (try stdin.readUntilDelimiterOrEof(&buf, '\n')) |line| {
40 line_number += 1;
41
39 // the lines we want all start with a 16 digit hex value42 // the lines we want all start with a 16 digit hex value
40 if (line.len < 16) continue;43 if (line.len < 16) continue;
41 _ = std.fmt.parseInt(u64, line[0..16], 16) catch continue;44 _ = std.fmt.parseInt(u64, line[0..16], 16) catch continue;
...@@ -57,7 +60,7 @@ pub fn main() !void {...@@ -57,7 +60,7 @@ pub fn main() !void {
57 else if (line[17] == ' ' and line[18] == 'w')60 else if (line[17] == ' ' and line[18] == 'w')
58 .weak61 .weak
59 else62 else
60 unreachable,63 std.debug.panic("unexpected kind on line {d}:\n{s}", .{ line_number, line }),
6164
62 .type = switch (line[23]) {65 .type = switch (line[23]) {
63 'F' => .function,66 'F' => .function,