Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

/callcap -Enable callcap profiling (Windows CE 5.0)

Windows CE 5.0
Send Feedback

This option causes the compiler to insert calls to profiling hooks at the beginning and end of each function.

You must compile profiling hooks without the callcap switch. If you compile the profiling hook functions with the callcap switch, the functions will perform infinite recursive calls to themselves.

The following code example, callcaphooks.c, shows a profiling hook function, _CAP_Enter_Function, for compilation without callcap.

// File: callcaphooks.c

#include <stdio.h>
int main();

void _CAP_Enter_Function(void *p) 
{
    if (p != main) 
        printf("Enter function   (at address %p) at %d\n", 
            p, GetTickCount());
        return;
}
void _CAP_Exit_Function(void *p) 
{
    if (p != main) 
        printf("Leaving function (at address %p) at %d\n", 
            p, GetTickCount());
    return;
}

The next example shows how callcap inserts calls to profiling hooks. To enable this, compile main with the callcap switch and link with the object file that contains the callcap hooks that compiled without callcap.

// File: main.c
#include <stdio.h>
double mul(double a, double b, int count)
{
    // The profiling hook, _CAP_Enter_Function() function, 
    // is called here with the address of this function.

    double r;

    // Simulate a long operation
    while (count-- > 0) 
        r = a * b;

    return a * b;

    // The profiling hook, _CAP_Exit_Function() function,
    // is called here with the address of this function.
}

The callcap switch inserts calls to the profiling hooks for all functions compiled with the callcap compiler switch.

int main()
{
    double d0 = 2.0, d1 = 4.0, result;

    // No profiling for printf, because the library function is not compiled with /callcap.
    printf("\n");     

Callcap profiling hooks are called after the function is entered and before leaving it. In contrast, the fastcap switch inserts calls to profiling hooks before calling the function and after returning the call.

    result = mul(d0, d1, 10000);
    return 0;
}

This form of profiling has lower overhead than the /fastcap - Enable fastcap profiling form but will not provide profiling information for external functions that have not been compiled with profiling enabled.

See Also

Compiler Options | /fastcap - Enable fastcap profiling


Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.


Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.