예제 #1
0
DynamicLib* rvmOpenDynamicLib(Env* env, const char* file, char** errorMsg) {
    *errorMsg = NULL;
    DynamicLib* dlib = NULL;

    void* handle = dlopen(file, RTLD_LOCAL | RTLD_LAZY);
    if (!handle) {
        *errorMsg = dlerror();
        TRACEF("Failed to load dynamic library '%s': %s", file, *errorMsg);
        return NULL;
    }

    if (file) {
        TRACEF("Opening dynamic library '%s'", file);
    }

    dlib = rvmAllocateMemoryAtomicUncollectable(env, sizeof(DynamicLib));
    if (!dlib) {
        dlclose(handle);
        return NULL;
    }

    dlib->handle = handle;
    if (file) {
        strncpy(dlib->path, file, sizeof(dlib->path) - 1);
    } else {
        strncpy(dlib->path, env->vm->options->imagePath, sizeof(dlib->path) - 1);
    }

    return dlib;
}
예제 #2
0
CallStack* rvmCaptureCallStackForThread(Env* env, Thread* thread) {
    if (thread == env->currentThread) {
        return rvmCaptureCallStack(env);
    }

    // dumpThreadStackTrace() must not be called concurrently
    obtainThreadStackTraceLock();
    
    if (!shared_callStack) {
        shared_callStack = rvmAllocateMemoryAtomicUncollectable(env, sizeof(CallStack) + sizeof(CallStackFrame) * MAX_CALL_STACK_LENGTH);
        if (!shared_callStack) {
            releaseThreadStackTraceLock();
            return NULL;
        }
    }

    memset(shared_callStack, 0, sizeof(CallStack) + sizeof(CallStackFrame) * MAX_CALL_STACK_LENGTH);
    dumpThreadStackTrace(env, thread, shared_callStack);
    if (rvmExceptionOccurred(env)) {
        releaseThreadStackTraceLock();
        return NULL;
    }

    // Make a copy of the CallStack that is just big enough
    CallStack* copy = allocateCallStackFrames(env, shared_callStack->length);
    if (!copy) {
        releaseThreadStackTraceLock();
        return NULL;
    }
    memcpy(copy, shared_callStack, sizeof(CallStack) + sizeof(CallStackFrame) * shared_callStack->length);

    releaseThreadStackTraceLock();

    return copy;
}
예제 #3
0
파일: init.c 프로젝트: rover12421/robovm
static jboolean initClasspathEntries(Env* env, char* basePath, char** raw, ClasspathEntry** first) {
    jint i = 0;
    while (raw[i]) {
        ClasspathEntry* entry = rvmAllocateMemoryAtomicUncollectable(env, sizeof(ClasspathEntry));
        if (!entry) return FALSE;
        absolutize(basePath, raw[i], entry->jarPath);
        LL_APPEND(*first, entry);
        i++;
    }

    return TRUE;
}
예제 #4
0
파일: bc.c 프로젝트: SinoJerk/robovm
static AddressClassLookup* getAddressClassLookups(Env* env) {
    if (!addressClassLookups) {
        jint count = 0;
        iterateClassInfos(env, countClassesWithConcreteMethodsCallback, _bcBootClassesHash, &count);
        iterateClassInfos(env, countClassesWithConcreteMethodsCallback, _bcClassesHash, &count);
        AddressClassLookup* lookups = rvmAllocateMemoryAtomicUncollectable(env, sizeof(AddressClassLookup) * count);
        if (!lookups) return NULL;
        AddressClassLookup* _lookups = lookups;
        iterateClassInfos(env, initAddressClassLookupsCallback, _bcBootClassesHash, &_lookups);
        iterateClassInfos(env, initAddressClassLookupsCallback, _bcClassesHash, &_lookups);
        qsort(lookups, count, sizeof(AddressClassLookup), addressClassLookupCompareQSort);
        addressClassLookupsCount = count;
        addressClassLookups = lookups;
    }
    return addressClassLookups;
}
예제 #5
0
파일: init.c 프로젝트: rover12421/robovm
DynamicLib* rvmOpenDynamicLib(Env* env, const char* file, char** errorMsg) {
    *errorMsg = NULL;
    DynamicLib* dlib = NULL;

    void* handle = dlopen(file, RTLD_LOCAL | RTLD_LAZY);
    if (!handle) {
        *errorMsg = dlerror();
        TRACEF("Failed to load dynamic library '%s': %s", file, *errorMsg);
        return NULL;
    }

    TRACEF("Opening dynamic library '%s'", file);

    dlib = rvmAllocateMemoryAtomicUncollectable(env, sizeof(DynamicLib));
    if (!dlib) {
        dlclose(handle);
        return NULL;
    }

    dlib->handle = handle;

    return dlib;
}