20#include "pedigree/kernel/Log.h"
21#include "pedigree/kernel/debugger/Backtrace.h"
22#include "pedigree/kernel/debugger/DwarfUnwinder.h"
23#include "pedigree/kernel/linker/KernelElf.h"
24#include "pedigree/kernel/processor/Processor.h"
25#include "pedigree/kernel/processor/ProcessorInformation.h"
26#include "pedigree/kernel/processor/StackFrame.h"
27#include "pedigree/kernel/processor/VirtualAddressSpace.h"
29extern uintptr_t start;
33Backtrace::~Backtrace() {}
43 WARNING_NOLOCK(
"Backtracer built without DWARF enabled.");
48 WARNING_NOLOCK(
"Dwarf backtracing not available.");
49#if X86_COMMON || HOSTED
52 ERROR_NOLOCK(
"Backtrace: No backtracing method available!");
57 ProcessorState initial(state);
64 while (i < MAX_STACK_FRAMES) {
65 if (!du.
unwind(initial, next, frameBase)) {
92 while (i < MAX_STACK_FRAMES) {
96 reinterpret_cast<void*
>(base +
sizeof(uintptr_t)))) {
97 uintptr_t nextAddress = *
reinterpret_cast<uintptr_t*
>(base);
109 if (nextAddress == 0)
119void Backtrace::prettyPrint(
HugeStaticString& buf,
size_t nFrames,
size_t nFromFrame) {
125 for (
size_t i = nFromFrame; i < nFrames + nFromFrame; i++) {
126 uintptr_t symStart = 0;
void performBacktrace(InterruptState &state)
uintptr_t m_pReturnAddresses[MAX_STACK_FRAMES]
void performBpBacktrace(uintptr_t base, uintptr_t instruction)
uintptr_t getBasePointer(size_t n)
void performDwarfBacktrace(InterruptState &state)
ProcessorState m_pStates[MAX_STACK_FRAMES]
uintptr_t getReturnAddress(size_t n)
uintptr_t m_pBasePointers[MAX_STACK_FRAMES]
bool unwind(const ProcessorState &inState, ProcessorState &outState, uintptr_t &frameBase)
static KernelElf & instance()
uintptr_t globalLookupSymbol(const char *pName)
static uintptr_t getInstructionPointer()
static ProcessorInformation & information()
static uintptr_t getBasePointer()