diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2018-02-22 18:40:15 +0200 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2018-02-22 18:46:36 +0200 |
commit | c4f2f8449ad09301e5725f69b7374d958cc5dff8 (patch) | |
tree | 084c8e916e09cd0cbd16bd6732b0fbff217fc81b /src | |
parent | 952720c8def83d62bc0d328c2cc46ead8254703d (diff) |
refactor commit
Diffstat (limited to 'src')
-rw-r--r-- | src/jvm/jvm.c | 179 | ||||
-rw-r--r-- | src/libandroid.c | 46 | ||||
-rw-r--r-- | src/libc-verbose.h | 117 | ||||
-rw-r--r-- | src/libc.c | 40 | ||||
-rw-r--r-- | src/libjvm-android.c | 9 | ||||
-rw-r--r-- | src/libjvm-java.c | 14 | ||||
-rw-r--r-- | src/linker/linker.c | 20 | ||||
-rw-r--r-- | src/wrapper/verbose.h | 16 | ||||
-rw-r--r-- | src/wrapper/wrapper.c | 29 |
9 files changed, 304 insertions, 166 deletions
diff --git a/src/jvm/jvm.c b/src/jvm/jvm.c index f3f6edf..abd2cb8 100644 --- a/src/jvm/jvm.c +++ b/src/jvm/jvm.c @@ -7,6 +7,7 @@ #include "dlfcn.h" #include "jvm.h" #include "wrapper/wrapper.h" +#include "wrapper/verbose.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #define container_of(ptr, type, member) ((type *)((char *)(1 ? (ptr) : &((type *)0)->member) - offsetof(type, member))) @@ -280,7 +281,7 @@ static jclass JNIEnv_FindClass(JNIEnv* p0, const char* p1) { assert(p0 && p1); - printf("%s\n", p1); + verbose("%s", p1); return jvm_make_class(jnienv_get_jvm(p0), p1); } @@ -437,7 +438,7 @@ static jclass JNIEnv_GetObjectClass(JNIEnv* env, jobject p1) { assert(env && p1); - printf("%u\n", (uint32_t)(uintptr_t)p1); + verbose("%u", (uint32_t)(uintptr_t)p1); return jvm_get_object(jnienv_get_jvm(env), p1)->this_klass; } @@ -451,7 +452,7 @@ static jmethodID jvm_make_method(struct jvm *jvm, jclass klass, const char *name, const char *sig) { assert(jvm && klass && name && sig); - printf("%s::%s::%s\n", jvm_get_object(jvm, klass)->klass.name.data, name, sig); + verbose("%s::%s::%s", jvm_get_object(jvm, klass)->klass.name.data, name, sig); struct jvm_object o = { .method.klass = klass, .type = JVM_OBJECT_METHOD }; jvm_string_set_cstr(&o.method.name, name, true); jvm_string_set_cstr(&o.method.signature, sig, true); @@ -489,7 +490,7 @@ jvm_form_symbol(struct jvm *jvm, jmethodID method_id, char *symbol, const size_t { assert(jvm && method_id); struct jvm_method *method = &jvm_get_object(jvm, method_id)->method; - printf("%s::%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data, method->signature.data); + verbose("%s::%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data, method->signature.data); snprintf(symbol, symbol_sz, "%s_%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); cstr_replace(symbol, '/', '_'); cstr_replace(symbol, '$', '_'); @@ -511,7 +512,7 @@ JNIEnv_CallObjectMethodA(JNIEnv* p0, jobject p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return NULL; } @@ -521,7 +522,7 @@ JNIEnv_CallBooleanMethod(JNIEnv* p0, jobject p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -541,7 +542,7 @@ JNIEnv_CallBooleanMethodA(JNIEnv* p0, jobject p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -551,7 +552,7 @@ JNIEnv_CallByteMethod(JNIEnv* p0, jobject p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -561,7 +562,7 @@ JNIEnv_CallByteMethodV(JNIEnv* p0, jobject p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -571,7 +572,7 @@ JNIEnv_CallByteMethodA(JNIEnv* p0, jobject p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -581,7 +582,7 @@ JNIEnv_CallCharMethod(JNIEnv* p0, jobject p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -591,7 +592,7 @@ JNIEnv_CallCharMethodV(JNIEnv* p0, jobject p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -601,7 +602,7 @@ JNIEnv_CallCharMethodA(JNIEnv* p0, jobject p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -611,7 +612,7 @@ JNIEnv_CallShortMethod(JNIEnv* p0, jobject p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -621,7 +622,7 @@ JNIEnv_CallShortMethodV(JNIEnv* p0, jobject p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -631,7 +632,7 @@ JNIEnv_CallShortMethodA(JNIEnv* p0, jobject p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -641,7 +642,7 @@ JNIEnv_CallIntMethod(JNIEnv* p0, jobject p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -661,7 +662,7 @@ JNIEnv_CallIntMethodA(JNIEnv* p0, jobject p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -671,7 +672,7 @@ JNIEnv_CallLongMethod(JNIEnv* p0, jobject p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -681,7 +682,7 @@ JNIEnv_CallLongMethodV(JNIEnv* p0, jobject p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -691,7 +692,7 @@ JNIEnv_CallLongMethodA(JNIEnv* p0, jobject p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -701,7 +702,7 @@ JNIEnv_CallFloatMethod(JNIEnv* p0, jobject p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -711,7 +712,7 @@ JNIEnv_CallFloatMethodV(JNIEnv* p0, jobject p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -721,7 +722,7 @@ JNIEnv_CallFloatMethodA(JNIEnv* p0, jobject p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -731,7 +732,7 @@ JNIEnv_CallDoubleMethod(JNIEnv* p0, jobject p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -741,7 +742,7 @@ JNIEnv_CallDoubleMethodV(JNIEnv* p0, jobject p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -751,7 +752,7 @@ JNIEnv_CallDoubleMethodA(JNIEnv* p0, jobject p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -761,7 +762,7 @@ JNIEnv_CallVoidMethod(JNIEnv* p0, jobject p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); } static void @@ -780,7 +781,7 @@ JNIEnv_CallVoidMethodA(JNIEnv* p0, jobject p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); } static jobject @@ -789,7 +790,7 @@ JNIEnv_CallNonvirtualObjectMethod(JNIEnv* p0, jobject p1, jclass p2, jmethodID p assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return NULL; } @@ -799,7 +800,7 @@ JNIEnv_CallNonvirtualObjectMethodV(JNIEnv* p0, jobject p1, jclass p2, jmethodID assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return NULL; } @@ -809,7 +810,7 @@ JNIEnv_CallNonvirtualObjectMethodA(JNIEnv* p0, jobject p1, jclass p2, jmethodID assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return NULL; } @@ -819,7 +820,7 @@ JNIEnv_CallNonvirtualBooleanMethod(JNIEnv* p0, jobject p1, jclass p2, jmethodID assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -829,7 +830,7 @@ JNIEnv_CallNonvirtualBooleanMethodV(JNIEnv* p0, jobject p1, jclass p2, jmethodID assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -839,7 +840,7 @@ JNIEnv_CallNonvirtualBooleanMethodA(JNIEnv* p0, jobject p1, jclass p2, jmethodID assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -849,7 +850,7 @@ JNIEnv_CallNonvirtualByteMethod(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3, assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -859,7 +860,7 @@ JNIEnv_CallNonvirtualByteMethodV(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3 assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -869,7 +870,7 @@ JNIEnv_CallNonvirtualByteMethodA(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3 assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -879,7 +880,7 @@ JNIEnv_CallNonvirtualCharMethod(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3, assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -889,7 +890,7 @@ JNIEnv_CallNonvirtualCharMethodV(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3 assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -899,7 +900,7 @@ JNIEnv_CallNonvirtualCharMethodA(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3 assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -909,7 +910,7 @@ JNIEnv_CallNonvirtualShortMethod(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3 assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -919,7 +920,7 @@ JNIEnv_CallNonvirtualShortMethodV(JNIEnv* p0, jobject p1, jclass p2, jmethodID p assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -929,7 +930,7 @@ JNIEnv_CallNonvirtualShortMethodA(JNIEnv* p0, jobject p1, jclass p2, jmethodID p assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -939,7 +940,7 @@ JNIEnv_CallNonvirtualIntMethod(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3, assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -949,7 +950,7 @@ JNIEnv_CallNonvirtualIntMethodV(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3, assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -959,7 +960,7 @@ JNIEnv_CallNonvirtualIntMethodA(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3, assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -969,7 +970,7 @@ JNIEnv_CallNonvirtualLongMethod(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3, assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -979,7 +980,7 @@ JNIEnv_CallNonvirtualLongMethodV(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3 assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -989,7 +990,7 @@ JNIEnv_CallNonvirtualLongMethodA(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3 assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -999,7 +1000,7 @@ JNIEnv_CallNonvirtualFloatMethod(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3 assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1009,7 +1010,7 @@ JNIEnv_CallNonvirtualFloatMethodV(JNIEnv* p0, jobject p1, jclass p2, jmethodID p assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1019,7 +1020,7 @@ JNIEnv_CallNonvirtualFloatMethodA(JNIEnv* p0, jobject p1, jclass p2, jmethodID p assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1029,7 +1030,7 @@ JNIEnv_CallNonvirtualDoubleMethod(JNIEnv* p0, jobject p1, jclass p2, jmethodID p assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1039,7 +1040,7 @@ JNIEnv_CallNonvirtualDoubleMethodV(JNIEnv* p0, jobject p1, jclass p2, jmethodID assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1049,7 +1050,7 @@ JNIEnv_CallNonvirtualDoubleMethodA(JNIEnv* p0, jobject p1, jclass p2, jmethodID assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1059,7 +1060,7 @@ JNIEnv_CallNonvirtualVoidMethod(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3, assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); } static void @@ -1068,7 +1069,7 @@ JNIEnv_CallNonvirtualVoidMethodV(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3 assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); } static void @@ -1077,7 +1078,7 @@ JNIEnv_CallNonvirtualVoidMethodA(JNIEnv* p0, jobject p1, jclass p2, jmethodID p3 assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); } static jfieldID @@ -1219,7 +1220,7 @@ JNIEnv_CallStaticObjectMethodA(JNIEnv* p0, jclass p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return NULL; } @@ -1229,7 +1230,7 @@ JNIEnv_CallStaticBooleanMethod(JNIEnv* p0, jclass p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1239,7 +1240,7 @@ JNIEnv_CallStaticBooleanMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1249,7 +1250,7 @@ JNIEnv_CallStaticBooleanMethodA(JNIEnv* p0, jclass p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1259,7 +1260,7 @@ JNIEnv_CallStaticByteMethod(JNIEnv* p0, jclass p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1269,7 +1270,7 @@ JNIEnv_CallStaticByteMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1279,7 +1280,7 @@ JNIEnv_CallStaticByteMethodA(JNIEnv* p0, jclass p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1289,7 +1290,7 @@ JNIEnv_CallStaticCharMethod(JNIEnv* p0, jclass p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1299,7 +1300,7 @@ JNIEnv_CallStaticCharMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1309,7 +1310,7 @@ JNIEnv_CallStaticCharMethodA(JNIEnv* p0, jclass p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1319,7 +1320,7 @@ JNIEnv_CallStaticShortMethod(JNIEnv* p0, jclass p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1329,7 +1330,7 @@ JNIEnv_CallStaticShortMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1339,7 +1340,7 @@ JNIEnv_CallStaticShortMethodA(JNIEnv* p0, jclass p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1349,7 +1350,7 @@ JNIEnv_CallStaticIntMethod(JNIEnv* p0, jclass p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1359,7 +1360,7 @@ JNIEnv_CallStaticIntMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1369,7 +1370,7 @@ JNIEnv_CallStaticIntMethodA(JNIEnv* p0, jclass p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1379,7 +1380,7 @@ JNIEnv_CallStaticLongMethod(JNIEnv* p0, jclass p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1389,7 +1390,7 @@ JNIEnv_CallStaticLongMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1399,7 +1400,7 @@ JNIEnv_CallStaticLongMethodA(JNIEnv* p0, jclass p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1409,7 +1410,7 @@ JNIEnv_CallStaticFloatMethod(JNIEnv* p0, jclass p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1419,7 +1420,7 @@ JNIEnv_CallStaticFloatMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1429,7 +1430,7 @@ JNIEnv_CallStaticFloatMethodA(JNIEnv* p0, jclass p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1439,7 +1440,7 @@ JNIEnv_CallStaticDoubleMethod(JNIEnv* p0, jclass p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1449,7 +1450,7 @@ JNIEnv_CallStaticDoubleMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1459,7 +1460,7 @@ JNIEnv_CallStaticDoubleMethodA(JNIEnv* p0, jclass p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); return 0; } @@ -1469,7 +1470,7 @@ JNIEnv_CallStaticVoidMethod(JNIEnv* p0, jclass p1, jmethodID p2, ...) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); } static void @@ -1488,7 +1489,7 @@ JNIEnv_CallStaticVoidMethodA(JNIEnv* p0, jclass p1, jmethodID p2, jvalue* p3) assert(p0 && p1 && p2); struct jvm *jvm = jnienv_get_jvm(p0); struct jvm_method *method = &jvm_get_object(jvm, p2)->method; - printf("%s::%s\n", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); + verbose("%s::%s", jvm_get_object(jvm, method->klass)->klass.name.data, method->name.data); } static jfieldID @@ -1626,7 +1627,7 @@ static jstring JNIEnv_NewStringUTF(JNIEnv* p0, const char* p1) { assert(p0); - printf("%s\n", p1); + verbose("%s", p1); struct jvm_object o = { .type = JVM_OBJECT_STRING }; jvm_string_set_cstr(&o.string, p1, true); return jvm_add_object_if_not_there(jnienv_get_jvm(p0), &o); @@ -1946,7 +1947,7 @@ jvm_register_native_method(struct jvm *jvm, const jclass klass, const JNINativeM jvm_string_set_cstr(&jvm->methods[i].method.name, method->name, true); jvm_string_set_cstr(&jvm->methods[i].method.signature, method->signature, true); jvm->methods[i].function = method->fnPtr; - printf("%s::%s::%s\n", jvm_get_object(jvm, klass)->klass.name.data, method->name, method->signature); + verbose("%s::%s::%s", jvm_get_object(jvm, klass)->klass.name.data, method->name, method->signature); } static jint @@ -2067,7 +2068,7 @@ JNIEnv_GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy) if (isCopy) *isCopy = JNI_FALSE; - printf("%s\n", (string ? jvm_get_object(jnienv_get_jvm(env), string)->string.data : "(null)")); + verbose("%s", (string ? jvm_get_object(jnienv_get_jvm(env), string)->string.data : "(null)")); return (string ? jvm_get_object(jnienv_get_jvm(env), string)->string.data : "(null)"); } diff --git a/src/libandroid.c b/src/libandroid.c index b25d21b..c8bafa9 100644 --- a/src/libandroid.c +++ b/src/libandroid.c @@ -3,29 +3,31 @@ #include <stdlib.h> #include <stdio.h> #include <assert.h> -#include "jvm/jni.h" #define GLFW_INCLUDE_NONE #include <GLFW/glfw3.h> +#include "jvm/jni.h" + // System #define PROP_NAME_MAX 32 #define PROP_VALUE_MAX 92 -int __system_property_get(const char *name, char *value) +int +__system_property_get(const char *name, char *value) { return 0; } // AConfiguration -struct AConfiguration -{ +struct AConfiguration { + char nop; }; -struct AAssetManager -{ +struct AAssetManager { + char nop; }; struct AConfiguration* @@ -47,8 +49,8 @@ AConfiguration_fromAssetManager(struct AConfiguration *out, struct AAssetManager // ALooper -static struct ALooper -{ +static struct ALooper { + char nop; } thread_looper; typedef void* ALooper_callbackFunc; @@ -85,6 +87,7 @@ ALooper_pollOnce(int timeoutMillis, int *outFd, int *outEvents, void **outData) // ASensor struct ASensor { + char nop; }; const char* @@ -118,9 +121,11 @@ ASensor_getMinDelay(struct ASensor const *sensor) } struct ASensorEvent { + char nop; }; struct ASensorEventQueue { + char nop; }; int @@ -154,9 +159,11 @@ ASensorEventQueue_getEvents(struct ASensorEventQueue *queue, struct ASensorEvent } struct ASensorManager { + char nop; }; struct ASensorList { + char nop; }; struct ASensorManager* @@ -191,8 +198,8 @@ ASensorManager_destroyEventQueue(struct ASensorManager *manager, struct ASensorE // AInput -struct AInputEvent -{ +struct AInputEvent { + char nop; }; int32_t @@ -381,8 +388,8 @@ AKeyEvent_getAction(const struct AInputEvent *key_event) return 0; } -struct AInputQueue -{ +struct AInputQueue { + char nop; }; void @@ -420,23 +427,22 @@ AInputQueue_finishEvent(struct AInputQueue *queue, struct AInputEvent *event, in // ANative -struct ANativeWindow -{ +struct ANativeWindow { GLFWwindow *glfw; }; -struct ANativeWindow_Buffer -{ +struct ANativeWindow_Buffer { + char nop; }; -struct ARect -{ +struct ARect { + char nop; }; static void glfw_error_cb(int code, const char *error) { - printf("%d: %s\n", code, error); + fprintf(stderr, "glfw: (%d) %s\n", code, error); } struct ANativeWindow* @@ -449,7 +455,7 @@ ANativeWindow_fromSurface(JNIEnv* env, jobject surface) return NULL; glfwInit(); - printf("glfw: %s\n", glfwGetVersionString()); + fprintf(stderr, "glfw: %s\n", glfwGetVersionString()); glfwSetErrorCallback(glfw_error_cb); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); diff --git a/src/libc-verbose.h b/src/libc-verbose.h new file mode 100644 index 0000000..bb03686 --- /dev/null +++ b/src/libc-verbose.h @@ -0,0 +1,117 @@ +#pragma once + +#include <stdarg.h> +#include <string.h> + +/** + * This file implements functions only for verbose output, which is useful for debugging. + * These functions can be enabled with -DVERBOSE_FUNCTIONS + */ + +int +bionic_chdir(const char *path) +{ + verbose("%s", path); + return chdir(path); +} + +int +bionic_rename(const char *old, const char *fresh) +{ + verbose("%s -> %s", old, fresh); + return rename(old, fresh); +} + +FILE* +bionic_fopen(const char *path, const char *mode) +{ + verbose("%s %s", path, mode); + return fopen(path, mode); +} + +DIR* +bionic_opendir(const char *path) +{ + verbose("%s", path); + return opendir(path); +} + +int +bionic_sprintf(char *str, const char *fmt, ...) +{ + verbose("%s", fmt); + va_list ap; + va_start(ap, fmt); + int r = vsprintf(str, fmt, ap); + va_end(ap); + return r; +} + +int +bionic_snprintf(char *str, size_t size, const char *fmt, ...) +{ + verbose("%s (%zu)", fmt, size); + va_list ap; + va_start(ap, fmt); + int r = vsnprintf(str, size, fmt, ap); + va_end(ap); + return r; +} + +size_t +bionic_strlen(const char *str) +{ + verbose("%s", str); + return strlen(str); +} + +char* +bionic_strcpy(char *dest, const char *src) +{ + verbose("%s", src); + return strcpy(dest, src); +} + +char* +bionic_strncpy(char *dest, const char *src, size_t n) +{ + verbose("%s (%zu)", src, n); + return strncpy(dest, src, n); +} + +extern char* strdup(const char*); + +char* +bionic_strdup(const char *str) +{ + verbose("%s", str); + return strdup(str); +} + +char* +bionic_strstr(const char *haystack, const char *needle) +{ + verbose("%s, %s", haystack, needle); + return strstr(haystack, needle); +} + +int +bionic_strcmp(const char *s1, const char *s2) +{ + verbose("%s == %s", s1, s2); + return strcmp(s1, s2); +} + +int +bionic_strncmp(const char *s1, const char *s2, size_t n) +{ + verbose("%s == %s (%zu)", s1, s2, n); + return strncmp(s1, s2, n); +} + +ssize_t +bionic_readlink(const char *path, char *buf, size_t bufsize) +{ + verbose("%s", path); + return readlink(path, buf, bufsize); +} @@ -9,6 +9,11 @@ #include <sys/stat.h> #include <sys/types.h> #include <sys/syscall.h> +#include "wrapper/verbose.h" + +#ifdef VERBOSE_FUNCTIONS +# include "libc-verbose.h" +#endif struct bionic_dirent { uint64_t d_ino; @@ -19,6 +24,7 @@ struct bionic_dirent { }; struct bionic_sigaction { + char nop; }; // Stuff that doesn't exist in glibc @@ -26,7 +32,7 @@ struct bionic_sigaction { void __assert2(const char* file, int line, const char* function, const char* failed_expression) { - fprintf(stderr, "%s:%d: %s: assertion \"%s\" failed", file, line, function, failed_expression); + fprintf(stderr, "%s:%d: %s: assertion \"%s\" failed\n", file, line, function, failed_expression); abort(); } @@ -39,12 +45,14 @@ gettid(void) int tgkill(int tgid, int tid, int sig) { + verbose("%d, %d, %d", tgid, tid, sig); return syscall(SYS_tgkill, tgid, tid, sig); } int tkill(int tid, int sig) { + verbose("%d, %d", tid, sig); return syscall(SYS_tkill, tid, sig); } @@ -66,25 +74,28 @@ bionic___errno(void) int bionic_stat(const char *restrict path, struct stat *restrict buf) { - printf("stat: %s\n", path); + verbose("%s", path); return stat(path, buf); } int bionic_lstat(const char *restrict path, struct stat *restrict buf) { + verbose("%s", path); return lstat(path, buf); } int bionic_fstat(int fd, struct stat *buf) { + verbose("%d", fd); return fstat(fd, buf); } int bionic_fstatat(int dirfd, const char *pathname, void *buf, int flags) { + verbose("%d, %s", dirfd, pathname); return fstatat(dirfd, pathname, buf, flags); } @@ -293,7 +304,7 @@ bionic_sysconf_to_glibc_sysconf(int name) case 0x009c: return _SC_LEVEL4_CACHE_ASSOC; case 0x009d: return _SC_LEVEL4_CACHE_LINESIZE; default: - assert(0 && "should not happend"); + assert(0 && "sysconf constant (%d) is not mapped"); } return 0xFFFF; } @@ -303,26 +314,3 @@ bionic_sysconf(int name) { return sysconf(bionic_sysconf_to_glibc_sysconf(name)); } - -// Debugging - -int -strcmp(const char *s1, const char *s2) -{ - printf("%s == %s\n", s1, s2); - return strcmp(s1, s2); -} - -int -strncmp(const char *s1, const char *s2, size_t n) -{ - printf("%s == %s (%zu)\n", s1, s2, n); - return strncmp(s1, s2, n); -} - -ssize_t -readlink(const char *path, char *buf, size_t bufsize) -{ - printf("%s\n", path); - return snprintf(buf, bufsize, "file.apk"); -} diff --git a/src/libjvm-android.c b/src/libjvm-android.c index 9b53db6..b83f6b8 100644 --- a/src/libjvm-android.c +++ b/src/libjvm-android.c @@ -2,6 +2,7 @@ #include <stdio.h> #include <assert.h> #include "jvm/jni.h" +#include "wrapper/verbose.h" jstring android_content_Context_getPackageName(JNIEnv *env, jobject object, va_list args) @@ -23,7 +24,7 @@ android_content_Context_getSharedPreferences(JNIEnv *env, jobject object, va_lis assert(env && object); jstring str = va_arg(args, jstring); (*env)->GetStringUTFChars(env, str, NULL); - printf("%d\n", va_arg(args, jint)); + verbose("%d", va_arg(args, jint)); va_end(args); static jobject sv; return (sv ? sv : (sv = (*env)->AllocObject(env, (*env)->FindClass(env, "android/content/SharedPreferences")))); @@ -34,7 +35,7 @@ android_content_SharedPreferences_getInt(JNIEnv *env, jobject object, va_list ar { assert(env && object); jstring str = va_arg(args, jstring); - printf("%s::%d\n", (*env)->GetStringUTFChars(env, str, NULL), va_arg(args, jint)); + verbose("%s::%d", (*env)->GetStringUTFChars(env, str, NULL), va_arg(args, jint)); va_end(args); return 0; } @@ -60,7 +61,7 @@ android_content_SharedPreferences_Editor_putInt(JNIEnv *env, jobject object, va_ { assert(env && object); jstring str = va_arg(args, jstring); - printf("%s::%d\n", (*env)->GetStringUTFChars(env, str, NULL), va_arg(args, jint)); + verbose("%s::%d", (*env)->GetStringUTFChars(env, str, NULL), va_arg(args, jint)); va_end(args); return object; } @@ -100,7 +101,7 @@ android_app_ApplicationErrorReport_getErrorReportReceiver(JNIEnv *env, jobject o jstring str = va_arg(args, jstring); jint flags = va_arg(args, jint); (*env)->GetStringUTFChars(env, str, NULL); - printf("%p, %d\n", obj, flags); + verbose("%p, %d", obj, flags); va_end(args); static jobject sv; return (sv ? sv : (sv = (*env)->AllocObject(env, (*env)->FindClass(env, "android/content/ComponentName")))); diff --git a/src/libjvm-java.c b/src/libjvm-java.c index e87b9a4..a043a30 100644 --- a/src/libjvm-java.c +++ b/src/libjvm-java.c @@ -6,6 +6,8 @@ #include <err.h> #include <dlfcn.h> #include "jvm/jni.h" +#include "linker/dlfcn.h" +#include "wrapper/verbose.h" void java_lang_System_load(JNIEnv *env, jobject object, va_list args) @@ -13,16 +15,20 @@ java_lang_System_load(JNIEnv *env, jobject object, va_list args) assert(env && object); const char *lib = (*env)->GetStringUTFChars(env, va_arg(args, jstring), NULL); va_end(args); - printf("%s\n", lib); + verbose("%s", lib); void *handle = bionic_dlopen(lib, RTLD_NOW | RTLD_GLOBAL); assert(handle); - void* (*JNI_OnLoad)(void*, void*); - if ((JNI_OnLoad = bionic_dlsym(handle, "JNI_OnLoad"))) { + union { + void *ptr; + void* (*fun)(void*, void*); + } JNI_OnLoad; + + if ((JNI_OnLoad.ptr = bionic_dlsym(handle, "JNI_OnLoad"))) { JavaVM *vm; (*env)->GetJavaVM(env, &vm); - JNI_OnLoad(vm, NULL); + JNI_OnLoad.fun(vm, NULL); } } diff --git a/src/linker/linker.c b/src/linker/linker.c index e5e1095..0927164 100644 --- a/src/linker/linker.c +++ b/src/linker/linker.c @@ -119,7 +119,7 @@ static const char *apkenv_ldpreload_names[LDPRELOAD_MAX + 1]; static soinfo *apkenv_preloads[LDPRELOAD_MAX + 1]; #if LINKER_DEBUG -int apkenv_debug_verbosity = 5; +int apkenv_debug_verbosity = 0; #endif static int apkenv_pid; @@ -1133,6 +1133,10 @@ apkenv_load_library(const char *name) Elf32_Ehdr *hdr; if(fd == -1) { + if (dlopen(name, RTLD_NOW | RTLD_GLOBAL)) { + DEBUG("Loaded %s with glibc dlopen\n", name); + return NULL; + } #if !LINKER_DEBUG if (!is_lib_optional(name)) #endif @@ -1365,12 +1369,9 @@ static int apkenv_reloc_library(soinfo *si, Elf32_Rel *rel, unsigned count) memcpy(wrap_sym_name + 7, sym_name, MIN(sizeof(wrap_sym_name) - 7, strlen(sym_name))); sym_addr = 0; - if (!strcmp(sym_name, "dl_iterate_phdr")) { - // FIXME: hack, move to libc.so - sym_addr = bionic_dl_iterate_phdr; - } else if ((sym_addr = dlsym(RTLD_DEFAULT, wrap_sym_name))) { + if ((sym_addr = (intptr_t)dlsym(RTLD_DEFAULT, wrap_sym_name))) { LINKER_DEBUG_PRINTF("%s hooked symbol %s to %x\n", si->name, wrap_sym_name, sym_addr); - } else if ((sym_addr = dlsym(RTLD_DEFAULT, sym_name))) { + } else if ((sym_addr = (intptr_t)dlsym(RTLD_DEFAULT, sym_name))) { LINKER_DEBUG_PRINTF("%s hooked symbol %s to %x\n", si->name, sym_name, sym_addr); } #if 0 @@ -1762,8 +1763,8 @@ static int apkenv_nullify_closed_stdio (void) static void apkenv_wrap_function(void *sym_addr, char *sym_name, int is_thumb, soinfo *si) { - void *hook = NULL; #ifdef APKENV_LATEHOOKS + void *hook = NULL; if((hook = apkenv_get_hooked_symbol(sym_name, 0)) != NULL) { // if we have a hook redirect the call to that by overwriting @@ -2068,13 +2069,8 @@ static int apkenv_link_image(soinfo *si, unsigned wr_offset) if(d[0] == DT_NEEDED){ DEBUG("%5d %s needs %s\n", apkenv_pid, si->name, si->strtab + d[1]); soinfo *lsi = NULL; -#if 1 // if (get_builtin_lib_handle(si->strtab + d[1]) == NULL) lsi = apkenv_find_library(si->strtab + d[1]); - if (!lsi && dlopen(si->strtab + d[1], RTLD_NOW | RTLD_GLOBAL)) { - DEBUG("Loaded %s with glibc dlopen\n", si->strtab + d[1]); - } -#endif if(lsi == 0) { /** * XXX Dirty Hack Alarm --thp XXX diff --git a/src/wrapper/verbose.h b/src/wrapper/verbose.h new file mode 100644 index 0000000..719edc7 --- /dev/null +++ b/src/wrapper/verbose.h @@ -0,0 +1,16 @@ +#pragma once + +#ifdef VERBOSE_FUNCTIONS +# include <stdarg.h> +static void +verbose(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fputc('\n', stderr); +} +#else +# define verbose(...) +#endif diff --git a/src/wrapper/wrapper.c b/src/wrapper/wrapper.c index 07d3239..3acef77 100644 --- a/src/wrapper/wrapper.c +++ b/src/wrapper/wrapper.c @@ -8,8 +8,10 @@ #include <dlfcn.h> #include <assert.h> #include <sys/mman.h> +#include "verbose.h" -#ifdef ANDROID_X86_LINKER +#ifdef VERBOSE_FUNCTIONS +# ifdef ANDROID_X86_LINKER __asm__( "wrapper_start: nop\n" "wrapper_symbol: pushl $0xFAFBFCFD\n" @@ -17,33 +19,38 @@ __asm__( "wrapper_call: movl $0xFAFBFCFD, %eax\njmp *%eax\n" "wrapper_end: nop\n" ); -# define WRAPPER_TRACE -#else -# warning "no wrapper asm for this platform, function tracing is not available" +# define WRAPPER_TRACE +# else +# warning "no wrapper asm for this platform, function tracing is not available" +# endif #endif #ifdef WRAPPER_TRACE extern char wrapper_start, wrapper_symbol, wrapper_trace, wrapper_call, wrapper_end; -static char* (*__cxa_demangle)(const char *mangled_name, char *output_buffer, size_t *length, int *status); + +static union { + void *ptr; + char* (*fun)(const char *mangled_name, char *output_buffer, size_t *length, int *status); +} __cxa_demangle; static void trace(const char *const symbol) { - if (__cxa_demangle) { + if (__cxa_demangle.ptr) { // >If output_buffer is not long enough, it is expanded using realloc // Holy fuck gcc what the fuck? Guess we don't use stack then, thanks int status; char *demangled; static __thread char *data; static __thread size_t size; - if ((demangled = __cxa_demangle(symbol, data, &size, &status))) { + if ((demangled = __cxa_demangle.fun(symbol, data, &size, &status))) { data = (data != demangled ? demangled : data); - printf("trace: %s\n", demangled); + verbose("trace: %s", demangled); return; } } - printf("trace: %s\n", symbol); + verbose("trace: %s", symbol); } #endif @@ -51,8 +58,8 @@ void* wrapper_create(const char *const symbol, void *function) { #ifdef WRAPPER_TRACE - if (!__cxa_demangle) - __cxa_demangle = dlsym(RTLD_DEFAULT, "__cxa_demangle"); + if (!__cxa_demangle.ptr) + __cxa_demangle.ptr = dlsym(RTLD_DEFAULT, "__cxa_demangle"); const size_t sz = &wrapper_end - &wrapper_start; unsigned char *fun = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); |