profile.c 1.67 KB
/*
 * Copyright (C) 1996-1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * 
 * This file is part of the SimOS distribution. 
 * See LICENSE file for terms of the license. 
 *
 */

/*****************************************************************
 * profile.c
 * 
 * Profiling support for simos. You must use a special "prof" to
 * view the results generated here. We currently only support
 * profiling on the SGI platform. 
 *
 * $Author: blythe $
 * $Date: 2002/05/29 01:09:10 $
 *****************************************************************/

#include <sys/types.h> 
#include <sys/time.h>
#include <fcntl.h>
#include <stdlib.h>
#include "simutil.h"
#include "sim_error.h"
#include "profile.h"

#ifdef PROFILING

#if defined(sgi)
#include <cmplrs/prof_header.h>
#include <sys/profil.h>

extern int monitor(int, int, void *, void *);
extern void moncontrol(int);
extern _ftext[];
extern etext[]; 
extern int errno;
#endif

void
StartProfile(void)
{
#ifdef sgi
    int err = 0;

    err = monitor(0, 1, _ftext, etext);
    if (err < 0) {
       CPUWarning("Error enabling profiling, errno = %d\n", errno);
       return;
    }
    CPUWarning("SIMOS: Starting profile\n");
#else
    CPUWarning("SIMOS: Profiling only available on SGI's\n");
#endif
}

void 
StopProfile(void)
{
#ifdef sgi
   moncontrol(3);
   CPUWarning("SIMOS: Stopping profile\n");
   return;
#else
    CPUWarning("SIMOS: Profiling only available on SGI's\n");
#endif

}

#else
/* PROFILING IS NOT DEFINED */
void 
StartProfile(void)
{
   CPUWarning("SIMOS: Must define PROFILING to use profiling\n");
}

void 
StopProfile(void)
{
   CPUWarning("SIMOS: Must define PROFILING to use profiling\n");
}

#endif