Xyris
0.5
Stacktrace.cpp
Go to the documentation of this file.
1
/**
2
* @file trace.cpp
3
* @author Keeton Feavel (
[email protected]
)
4
* @brief Kernel stack tracing
5
* @version 0.3
6
* @date 2020-08-09
7
*
8
* @copyright Copyright the Xyris Contributors (c) 2020
9
*
10
*/
11
12
#include "
Logger.hpp
"
13
#include <
Arch/Arch.hpp
>
14
#include <
Devices/Graphics/console.hpp
>
15
#include <
Devices/Serial/rs232.hpp
>
16
#include <
Library/stdio.hpp
>
17
#include <
Memory/paging.hpp
>
18
#include <
Stacktrace.hpp
>
19
20
#define STACK_TRACE_BUF_SZ 32
21
22
namespace
Stack
{
23
24
void
printTrace
(
size_t
max)
25
{
26
// Define our stack
27
struct
Arch::stackframe
* frame;
28
asm
volatile
(
29
"movl %%ebp, %0"
30
:
"=r"
(frame));
31
Console::printf
(
"\033[31mStack trace:\033[0m\n"
);
32
Logger::Print
(
"\033[31mStack trace:\033[0m\n"
);
33
34
for
(
size_t
i = 0; frame != NULL && i < max; ++i) {
35
Console::printf
(
"0x%08zX\n"
, frame->
eip
);
36
Logger::Print
(
"0x%08zX\n"
, frame->
eip
);
37
if
((uintptr_t)frame->
ebp
== 0x00000000) {
38
break
;
39
}
40
frame = frame->
ebp
;
41
}
42
}
43
44
}
// !namespace Stack
stdio.hpp
Arch::stackframe::ebp
struct stackframe * ebp
Definition:
Arch.i686.hpp:19
Arch::stackframe::eip
size_t eip
Definition:
Arch.i686.hpp:20
console.hpp
Framebuffer console.
Stack::printTrace
void printTrace(size_t max)
Definition:
Stacktrace.cpp:24
rs232.hpp
A simple, write-only driver for the RS232 serial device standard. Code mostly ported from Panix-Archi...
Arch.hpp
Architecture control and initialization.
Arch::stackframe
Definition:
Arch.i686.hpp:18
Console::printf
int printf(const char *fmt,...)
Definition:
console.cpp:273
Stacktrace.hpp
Logger::Print
static void Print(const char *fmt,...)
Definition:
Logger.cpp:111
paging.hpp
Stack
Definition:
Stacktrace.cpp:22
Logger.hpp
Kernel
Stacktrace.cpp
Generated by
1.8.17