To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit 06cd4ae0 authored by john's avatar john
Browse files

changed logging to use buffers

parent d7f6679f
......@@ -775,14 +775,15 @@ static void reportMethod(char* class_name, jlong class_tag, jmethodID method) {
if (res!=JNI_OK) return;
log_field_string(LOG_PREFIX_METHOD_PREPARE);
log_field_current_time();
log_field_string(class_name);
log_field_jlong((jlong)method);
/* log_field_jlong(class_tag); */
log_field_string(name_ptr);
log_field_string(signature_ptr);
log_eol();
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_METHOD_PREPARE);
log_field_current_time(buffer);
log_field_string(buffer, class_name);
log_field_jlong(buffer, (jlong)method);
/* log_field_jlong(buffer, class_tag); */
log_field_string(buffer, name_ptr);
log_field_string(buffer, signature_ptr);
log_eol(buffer);
if (name_ptr!=NULL) JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)name_ptr);
if (signature_ptr!=NULL) JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)signature_ptr);
......@@ -824,11 +825,12 @@ static void processClassPrepare(jvmtiEnv *jvmti_env,
int i=0;
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_CLASS_PREPARE);
log_field_current_time();
// log_field_jlong(class_tag);
log_field_string(signature);
log_eol();
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_CLASS_PREPARE);
log_field_current_time(buffer);
// log_field_jlong(buffer, class_tag);
log_field_string(buffer, signature);
log_eol(buffer);
rawMonitorExit(&lockLog);
while(i<method_count) {
rawMonitorEnter(&lockLog);
......
......@@ -38,9 +38,10 @@ void allocation_callbacks(const jvmtiCapabilities* capabilities, jvmtiEventCallb
static jint forceGC(JNIEnv *env) {
gcCount = 0;
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_GC);
log_field_current_time();
log_eol();
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_GC);
log_field_current_time(buffer);
log_eol(buffer);
rawMonitorExit(&lockLog);
jint res = JVMTI_FUNC_PTR(baseEnv,ForceGarbageCollection)(baseEnv);
setReportHeap(env,!FALSE);
......@@ -102,21 +103,22 @@ JNIEXPORT void JNICALL Java_org_dacapo_instrument_Agent_internalLogPointerChange
/* trace allocation */
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_POINTER);
log_field_current_time();
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_POINTER);
log_field_current_time(buffer);
log_thread(thread,thread_tag,thread_has_new_tag,thread_klass,thread_klass_tag,thread_klass_has_new_tag);
log_thread(buffer, thread,thread_tag,thread_has_new_tag,thread_klass,thread_klass_tag,thread_klass_has_new_tag);
log_field_jlong(object_tag);
log_class(object_klass,object_klass_tag,object_klass_has_new_tag);
log_field_jlong(buffer, object_tag);
log_class(buffer, object_klass,object_klass_tag,object_klass_has_new_tag);
log_field_jlong(before_tag);
log_class(before_klass,before_klass_tag,before_klass_has_new_tag);
log_field_jlong(buffer, before_tag);
log_class(buffer, before_klass,before_klass_tag,before_klass_has_new_tag);
log_field_jlong(after_tag);
log_class(after_klass,after_klass_tag,after_klass_has_new_tag);
log_field_jlong(buffer, after_tag);
log_class(buffer, after_klass,after_klass_tag,after_klass_has_new_tag);
log_eol();
log_eol(buffer);
rawMonitorExit(&lockLog);
}
}
......@@ -155,20 +157,21 @@ JNIEXPORT void JNICALL Java_org_dacapo_instrument_Agent_internalLogStaticPointer
/* trace allocation */
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_STATIC_POINTER);
log_field_current_time();
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_STATIC_POINTER);
log_field_current_time(buffer);
log_thread(thread,thread_tag,thread_has_new_tag,thread_klass,thread_klass_tag,thread_klass_has_new_tag);
log_thread(buffer, thread,thread_tag,thread_has_new_tag,thread_klass,thread_klass_tag,thread_klass_has_new_tag);
log_class(object_klass,object_klass_tag,object_klass_has_new_tag);
log_class(buffer, object_klass,object_klass_tag,object_klass_has_new_tag);
log_field_jlong(before_tag);
log_class(before_klass,before_klass_tag,before_klass_has_new_tag);
log_field_jlong(buffer, before_tag);
log_class(buffer, before_klass,before_klass_tag,before_klass_has_new_tag);
log_field_jlong(after_tag);
log_class(after_klass,after_klass_tag,after_klass_has_new_tag);
log_field_jlong(buffer, after_tag);
log_class(buffer, after_klass,after_klass_tag,after_klass_has_new_tag);
log_eol();
log_eol(buffer);
rawMonitorExit(&lockLog);
}
}
......@@ -200,18 +203,19 @@ static void internalReportAlloc(jvmtiEnv *jvmti, JNIEnv *jni_env, jthread thread
/* trace allocation */
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_ALLOCATION);
log_field_current_time();
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_ALLOCATION);
log_field_current_time(buffer);
log_thread(thread,thread_tag,thread_has_new_tag,object_klass,object_klass_tag,object_klass_has_new_tag);
log_thread(buffer, thread,thread_tag,thread_has_new_tag,object_klass,object_klass_tag,object_klass_has_new_tag);
log_field_jlong(tag);
log_class(object_klass,object_klass_tag,object_klass_has_new_tag);
log_field_jlong(buffer, tag);
log_class(buffer, object_klass,object_klass_tag,object_klass_has_new_tag);
log_field_jlong(size);
log_field_jint(site);
log_field_jlong(buffer, size);
log_field_jint(buffer, site);
log_eol();
log_eol(buffer);
rawMonitorExit(&lockLog);
}
}
......@@ -244,10 +248,11 @@ void JNICALL callbackObjectFree(jvmtiEnv *jvmti, jlong tag)
if (jvmRunning && !jvmStopped) {
/* trace free */
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_FREE);
log_field_current_time();
log_field_jlong(tag);
log_eol();
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_FREE);
log_field_current_time(buffer);
log_field_jlong(buffer, tag);
log_eol(buffer);
rawMonitorExit(&lockLog);
}
}
......
......@@ -37,6 +37,7 @@ void call_chain_logon(JNIEnv* env) {
#define START_FRAME 4
void log_call_chain(JNIEnv *jni_env, jclass klass, jobject thread) {
void* buffer = NULL;
jniNativeInterface* jni_table = JNIFunctionTable();
jlong thread_tag = 0;
......@@ -56,9 +57,10 @@ void log_call_chain(JNIEnv *jni_env, jclass klass, jobject thread) {
err = JVMTI_FUNC_PTR(baseEnv,GetStackTrace)(baseEnv, thread, START_FRAME, MAX_NUMBER_OF_FRAMES,frames, &count);
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_CALL_CHAIN_START);
log_thread(thread,thread_tag,thread_has_new_tag,thread_klass,thread_klass_tag,thread_klass_has_new_tag);
log_eol();
buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_CALL_CHAIN_START);
log_thread(buffer, thread,thread_tag,thread_has_new_tag,thread_klass,thread_klass_tag,thread_klass_has_new_tag);
log_eol(buffer);
rawMonitorExit(&lockLog);
int i;
......@@ -73,11 +75,12 @@ void log_call_chain(JNIEnv *jni_env, jclass klass, jobject thread) {
jboolean klass_has_new_tag = getTag(klass,&klass_tag);
rawMonitorExit(&lockTag);
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_CALL_CHAIN_FRAME);
log_field_jlong(thread_tag);
log_field_jlong((jlong)i);
log_class(klass,klass_tag,klass_has_new_tag);
rawMonitorEnter(&lockLog);
buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_CALL_CHAIN_FRAME);
log_field_jlong(buffer, thread_tag);
log_field_jlong(buffer, (jlong)i);
log_class(buffer, klass,klass_tag,klass_has_new_tag);
char* name_ptr = NULL;
char* signature_ptr = NULL;
......@@ -85,17 +88,17 @@ void log_call_chain(JNIEnv *jni_env, jclass klass, jobject thread) {
jint res = JVMTI_FUNC_PTR(baseEnv,GetMethodName)(baseEnv,frames[i].method,&name_ptr,&signature_ptr,&generic_ptr);
log_field_string(LOG_PREFIX_METHOD_PREPARE);
log_field_pointer(frames[i].method);
log_field_jlong(class_tag);
log_field_string(name_ptr);
log_field_string(signature_ptr);
log_field_string(buffer, LOG_PREFIX_METHOD_PREPARE);
log_field_pointer(buffer, frames[i].method);
log_field_jlong(buffer, class_tag);
log_field_string(buffer, name_ptr);
log_field_string(buffer, signature_ptr);
if (name_ptr!=NULL) JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)name_ptr);
if (signature_ptr!=NULL) JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)signature_ptr);
if (generic_ptr!=NULL) JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)generic_ptr);
log_eol();
log_eol(buffer);
rawMonitorExit(&lockLog);
}
......@@ -119,9 +122,10 @@ void log_call_chain(JNIEnv *jni_env, jclass klass, jobject thread) {
*/
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_CALL_CHAIN_STOP);
log_field_jlong(thread_tag);
log_eol();
buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_CALL_CHAIN_STOP);
log_field_jlong(buffer, thread_tag);
log_eol(buffer);
rawMonitorExit(&lockLog);
}
......
......@@ -62,13 +62,14 @@ void JNICALL callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thr
rawMonitorExit(&lockTag);
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_EXCEPTION);
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_EXCEPTION);
log_thread(thread, thread_tag, thread_has_new_tag, klass, klass_tag, klass_has_new_tag);
log_thread(buffer, thread, thread_tag, thread_has_new_tag, klass, klass_tag, klass_has_new_tag);
log_field_jlong(exception_tag);
log_field_jlong(buffer, exception_tag);
log_class(exception_klass, exception_klass_tag, exception_klass_has_new_tag);
log_class(buffer, exception_klass, exception_klass_tag, exception_klass_has_new_tag);
char* name = NULL;
char* signature = NULL;
......@@ -76,15 +77,15 @@ void JNICALL callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thr
char* class_signature = NULL;
char* class_generic = NULL;
log_field_pointer(catch_method);
log_field_pointer(buffer, catch_method);
JVMTI_FUNC_PTR(baseEnv,GetMethodDeclaringClass)(baseEnv,method,&klass)==JNI_OK &&
JVMTI_FUNC_PTR(baseEnv,GetMethodName)(baseEnv,method,&name,&signature,&generic)==JNI_OK &&
JVMTI_FUNC_PTR(baseEnv,GetClassSignature)(baseEnv,klass,&class_signature,&class_generic)==JNI_OK;
log_field_string(class_signature);
log_field_string(name);
log_field_string(signature);
log_field_string(buffer, class_signature);
log_field_string(buffer, name);
log_field_string(buffer, signature);
if (class_signature!=NULL) { JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)class_signature); class_signature = NULL; }
if (class_generic!=NULL) { JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)class_generic); class_generic = NULL; }
......@@ -96,9 +97,9 @@ void JNICALL callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thr
JVMTI_FUNC_PTR(baseEnv,GetMethodName)(baseEnv,catch_method,&name,&signature,&generic)==JNI_OK &&
JVMTI_FUNC_PTR(baseEnv,GetClassSignature)(baseEnv,klass,&class_signature,&class_generic)==JNI_OK;
log_field_string(class_signature);
log_field_string(name);
log_field_string(signature);
log_field_string(buffer, class_signature);
log_field_string(buffer, name);
log_field_string(buffer, signature);
if (class_signature!=NULL) { JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)class_signature); class_signature = NULL; }
if (class_generic!=NULL) { JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)class_generic); class_generic = NULL; }
......@@ -106,7 +107,7 @@ void JNICALL callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thr
if (signature!=NULL) { JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)signature); signature = NULL; }
if (generic!=NULL) { JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)generic); generic = NULL; }
log_eol();
log_eol(buffer);
rawMonitorExit(&lockLog);
}
}
......@@ -132,13 +133,14 @@ void JNICALL callbackExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthrea
rawMonitorExit(&lockTag);
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_EXCEPTION_CATCH);
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_EXCEPTION_CATCH);
log_thread(thread, thread_tag, thread_has_new_tag, klass, klass_tag, klass_has_new_tag);
log_thread(buffer, thread, thread_tag, thread_has_new_tag, klass, klass_tag, klass_has_new_tag);
log_field_jlong(exception_tag);
log_field_jlong(buffer, exception_tag);
log_class(exception_klass, exception_klass_tag, exception_klass_has_new_tag);
log_class(buffer, exception_klass, exception_klass_tag, exception_klass_has_new_tag);
char* name_ptr = NULL;
char* signature_ptr = NULL;
......@@ -146,15 +148,15 @@ void JNICALL callbackExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthrea
JVMTI_FUNC_PTR(baseEnv,GetMethodName)(baseEnv,method,&name_ptr,&signature_ptr,&generic_ptr);
log_field_string("<class_name>");
log_field_string(name_ptr);
log_field_string(signature_ptr);
log_field_string(buffer, "<class_name>");
log_field_string(buffer, name_ptr);
log_field_string(buffer, signature_ptr);
if (name_ptr!=NULL) JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)name_ptr);
if (signature_ptr!=NULL) JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)signature_ptr);
if (generic_ptr!=NULL) JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)generic_ptr);
log_eol();
log_eol(buffer);
rawMonitorExit(&lockLog);
}
}
......
......@@ -281,13 +281,14 @@ JNIEXPORT void JNICALL Java_org_dacapo_instrument_Agent_internalLog
const char *c_m = JVMTI_FUNC_PTR(env,GetStringUTFChars)(env, m, &iscopy_m);
rawMonitorEnter(&lockLog);
log_field_string(c_e);
log_field_current_time();
void* buffer = log_buffer_get();
log_field_string(buffer, c_e);
log_field_current_time(buffer);
log_thread(thread, thread_tag, thread_has_new_tag, thread_klass, thread_klass_tag, thread_klass_has_new_tag);
log_thread(buffer, thread, thread_tag, thread_has_new_tag, thread_klass, thread_klass_tag, thread_klass_has_new_tag);
log_field_string(c_m);
log_eol();
log_field_string(buffer, c_m);
log_eol(buffer);
rawMonitorExit(&lockLog);
JVMTI_FUNC_PTR(env,ReleaseStringUTFChars)(env, e, c_e);
......@@ -323,9 +324,10 @@ JNIEXPORT void JNICALL Java_org_dacapo_instrument_Agent_internalStart
logState = logFile != FILE_IS_CLOSED;
if (logState) {
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_START);
log_field_current_time();
log_eol();
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_START);
log_field_current_time(buffer);
log_eol(buffer);
rawMonitorExit(&lockLog);
allocation_logon(env);
......@@ -350,9 +352,10 @@ JNIEXPORT void JNICALL Java_org_dacapo_instrument_Agent_internalStop
logState = FALSE;
if (tmp) {
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_STOP);
log_field_current_time();
log_eol();
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_STOP);
log_field_current_time(buffer);
log_eol(buffer);
rawMonitorExit(&lockLog);
}
}
......@@ -387,16 +390,17 @@ JNIEXPORT void JNICALL Java_org_dacapo_instrument_Agent_internalHeapReport(JNIEn
rawMonitorExit(&lockTag);
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_HEAP_REPORT);
log_field_current_time();
void* buffer = log_buffer_get();
log_field_string(buffer, LOG_PREFIX_HEAP_REPORT);
log_field_current_time(buffer);
log_thread(thread, thread_tag, thread_has_new_tag, thread_klass, thread_klass_tag, thread_klass_has_new_tag);
log_thread(buffer, thread, thread_tag, thread_has_new_tag, thread_klass, thread_klass_tag, thread_klass_has_new_tag);
log_field_jlong(used);
log_field_jlong(free);
log_field_jlong(total);
log_field_jlong(max);
log_eol();
log_field_jlong(buffer, used);
log_field_jlong(buffer, free);
log_field_jlong(buffer, total);
log_field_jlong(buffer, max);
log_eol(buffer);
rawMonitorExit(&lockLog);
return;
......@@ -412,7 +416,7 @@ static char end_of_line = '\n';
/* */
void* log_get_buffer() {
void* log_buffer_get() {
struct buffer_s* buffer = NULL;
if (buffer_head == NULL) {
buffer = (struct buffer_s*)malloc(sizeof(struct buffer_s));
......@@ -426,51 +430,56 @@ void* log_get_buffer() {
return buffer;
}
void log_put_buffer(void* buffer) {
void log_buffer_put(void* buffer) {
((struct buffer_s*)buffer)->next = buffer_head;
buffer_head = (struct buffer_s*)buffer;
}
static void write_field(const char* text, int text_length, _Bool use_delimiter) {
if (logFile == FILE_IS_CLOSED) {
fprintf(stderr,"LOG_FILE IS CLOSED\n");
exit(10);
}
void log_buffer_ensure_space(struct buffer_s* b, int size) {
if ((b->buffer_len - b->buffer_pos) < 0) {
char* tmp = (char*)malloc(sizeof(char)*(2*b->buffer_len));
memcpy(tmp, b->buffer, sizeof(char)*b->buffer_len);
free(b->buffer);
b->buffer = tmp;
}
}
static void write_field(struct buffer_s* buffer, const char* text, int text_length, _Bool use_delimiter) {
if (first_field) {
first_field = FALSE;
} else {
WRITE(&field_separator,sizeof(char),1);
log_buffer_ensure_space(buffer, 1);
buffer->buffer[buffer->buffer_pos++] = field_separator;
}
if (use_delimiter) {
char temp_field[10240];
int temp_length = 0;
temp_field[temp_length++] = field_delimiter;
log_buffer_ensure_space(buffer, 1);
buffer->buffer[buffer->buffer_pos++] = field_delimiter;
if (text!=NULL) {
int i;
for(i=0; i<text_length;++i) {
log_buffer_ensure_space(buffer, 2);
if (text[i]==field_delimiter)
temp_field[temp_length++] = field_delimiter;
temp_field[temp_length++] = field_delimiter;
buffer->buffer[buffer->buffer_pos++] = field_delimiter;
buffer->buffer[buffer->buffer_pos++] = text[i];
}
}
temp_field[temp_length++] = field_delimiter;
WRITE(temp_field,sizeof(char),temp_length);
log_buffer_ensure_space(buffer, 1);
buffer->buffer[buffer->buffer_pos++] = field_delimiter;
} else {
if(text!=NULL && 0<text_length) {
WRITE(text,sizeof(char),text_length);
log_buffer_ensure_space(buffer, text_length);
strncpy(buffer->buffer+buffer->buffer_pos,text,text_length);
buffer->buffer_pos += text_length;
}
}
}
void log_field_string(const char* text) {
void log_field_string(void* buffer, const char* text) {
if (text==NULL)
write_field(NULL,0,TRUE);
write_field((struct buffer_s*)buffer,NULL,0,TRUE);
else {
int text_length = 0;
_Bool use_delimiter = FALSE;
......@@ -480,45 +489,45 @@ void log_field_string(const char* text) {
++text_length;
}
write_field(text,text_length,use_delimiter);
write_field((struct buffer_s*)buffer, text,text_length,use_delimiter);
}
}
void log_field_jboolean(jboolean v) {
log_field_string(v?"true":"false");
void log_field_jboolean(void* buffer, jboolean v) {
log_field_string(buffer, v?"true":"false");
}
void log_field_int(int v) {
void log_field_int(void* buffer, int v) {
char tmp[32];
sprintf(tmp,"%d",v);
log_field_string(tmp);
log_field_string(buffer, tmp);
}
void log_field_jint(jint v) {
void log_field_jint(void* buffer, jint v) {
char tmp[32];
sprintf(tmp,"%" FORMAT_JINT,v);
log_field_string(tmp);
log_field_string(buffer, tmp);
}
void log_field_jlong(jlong v) {
void log_field_jlong(void* buffer, jlong v) {
char tmp[64];
sprintf(tmp,"%" FORMAT_JLONG,v);
log_field_string(tmp);
log_field_string(buffer, tmp);
}
void log_field_long(long v) {
void log_field_long(void* buffer, long v) {
char tmp[64];
sprintf(tmp,"%ld",v);
log_field_string(tmp);
log_field_string(buffer, tmp);
}
void log_field_pointer(const void* p) {
void log_field_pointer(void* buffer, const void* p) {
char tmp[64];
sprintf(tmp,"%" FORMAT_PTR, PTR_CAST(p));
log_field_string(tmp);
log_field_string(buffer, tmp);
}
void log_field_string_n(const char* text, int field_length) {
void log_field_string_n(void* buffer, const char* text, int field_length) {
int i;
_Bool use_delimiter = FALSE;
......@@ -526,11 +535,11 @@ void log_field_string_n(const char* text, int field_length) {
use_delimiter = text[i]==field_delimiter || text[i]==field_separator;
}
write_field(text,field_length,use_delimiter);
write_field((struct buffer_s*)buffer,text,field_length,use_delimiter);
}
void log_thread(jthread thread, jlong thread_tag, jboolean thread_has_new_tag, jobject klass, jlong klass_tag, jboolean klass_has_new_tag) {
log_field_jlong(thread_tag);
void log_thread(void* buffer, jthread thread, jlong thread_tag, jboolean thread_has_new_tag, jobject klass, jlong klass_tag, jboolean klass_has_new_tag) {
log_field_jlong(buffer, thread_tag);
if (thread_has_new_tag) {
jniNativeInterface* jni_table = JNIFunctionTable();
......@@ -538,17 +547,17 @@ void log_thread(jthread thread, jlong thread_tag, jboolean thread_has_new_tag, j
// get thread name.
jvmtiThreadInfo info;
JVMTI_FUNC_PTR(baseEnv,GetThreadInfo)(baseEnv, thread, &info);
log_field_string(info.name);
log_field_string(buffer, info.name);
if (info.name!=NULL) JVMTI_FUNC_PTR(baseEnv,Deallocate)(baseEnv,(unsigned char*)info.name);
} else {
log_field_string(NULL);
log_field_string(buffer, NULL);
}
log_class(klass, klass_tag, klass_has_new_tag);
log_class(buffer, klass, klass_tag, klass_has_new_tag);
}
void log_class(jobject klass, jlong klass_tag, jboolean klass_has_new_tag) {
log_field_jlong(klass_tag);
void log_class(void* buffer, jobject klass, jlong klass_tag, jboolean klass_has_new_tag) {
log_field_jlong(buffer, klass_tag);
if (klass_has_new_tag) {
jniNativeInterface* jni_table = JNIFunctionTable();
......@@ -556,64 +565,49 @@ void log_class(jobject klass, jlong klass_tag, jboolean klass_has_new_tag) {
char* generic = NULL;
JVMTI_FUNC_PTR(baseEnv,GetClassSignature)(baseEnv,klass,&signature,&generic);