< prev index next >

src/demo/share/jvmti/waiters/waiters.cpp

Print this page
rev 12879 : 8136556: Add the ability to perform static builds of MacOSX x64 binaries
Reviewed-by: ihse, bdelsart, gadams, lfoltan, rriggs, hseigel, twisti
   1 /*
   2  * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
   3  *
   4  * Redistribution and use in source and binary forms, with or without
   5  * modification, are permitted provided that the following conditions
   6  * are met:
   7  *
   8  *   - Redistributions of source code must retain the above copyright
   9  *     notice, this list of conditions and the following disclaimer.
  10  *
  11  *   - Redistributions in binary form must reproduce the above copyright
  12  *     notice, this list of conditions and the following disclaimer in the
  13  *     documentation and/or other materials provided with the distribution.
  14  *
  15  *   - Neither the name of Oracle nor the names of its
  16  *     contributors may be used to endorse or promote products derived
  17  *     from this software without specific prior written permission.
  18  *
  19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  20  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR


 226     {
 227         menter(jvmti, vm_death_lock); {
 228             if ( !vm_death_active ) {
 229                 get_agent(jvmti)->monitor_waited(jvmti, env, thread,
 230                                                  object, timed_out);
 231             }
 232         } mexit(jvmti, vm_death_lock);
 233     }
 234     static void JNICALL
 235     object_free(jvmtiEnv* jvmti, jlong tag)
 236     {
 237         menter(jvmti, vm_death_lock); {
 238             if ( !vm_death_active ) {
 239                 get_agent(jvmti)->object_free(jvmti, tag);
 240             }
 241         } mexit(jvmti, vm_death_lock);
 242     }
 243 
 244     /* Agent_OnLoad() is called first, we prepare for a VM_INIT event here. */
 245     JNIEXPORT jint JNICALL
 246     Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
 247     {
 248         jvmtiEnv           *jvmti;
 249         jint                rc;
 250         jvmtiError          err;
 251         jvmtiCapabilities   capabilities;
 252         jvmtiEventCallbacks callbacks;
 253 
 254         /* Get JVMTI environment */
 255         rc = vm->GetEnv((void **)&jvmti, JVMTI_VERSION);
 256         if (rc != JNI_OK) {
 257             fatal_error("ERROR: Unable to create jvmtiEnv, GetEnv failed, error=%d\n", rc);
 258             return -1;
 259         }
 260 
 261         /* Get/Add JVMTI capabilities */
 262         (void)memset(&capabilities, 0, sizeof(capabilities));
 263         capabilities.can_generate_monitor_events        = 1;
 264         capabilities.can_get_monitor_info               = 1;
 265         capabilities.can_tag_objects                    = 1;
 266         capabilities.can_generate_object_free_events    = 1;


 271         memset(&callbacks, 0, sizeof(callbacks));
 272         callbacks.VMInit                  = &vm_init;
 273         callbacks.VMDeath                 = &vm_death;
 274         callbacks.ThreadStart             = &thread_start;
 275         callbacks.ThreadEnd               = &thread_end;
 276         callbacks.MonitorContendedEnter   = &monitor_contended_enter;
 277         callbacks.MonitorContendedEntered = &monitor_contended_entered;
 278         callbacks.MonitorWait             = &monitor_wait;
 279         callbacks.MonitorWaited           = &monitor_waited;
 280         callbacks.ObjectFree              = &object_free;
 281         err = jvmti->SetEventCallbacks(&callbacks, (jint)sizeof(callbacks));
 282         check_jvmti_error(jvmti, err, "set event callbacks");
 283         err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
 284                         JVMTI_EVENT_VM_INIT, NULL);
 285         check_jvmti_error(jvmti, err, "set event notify");
 286         return 0;
 287     }
 288 
 289     /* Agent_OnUnload() is called last */
 290     JNIEXPORT void JNICALL
 291     Agent_OnUnload(JavaVM *vm)
 292     {
 293     }
 294 
 295 } /* of extern "C" */
   1 /*
   2  * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
   3  *
   4  * Redistribution and use in source and binary forms, with or without
   5  * modification, are permitted provided that the following conditions
   6  * are met:
   7  *
   8  *   - Redistributions of source code must retain the above copyright
   9  *     notice, this list of conditions and the following disclaimer.
  10  *
  11  *   - Redistributions in binary form must reproduce the above copyright
  12  *     notice, this list of conditions and the following disclaimer in the
  13  *     documentation and/or other materials provided with the distribution.
  14  *
  15  *   - Neither the name of Oracle nor the names of its
  16  *     contributors may be used to endorse or promote products derived
  17  *     from this software without specific prior written permission.
  18  *
  19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  20  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR


 226     {
 227         menter(jvmti, vm_death_lock); {
 228             if ( !vm_death_active ) {
 229                 get_agent(jvmti)->monitor_waited(jvmti, env, thread,
 230                                                  object, timed_out);
 231             }
 232         } mexit(jvmti, vm_death_lock);
 233     }
 234     static void JNICALL
 235     object_free(jvmtiEnv* jvmti, jlong tag)
 236     {
 237         menter(jvmti, vm_death_lock); {
 238             if ( !vm_death_active ) {
 239                 get_agent(jvmti)->object_free(jvmti, tag);
 240             }
 241         } mexit(jvmti, vm_death_lock);
 242     }
 243 
 244     /* Agent_OnLoad() is called first, we prepare for a VM_INIT event here. */
 245     JNIEXPORT jint JNICALL
 246     DEF_Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
 247     {
 248         jvmtiEnv           *jvmti;
 249         jint                rc;
 250         jvmtiError          err;
 251         jvmtiCapabilities   capabilities;
 252         jvmtiEventCallbacks callbacks;
 253 
 254         /* Get JVMTI environment */
 255         rc = vm->GetEnv((void **)&jvmti, JVMTI_VERSION);
 256         if (rc != JNI_OK) {
 257             fatal_error("ERROR: Unable to create jvmtiEnv, GetEnv failed, error=%d\n", rc);
 258             return -1;
 259         }
 260 
 261         /* Get/Add JVMTI capabilities */
 262         (void)memset(&capabilities, 0, sizeof(capabilities));
 263         capabilities.can_generate_monitor_events        = 1;
 264         capabilities.can_get_monitor_info               = 1;
 265         capabilities.can_tag_objects                    = 1;
 266         capabilities.can_generate_object_free_events    = 1;


 271         memset(&callbacks, 0, sizeof(callbacks));
 272         callbacks.VMInit                  = &vm_init;
 273         callbacks.VMDeath                 = &vm_death;
 274         callbacks.ThreadStart             = &thread_start;
 275         callbacks.ThreadEnd               = &thread_end;
 276         callbacks.MonitorContendedEnter   = &monitor_contended_enter;
 277         callbacks.MonitorContendedEntered = &monitor_contended_entered;
 278         callbacks.MonitorWait             = &monitor_wait;
 279         callbacks.MonitorWaited           = &monitor_waited;
 280         callbacks.ObjectFree              = &object_free;
 281         err = jvmti->SetEventCallbacks(&callbacks, (jint)sizeof(callbacks));
 282         check_jvmti_error(jvmti, err, "set event callbacks");
 283         err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
 284                         JVMTI_EVENT_VM_INIT, NULL);
 285         check_jvmti_error(jvmti, err, "set event notify");
 286         return 0;
 287     }
 288 
 289     /* Agent_OnUnload() is called last */
 290     JNIEXPORT void JNICALL
 291     DEF_Agent_OnUnload(JavaVM *vm)
 292     {
 293     }
 294 
 295 } /* of extern "C" */
< prev index next >