1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

LibJS/JIT: Produce & register an ELF image for GDB JIT Interface

Using the code that it has just produced, the JIT::Compiler can build an
ELF image so that we can attach meaningful symbols to JITted code, and
thus enable GDB to display more information about the code that we're
running.
This commit is contained in:
Jesús (gsus) Lapastora 2023-11-11 23:35:24 +01:00 committed by Andrew Kaster
parent 149e382735
commit f0b984567a
3 changed files with 20 additions and 3 deletions

View file

@ -1,12 +1,14 @@
/*
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2023, Simon Wanner <simon@skyrising.xyz>
* Copyright (c) 2023, Jesús Lapastora <cyber.gsuscode@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/OwnPtr.h>
#include <AK/Platform.h>
#include <LibJIT/GDB.h>
#include <LibJS/Bytecode/CommonImplementations.h>
#include <LibJS/Bytecode/Instruction.h>
#include <LibJS/Bytecode/Interpreter.h>
@ -3757,7 +3759,14 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
dbgln("\033[32;1mJIT compilation succeeded!\033[0m {}", bytecode_executable.name);
}
auto executable = make<NativeExecutable>(executable_memory, compiler.m_output.size(), mapping);
auto const code = ReadonlyBytes {
executable_memory,
compiler.m_output.size(),
};
auto gdb_object = ::JIT::GDB::build_gdb_image(code, "LibJS JIT"sv, "LibJS JITted code"sv);
auto executable = make<NativeExecutable>(executable_memory, compiler.m_output.size(), mapping, move(gdb_object));
if constexpr (DUMP_JIT_DISASSEMBLY)
executable->dump_disassembly(bytecode_executable);
return executable;