/* Get call stack, return levels of call stack trace output buffer size buffer size offset which lvl start  */
int backtrace_now_get(void *trace[], int size, int offset)
/* Get call stack, return levels of call stack trace output buffer size buffer size offset which lvl start  */
int backtrace_now_get(void *trace[], int size, int offset)
{
    char *PC;
    long  *SP;
    int   lvl;
    int   ret;
    SP = RHINO_GET_SP();
    PC = RHINO_GET_PC();
    memset(trace, 0, size * sizeof(void *));
    for (lvl = 0; lvl < BT_LVL_LIMIT; lvl++) {
        ret = backtraceFromStack(&SP, &PC, NULL);
        if (ret != 0) {
            break;
        }
        if (lvl >= offset && lvl - offset < size) {
            trace[lvl - offset] = PC;
        }
        if (lvl - offset >= size) {
            break;
        }
    }
    return lvl - offset < 0 ? 0 : lvl - offset;
}