// A trivial OnLoad implementation that only initializes the global jvmti_env. static jint MinimalOnLoad(JavaVM* vm,
[[maybe_unused]] char* options,
[[maybe_unused]] void* reserved) { if (vm->GetEnv(reinterpret_cast<void**>(&jvmti_env), JVMTI_VERSION_1_0) != 0) {
printf("Unable to get jvmti env!\n"); return1;
}
SetStandardCapabilities(jvmti_env); return0;
}
// A list of all non-standard the agents we have for testing. All other agents will use // MinimalOnLoad. static AgentLib agents[] = {
{ "901-hello-ti-agent", Test901HelloTi::OnLoad, nullptr },
{ "909-attach-agent", nullptr, Test909AttachAgent::OnAttach },
{ "916-obsolete-jit", common_redefine::OnLoad, nullptr },
{ "921-hello-failure", common_retransform::OnLoad, nullptr },
{ "934-load-transform", common_retransform::OnLoad, nullptr },
{ "935-non-retransformable", common_transform::OnLoad, nullptr },
{ "936-search-onload", Test936SearchOnload::OnLoad, nullptr },
{ "937-hello-retransform-package", common_retransform::OnLoad, nullptr },
{ "938-load-transform-bcp", common_retransform::OnLoad, nullptr },
{ "939-hello-transformation-bcp", common_redefine::OnLoad, nullptr },
{ "941-recursive-obsolete-jit", common_redefine::OnLoad, nullptr },
{ "943-private-recursive-jit", common_redefine::OnLoad, nullptr },
{ "993-non-debuggable", nullptr, Test993BreakpointsNonDebuggable::OnLoad },
{ "1919-vminit-thread-start-timing", Test1919VMInitThreadStart::OnLoad, nullptr },
{ "2031-zygote-compiled-frame-deopt", nullptr, MinimalOnLoad },
{ "2039-load-transform-larger", common_retransform::OnLoad, nullptr },
};
static AgentLib* FindAgent(char* name) { for (AgentLib& l : agents) { if (strncmp(l.name, name, strlen(l.name)) == 0) { return &l;
}
} return nullptr;
}
staticbool FindAgentNameAndOptions(char* options, /*out*/char** name, /*out*/char** other_options) { // Name is the first element.
*name = options; char* rest = options; // name is the first thing in the options while (*rest != '\0' && *rest != ',') {
rest++;
} if (*rest == ',') {
*rest = '\0';
rest++;
}
*other_options = rest; returntrue;
}
extern"C" JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM* vm, char* options, void* reserved) { char* remaining_options = nullptr; char* name_option = nullptr; if (!FindAgentNameAndOptions(options, &name_option, &remaining_options)) {
printf("Unable to find agent name in options: %s\n", options); return -1;
}
SetIsJVM(remaining_options);
AgentLib* lib = FindAgent(name_option);
OnLoad fn = nullptr; if (lib == nullptr) {
fn = &MinimalOnLoad;
} else { if (lib->load == nullptr) {
printf("agent: %s does not include an OnLoad method.\n", name_option); return -3;
}
fn = lib->load;
} return fn(vm, remaining_options, reserved);
}
extern"C" JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM* vm, char* options, void* reserved) { char* remaining_options = nullptr; char* name_option = nullptr; if (!FindAgentNameAndOptions(options, &name_option, &remaining_options)) {
printf("Unable to find agent name in options: %s\n", options); return -1;
}
AgentLib* lib = FindAgent(name_option); if (lib == nullptr) {
printf("Unable to find agent named: %s, add it to the list in test/ti-agent/common_load.cc\n",
name_option); return -2;
} if (lib->attach == nullptr) {
printf("agent: %s does not include an OnAttach method.\n", name_option); return -3;
}
SetIsJVM(remaining_options); return lib->attach(vm, remaining_options, reserved);
}
} // namespace art
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.