profile.c
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* 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