kernel: Add a hexdump() method to log binary data for debugging
All checks were successful
Build and test / build (push) Successful in 1m33s
All checks were successful
Build and test / build (push) Successful in 1m33s
This commit is contained in:
parent
6443ec77f8
commit
59713279a0
@ -6,6 +6,7 @@
|
|||||||
#include <luna/Format.h>
|
#include <luna/Format.h>
|
||||||
#include <luna/SourceLocation.h>
|
#include <luna/SourceLocation.h>
|
||||||
#include <luna/Spinlock.h>
|
#include <luna/Spinlock.h>
|
||||||
|
#include <luna/StringBuilder.h>
|
||||||
|
|
||||||
static bool g_debug_enabled = true;
|
static bool g_debug_enabled = true;
|
||||||
static bool g_serial_enabled = true;
|
static bool g_serial_enabled = true;
|
||||||
@ -174,3 +175,23 @@ static bool g_check_already_failed = false;
|
|||||||
}
|
}
|
||||||
CPU::efficient_halt();
|
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 {};
|
||||||
|
}
|
||||||
|
@ -26,6 +26,8 @@ void set_text_console_initialized();
|
|||||||
#define kwarnln(...) log(LogLevel::Warn, __VA_ARGS__)
|
#define kwarnln(...) log(LogLevel::Warn, __VA_ARGS__)
|
||||||
#define kerrorln(...) log(LogLevel::Error, __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,
|
[[noreturn]] extern void __critical_error_handler(SourceLocation location, const char* expr, const char* failmsg,
|
||||||
const char* errmsg);
|
const char* errmsg);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user