diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 23d134f84c..3d8bc565e7 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -756,7 +756,13 @@ const StackIterator = union(enum) { // Use `di_first` here so we report the PC in the context before unwinding any further. return .{ .di_first = .init(context_ptr) }; } - if (SelfInfo.supports_unwinding and cpu_context.Native != noreturn) { + // Workaround the C backend being unable to use inline assembly on MSVC by disabling the + // call to `current`. This effectively constrains stack trace collection and dumping to FP + // unwinding when building with CBE for MSVC. + if (!(builtin.zig_backend == .stage2_c and builtin.target.abi == .msvc) and + SelfInfo.supports_unwinding and + cpu_context.Native != noreturn) + { // We don't need `di_first` here, because our PC is in `std.debug`; we're only interested // in our caller's frame and above. return .{ .di = .init(&.current()) }; diff --git a/lib/std/debug/cpu_context.zig b/lib/std/debug/cpu_context.zig index b9dd49767f..fdf6ebd243 100644 --- a/lib/std/debug/cpu_context.zig +++ b/lib/std/debug/cpu_context.zig @@ -316,7 +316,7 @@ pub const X86_64 = struct { \\movq %%r15, 0x78(%%rdi) \\leaq (%%rip), %%rax \\movq %%rax, 0x80(%%rdi) - \\movq 0x00(%%rdi), %%rax // restore saved rax + \\movq 0x00(%%rdi), %%rax : : [gprs] "{rdi}" (&ctx.gprs.values), : .{ .memory = true }); @@ -431,7 +431,7 @@ pub const Aarch64 = extern struct { \\str x1, [x0, #0x0f8] \\adr x1, . \\str x1, [x0, #0x100] - \\ldr x1, [x0, #0x008] // restore saved x1 + \\ldr x1, [x0, #0x008] : : [gprs] "{x0}" (&ctx), : .{ .memory = true });