Commit Graph

12 Commits

Author SHA1 Message Date
Alan Modra
fd67aa1129 Update year range in copyright notice of binutils files
Adds two new external authors to etc/update-copyright.py to cover
bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then
updates copyright messages as follows:

1) Update cgen/utils.scm emitted copyrights.
2) Run "etc/update-copyright.py --this-year" with an extra external
   author I haven't committed, 'Kalray SA.', to cover gas testsuite
   files (which should have their copyright message removed).
3) Build with --enable-maintainer-mode --enable-cgen-maint=yes.
4) Check out */po/*.pot which we don't update frequently.
2024-01-04 22:58:12 +10:30
Vladimir Mezentsev
53beac2e23 gprofng: Fix -Wformat= warnings
Added format attribute to several gprofng functions.
Fixed -Wformat= warnings.

gprofng/ChangeLog
2023-10-23  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	* libcollector/heaptrace.c: Fixed -Wformat= warnings.
	* libcollector/hwprofile.c: Likewise.
	* libcollector/iolib.c: Likewise.
	* libcollector/iotrace.c: Likewise.
	* libcollector/jprofile.c: Likewise.
	* libcollector/profile.c: Likewise.
	* libcollector/synctrace.c: Likewise.
	* src/ClassFile.cc: Likewise.
	* src/SourceFile.cc: Likewise.
	* libcollector/libcol_util.h: Added format attribute.
	* src/Emsg.h: Likewise.
	* src/collector_module.h: Likewise.
	* src/data_pckts.h: Define fld_sizeof.
2023-10-24 23:27:30 -07:00
Vladimir Mezentsev
35fab451d9 gprofng: 30360 Seg. Fault when application uses std::thread
We interpose a lot of libC functions (dlopen, fork, pthread_create, etc.).
Some of these functions have versions. For example,

% nm -D /lib64/gprofng/libgp-collector.so  | grep thread_create@ | sort
000000000004b420 T pthread_create@GLIBC_2.34
000000000004b490 T pthread_create@GLIBC_2.17
000000000004b500 T pthread_create@GLIBC_2.2.5
000000000004b570 T pthread_create@GLIBC_2.1
000000000004b5e0 T pthread_create@GLIBC_2.0

Our library does not set the default version for symbols.
This is correct because we don't know which libC will be used.

gcc and g++ links differently the version symbols when the default version is
not set. c-linker is using our pthread_create@GLIBC_2.34 and c++-linker is using
our pthread_create@GLIBC_2.0 by default.

The current implementation of the interposed functions is:
  If we are in our pthread_create@GLIBC_<NN>,
  we use dlvsym (dlflag, "pthread_create", "GLIBC_<NN>") to find and call
  the same function from libC.
In the test from PR 30360, pthread_create@GLIBC_2.0 is not in the current libC.
We need to call the default version symbol from libC.

gprofng/ChangeLog
2023-04-16  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/30360
	* libcollector/iotrace.c: Find and call a default libC version symbol.
	* libcollector/dispatcher.c: Likewise.
	* libcollector/iotrace.c: Likewise.
	* libcollector/linetrace.c: Likewise.
	* libcollector/mmaptrace.c: Likewise.
	* libcollector/synctrace.c: Likewise.
	* libcollector/collector.h (REAL_DCL): Remove an unused argument.
2023-04-17 13:01:38 -07:00
Vladimir Mezentsev
f2f9bde5cd gprofng: Add version symbols to libgprofng.ver
gprofng/ChangeLog
2023-03-29  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/30089
	* libcollector/libgprofng.ver: Add version symbols.
	* libcollector/synctrace.c: Fix typo for pthread_mutex_lock.
2023-03-29 23:09:40 -07:00
Vladimir Mezentsev
66f76c545b gprofng: 30089 [display text] Invalid number of threads
The real problem is that libcollector doesn't interpose thread_create@GLIBC_2.34
We interpose a lot of libC functions (dlopen, fork, pthread_create, etc.).
Some of these functions have versions. For example, dlopen@GLIBC_2.34,
dlopen@GLIBC_2.17, dlopen@GLIBC_2.2.5, etc.
We have to interpose each of the functions because we don't know
which version of libC will be used during profiling.
Historically, we have used three versions of scripts (mapfile.aarch64-Linux,
mapfile.amd64-Linux, mapfile.intel-Linux).
Three are not needed. One is enough

The fixes below include:
 - merged all version symbols into one version script.
 - added new version symbols which are defined in latest versions of libC.
 - removed unused defines and duplicated code.
 - added the DCL_FUNC_VER macro to define the version symbols.

Tested on x86_64 and aarch64 (OL8/OL9). No regression.

gprofng/ChangeLog
2023-03-23  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/30089
	* libcollector/Makefile.am: Use libgprofng.ver instead of mapfile.*
	* libcollector/configure.ac: Delete GPROFNG_VARIANT.
	* src/collector_module.h: Move the SYMVER_ATTRIBUTE macro to collector.h
	* libcollector/collector.h: Add macros (SYMVER_ATTRIBUTE, DCL_FUNC_VER).
	Remove unused defines.
	* libcollector/dispatcher.c: Interpose functions from libC.
	Clean up the old code.
	* libcollector/iotrace.c: Likewise.
	* libcollector/libcol_util.c: Likewise.
	* libcollector/linetrace.c: Likewise.
	* libcollector/mmaptrace.c: Likewise.
	* libcollector/synctrace.c: Likewise.
	* libcollector/libgprofng.ver: New file.
	* libcollector/Makefile.in: Rebuild.
	* libcollector/configure: Rebuild.
	* libcollector/mapfile.aarch64-Linux: Removed.
	* libcollector/mapfile.amd64-Linux: Removed.
	* libcollector/mapfile.intel-Linux: Removed.
	* libcollector/mapfile.sparc-Linux: Removed.
	* libcollector/mapfile.sparcv9-Linux: Removed.
2023-03-27 11:47:52 -07:00
Vladimir Mezentsev
de8e705968 gprofng: Use prototype to call libc functions
libcollector may not link against libC.
We use dlsym() to get a function from libc.
In some files, pointers to these functions do not have prototypes.
I also moved the shared definitions to libcollector/collect.h.

gprofng/ChangeLog
2023-03-15  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	libcollector/collector.c: Add prototypes.
	libcollector/dispatcher.c: Likewise.
	libcollector/heaptrace.c: Likewise.
	libcollector/iotrace.c: Likewise.
	libcollector/linetrace.c: Likewise.
	libcollector/mmaptrace.c: Likewise.
	libcollector/synctrace.c: Likewise.
	libcollector/collector.h: Add CALL_REAL(), NULL_PTR(), and DBG_LT.
2023-03-19 18:03:58 -07:00
Alan Modra
76bdc7266a Update year range in gprofng copyright notices
This adds 'Innovative Computing Labs' as an external author to
update-copyright.py, to cover the copyright notice in
gprofng/common/opteron_pcbe.c, and uses that plus another external
author 'Oracle and' to update gprofng copyright dates.  I'm not going
to commit 'Oracle and' as an accepted author, but that covers the
string "Copyright (c) 2006, 2012, Oracle and/or its affiliates. All
rights reserved." found in gprofng/testsuite/gprofng.display/jsynprog
files.
2023-01-01 23:26:30 +10:30
Vladimir Mezentsev
9c48ba47b3 gprofng: fix build with --enable-pgo-build=lto
gprofng/ChangeLog
2022-10-04  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/29579
	* libcollector/dispatcher.c: Fix the symbol version in SYMVER_ATTRIBUTE.
	* libcollector/iotrace.c: Likewise.
	* libcollector/linetrace.c: Likewise.
	* libcollector/mmaptrace.c: Likewise.
	* libcollector/synctrace.c: Likewise.
2022-10-04 19:59:49 -07:00
Vladimir Mezentsev
fe39ffdc20 gprofng: fix build issues on musl
gprofng/ChangeLog
2022-09-14  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/29477
	* configure.ac: Set __MUSL_LIBC.
	* configure: Rebuild.
	* common/config.h.in: Rebuild.
	* src/collector_module.h: Fix compiler errors because mmap64, open64,
	pwrite64 are macros and getcontext() is absent on musl.
	* libcollector/collector.c: Likewise.
	* libcollector/hwprofile.c: Likewise.
	* libcollector/iolib.c: Likewise.
	* libcollector/libcol_util.c: Likewise.
	* libcollector/linetrace.c: Likewise.
	* libcollector/memmgr.c: Likewise.
	* libcollector/profile.c: Likewise.
	* libcollector/unwind.c: Likewise.
	* libcollector/dispatcher.c: Likewise.
	* src/Experiment.cc: Likewise.
	* libcollector/collector.h: Use dlsym() because dlvsym() is not defined
	on musl.
	* libcollector/iotrace.c: Remove interposition of versioned functions.
	* libcollector/mmaptrace.c: Likewise.
	* libcollector/libcol_util.h: Fix -Wint-to-pointer-cast warnings.
	* libcollector/jprofile.c: Likewise.
	* libcollector/synctrace.c: Include "collector.h".
	* src/Print.cc: Use get_basename() because basename() is not defined
	on musl.
	* common/hwcdrv.c: Fix -Wformat= warnings.
2022-09-14 18:38:09 -07:00
Vladimir Mezentsev
2a2cb7cf2c gprofng: fix build with -mx32
gprofng/ChangeLog
2022-05-26  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/28983
	* libcollector/libcol_util.h (__collector_getsp, __collector_getfp,
	__collector_getpc): Adapt for build with -mx32
	* libcollector/heaptrace.c: Fix -Wpointer-to-int-cast warnings.
	* libcollector/hwprofile.h: Likewise.
	* libcollector/mmaptrace.c: Likewise.
	* libcollector/synctrace.c: Likewise.
	* libcollector/unwind.c: Likewise.
2022-05-26 23:27:50 -07:00
H.J. Lu
f4be26838d gprofng: Use symver attribute if available
Use symver attribute if available, instead of asm statement, to support
LTO build.

	PR gprof/28962
	* libcollector/dispatcher.c (timer_create@@GLIBC_2.3.3): Use
	SYMVER_ATTRIBUTE.
	(timer_create@GLIBC_2.2): Likewise.
	(timer_create@GLIBC_2.2.5): Likewise.
	(pthread_create@@GLIBC_2.1): Likewise.
	(pthread_create@GLIBC_2.0): Likewise.
	* libcollector/iotrace.c (open64@@GLIBC_2.2): Likewise.
	(open64@GLIBC_2.1): Likewise.
	(fopen@@GLIBC_2.1): Likewise.
	(fopen@GLIBC_2.0): Likewise.
	(fclose@@GLIBC_2.1): Likewise.
	(fclose@GLIBC_2.0): Likewise.
	(fdopen@@GLIBC_2.1): Likewise.
	(fdopen@GLIBC_2.0): Likewise.
	(pread@@GLIBC_2.2): Likewise.
	(pread@GLIBC_2.1): Likewise.
	(pwrite@@GLIBC_2.2): Likewise.
	(pwrite@GLIBC_2.1): Likewise.
	(pwrite64@@GLIBC_2.2): Likewise.
	(pwrite64@GLIBC_2.1): Likewise.
	(fgetpos@@GLIBC_2.2): Likewise.
	(fgetpos@GLIBC_2.0): Likewise.
	(fgetpos64@@GLIBC_2.2): Likewise.
	(fgetpos64@GLIBC_2.1): Likewise.
	(fsetpos@@GLIBC_2.2): Likewise.
	(fsetpos@GLIBC_2.0): Likewise.
	(fsetpos64@@GLIBC_2.2): Likewise.
	(fsetpos64@GLIBC_2.1): Likewise.
	* libcollector/linetrace.c (posix_spawn@@GLIBC_2.15): Likewise.
	(posix_spawn@GLIBC_2.2): Likewise.
	(posix_spawn@GLIBC_2.2.5): Likewise.
	(posix_spawnp@@GLIBC_2.15): Likewise.
	(posix_spawnp@GLIBC_2.2): Likewise.
	(posix_spawnp@GLIBC_2.2.5): Likewise.
	(popen@@GLIBC_2.1): Likewise.
	(popen@GLIBC_2.0): Likewise.
	(_popen@@GLIBC_2.1): Likewise.
	(_popen@GLIBC_2.0): Likewise.
	* libcollector/mmaptrace.c (dlopen@@GLIBC_2.1): Likewise.
	(dlopen@GLIBC_2.0): Likewise.
	* libcollector/synctrace.c (pthread_cond_wait@@GLIBC_2.3.2):
	Likewise.
	(pthread_cond_wait@GLIBC_2.0): Likewise.
	(pthread_cond_wait@GLIBC_2.2.5): Likewise.
	(pthread_cond_wait@GLIBC_2.2): Likewise.
	(pthread_cond_timedwait@@GLIBC_2.3.2): Likewise.
	(pthread_cond_timedwait@GLIBC_2.0): Likewise.
	(pthread_cond_timedwait@GLIBC_2.2.5): Likewise.
	(pthread_cond_timedwait@GLIBC_2.2): Likewise.
	(sem_wait@@GLIBC_2.1): Likewise.
	(sem_wait@GLIBC_2.0): Likewise.
	* src/collector_module.h (SYMVER_ATTRIBUTE): New.
2022-03-16 06:45:06 -07:00
Vladimir Mezentsev
bb368aad29 gprofng: a new GNU profiler
top-level
	* Makefile.def: Add gprofng module.
	* configure.ac: Add --enable-gprofng option.
	* src-release.sh: Add gprofng.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* gprofng: New directory.

binutils
	* MAINTAINERS: Add gprofng maintainer.
	* README-how-to-make-a-release: Add gprofng.

include.
	* collectorAPI.h: New file.
	* libcollector.h: New file.
	* libfcollector.h: New file.
2022-03-11 08:58:31 +00:00