mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:07:34 +00:00
LibJIT: Integrate GDB JIT Interface with ELF builders
Provide a function to create an ELF image in a format GDB expects. Outside of ELF platforms this image doesn't make much sense, and in MacOS a Mach-O memory image is required: see https://chromium.googlesource.com/v8/v8.git/+/refs/heads/main/src/diagnostics/gdb-jit.cc#1802 Since GDB requires active runtime addresses for the code, copying the generated code into the image will not help. Instead, `build_gdb_image` writes the runtime addresses of the code into a NOBITS `.text` section.
This commit is contained in:
parent
48a9d0ede8
commit
149e382735
4 changed files with 122 additions and 0 deletions
|
@ -6,10 +6,23 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/Span.h>
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace JIT::GDB {
|
||||
|
||||
void register_into_gdb(ReadonlyBytes data);
|
||||
void unregister_from_gdb(ReadonlyBytes data);
|
||||
|
||||
// Build a GDB compatible image to register with the GDB JIT Interface.
|
||||
// Returns Optional since the platform may not be supported.
|
||||
// The `code` must be the region of memory that will be executed, since the
|
||||
// image will hold direct references to addresses within the code. This way GDB
|
||||
// will be able to identify the code region and insert breakpoints into it.
|
||||
// Both `file_symbol_name` and `code_symbol_name` will end up in the symbol
|
||||
// table of the image. They represent a file name for the image and a name for
|
||||
// the region of code that is being executed.
|
||||
Optional<FixedArray<u8>> build_gdb_image(ReadonlyBytes code, StringView file_symbol_name, StringView code_symbol_name);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue