-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.cpp
More file actions
35 lines (30 loc) · 767 Bytes
/
debug.cpp
File metadata and controls
35 lines (30 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "debug.hpp"
class debug debug;
debug::debug() : elf_sec(0) { }
void debug::init(struct multiboot_info *mboot)
{
if (mboot->flags & (1 << 5) && mboot->u.elf_sec.num)
{
this->elf_sec = &mboot->u.elf_sec;
LOG(KERN_NOTICE "debug informations found (%d symbols)\n", this->elf_sec->num);
}
else
{
LOG(KERN_NOTICE "no debug informations found\n");
}
}
void debug::trace()
{
u32 *stack;
size_t frame = 0;
u32 ebp, eip;
asm volatile ("mov %0, ebp" : "=a"(stack));
while (stack) // TODO: avoid overflow without relying on &stack_top
{
ebp = stack[0];
eip = stack[1];
term.printk("%u: %8x in ??? ()\n", frame, eip);
stack = (u32*)ebp;
++frame;
}
}