diff options
author | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2023-03-23 11:46:08 -0700 |
---|---|---|
committer | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2023-03-27 11:47:52 -0700 |
commit | 66f76c545b293f8b89fef0f996a3a48fa59fae61 (patch) | |
tree | 156a39c23f3c0e0dd694ee12e0a921b248ede4d3 /gprofng/libcollector/collector.h | |
parent | 57573e54afb9f7ed957eec43dfd2830f2384c970 (diff) | |
download | gdb-66f76c545b293f8b89fef0f996a3a48fa59fae61.zip gdb-66f76c545b293f8b89fef0f996a3a48fa59fae61.tar.gz gdb-66f76c545b293f8b89fef0f996a3a48fa59fae61.tar.bz2 |
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.
Diffstat (limited to 'gprofng/libcollector/collector.h')
-rw-r--r-- | gprofng/libcollector/collector.h | 80 |
1 files changed, 22 insertions, 58 deletions
diff --git a/gprofng/libcollector/collector.h b/gprofng/libcollector/collector.h index 77957ec..12a6e15 100644 --- a/gprofng/libcollector/collector.h +++ b/gprofng/libcollector/collector.h @@ -32,9 +32,25 @@ #define CALL_REAL(x) (__real_##x) #define NULL_PTR(x) (__real_##x == NULL) +#define SYS_LIBC_NAME "libc.so.6" + +#ifdef __has_attribute +#if __has_attribute (__symver__) +#define SYMVER_ATTRIBUTE(sym, symver) __attribute__ ((__symver__ (#symver))) +#endif +#endif +#ifndef SYMVER_ATTRIBUTE +# define SYMVER_ATTRIBUTE(sym, symver) __asm__(".symver " #sym "," #symver); +#endif + #if defined(__MUSL_LIBC) #define dlvsym(f, nm, v) dlsym (f, nm) #define SIGEV_THREAD_ID 4 +#define DCL_FUNC_VER(REAL_DCL, sym, ver) +#else +#define DCL_FUNC_VER(REAL_DCL, sym, ver) \ + SYMVER_ATTRIBUTE (__collector_ ## sym, ver) \ + REAL_DCL (__collector_ ## sym, CALL_REAL (sym)) #endif extern hrtime_t __collector_start_time; @@ -51,7 +67,8 @@ extern int __collector_write_packet (struct DataHandle*, CM_Packet*); extern int __collector_write_string (struct DataHandle*, char*, int); extern FrameInfo __collector_get_frame_info (hrtime_t, int, void *); extern FrameInfo __collector_getUID (CM_Array *arg, FrameInfo uid); -extern int __collector_getStackTrace (void *buf, int size, void *bptr, void *eptr, void *arg); +extern int __collector_getStackTrace (void *buf, int size, void *bptr, + void *eptr, void *arg); extern void *__collector_ext_return_address (unsigned level); extern void __collector_mmap_fork_child_cleanup (); @@ -83,10 +100,8 @@ extern void __collector_ext_dispatcher_restart (); extern void __collector_ext_dispatcher_deinstall (); extern void __collector_ext_usage_sample (Smpl_type type, char *name); extern void __collector_ext_profile_handler (siginfo_t *, ucontext_t *); -extern int __collector_ext_clone_pthread (int (*fn)(void *), void *child_stack, int flags, void *arg, - va_list va /* pid_t *ptid, struct user_desc *tlspid_t *" ctid" */); - -/* D-light related functions */ +extern int __collector_ext_clone_pthread (int (*fn)(void *), void *child_stack, + int flags, void *arg, va_list va); extern int __collector_sigprof_install (); extern int __collector_ext_hwc_active (); extern void __collector_ext_hwc_check (siginfo_t *, ucontext_t *); @@ -98,7 +113,8 @@ extern int (*__collector_VM_ReadByteInstruction)(unsigned char *); extern int (*__collector_omp_stack_trace)(char*, int, hrtime_t, void*); extern hrtime_t (*__collector_gethrtime)(); extern int (*__collector_mpi_stack_trace)(char*, int, hrtime_t); -extern int __collector_open_experiment (const char *exp, const char *par, sp_origin_t origin); +extern int __collector_open_experiment (const char *exp, const char *par, + sp_origin_t origin); extern void __collector_suspend_experiment (char *why); extern void __collector_resume_experiment (); extern void __collector_clean_state (); @@ -198,56 +214,4 @@ enum #endif /* DEBUG */ -// To find the glibc version: -// objdump -T /lib*/*so /lib*/*/*.so | grep popen -// IMPORTANT: The GLIBC_* versions below must match those in mapfile.<variant> - #if ARCH(Aarch64) - #define SYS_LIBC_NAME "libc.so.6" - #define SYS_PTHREAD_CREATE_VERSION "GLIBC_2.17" - #define SYS_DLOPEN_VERSION "GLIBC_2.17" - #define SYS_POPEN_VERSION "GLIBC_2.17" - #define SYS_FOPEN_X_VERSION "GLIBC_2.17" - #define SYS_FGETPOS_X_VERSION "GLIBC_2.17" - -#elif ARCH(Intel) - #define SYS_LIBC_NAME "libc.so.6" - #define SYS_POSIX_SPAWN_VERSION "GLIBC_2.15" - #if WSIZE(32) - #define SYS_PTHREAD_CREATE_VERSION "GLIBC_2.1" - #define SYS_DLOPEN_VERSION "GLIBC_2.1" - #define SYS_POPEN_VERSION "GLIBC_2.1" - #define SYS_TIMER_X_VERSION "GLIBC_2.2" - #define SYS_FOPEN_X_VERSION "GLIBC_2.1" - #define SYS_FGETPOS_X_VERSION "GLIBC_2.2" - #define SYS_FGETPOS64_X_VERSION "GLIBC_2.2" - #define SYS_OPEN64_X_VERSION "GLIBC_2.2" - #define SYS_PREAD_X_VERSION "GLIBC_2.2" - #define SYS_PWRITE_X_VERSION "GLIBC_2.2" - #define SYS_PWRITE64_X_VERSION "GLIBC_2.2" - #else /* WSIZE(64) */ - #define SYS_PTHREAD_CREATE_VERSION "GLIBC_2.2.5" - #define SYS_DLOPEN_VERSION "GLIBC_2.2.5" - #define SYS_POPEN_VERSION "GLIBC_2.2.5" - #define SYS_TIMER_X_VERSION "GLIBC_2.3.3" - #define SYS_FOPEN_X_VERSION "GLIBC_2.2.5" - #define SYS_FGETPOS_X_VERSION "GLIBC_2.2.5" - #endif - - #elif ARCH(SPARC) - #define SYS_LIBC_NAME "libc.so.6" - #define SYS_DLOPEN_VERSION "GLIBC_2.1" - #if WSIZE(32) - #define SYS_PTHREAD_CREATE_VERSION "GLIBC_2.1" - #define SYS_POPEN_VERSION "GLIBC_2.1" - #define SYS_FOPEN_X_VERSION "GLIBC_2.1" - #define SYS_FGETPOS_X_VERSION "GLIBC_2.2" - #else /* WSIZE(64) */ - #define SYS_PTHREAD_CREATE_VERSION "GLIBC_2.2" - #define SYS_POPEN_VERSION "GLIBC_2.2" - #define SYS_TIMER_X_VERSION "GLIBC_2.3.3" - #define SYS_FOPEN_X_VERSION "GLIBC_2.2" - #define SYS_FGETPOS_X_VERSION "GLIBC_2.2" - #endif - #endif - #endif |