示例#1
0
/*
 * This function allows the user to query in which mode, if at all, 
 *VTune is running
 */
ITT_EXTERN_C iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive()
{
    if (!iJIT_DLL_is_missing)
    {
        loadiJIT_Funcs();
    }

    return executionMode;
}
示例#2
0
/* The new mode call back routine */
ITT_EXTERN_C void JITAPI 
iJIT_RegisterCallbackEx(void *userdata, iJIT_ModeChangedEx 
                        NewModeCallBackFuncEx) 
{
    /* is it already missing... or the load of functions from the DLL failed */
    if (iJIT_DLL_is_missing || !loadiJIT_Funcs())
    {
        /* then do not bother with notifications */
        NewModeCallBackFuncEx(userdata, iJIT_NO_NOTIFICATIONS);  
        /* Error: could not load JIT functions. */
        return;
    }
    /* nothing to do with the callback */
}
示例#3
0
ITT_EXTERN_C int JITAPI
iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData)
{
    int ReturnValue = 0;

    /* initialization part - the collector has not been loaded yet. */
    if (!FUNC_NotifyEvent)
    {
        if (iJIT_DLL_is_missing)
            return 0;

        if (!loadiJIT_Funcs())
            return 0;
    }

    if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED ||
        event_type == iJVM_EVENT_TYPE_METHOD_UPDATE)
    {
        if (((piJIT_Method_Load)EventSpecificData)->method_id == 0)
            return 0;
    }
    else if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2)
    {
        if (((piJIT_Method_Load_V2)EventSpecificData)->method_id == 0)
            return 0;
    }
    else if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3)
    {
        if (((piJIT_Method_Load_V3)EventSpecificData)->method_id == 0)
            return 0;
    }
    else if (event_type == iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED)
    {
        if (((piJIT_Method_Inline_Load)EventSpecificData)->method_id == 0 ||
            ((piJIT_Method_Inline_Load)EventSpecificData)->parent_method_id == 0)
            return 0;
    }

    if (FUNC_NotifyEvent)
    {
        ReturnValue = (int)FUNC_NotifyEvent(event_type, EventSpecificData);
    }

    return ReturnValue;
}
示例#4
0
ITT_EXTERN_C int JITAPI 
iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData)
{
    int ReturnValue;

    /*
     * This section is for debugging outside of VTune. 
     * It creates the environment variables that indicates call graph mode.
     * If running outside of VTune remove the remark.
     *
     *
     * static int firstTime = 1;
     * char DoCallGraph[12] = "DoCallGraph";
     * if (firstTime)
     * {
     * firstTime = 0;
     * SetEnvironmentVariable( "BISTRO_COLLECTORS_DO_CALLGRAPH", DoCallGraph);
     * }
     *
     * end of section.
    */

    /* initialization part - the functions have not been loaded yet. This part
     *        will load the functions, and check if we are in Call Graph mode. 
     *        (for special treatment).
     */
    if (!FUNC_NotifyEvent) 
    {
        if (iJIT_DLL_is_missing) 
            return 0;

        /* load the Function from the DLL */
        if (!loadiJIT_Funcs()) 
            return 0;

        /* Call Graph initialization. */
    }

    /* If the event is method entry/exit, check that in the current mode 
     * VTune is allowed to receive it
     */
    if ((event_type == iJVM_EVENT_TYPE_ENTER_NIDS || 
         event_type == iJVM_EVENT_TYPE_LEAVE_NIDS) &&
        (executionMode != iJIT_CALLGRAPH_ON))
    {
        return 0;
    }
    /* This section is performed when method enter event occurs.
     * It updates the virtual stack, or creates it if this is the first 
     * method entry in the thread. The stack pointer is decreased.
     */
    if (event_type == iJVM_EVENT_TYPE_ENTER_NIDS)
    {
#if ITT_PLATFORM==ITT_PLATFORM_WIN
        pThreadStack threadStack = 
            (pThreadStack)TlsGetValue (threadLocalStorageHandle);
#else  /* ITT_PLATFORM==ITT_PLATFORM_WIN */
        pThreadStack threadStack = 
            (pThreadStack)pthread_getspecific(threadLocalStorageHandle);
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */

        /* check for use of reserved method IDs */
        if ( ((piJIT_Method_NIDS) EventSpecificData)->method_id <= 999 )
            return 0;

        if (!threadStack)
        {
            /* initialize the stack. */
            threadStack = (pThreadStack) calloc (sizeof(ThreadStack), 1);
            threadStack->TopStack = INIT_TOP_Stack;
            threadStack->CurrentStack = INIT_TOP_Stack;
#if ITT_PLATFORM==ITT_PLATFORM_WIN
            TlsSetValue(threadLocalStorageHandle,(void*)threadStack);
#else  /* ITT_PLATFORM==ITT_PLATFORM_WIN */
            pthread_setspecific(threadLocalStorageHandle,(void*)threadStack);
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
        }

        /* decrease the stack. */
        ((piJIT_Method_NIDS) EventSpecificData)->stack_id = 
            (threadStack->CurrentStack)--;
    }

    /* This section is performed when method leave event occurs
     * It updates the virtual stack.
     *    Increases the stack pointer.
     *    If the stack pointer reached the top (left the global function)
     *        increase the pointer and the top pointer.
     */
    if (event_type == iJVM_EVENT_TYPE_LEAVE_NIDS)
    {
#if ITT_PLATFORM==ITT_PLATFORM_WIN
        pThreadStack threadStack = 
           (pThreadStack)TlsGetValue (threadLocalStorageHandle);
#else  /* ITT_PLATFORM==ITT_PLATFORM_WIN */
        pThreadStack threadStack = 
            (pThreadStack)pthread_getspecific(threadLocalStorageHandle);
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */

        /* check for use of reserved method IDs */
        if ( ((piJIT_Method_NIDS) EventSpecificData)->method_id <= 999 )
            return 0;

        if (!threadStack)
        {
            /* Error: first report in this thread is method exit */
            exit (1);
        }

        ((piJIT_Method_NIDS) EventSpecificData)->stack_id = 
            ++(threadStack->CurrentStack) + 1;

        if (((piJIT_Method_NIDS) EventSpecificData)->stack_id 
               > threadStack->TopStack)
            ((piJIT_Method_NIDS) EventSpecificData)->stack_id = 
                (unsigned int)-1;
    }

    if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED)
    {
        /* check for use of reserved method IDs */
        if ( ((piJIT_Method_Load) EventSpecificData)->method_id <= 999 )
            return 0;
    }

    ReturnValue = (int)FUNC_NotifyEvent(event_type, EventSpecificData);   

    return ReturnValue;
}