mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 11:45:06 +00:00
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:
parent
0b66656ca9
commit
1c06111cbd
16 changed files with 157 additions and 26 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Bytecode/Executable.h>
|
||||
#include <LibJS/Bytecode/Instruction.h>
|
||||
#include <LibJS/Bytecode/Op.h>
|
||||
|
||||
|
@ -25,4 +26,20 @@ void Instruction::destroy(Instruction& instruction)
|
|||
#undef __BYTECODE_OP
|
||||
}
|
||||
|
||||
UnrealizedSourceRange InstructionStreamIterator::source_range() const
|
||||
{
|
||||
VERIFY(m_executable);
|
||||
auto record = dereference().source_record();
|
||||
return {
|
||||
.source_code = m_executable->source_code,
|
||||
.start_offset = record.source_start_offset,
|
||||
.end_offset = record.source_end_offset,
|
||||
};
|
||||
}
|
||||
|
||||
RefPtr<SourceCode> InstructionStreamIterator::source_code() const
|
||||
{
|
||||
return m_executable ? m_executable->source_code.ptr() : nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue