-
Notifications
You must be signed in to change notification settings - Fork 0
/
jni_util.c
52 lines (47 loc) · 1.37 KB
/
jni_util.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "jni_util.h"
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
/* Shared instance between all JVMTI users -
because the JVMTI API doesn't have GetEventCallbacks(),
we need to allow adding/changing callbacks without knowing about
other code. */
static jvmtiEventCallbacks jvmti_callbacks;
/*
* Free a set of JVMTI references. Pass (void *)-1 as the last parameter.
* Be *sure* to cast the last argument to a pointer.
*/
jvmtiError free_jvmti_refs(jvmtiEnv *jvmti, ...)
{
jvmtiError jerr = JVMTI_ERROR_NONE;
va_list s;
unsigned char *p;
va_start(s, jvmti);
while((p = va_arg(s, unsigned char *)) != (void *)-1)
{
if(!p)
{
fprintf(stderr, "WARNING: null pointer passed to free_jvmti_refs()\n");
continue;
}
jerr = (*jvmti)->Deallocate(jvmti, p);
/* if(check_jvmti_error(Gagent.jvmti, Gagent.jerr) != JVMTI_ERROR_NONE) */
/* jerr = Gagent.jerr; */
}
va_end(s);
return jerr;
}
jvmtiEventCallbacks *get_jvmti_callbacks()
{
return &jvmti_callbacks;
}
jvmtiError
event_change(jvmtiEnv *jvmti, jvmtiEventMode mode,
jvmtiEvent type, jthread thread)
{
jvmtiError jerr = (*jvmti)->SetEventNotificationMode(jvmti, mode, type, thread);
/* if(jerr == JVMTI_ERROR_NONE) */
/* event_states[type - JVMTI_MIN_EVENT_TYPE_VAL] = mode; */
return jerr;
}