summaryrefslogtreecommitdiff
path: root/stage3/shell.c
diff options
context:
space:
mode:
authorLizzy Fleckenstein <lizzy@vlhl.dev>2024-01-09 22:00:10 +0100
committerLizzy Fleckenstein <lizzy@vlhl.dev>2024-01-09 22:00:10 +0100
commit0d9286a860ff888dbb35fa6b92703496af3abecf (patch)
treea40596ae85efee3ee8b33fb9241200932f933290 /stage3/shell.c
parentd8d31c16138a4d6dc1ff3d33b3172c151c221767 (diff)
downloadcuddles-0d9286a860ff888dbb35fa6b92703496af3abecf.tar.xz
refactor heap code and add heap debugging
Diffstat (limited to 'stage3/shell.c')
-rw-r--r--stage3/shell.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/stage3/shell.c b/stage3/shell.c
index 0d24859..7930130 100644
--- a/stage3/shell.c
+++ b/stage3/shell.c
@@ -317,6 +317,24 @@ static void cmd_choose(str arg)
}
}
+static void cmd_heapdbg(str arg)
+{
+ (void) arg;
+ heap_header *free_ptr = heap_get_free_ptr();
+
+ heap_header *h = free_ptr;
+ for (;;) {
+ print_hex((u64) h);
+ print(S(" "));
+ print_hex(h->size);
+ print(S("\n"));
+
+ h = h->next;
+ if (h == free_ptr)
+ break;
+ }
+}
+
typedef struct {
str name;
void (*fn)(str arg);
@@ -340,6 +358,7 @@ static command registry[] = {
{ S("watchdog"), &cmd_watchdog },
{ S("clocktest"), &cmd_clocktest },
{ S("choose"), &cmd_choose },
+ { S("heapdbg"), &cmd_heapdbg },
};
void shell_run_cmd(str cmd)