| 493 | } |
| 494 | |
| 495 | extern "C" DLLEXPORT jint JNICALL |
| 496 | Agent_OnAttach(JavaVM* vm, char* options, void* reserved) { |
| 497 | Arguments args; |
| 498 | Error error = args.parse(options); |
| 499 | |
| 500 | Log::open(args); |
| 501 | |
| 502 | if (error) { |
| 503 | Log::error("%s", error.message()); |
| 504 | return ARGUMENTS_ERROR; |
| 505 | } |
| 506 | |
| 507 | if (!VM::init(vm, true)) { |
| 508 | Log::error("JVM does not support Tool Interface"); |
| 509 | return COMMAND_ERROR; |
| 510 | } |
| 511 | |
| 512 | error = Profiler::instance()->run(args); |
| 513 | if (error) { |
| 514 | Log::error("%s", error.message()); |
| 515 | if (args.hasTemporaryLog()) Log::close(); |
| 516 | return COMMAND_ERROR; |
| 517 | } |
| 518 | |
| 519 | if (args._action == ACTION_STOP && args.hasTemporaryLog()) { |
| 520 | // The launcher immediately deletes logs after printing |
| 521 | Log::close(); |
| 522 | } |
| 523 | |
| 524 | return 0; |
| 525 | } |
| 526 | |
| 527 | extern "C" DLLEXPORT jint JNICALL |
| 528 | JNI_OnLoad(JavaVM* vm, void* reserved) { |
nothing calls this directly
no test coverage detected