gmon.c (30ac8b16e26c7779cd977f1e438094a4c56c8136) gmon.c (683728f17df00631d446d9dd5f49a622989203f2)
1/*-
2 * Copyright (c) 1983, 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 21 unchanged lines hidden (view full) ---

30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if !defined(lint) && defined(LIBC_SCCS)
35static char sccsid[] = "@(#)gmon.c 8.1 (Berkeley) 6/4/93";
36#endif
37
1/*-
2 * Copyright (c) 1983, 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 21 unchanged lines hidden (view full) ---

30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if !defined(lint) && defined(LIBC_SCCS)
35static char sccsid[] = "@(#)gmon.c 8.1 (Berkeley) 6/4/93";
36#endif
37
38#ifndef __NETBSD_SYSCALLS
38#ifndef __alpha__
39
39#include <sys/param.h>
40#include <sys/time.h>
41#include <sys/gmon.h>
42#include <sys/sysctl.h>
43
40#include <sys/param.h>
41#include <sys/time.h>
42#include <sys/gmon.h>
43#include <sys/sysctl.h>
44
45#include <err.h>
46#include <errno.h>
44#include <stdio.h>
45#include <fcntl.h>
46#include <unistd.h>
47
48#if defined(__ELF__)
49extern char *minbrk asm (".minbrk");
50#else
51extern char *minbrk asm ("minbrk");
52#endif
53
47#include <stdio.h>
48#include <fcntl.h>
49#include <unistd.h>
50
51#if defined(__ELF__)
52extern char *minbrk asm (".minbrk");
53#else
54extern char *minbrk asm ("minbrk");
55#endif
56
57extern char *__progname;
58
54struct gmonparam _gmonparam = { GMON_PROF_OFF };
55
56static int s_scale;
57/* see profil(2) where this is describe (incorrectly) */
58#define SCALE_1_TO_1 0x10000L
59
60#define ERR(s) write(2, s, sizeof(s))
61

--- 72 unchanged lines hidden (view full) ---

134 int fromindex;
135 int endfrom;
136 u_long frompc;
137 int toindex;
138 struct rawarc rawarc;
139 struct gmonparam *p = &_gmonparam;
140 struct gmonhdr gmonhdr, *hdr;
141 struct clockinfo clockinfo;
59struct gmonparam _gmonparam = { GMON_PROF_OFF };
60
61static int s_scale;
62/* see profil(2) where this is describe (incorrectly) */
63#define SCALE_1_TO_1 0x10000L
64
65#define ERR(s) write(2, s, sizeof(s))
66

--- 72 unchanged lines hidden (view full) ---

139 int fromindex;
140 int endfrom;
141 u_long frompc;
142 int toindex;
143 struct rawarc rawarc;
144 struct gmonparam *p = &_gmonparam;
145 struct gmonhdr gmonhdr, *hdr;
146 struct clockinfo clockinfo;
147 char outname[128];
142 int mib[2];
143 size_t size;
144#ifdef DEBUG
145 int log, len;
146 char buf[200];
147#endif
148
149 if (p->state == GMON_PROF_ERROR)

--- 10 unchanged lines hidden (view full) ---

160 } else if (clockinfo.profhz == 0) {
161 if (clockinfo.hz != 0)
162 clockinfo.profhz = clockinfo.hz;
163 else
164 clockinfo.profhz = hertz();
165 }
166
167 moncontrol(0);
148 int mib[2];
149 size_t size;
150#ifdef DEBUG
151 int log, len;
152 char buf[200];
153#endif
154
155 if (p->state == GMON_PROF_ERROR)

--- 10 unchanged lines hidden (view full) ---

166 } else if (clockinfo.profhz == 0) {
167 if (clockinfo.hz != 0)
168 clockinfo.profhz = clockinfo.hz;
169 else
170 clockinfo.profhz = hertz();
171 }
172
173 moncontrol(0);
168 fd = open("gmon.out", O_CREAT|O_TRUNC|O_WRONLY, 0666);
174 snprintf(outname,sizeof(outname),"%s.gmon",__progname);
175 fd = open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666);
169 if (fd < 0) {
176 if (fd < 0) {
170 perror("mcount: gmon.out");
177 warnx("_mcleanup: %s - %s",outname,strerror(errno));
171 return;
172 }
173#ifdef DEBUG
174 log = open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664);
175 if (log < 0) {
178 return;
179 }
180#ifdef DEBUG
181 log = open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664);
182 if (log < 0) {
176 perror("mcount: gmon.log");
183 perror("_mcleanup: gmon.log");
177 return;
178 }
179 len = sprintf(buf, "[mcleanup1] kcount 0x%x ssiz %d\n",
180 p->kcount, p->kcountsize);
181 write(log, buf, len);
182#endif
183 hdr = (struct gmonhdr *)&gmonhdr;
184 hdr->lpc = p->lowpc;

--- 76 unchanged lines hidden ---
184 return;
185 }
186 len = sprintf(buf, "[mcleanup1] kcount 0x%x ssiz %d\n",
187 p->kcount, p->kcountsize);
188 write(log, buf, len);
189#endif
190 hdr = (struct gmonhdr *)&gmonhdr;
191 hdr->lpc = p->lowpc;

--- 76 unchanged lines hidden ---