File:  [Research Unix] / researchv9 / libc / gen / mon.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:22:00 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv9-SUN3_old, researchv9-SUN3, HEAD
researchv9-SUN3(old)

int *_mcbase;
int _setmonexit = 1;

_monexit()
{
	monitor((char *)0, (char *)0, (int *)0, 0, 0);
}

monitor(lowpc, highpc, buf, bufsiz, cntsiz)
char *lowpc, *highpc;
int *buf, bufsiz;
{
	register o;
	static *sbuf, ssiz;
	struct phdr {
		int *lpc;
		int *hpc;
		int ncnt;
	};
	struct cnt {
		int *pc;
		long ncall;
	};

	if (lowpc == 0) {
		profil((short *)0, 0, 0, 0);
		o = creat("mon.out", 0666);
		write(o, sbuf, ssiz);
		close(o);
		return;
	}
	if(_setmonexit){
		_setmonexit = 0;
		onexit(_monexit);
	}
	sbuf = buf;
	ssiz = bufsiz;
	buf[0] = (int)lowpc;
	buf[1] = (int)highpc;
	buf[2] = cntsiz;
	_mcbase = (int *) (((int)buf) + sizeof(struct phdr));
	buf = (int *) (((int)_mcbase) + (o = cntsiz*sizeof(struct cnt)));
	bufsiz -= o + sizeof(struct phdr);
	memset((char *)_mcbase, 0, o);	/* clear counts */
	if (bufsiz<=0)
		return;
	o = bufsiz*65536.0/(highpc - lowpc);
	profil(buf, bufsiz, lowpc, o);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.