fixed: apparently, the profil system-call does not quite work as described

in the manual page?
This commit is contained in:
ceriel 1988-09-19 16:55:35 +00:00
parent 6d3e9fb7af
commit f8fb06210d

View file

@ -28,15 +28,15 @@ monitor(lowpc, highpc, buffer, bufsize, nfunc)
buffer += sizeof(char *); buffer += sizeof(char *);
*(char **) buffer = (char *) highpc; *(char **) buffer = (char *) highpc;
buffer += sizeof(char *); buffer += sizeof(char *);
*(short *) buffer = nfunc; *(int *) buffer = nfunc;
buffer += 2; buffer += sizeof(int);
buffer += (sizeof (char *) + sizeof(long)) * nfunc; buffer += (sizeof (char *) + sizeof(long)) * nfunc;
bufsize -= ((sizeof (char *) + sizeof(long)) * nfunc + 2 * sizeof(char *) + sizeof(int)) >> 1; bufsize -= ((sizeof (char *) + sizeof(long)) * nfunc + 2 * sizeof(char *) + sizeof(int)) >> 1;
if (bufsize < 0) return; if (bufsize < 0) return;
scale = ((char *) highpc - (char *) lowpc) >> 1; scale = ((char *) highpc - (char *) lowpc) >> 1;
if (bufsize < scale) if (bufsize < scale)
scale = ((long) bufsize << 15) / scale; scale = ((long) bufsize << 15) / scale;
else scale = 0x7fff; else scale = 0x8000;
bufp = buffer; bufp = buffer;
sc = scale << 1; sc = scale << 1;
bufs = bufsize << 1; bufs = bufsize << 1;
@ -45,7 +45,7 @@ monitor(lowpc, highpc, buffer, bufsize, nfunc)
moncontrol(mode) moncontrol(mode)
{ {
profil(bs, bufs, *(char **) bufp, !mode ? 0 : sc); profil(bufp, bufs, *(char **) bp, !mode ? 0 : sc);
} }
#define NCOUNTS 300 #define NCOUNTS 300
@ -53,7 +53,7 @@ moncontrol(mode)
monstartup(lowpc, highpc) monstartup(lowpc, highpc)
int (*lowpc)(), (*highpc)(); int (*lowpc)(), (*highpc)();
{ {
int sz = (((char *) highpc - (char *) lowpc + 7) & ~7) << 1; int sz = (((char *) highpc - (char *) lowpc + 7) & ~7);
char *s, *sbrk(); char *s, *sbrk();
sz += NCOUNTS * (sizeof(long) + sizeof(char *)) + 2 * sizeof(char *) + sizeof(int); sz += NCOUNTS * (sizeof(long) + sizeof(char *)) + 2 * sizeof(char *) + sizeof(int);