authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-04-23 10:05:46+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-04-23 10:05:46+02:00
log374d16793f115a5f35060a972fc5d3b43dac958a
tree4fc296088ba0d058987dcb442306a28d2e68f9f1
parentb095e33667972cb650341e8cfbae7ae41ca9580d

Go one instruction before the return address

The return address may not point to an area covered by the debug infos so we hope for the best and decrement the address so that it points to the caller instruction.

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

std/debug.zig+4-4
......@@ -221,7 +221,7 @@ pub fn writeStackTrace(
221221 frame_index = (frame_index + 1) % stack_trace.instruction_addresses.len;
222222 }) {
223223 const return_address = stack_trace.instruction_addresses[frame_index];
224 try printSourceAtAddress(debug_info, out_stream, return_address, tty_color);
224 try printSourceAtAddress(debug_info, out_stream, return_address - 1, tty_color);
225225 }
226226}
227227
......@@ -263,7 +263,7 @@ pub fn writeCurrentStackTrace(out_stream: var, debug_info: *DebugInfo, tty_color
263263 }
264264 var it = StackIterator.init(start_addr);
265265 while (it.next()) |return_address| {
266 try printSourceAtAddress(debug_info, out_stream, return_address, tty_color);
266 try printSourceAtAddress(debug_info, out_stream, return_address - 1, tty_color);
267267 }
268268}
269269
......@@ -689,9 +689,9 @@ pub fn printSourceAtAddressDwarf(
689689 return;
690690 };
691691 const compile_unit_name = try compile_unit.die.getAttrString(debug_info, DW.AT_name);
692 if (getLineNumberInfoDwarf(debug_info, compile_unit.*, address - 1)) |line_info| {
692 if (getLineNumberInfoDwarf(debug_info, compile_unit.*, address)) |line_info| {
693693 defer line_info.deinit();
694 const symbol_name = getSymbolNameDwarf(debug_info, address - 1) orelse "???";
694 const symbol_name = getSymbolNameDwarf(debug_info, address) orelse "???";
695695 try printLineInfo(
696696 out_stream,
697697 line_info,