Ejemplo n.º 1
0
// stack trace helper
static ProfileStackTrace getStackTrace() {
    ProfileStackTrace trace;

    if (g_context.isNull()) return trace;
    JIT::VMRegAnchor _;
    ActRec *fp = g_context->getFP();
    if (!fp) return trace;
    PC pc = g_context->getPC();

    const Func *f = fp->m_func;
    Unit *u = f->unit();
    Offset off = pc - u->entry();
    for (;;) {
        trace.push_back({ f, off, fp->inGenerator() });
        fp = g_context->getPrevVMState(fp, &off);
        if (!fp) break;
        f = fp->m_func;
    }
    return trace;
}