Step 1: Enable the trace
Enable and disable the trace from your software that has the trace hooks defined.
The following code shows the use of trace events to time the running of a program loop.
#include <sys/trcctl.h>
#include <sys/trcmacros.h>
#include <sys/trchkid.h>
char *ctl_file = "/dev/systrctl";
int ctlfd;
int i;
main()
{
printf("configuring trace collection \n");
if (trcstart("-ad")){
perror("trcstart");
exit(1);
}
printf("turning trace on \n");
if(trcon(0)){
perror("TRCON");
exit(1);
}
/* here is the code that is being traced */
for(i=1;i<11;i++){
TRCHKL1T(HKWD_USER1,i);
/* sleep(1) */
/* you can uncomment sleep to make the loop
/* take longer. If you do, you will want to
/* filter the output or you will be */
/* overwhelmed with 11 seconds of data */
}
/* stop tracing code */
printf("turning trace off\n");
if(trcstop(0)){
perror("TRCOFF");
exit(1);
}