kernel: Add a hexdump() method to log binary data for debugging
All checks were successful
Build and test / build (push) Successful in 1m33s

This commit is contained in:
apio 2024-03-29 12:12:56 +01:00
parent 6443ec77f8
commit 59713279a0
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 23 additions and 0 deletions

View File

@ -6,6 +6,7 @@
#include <luna/Format.h>
#include <luna/SourceLocation.h>
#include <luna/Spinlock.h>
#include <luna/StringBuilder.h>
static bool g_debug_enabled = true;
static bool g_serial_enabled = true;
@ -174,3 +175,23 @@ static bool g_check_already_failed = false;
}
CPU::efficient_halt();
}
Result<void> hexdump(void* data, usize size)
{
StringBuilder sb;
u8* ptr = (u8*)data;
while (size)
{
TRY(sb.format("%#2x ", *ptr));
ptr++;
size--;
}
auto message = TRY(sb.string());
kdbgln("hexdump: %s", message.chars());
return {};
}

View File

@ -26,6 +26,8 @@ void set_text_console_initialized();
#define kwarnln(...) log(LogLevel::Warn, __VA_ARGS__)
#define kerrorln(...) log(LogLevel::Error, __VA_ARGS__)
Result<void> hexdump(void* data, usize size);
[[noreturn]] extern void __critical_error_handler(SourceLocation location, const char* expr, const char* failmsg,
const char* errmsg);