Compare commits
No commits in common. "3ca31770e7d4cbf3a42b26ae3880b3b6dee65622" and "37e046d766a187d5c8786139504f8de75f7746de" have entirely different histories.
3ca31770e7
...
37e046d766
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,7 +2,6 @@ Luna.iso
|
||||
toolchain/
|
||||
build/
|
||||
initrd/boot/moon
|
||||
initrd/ksyms
|
||||
env-local.sh
|
||||
initrd/bin/**
|
||||
base/usr/bin/**
|
||||
|
2
initrd/sbin/mount-ext2fs
Normal file
2
initrd/sbin/mount-ext2fs
Normal file
@ -0,0 +1,2 @@
|
||||
mkdir /mnt
|
||||
mount -t ext2 /dev/cd0p2 /mnt
|
@ -8,7 +8,6 @@ set(SOURCES
|
||||
src/Log.cpp
|
||||
src/Pledge.cpp
|
||||
src/cxxabi.cpp
|
||||
src/Symbols.cpp
|
||||
src/video/Framebuffer.cpp
|
||||
src/video/TextConsole.cpp
|
||||
src/memory/MemoryManager.cpp
|
||||
@ -151,6 +150,4 @@ target_include_directories(moon PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gen)
|
||||
|
||||
target_link_options(moon PRIVATE LINKER:-T ${CMAKE_CURRENT_LIST_DIR}/moon.ld -nostdlib -nodefaultlibs)
|
||||
|
||||
add_custom_command(TARGET moon POST_BUILD COMMAND ${LUNA_ROOT}/tools/generate-symbols.sh)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/moon" DESTINATION ${LUNA_ROOT}/initrd/boot)
|
||||
|
@ -1,95 +0,0 @@
|
||||
#include "Symbols.h"
|
||||
#include "Log.h"
|
||||
#include "arch/MMU.h"
|
||||
#include "boot/bootboot.h"
|
||||
#include "fs/InitRD.h"
|
||||
#include <luna/Scanf.h>
|
||||
#include <luna/TarStream.h>
|
||||
#include <luna/Vector.h>
|
||||
|
||||
extern const BOOTBOOT bootboot;
|
||||
|
||||
static bool g_symbols_loaded = false;
|
||||
|
||||
struct Symbol
|
||||
{
|
||||
u64 address;
|
||||
char symbol[256];
|
||||
};
|
||||
|
||||
Vector<Symbol> g_symbols;
|
||||
|
||||
extern const u8 kernel_start;
|
||||
extern const u8 kernel_end;
|
||||
|
||||
static int sscanf(const char* str, const char* format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
int rc = scanf_impl(str, format, ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
namespace Symbols
|
||||
{
|
||||
Result<void> load()
|
||||
{
|
||||
const u64 virtual_initrd_address = MMU::translate_physical_address(bootboot.initrd_ptr);
|
||||
|
||||
TarStream stream;
|
||||
stream.initialize((void*)virtual_initrd_address, bootboot.initrd_size);
|
||||
|
||||
TarStream::Entry file;
|
||||
while (TRY(stream.read_next_entry(file)))
|
||||
{
|
||||
if (file.name.view() == "ksyms")
|
||||
{
|
||||
char* string = strtok(const_cast<char*>((const char*)file.data()), "\n");
|
||||
if (!string) return {};
|
||||
|
||||
do {
|
||||
Symbol symbol;
|
||||
memset(symbol.symbol, 0, sizeof(symbol.symbol));
|
||||
|
||||
char unused;
|
||||
int nread;
|
||||
|
||||
sscanf(string, "%lx %c %n", &symbol.address, &unused, &nread);
|
||||
strlcpy(symbol.symbol, string + nread, sizeof(symbol));
|
||||
|
||||
TRY(g_symbols.try_append(symbol));
|
||||
} while ((string = strtok(nullptr, "\n")));
|
||||
|
||||
kinfoln("Successfully loaded %zu kernel debug symbols", g_symbols.size());
|
||||
|
||||
g_symbols_loaded = true;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
StringView lookup(u64 address)
|
||||
{
|
||||
if (!g_symbols_loaded) return StringView {};
|
||||
if (address < (u64)&kernel_start) return StringView {};
|
||||
if (address >= (u64)&kernel_end) return StringView {};
|
||||
|
||||
for (isize i = (isize)g_symbols.size() - 1; i >= 0; i--)
|
||||
{
|
||||
if (g_symbols[i].address < address)
|
||||
{
|
||||
usize index = i + 1;
|
||||
if (index == g_symbols.size()) return StringView {};
|
||||
return StringView { g_symbols[index].symbol };
|
||||
}
|
||||
}
|
||||
|
||||
return StringView {};
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
#include <luna/StringView.h>
|
||||
#include <luna/Types.h>
|
||||
|
||||
namespace Symbols
|
||||
{
|
||||
Result<void> load();
|
||||
StringView lookup(u64 address);
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
#include "arch/CPU.h"
|
||||
#include "Log.h"
|
||||
#include "Symbols.h"
|
||||
#include "api/Mouse.h"
|
||||
#include "arch/Keyboard.h"
|
||||
#include "arch/Timer.h"
|
||||
@ -369,7 +368,7 @@ namespace CPU
|
||||
rbp,
|
||||
[](u64 instruction, void* arg) {
|
||||
int* ptr = (int*)arg;
|
||||
kinfoln("#%d at %p in %s", *ptr, (void*)instruction, Symbols::lookup(instruction).chars());
|
||||
kinfoln("#%d at %p", *ptr, (void*)instruction);
|
||||
(*ptr)++;
|
||||
},
|
||||
&frame_index);
|
||||
@ -388,7 +387,7 @@ namespace CPU
|
||||
regs,
|
||||
[](u64 instruction, void* arg) {
|
||||
int* ptr = (int*)arg;
|
||||
kinfoln("#%d at %p in %s", *ptr, (void*)instruction, Symbols::lookup(instruction).chars());
|
||||
kinfoln("#%d at %p", *ptr, (void*)instruction);
|
||||
(*ptr)++;
|
||||
},
|
||||
&frame_index);
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "Log.h"
|
||||
#include "Symbols.h"
|
||||
#include "arch/CPU.h"
|
||||
#include "arch/Timer.h"
|
||||
#include "binfmt/BinaryFormat.h"
|
||||
@ -54,8 +53,6 @@ void oom_thread()
|
||||
kinfoln("Current platform: %s", CPU::platform_string().chars());
|
||||
kinfoln("Current processor: %s", CPU::identify().value_or("(unknown)"_sv).chars());
|
||||
|
||||
Symbols::load();
|
||||
|
||||
auto root = mark_critical(TmpFS::FileSystem::create(), "Failed to create initial ramfs");
|
||||
mark_critical(VFS::mount_root(root), "Failed to mount the initial ramfs as the root filesystem");
|
||||
mark_critical(InitRD::populate_vfs(), "Failed to load files from the initial ramdisk");
|
||||
|
@ -6,4 +6,8 @@ source $(dirname $0)/env.sh
|
||||
|
||||
cd $LUNA_ROOT
|
||||
|
||||
nm -C -n $LUNA_BUILD_DIR/kernel/moon | grep -vE \\.Lubsan_data | awk '{ if ($2 != "a") print; }' | uniq > initrd/ksyms
|
||||
rm -f initrd/sys/moon.sym
|
||||
|
||||
nm -C -n initrd/boot/moon | grep -vE \\.Lubsan_data | awk '{ if ($2 != "a") print; }' | uniq > initrd/sys/moon.sym
|
||||
|
||||
chmod 400 initrd/sys/moon.sym
|
Loading…
x
Reference in New Issue
Block a user