MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / initialize

Method initialize

src/instrument.cpp:1062–1083  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1060volatile bool Instrument::_running;
1061
1062Error Instrument::initialize() {
1063 if (!_instrument_class_loaded) {
1064 if (!VM::loaded()) {
1065 return Error("Profiling event is not supported with non-Java processes");
1066 }
1067
1068 JNIEnv* jni = VM::jni();
1069 JNINativeMethod native_method[2];
1070 native_method[0] = {(char*)"recordEntry", (char*)"()V", (void*)recordEntry};
1071 native_method[1] = {(char*)"recordExit0", (char*)"(J)V", (void*)recordExit0};
1072
1073 jclass cls = jni->DefineClass(INSTRUMENT_NAME, NULL, (const jbyte*)INSTRUMENT_CLASS, INCBIN_SIZEOF(INSTRUMENT_CLASS));
1074 if (cls == NULL || jni->RegisterNatives(cls, native_method, 2) != 0) {
1075 jni->ExceptionDescribe();
1076 return Error("Could not load Instrument class");
1077 }
1078
1079 _instrument_class_loaded = true;
1080 }
1081
1082 return Error::OK;
1083}
1084
1085Error Instrument::start(Arguments& args) {
1086 Error error = initialize();

Callers

nothing calls this directly

Calls 1

ErrorClass · 0.85

Tested by

no test coverage detected