proc.enableReschedule(false, null);
proc.enableReschedule(false);
    public static Object[] getStackTrace(VmThread current) {        if (current.inException) {            Unsafe.debug("Exception in getStackTrace");            VmProcessor.current().getArchitecture().getStackReader()                    .debugStackTrace();            Unsafe.die("getStackTrace");            return null;        } else {            current.inException = true;        }        if (Vm.getHeapManager().isLowOnMemory()) {            return null;        }        final VmProcessor proc = VmProcessor.current();        final VmStackReader reader = proc.getArchitecture().getStackReader();        final VmStackFrame[] mt;        // Address lastIP = null;        if (current.isInSystemException()) {            proc.disableReschedule(false, null);            try {                mt = reader.getVmStackTrace(current.getExceptionStackFrame(),                        current.getExceptionInstructionPointer(),                        STACKTRACE_LIMIT);            } finally {                proc.enableReschedule(false, null);            }        } else if (current == proc.getCurrentThread()) {            final Address curFrame = VmMagic.getCurrentFrame();            mt = reader.getVmStackTrace(reader.getPrevious(curFrame), reader                    .getReturnAddress(curFrame), STACKTRACE_LIMIT);        } else {            proc.disableReschedule(false, null);            try {                mt = reader.getVmStackTrace(current.getStackFrame(), current                        .getInstructionPointer(), STACKTRACE_LIMIT);                // lastIP = current.getInstructionPointer();            } finally {                proc.enableReschedule(false, null);            }        }        final int cnt = (mt == null) ? 0 : mt.length;        VmType lastClass = null;        // skip the first element which is VMThrowable.fillInStackTrace()        int i = 1;        while (i < cnt) {            final VmStackFrame f = mt[i];            if (f == null) {                break;            }            final VmMethod method = f.getMethod();            if (method == null) {                break;            }            final VmType< ? > vmClass = method.getDeclaringClass();            if (vmClass == null) {                break;            }            final VmType< ? > sClass = vmClass.getSuperClass();            if ((lastClass != null) && (sClass != lastClass)                    && (vmClass != lastClass)) {                break;            }            final String mname = method.getName();            if (mname == null) {                break;            }            if (!("<init>".equals(mname) || "fillInStackTrace".equals(mname) || "getStackTrace"                    .equals(mname))) {                break;            }            lastClass = vmClass;            i++;        }        final VmStackFrame[] st = new VmStackFrame[cnt - i];        int j = 0;        for (; i < cnt; i++) {            st[j++] = mt[i];        }        current.inException = false;        return st;    }