- asm(" .text"); /* make sure we're in text space */
- /*
- * Check that we are profiling.
- */
- if (profiling)
- goto out;
- /*
- * Find the return address for mcount,
- * and the return address for mcount's caller.
- */
-#ifdef lint
- selfpc = (char *)0;
- frompcindex = 0;
-#else
- ; /* avoid label botch */
-#ifdef __GNUC__
-#if defined(vax)
- Fix Me!!
-#endif
-#if defined(tahoe)
- Fix Me!!
-#endif
-#if defined(hp300)
- /*
- * selfpc = pc pushed by mcount jsr,
- * frompcindex = pc pushed by jsr into self.
- * In GCC the caller's stack frame has already been built so we
- * have to chase a6 to find caller's raddr. This assumes that all
- * routines we are profiling were built with GCC and that all
- * profiled routines use link/unlk.
- */
- asm("movl a6@(4),%0" : "=r" (selfpc));
- asm("movl a6@(0)@(4),%0" : "=r" (frompcindex));
-#endif
-#else
-#if defined(vax)
- asm(" movl (sp), r11"); /* selfpc = ... (jsb frame) */
- asm(" movl 16(fp), r10"); /* frompcindex = (calls frame) */
-#endif
-#if defined(tahoe)
- asm(" movl -8(fp),r12"); /* selfpc = callf frame */
- asm(" movl (fp),r11");
- asm(" movl -8(r11),r11"); /* frompcindex = 1 callf frame back */
-#endif
-#if defined(hp300)
- asm(" .text"); /* make sure we're in text space */
- asm(" movl a6@(4),a5"); /* selfpc = pc pushed by mcount jsr */
- asm(" movl a6@(8),a4"); /* frompcindex = pc pushed by jsr into
- self, stack frame not yet built */
-#endif
-#endif /* not __GNUC__ */
-#endif /* not lint */
- /*
- * Insure that we cannot be recursively invoked.
- * this requires that splhigh() and splx() below
- * do NOT call mcount!
- */
-#if defined(hp300) && defined(__GNUC__)
- asm("movw sr,%0" : "=g" (s));
- asm("movw #0x2700,sr");
-#else
- s = splhigh();
-#endif
- /*
- * Check that frompcindex is a reasonable pc value.
- * For example: signal catchers get called from the stack,
- * not from text space. too bad.
- */
- frompcindex = (u_short *)((long)frompcindex - (long)s_lowpc);
- if ((u_long)frompcindex > s_textsize)
- goto done;
- frompcindex =
- &froms[((long)frompcindex) / (HASHFRACTION * sizeof (*froms))];
- toindex = *frompcindex;
- if (toindex == 0) {
- /*
- * First time traversing this arc
- */
- toindex = ++tos[0].link;
- if (toindex >= tolimit)
- goto overflow;
- *frompcindex = toindex;
- top = &tos[toindex];
- top->selfpc = selfpc;
- top->count = 1;
- top->link = 0;
- goto done;
- }
- top = &tos[toindex];
- if (top->selfpc == selfpc) {
- /*
- * Arc at front of chain; usual case.
- */
- top->count++;
- goto done;
+ if (ticks == 0)
+ return;
+ prof = &p->p_stats->p_prof;
+ if (pc < prof->pr_off ||
+ (i = PC_TO_INDEX(pc, prof)) >= prof->pr_size)
+ return; /* out of range; ignore */
+
+ addr = prof->pr_base + i;
+ if ((v = fuswintr(addr)) == -1 || suswintr(addr, v + ticks) == -1) {
+ prof->pr_addr = pc;
+ prof->pr_ticks = ticks;
+ need_proftick(p);