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

dacapomethod.c 2.24 KB
Newer Older
1
#include "dacapolog.h"
2
#include "dacapotag.h"
3
#include "dacapooptions.h"
4
#include "dacapolock.h"
5
#include "dacapothread.h"
6

7
#include "dacapomethod.h"
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

void method_init() {

}

void method_capabilities(const jvmtiCapabilities* availableCapabilities, jvmtiCapabilities* capabilities) {
    if (isSelected(OPT_METHOD_EVENTS,NULL)) {
	    capabilities->can_generate_method_entry_events    = availableCapabilities->can_generate_method_entry_events;
    	capabilities->can_generate_method_exit_events     = availableCapabilities->can_generate_method_exit_events;
	}
}

void method_callbacks(const jvmtiCapabilities* capabilities, jvmtiEventCallbacks* callbacks) {
    if (isSelected(OPT_METHOD_EVENTS,NULL)) {
	    if (capabilities->can_generate_method_entry_events) DEFINE_CALLBACK(callbacks,MethodEntry,JVMTI_EVENT_METHOD_ENTRY);
		if (capabilities->can_generate_method_exit_events)  DEFINE_CALLBACK(callbacks,MethodExit,JVMTI_EVENT_METHOD_EXIT);
	}
}

john's avatar
john committed
27
28
29
30
void method_live(jvmtiEnv* jvmti, JNIEnv* env) {

}

31
32
33
34
void method_logon(JNIEnv* env) {

}

john's avatar
john committed
35
void method_class(jvmtiEnv *env, JNIEnv *jnienv, jthread thread, jclass klass) {
john's avatar
john committed
36
37
38

}

39
40
41
/* JVMTI_EVENT_METHOD_ENTRY */
void JNICALL callbackMethodEntry(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jmethodID method) {
	if (logState) {
john's avatar
john committed
42
43
		jniNativeInterface* jni_table = JNIFunctionTable();

44
		jlong thread_tag = 0;
john's avatar
john committed
45
46
		jclass thread_klass = JVM_FUNC_PTR(jni_table,GetObjectClass)(jni_env,thread);
		jlong thread_klass_tag = 0;
47

48
		rawMonitorEnter(&lockTag);
49
		jboolean thread_has_new_tag = getTag(thread, &thread_tag);
john's avatar
john committed
50
		jboolean thread_klass_has_new_tag = getTag(thread_klass, &thread_klass_tag);
51
		rawMonitorExit(&lockTag);
52

53
		rawMonitorEnter(&lockLog);
john's avatar
john committed
54
55
56
		void* buffer = log_buffer_get();
		log_field_string(buffer, LOG_PREFIX_METHOD_ENTER);
		log_field_current_time(buffer);
john's avatar
john committed
57
		
john's avatar
john committed
58
		log_thread(buffer, thread, thread_tag, thread_has_new_tag,thread_klass,thread_klass_tag,thread_klass_has_new_tag);
john's avatar
john committed
59

john's avatar
john committed
60
61
		log_field_jlong(buffer, (jlong)method);
		log_eol(buffer);
62
		rawMonitorExit(&lockLog);
63
64
65
66
67
68
69
70
71
	}
}

/* JVMTI_EVENT_METHOD_EXIT */
void JNICALL callbackMethodExit(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jmethodID method, jboolean was_popped_by_exception, jvalue return_value) {
	if (logState) {
		/* record thread as exiting from method */
	}
}