#include "EhStackInfo.h"
#include <stack>
#include "Common/StackType.h"
#include "Interpreter/Options.h"
namespace MapleRuntime {
void EHStackInfo::FillInStackTrace()
{
UnwindContext uwContext;
CheckTopUnwindContextAndInit(uwContext);
DLOG(INTERPRETER, "EHStackInfo::FillInStackTrace, top frame type: %d, name: %s", uwContext.frameInfo.GetFrameType(),
uwContext.frameInfo.GetFuncName().Str());
while (!uwContext.frameInfo.mFrame.IsAnchorFrame(anchorFA)) {
AnalyseAndSetFrameType(uwContext);
if (n2cCount == 1) {
return;
}
stack.emplace_back(uwContext.frameInfo);
DLOG(INTERPRETER, " Added frame to EH stack info, frame type: %d, name: %s",
uwContext.frameInfo.GetFrameType(), uwContext.frameInfo.GetFuncName().Str());
UnwindContext caller;
lastFrameType = uwContext.frameInfo.GetFrameType();
#ifndef _WIN64
if (uwContext.UnwindToCallerContext(caller) == false) {
#else
if (uwContext.UnwindToCallerContext(caller, uwCtxStatus) == false) {
#endif
return;
}
uwContext = caller;
}
}
}