Attempted to use `gprofng` today and got the failure: $ gprofng collect app $(which ls) Creating experiment directory test.3.er (Process ID: 2240198) ... ...-coreutils-9.1/bin/ls: symbol lookup error: ..-binutils-2.39/bin/../lib/gprofng/libgp-collector.so: undefined symbol: __collector_jprofile_start_attach I think the failure happens because __collector_jprofile_start_attach() is conditionally enabled but used unconditionally: $ git grep -P '__collector_jprofile_start_attach|GPROFNG_JAVA_PROFILING' | cat # unconditional use and export: gprofng/libcollector/collector.c: __collector_jprofile_start_attach (); gprofng/libcollector/collector.h:extern int __collector_jprofile_start_attach (); # conditional definition: gprofng/libcollector/jprofile.c:#if defined(GPROFNG_JAVA_PROFILING) gprofng/libcollector/jprofile.c:int __collector_jprofile_start_attach (void); gprofng/libcollector/jprofile.c:__collector_jprofile_start_attach (void) gprofng/libcollector/jprofile.c:#endif /* GPROFNG_JAVA_PROFILING */
So far I worked it around locally by removing java-specific code in libcollector: --- a/gprofng/libcollector/collector.c +++ b/gprofng/libcollector/collector.c @@ -912,9 +912,11 @@ __collector_open_experiment (const char *exp, const char *params, sp_origin_t or /* init tsd for unwind, called right after __collector_tsd_allocate()*/ __collector_ext_unwind_key_init (1, NULL); +#if defined(GPROFNG_JAVA_PROFILING) /* start java attach if suitable */ if (exp_origin == SP_ORIGIN_DBX_ATTACH) __collector_jprofile_start_attach (); +#endif start_sec_time = CALL_UTIL (time)(NULL); __collector_start_time = collector_interface.getHiResTime (); TprintfT (DBG_LT0, "\t__collector_open_experiment; resetting start_time\n"); --- a/gprofng/libcollector/unwind.c +++ b/gprofng/libcollector/unwind.c @@ -557,6 +557,7 @@ __collector_get_frame_info (hrtime_t ts, int mode, void *arg) int size = max_frame_size; #define MIN(a,b) ((a)<(b)?(a):(b)) +#if defined(GPROFNG_JAVA_PROFILING) /* get Java info */ if (__collector_java_mode && __collector_java_asyncgetcalltrace_loaded && context && !pseudo_context) { @@ -569,6 +570,7 @@ __collector_get_frame_info (hrtime_t ts, int mode, void *arg) size -= sz; } } +#endif /* get native stack */ if (context) Is it a reasonable approach? Or should jprofile.c unconditionally define those functions? Say, with a possible no-op when `javac` is not available. What would be your preference?
Thanks for catching this. My ol8 and ol9 are not reporting anything. % gprofng collect app $(which ls) Creating experiment directory test.1.er (Process ID: 155186) ... acinclude.m4 common configure doc libcollector Makefile.in src testsuite aclocal.m4 config configure.ac gp-display-html Makefile.am README test.1.er These functions are undefined (but never called): % nm lib/gprofng/libgp-collector.so | egrep '__collector_jprofile_start_attach|__collector_ext_jstack_unwind' U __collector_ext_jstack_unwind U __collector_jprofile_start_attach I will push your fix to the master branch.
The master branch has been updated by Vladimir Mezentsev <vmezents@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=49ddd814ac1071af7c4f45d5f8398b91862f2c7f commit 49ddd814ac1071af7c4f45d5f8398b91862f2c7f Author: Vladimir Mezentsev <vladimir.mezentsev@oracle.com> Date: Wed Aug 17 19:55:23 2022 -0700 gprofng: fix bug 29479 Collection fails when built without java support gprofng/ChangeLog 2022-08-17 Vladimir Mezentsev <vladimir.mezentsev@oracle.com> PR gprofng/29479 * libcollector/collector.c: Add #if defined(GPROFNG_JAVA_PROFILING) for java specific code. * libcollector/unwind.c: Likewise.
Fixed in the master branch.