old versions; put these to bed
[unix-history] / usr / src / lib / libc / gmon / gmon.c
index ace54df..1c9f0d6 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)gmon.c      1.8 (Berkeley) %G%";
+static char *sccsid = "@(#)gmon.c      4.4 (Berkeley) %G%";
 
 #ifdef DEBUG
 #include <stdio.h>
 
 #ifdef DEBUG
 #include <stdio.h>
@@ -48,14 +48,15 @@ start()
        /*
         *      ALL REGISTER VARIABLES!!!
         */
        /*
         *      ALL REGISTER VARIABLES!!!
         */
-    register struct kframe     *kfp;           /* r11 */
+    register int               r11;            /* init needs r11 */
+    register struct kframe     *kfp;           /* r10 */
     register char              **targv;
     register char              **argv;
 
 #ifdef lint
     kfp = 0;
 #else not lint
     register char              **targv;
     register char              **argv;
 
 #ifdef lint
     kfp = 0;
 #else not lint
-    asm( "     movl    sp,r11" );              /* catch it quick */
+    asm( "     movl    sp,r10" );              /* catch it quick */
 #endif not lint
     for ( argv = targv = &kfp -> kargv[0] ; *targv++ ; /* void */ )
        /* VOID */ ;
 #endif not lint
     for ( argv = targv = &kfp -> kargv[0] ; *targv++ ; /* void */ )
        /* VOID */ ;
@@ -89,6 +90,7 @@ static unsigned short tolimit = 0;
 static char            *s_lowpc = 0;
 static char            *s_highpc = 0;
 static unsigned long   s_textsize = 0;
 static char            *s_lowpc = 0;
 static char            *s_highpc = 0;
 static unsigned long   s_textsize = 0;
+static char            *minsbrk = 0;
 
 static int     ssiz;
 static int     *sbuf;
 
 static int     ssiz;
 static int     *sbuf;
@@ -296,3 +298,23 @@ monitor( lowpc , highpc , buf , bufsiz )
        o = 65536;
     profil( buf , bufsiz , lowpc , o );
 }
        o = 65536;
     profil( buf , bufsiz , lowpc , o );
 }
+
+/*
+ * This is a stub for the "brk" system call, which we want to
+ * catch so that it will not deallocate our data space.
+ * (of which the program is not aware)
+ */
+asm("#define _curbrk curbrk");
+extern char *curbrk;
+
+brk(addr)
+       char *addr;
+{
+
+       if (addr < minsbrk)
+               addr = minsbrk;
+       asm("   chmk    $17");
+       asm("   jcs     cerror");
+       curbrk = addr;
+       return (0);
+}