/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
/* Tracker class support functions. */
/*
* This file contains the native support calls for the Tracker
* class. These native methods are registered and not made extern.
* Tracking is engaged by using JNI to assign to a static field in the
* Tracker class.
*
* Just like JVMTI callbacks, it's best that we keep track of these so that
* when the VM_DEATH happens we know to wait for them to complete.
*
* This file also contains the functions that will initialize the Tracker
* interface for BCI and identify the Tracker methods to make sure
* they are not included in any stack traces obtained from JVMTI.
*
* RFE: The performance of the java injected code calling native methods
* could be an issue here, cpu=times seems to be the worst where
* a native call is made for entry and exit, even on the smallest
* Java method. The alternative would be to cache the data on
* the Java side, and either push it out to the native side, or
* use some kind of pull from the native side, or even using
* shared memory or a socket. However having said that, the
* current performance issues are more around sheer memory needed,
* and repeated calls to GetThreadCpuTime(), which is being investigated.
*
*/
#include "hprof.h"
/* Macros to surround tracker based callback code.
* Also see BEGIN_CALLBACK and END_CALLBACK in hprof_init.c.
* If the VM_DEATH callback is active in the begining, then this callback
* just blocks (it is assumed we don't want to return to the VM).
* If the VM_DEATH callback is active at the end, then this callback
* will notify the VM_DEATH callback if it's the last one.
*
* WARNING: No not 'return' or 'goto' out of the BEGIN_TRACKER_CALLBACK/END_TRACKER_CALLBACK
* block, this will mess up the count.
*/
#define BEGIN_TRACKER_CALLBACK() \
{ /* BEGIN OF TRACKER_CALLBACK */ \
if ( gdata->tracking_engaged != 0 ) { \
if (!gdata->vm_death_callback_active) { \
gdata->active_callbacks++; \
} \
} \
if ( !bypass ) { \
/* BODY OF TRACKER_CALLBACK CODE */
gdata->active_callbacks--; \
if (gdata->active_callbacks < 0) { \
} \
if (gdata->vm_death_callback_active) { \
if (gdata->active_callbacks == 0) { \
} \
} \
} \
} /* END OF TRACKER_CALLBACK */
/*
* Class: Tracker
* Method: nativeNewArray
*/
static void JNICALL
{
} END_TRACKER_CALLBACK();
}
/*
* Class: Tracker
* Method: nativeObjectInit
*/
static void JNICALL
{
} END_TRACKER_CALLBACK();
}
/*
* Class: Tracker
* Method: nativeCallSite
*/
static void JNICALL
{
} END_TRACKER_CALLBACK();
}
/*
* Class: Tracker
* Method: nativeReturnSite
*/
static void JNICALL
{
} END_TRACKER_CALLBACK();
}
/* ------------------------------------------------------------------- */
/* Set Java static field to turn on native code calls in Tracker. */
static void
{
return;
}
gdata->tracking_engaged = 0;
/* Activate or deactivate the injection code on the Java side */
}
}
void
{
}
void
{
set_engaged(env, 0);
}
{
int i;
return JNI_FALSE;
}
for ( i = 0 ; i < gdata->tracker_method_count ; i++ ) {
return JNI_TRUE;
}
}
return JNI_FALSE;
}
{
(void*)&Tracker_nativeNewArray },
(void*)&Tracker_nativeObjectInit },
(void*)&Tracker_nativeCallSite },
(void*)&Tracker_nativeReturnSite }
};
static struct {
char *name;
char *sig;
} tracker_methods[] =
{
};
void
tracker_setup_class(void)
{
HPROF_ASSERT(cnum!=0);
}
void
{
int i;
return;
}
(int)sizeof(tracker_methods)/(int)sizeof(tracker_methods[0]);
for ( i=0 ; i < gdata->tracker_method_count ; i++ ) {
}
}