diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-02-11 17:17:04 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-02-11 17:17:04 +0000 |
commit | b9b7d91c8b1464d9d5bfbf87187026f3762b7947 (patch) | |
tree | d006232c1bd8ee82552cf71f7b20dd78e9c4b5db /lib | |
parent | 978c2a9a6ce439c855d41c5574cde2c05d305dea (diff) |
Sync with libkern's copy. No functional change.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gmon/mcount.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/libc/gmon/mcount.c b/lib/libc/gmon/mcount.c index d5faba86654..f18b1b52089 100644 --- a/lib/libc/gmon/mcount.c +++ b/lib/libc/gmon/mcount.c @@ -1,4 +1,5 @@ -/* $OpenBSD: mcount.c,v 1.11 2010/05/09 15:56:08 kettenis Exp $ */ +/* $OpenBSD: mcount.c,v 1.12 2013/02/11 17:17:03 mpi Exp $ */ + /*- * Copyright (c) 1983, 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -41,10 +42,6 @@ * _mcount updates data structures that represent traversals of the * program's call graph edges. frompc and selfpc are the return * address and function address that represents the given call graph edge. - * - * Note: the original BSD code used the same variable (frompcindex) for - * both frompcindex and frompc. Any reasonable, modern compiler will - * perform this optimization. */ _MCOUNT_DECL(u_long frompc, u_long selfpc) __used; /* _mcount; may be static, inline, etc */ @@ -56,9 +53,21 @@ _MCOUNT_DECL(u_long frompc, u_long selfpc) long toindex; #ifdef _KERNEL int s; -#endif + /* + * Do not profile execution if memory for the current CPU + * desciptor and profiling buffers has not yet been allocated + * or if the CPU we are running on has not yet set its trap + * handler. + */ + if (gmoninit == 0) + return; + + if ((p = curcpu()->ci_gmon) == NULL) + return; +#else p = &_gmonparam; +#endif /* * check that we are profiling * and that we aren't recursively invoked. @@ -171,10 +180,8 @@ overflow: return; } -#ifndef lint /* * Actual definition of mcount function. Defined in <machine/profile.h>, * which is included by <sys/gmon.h>. */ MCOUNT -#endif |