mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-26 13:01:34 +03:00
Removes dead code, updates some tests, fixes typos in comments, formats
This commit is contained in:
@@ -9,7 +9,7 @@ pub fn main() !void {
|
||||
|
||||
const captured_st = try foo(&stdout.interface, &st_buf);
|
||||
try std.debug.writeStackTrace(&captured_st, .{ .writer = &stdout.interface, .mode = .no_color });
|
||||
try stdout.interface.print("stack trace index: {d}\n", .{captured_st.index});
|
||||
try stdout.interface.print("stack trace index: {d}\n", .{captured_st.return_addresses.len});
|
||||
|
||||
try stdout.interface.flush();
|
||||
}
|
||||
|
||||
@@ -466,8 +466,7 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext, os: std.Target.
|
||||
\\}
|
||||
,
|
||||
.expect_error = "ThisIsSoSad",
|
||||
.expect_trace =
|
||||
switch (os) {
|
||||
.expect_trace = switch (os) {
|
||||
// LLVM doesn't emit column info in the binary annotations for inlinee callees in PDBs,
|
||||
// so our expected result is slightly different for Windows than on other operating
|
||||
// systems.
|
||||
|
||||
@@ -52,23 +52,24 @@ pub fn main(init: std.process.Init) !void {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If both the row and column are present, this it he column end. Otherwise it's the line end.
|
||||
const src_pos_end = std.mem.indexOf(u8, in_line, ": 0x") orelse {
|
||||
try w.writeAll(in_line);
|
||||
continue;
|
||||
};
|
||||
const src_row_or_path_end = std.mem.lastIndexOfScalar(u8, in_line[0..src_pos_end], ':') orelse {
|
||||
try w.writeAll(in_line);
|
||||
continue;
|
||||
const src_pos_start = b: {
|
||||
const postfix = ".zig:";
|
||||
const postfix_index = std.mem.lastIndexOf(u8, in_line[0..src_pos_end], postfix) orelse {
|
||||
try w.writeAll(in_line);
|
||||
continue;
|
||||
};
|
||||
break :b postfix_index + postfix.len;
|
||||
};
|
||||
const src_path_end = std.mem.lastIndexOfScalar(u8, in_line[0..src_row_or_path_end], ':')
|
||||
orelse src_row_or_path_end;
|
||||
|
||||
const addr_end = std.mem.indexOfPos(u8, in_line, src_pos_end, " in ") orelse {
|
||||
const addr_end = std.mem.findPos(u8, in_line, src_pos_end, " in ") orelse {
|
||||
try w.writeAll(in_line);
|
||||
continue;
|
||||
};
|
||||
const symbol_end = std.mem.indexOfPos(u8, in_line, addr_end, " (") orelse {
|
||||
const symbol_end = std.mem.findPos(u8, in_line, addr_end, " (") orelse {
|
||||
try w.writeAll(in_line);
|
||||
continue;
|
||||
};
|
||||
@@ -87,7 +88,7 @@ pub fn main(init: std.process.Init) !void {
|
||||
//
|
||||
// ...with that first '_' being replaced by its basename.
|
||||
|
||||
const src_path = in_line[0..src_path_end];
|
||||
const src_path = in_line[0..src_pos_start];
|
||||
const basename_start = if (std.mem.lastIndexOfAny(u8, src_path, "/\\")) |i| i + 1 else 0;
|
||||
const symbol_start = addr_end + " in ".len;
|
||||
try w.writeAll(in_line[basename_start..src_pos_end]);
|
||||
|
||||
@@ -12,13 +12,13 @@ pub fn main(init: std.process.Init) void {
|
||||
var add_addr: usize = undefined;
|
||||
_ = add(1, 2, &add_addr);
|
||||
|
||||
const symbols = di.getSymbols(io, add_addr) catch |err| fatal("failed to get symbol: {t}", .{err});
|
||||
const symbols = di.getSymbols(io, add_addr, false) catch |err| fatal("failed to get symbol: {t}", .{err});
|
||||
const debug_gpa = std.debug.getDebugInfoAllocator();
|
||||
defer for (symbols) |symbol| {
|
||||
if (symbol.source_location) |sl| {
|
||||
debug_gpa.free(sl.file_name);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (symbols.len != 1) fatal("expected 1 symbol, found {}", .{symbols.len});
|
||||
const symbol = symbols[0];
|
||||
|
||||
+1
-2
@@ -2168,7 +2168,6 @@ pub fn addErrorTraceTests(
|
||||
error_traces.addCases(darling_cases, .macos);
|
||||
}
|
||||
|
||||
|
||||
return step;
|
||||
}
|
||||
|
||||
@@ -2291,7 +2290,7 @@ pub fn addCliTests(b: *std.Build) *Step {
|
||||
\\ return num * num;
|
||||
\\}
|
||||
\\extern fn zig_panic() noreturn;
|
||||
\\pub fn panic(msg: []const u8, error_return_trace: ?*@import("builtin").StackTrace, _: ?usize) noreturn {
|
||||
\\pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace, _: ?usize) noreturn {
|
||||
\\ _ = msg;
|
||||
\\ _ = error_return_trace;
|
||||
\\ zig_panic();
|
||||
|
||||
Reference in New Issue
Block a user