LibJS: Add file & line number to bytecode VM stack traces :^)

This works by adding source start/end offset to every bytecode
instruction. In the future we can make this more efficient by keeping
a map of bytecode ranges to source ranges in the Executable instead,
but let's just get traces working first.

Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
This commit is contained in:
Andreas Kling 2023-09-01 16:53:55 +02:00
commit 1c06111cbd
Notes: sideshowbarker 2024-07-16 21:39:23 +09:00
16 changed files with 157 additions and 26 deletions

View file

@ -83,9 +83,12 @@ void Error::populate_stack()
if (function_name.is_empty())
function_name = "<unknown>"sv;
UnrealizedSourceRange range = {};
if (context->instruction_stream_iterator.has_value())
range = context->instruction_stream_iterator->source_range();
TracebackFrame frame {
.function_name = move(function_name),
.source_range_storage = context->source_range,
.source_range_storage = range,
};
m_traceback.append(move(frame));