Home | History | Annotate | Download | only in gmon
History log of /src/lib/libc/gmon/gmon.c
RevisionDateAuthorComments
 1.37  06-May-2022  rin PR lib/56395
PR toolchain/56771

Fix profiling on CPUs that do not support unaligned memory access;
Allocate objects (referenced from struct gmonparam) with proper
alignments.

For monstartup(), objects are allocated on heap. Break is not
guaranteed to be aligned at all, unlike stack pointer.

For _m_gmon_alloc(), objects are allocated on anonymous memory.
p->tos is not aligned properly in general.

This fixes quasi-random crashes for *_profile tests, at least on
SH-4 and PowerPC 403 [1]. Also, no regression is observed for
others as far as I can see.

This change does not cause any ABI breakage, as long as application
uses proper pointers; use p->tos instead of evil pointer arithmetic
like (struct tostruct *)((char *)p->froms + p->fromssize) [2].

[1] Timeout should be increased for some tests. "pic" variants
still fail as expected. Dynamically-linked binaries also crash in
rtld for SH-4, but this seems different problem...

[2] This example did not work even before, since the order of
froms[] and tos[] is reversed depending on which of monstartup() or
_m_gmon_alloc() is used for allocation.
 1.36  03-Jul-2021  christos PR/56246: Yuichiro Naito: gprof(1) never show call graphs when profiling
multi-threaded application
 1.35  18-Sep-2014  christos make more descriptors that we open as close-on-exec
 1.34  13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.33  05-Jan-2011  wiz branches: 1.33.6;
Fix fdleak in #ifdef DEBUG. Found by cppcheck.
 1.32  01-Mar-2010  christos - KNF
- fix hertz()
- fix error and warning messages
 1.31  17-Jan-2010  wiz Close log file handle after using it. Found by cppcheck.
 1.30  12-Feb-2009  lukem sign-compare fixes
 1.29  15-Oct-2006  christos branches: 1.29.28;
fix incomplete initializers
 1.28  04-Oct-2006  christos don't include <sys/param.h> twice.
 1.27  04-Oct-2006  dogcow use rownddown/rowndup in sys/param.h instead of their now-deleted UC equivs
formerly in sys/gmon.h.
 1.26  11-May-2006  mrg in _m_gmon_destructor(0 when traversing the list, add (void *) to the cast
chain.
 1.25  24-Jan-2006  christos fix debugging printf formats.
 1.24  24-Jan-2006  christos fix compilation with -DDEBUG
 1.23  29-Nov-2005  christos WARNS=4
 1.22  10-May-2004  thorpej Make gmon / mcount work properly for threaded applications by keeping
thread-specific gmonparam structures and then merging them before dumping
the profile buffers.

Written by Nathan J. Williams, contributed by Wasabi Systems, Inc.
 1.21  07-Aug-2003  agc branches: 1.21.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.20  06-Apr-2003  dsl Use snprintf instead of hand crafted string copy and numeric conversion.
Avoids problems if/when the pid is greater than 999999.
(approved by christos)
 1.19  11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.18  26-Apr-2002  christos disable profiling set{u,g}id binaries.
 1.17  19-Feb-2001  cgd branches: 1.17.2;
convert from __progname to getprogname()
 1.16  20-Dec-2000  christos fix nested extern
fix sbrk casts
 1.15  14-Jan-1999  kleink branches: 1.15.10;
* On architectures using ELF, and conditionally on those in transition, rename
_ASM_LABEL(cerror) and _ASM_LABEL(curbrk) to _C_LABEL(__cerror) and
_C_LABEL(__curbrk) (or their respective architecture-specific equivalents) to
avoid possible name clashes with identifiers used in user applications.
* Do the same for minbrk on all architectures to avoid a GCC-specific (and
on ELF architectures effectively useless) symbol reference renaming in MI code.
 1.14  13-Nov-1998  christos delint
 1.13  10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.12  04-Jul-1998  kleink Prefer STDERR_FILENO over 2.
 1.11  03-Feb-1998  perry remove obsolete register declarations
 1.10  13-Jul-1997  christos Fix RCSID's
Use warn instead of perror()
Use "namespace.h"
Add missing prototypes
 1.9  22-Apr-1997  mrg be safe with buffers. KNF.
 1.8  23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.7  19-Dec-1996  cgd use __inline and __asm, rather than inline and asm. By default (without -g)
lint won't accept the latter two, but will accept the former two as valid.
As far as gcc's concerned, they're the same.
 1.6  12-Jun-1996  cgd branches: 1.6.2;
use p->hashfraction when doing non-time-critical calculations, rather than
using HASHFRACTION directly. in time-critical calculations, if HASHFRACTION
is a power of two, check that p->hashfraction == HASHFRACTION and if so do
the calculation with the compiled-in value so that the compiler can optimize
out (potentially) expensive divisions. if p->hashfraction != HASHFRACTION,
actually do the division. This has the result that on machines with slow
division, the division can be optimized out of the common case, but that
if HASHFRACTION changes from the compiled-in value (for whatever reason),
profiling will still work. Changes suggested by Chris Torek.
 1.5  21-Nov-1995  jtc branches: 1.5.4;
Add support for PROFDIR environment variable
 1.4  04-Nov-1995  cgd kill a gratuitous cast of lowpc to an int
 1.3  27-Feb-1995  cgd clean up Ids
 1.2  14-May-1994  cgd branches: 1.2.4;
rcsids. also, avoid floating point when picking scale value. doesn't
cost much, only done once.
 1.1  14-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1  14-May-1994  cgd user-land profiling code.
 1.2.4.1  02-May-1995  jtc #include "namespace.h"
 1.5.4.1  12-Jun-1996  cgd pull up from trunk:
>use p->hashfraction when doing non-time-critical calculations, rather than
>using HASHFRACTION directly. in time-critical calculations, if HASHFRACTION
>is a power of two, check that p->hashfraction == HASHFRACTION and if so do
>the calculation with the compiled-in value so that the compiler can optimize
>out (potentially) expensive divisions. if p->hashfraction != HASHFRACTION,
>actually do the division. This has the result that on machines with slow
>division, the division can be optimized out of the common case, but that
>if HASHFRACTION changes from the compiled-in value (for whatever reason),
>profiling will still work. Changes suggested by Chris Torek.
 1.6.2.1  20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.15.10.1  26-Apr-2002  he Pull up revision 1.18 (requested by christos):
Refuse to open gmon.out file if we are set{u,g}id, and not executing
as the owner/group.
 1.17.2.2  11-Nov-2002  nathanw Catch up to -current
 1.17.2.1  21-Jun-2002  nathanw Catch up to -current.
 1.21.2.1  11-May-2004  tron Pull up revision 1.22 (requested by thorpej in ticket #308):
Make gmon / mcount work properly for threaded applications by keeping
thread-specific gmonparam structures and then merging them before
dumping
the profile buffers.
Written by Nathan J. Williams, contributed by Wasabi Systems, Inc.
 1.29.28.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.33.6.1  17-Apr-2012  yamt sync with head

RSS XML Feed