skyline/app/src/main/cpp/skyline/common/exception.cpp
PixelyIon 41b98c7daa Add stack tracing to skyline::exception
Skyline's `exception` class now stores a list of all stack frames during the invocation of the exception. These can later be parsed by the exception handler to generate a human-readable stack trace. To assist with more complete stack traces, `-fno-omit-frame-pointer` is now passed on debug builds which forces the inclusion of frames on function calls.
2022-04-14 14:14:52 +05:30

21 lines
640 B
C++

// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
#include "signal.h"
#include "exception.h"
namespace skyline {
std::vector<void *> exception::GetStackFrames() {
std::vector<void*> frames;
signal::StackFrame *frame{};
asm("MOV %0, FP" : "=r"(frame));
if (frame)
frame = frame->next; // We want to skip the first frame as it's going to be the caller of this function
while (frame && frame->lr) {
frames.push_back(frame->lr);
frame = frame->next;
}
return frames;
}
}