1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:27:35 +00:00

Userland: Hardcode the x86_64 kernel base address for now

This commit is contained in:
Gunnar Beutner 2021-07-20 13:40:35 +02:00 committed by Andreas Kling
parent 4fdee56ba3
commit 60b52cfb02
6 changed files with 43 additions and 6 deletions

View file

@ -30,7 +30,14 @@ DisassemblyModel::DisassemblyModel(const Debug::DebugSession& debug_session, con
OwnPtr<ELF::Image> kernel_elf;
const ELF::Image* elf = nullptr;
if (containing_function.value().address_low >= 0xc0000000) {
// FIXME: Use /proc for this
#if ARCH(I386)
FlatPtr kernel_base = 0xc0000000;
#else
FlatPtr kernel_base = 0x2000000000;
#endif
if (containing_function.value().address_low >= kernel_base) {
auto file_or_error = MappedFile::map("/boot/Kernel.debug");
if (file_or_error.is_error())
return;

View file

@ -40,7 +40,13 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node)
OwnPtr<ELF::Image> kernel_elf;
const ELF::Image* elf;
FlatPtr base_address = 0;
if (m_node.address() >= 0xc0000000) {
// FIXME: Use /proc for this
#if ARCH(I386)
FlatPtr kernel_base = 0xc0000000;
#else
FlatPtr kernel_base = 0x2000000000;
#endif
if (m_node.address() >= kernel_base) {
if (!m_kernel_file) {
auto file_or_error = MappedFile::map("/boot/Kernel.debug");
if (file_or_error.is_error())

View file

@ -301,6 +301,13 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St
continue;
}
// FIXME: Use /proc for this
#if ARCH(I386)
FlatPtr kernel_base = 0xc0000000;
#else
FlatPtr kernel_base = 0x2000000000;
#endif
auto* stack = perf_event.get_ptr("stack");
VERIFY(stack);
auto& stack_array = stack->as_array();
@ -311,7 +318,7 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St
FlyString object_name;
String symbol;
if (ptr >= 0xc0000000) {
if (ptr >= kernel_base) {
if (kernel_elf) {
symbol = kernel_elf->symbolicate(ptr, &offset);
} else {
@ -338,7 +345,7 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St
continue;
FlatPtr innermost_frame_address = event.frames.at(1).address;
event.in_kernel = innermost_frame_address >= 0xc0000000;
event.in_kernel = innermost_frame_address >= kernel_base;
events.append(move(event));
}

View file

@ -105,7 +105,13 @@ GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
if (node->is_root()) {
return GUI::FileIconProvider::icon_for_executable(node->process().executable);
}
if (node->address() >= 0xc0000000)
// FIXME: Use /proc for this
#if ARCH(I386)
FlatPtr kernel_base = 0xc0000000;
#else
FlatPtr kernel_base = 0x2000000000;
#endif
if (node->address() >= kernel_base)
return m_kernel_frame_icon;
return m_user_frame_icon;
}

View file

@ -82,7 +82,12 @@ Vector<Symbol> symbolicate_thread(pid_t pid, pid_t tid)
Vector<RegionWithSymbols> regions;
regions.append(RegionWithSymbols {
// FIXME: Use /proc for this
#if ARCH(I386)
.base = 0xc0000000,
#else
.base = 0x2000000000,
#endif
.size = 0x3fffffff,
.path = "/boot/Kernel.debug",
.is_relative = false });

View file

@ -44,7 +44,13 @@ int main(int argc, char** argv)
auto frame_number = symbols.size() - 1;
for (auto& symbol : symbols) {
// Make kernel stack frames stand out.
int color = symbol.address < 0xc0000000 ? 35 : 31;
// FIXME: Use /proc for this
#if ARCH(I386)
FlatPtr kernel_base = 0xc0000000;
#else
FlatPtr kernel_base = 0x2000000000;
#endif
int color = symbol.address < kernel_base ? 35 : 31;
out("{:3}: \033[{};1m{:p}\033[0m | ", frame_number, color, symbol.address);
if (!symbol.name.is_empty())
out("{} ", symbol.name);