| 96 | } |
| 97 | |
| 98 | extern "C" DLLEXPORT jbyteArray JNICALL |
| 99 | Java_one_profiler_AsyncProfiler_execute1(JNIEnv* env, jobject unused, jstring command) { |
| 100 | Arguments args; |
| 101 | const char* command_str = env->GetStringUTFChars(command, NULL); |
| 102 | Error error = args.parse(command_str); |
| 103 | env->ReleaseStringUTFChars(command, command_str); |
| 104 | |
| 105 | if (error) { |
| 106 | throwNew(env, "java/lang/IllegalArgumentException", error.message()); |
| 107 | return NULL; |
| 108 | } |
| 109 | if (args.hasOutputFile()) { |
| 110 | throwNew(env, "java/lang/IllegalArgumentException", "execute1 calls should not specify an output file argument"); |
| 111 | return NULL; |
| 112 | } |
| 113 | |
| 114 | Log::open(args); |
| 115 | |
| 116 | BufferWriter out; |
| 117 | // TODO: This is doing one more copy than necessary, from ProtoWriter to BufferWriter |
| 118 | error = Profiler::instance()->runInternal(args, out); |
| 119 | if (error) { |
| 120 | throwNew(env, "java/lang/IllegalStateException", error.message()); |
| 121 | return NULL; |
| 122 | } |
| 123 | |
| 124 | jbyteArray output = env->NewByteArray(out.size()); |
| 125 | env->SetByteArrayRegion(output, 0, out.size(), (const jbyte*) out.buf()); |
| 126 | return output; |
| 127 | } |
| 128 | |
| 129 | extern "C" DLLEXPORT jlong JNICALL |
| 130 | Java_one_profiler_AsyncProfiler_getSamples(JNIEnv* env, jobject unused) { |
nothing calls this directly
no test coverage detected