aboutsummaryrefslogtreecommitdiff
path: root/gprofng
diff options
context:
space:
mode:
authorVladimir Mezentsev <vladimir.mezentsev@oracle.com>2024-01-19 18:40:21 -0800
committerVladimir Mezentsev <vladimir.mezentsev@oracle.com>2024-01-22 09:56:42 -0800
commitc37ad9ea1618969273b3a3b75278b0e96bb63a78 (patch)
treedc94b2e961e9d828fe08fc5a20f92afe1ee81f94 /gprofng
parente97522312be8a4e666aaa69ddd3f2107c1e38582 (diff)
downloadgdb-c37ad9ea1618969273b3a3b75278b0e96bb63a78.zip
gdb-c37ad9ea1618969273b3a3b75278b0e96bb63a78.tar.gz
gdb-c37ad9ea1618969273b3a3b75278b0e96bb63a78.tar.bz2
Fix 31252 gprofng causes testsuite parallel jobs fail
Before running our tests, we made a fake installation into ./tmpdir. This installation changes libopcodes.la in the build area. Gas testing may fail if gas and gprofng tests are run in parallel. I create a script to run gprofng. Inside this script, LD_LIBRARY_PATH, GPROFNG_SYSCONFDIR are set. putenv_libcollector_ld_misc() first uses $GPROFNG_PRELOAD_LIBDIRS to create directories for SP_COLLECTOR_LIBRARY_PATH ($SP_COLLECTOR_LIBRARY_PATH is used to set up LD_PRELOAD). gprofng/ChangeLog 2024-01-19 Vladimir Mezentsev <vladimir.mezentsev@oracle.com> PR gprofng/31252 PR gprofng/30808 * src/envsets.cc (putenv_libcollector_ld_misc): Use $GPROFNG_PRELOAD_LIBDIRS first to build SP_COLLECTOR_LIBRARY_PATH. * testsuite/config/default.exp: Create a script to run gprofng. * testsuite/lib/display-lib.exp: Fix typo.
Diffstat (limited to 'gprofng')
-rw-r--r--gprofng/src/envsets.cc36
-rw-r--r--gprofng/testsuite/config/default.exp37
-rw-r--r--gprofng/testsuite/lib/display-lib.exp4
3 files changed, 57 insertions, 20 deletions
diff --git a/gprofng/src/envsets.cc b/gprofng/src/envsets.cc
index 1ca39ed..9cef745 100644
--- a/gprofng/src/envsets.cc
+++ b/gprofng/src/envsets.cc
@@ -146,20 +146,42 @@ collect::putenv_libcollector_ld_misc ()
// so that -agentlib:gp-collector works
// and so that collect -F works with 32/64-bit mix of processes
- // Set GPROFNG_PRELOAD_LIBDIRS
+ StringBuilder sb;
+ sb.append ("SP_COLLECTOR_LIBRARY_PATH=");
+ int len = sb.length ();
+ int cnt = 0;
+ char *fname;
char *ev = getenv (GPROFNG_PRELOAD_LIBDIRS);
char *libpath_list = NULL;
- if (ev == NULL && settings->preload_libdirs == NULL)
+ if (ev)
+ { /* GPROFNG_PRELOAD_LIBDIRS is used only in the gprofng testing.
+ * Use these directories first. */
+ ev = strdup (ev);
+ for (char *s = ev; s;)
+ {
+ char *s1 = strchr (s, ':');
+ if (s1)
+ *(s1++) = 0;
+ fname = dbe_sprintf ("%s/%s", s, LIBGP_COLLECTOR);
+ if (access (fname, R_OK | F_OK) == 0)
+ {
+ if (++cnt != 1)
+ sb.append (':');
+ sb.append (s);
+ }
+ free (fname);
+ s = s1;
+ }
+ free (ev);
+ ev = NULL;
+ }
+ if (settings->preload_libdirs == NULL)
{
settings->read_rc (false);
ev = settings->preload_libdirs;
}
ev = dbe_strdup (ev);
- StringBuilder sb;
- sb.appendf ("%s=", "SP_COLLECTOR_LIBRARY_PATH");
- int len = sb.length ();
- int cnt = 0;
- char *fname = dbe_sprintf ("%s/%s/%s", LIBDIR, PACKAGE, LIBGP_COLLECTOR);
+ fname = dbe_sprintf ("%s/%s/%s", LIBDIR, PACKAGE, LIBGP_COLLECTOR);
if (access (fname, R_OK | F_OK) == 0)
{
++cnt;
diff --git a/gprofng/testsuite/config/default.exp b/gprofng/testsuite/config/default.exp
index e22d99b..6b51d57 100644
--- a/gprofng/testsuite/config/default.exp
+++ b/gprofng/testsuite/config/default.exp
@@ -19,6 +19,7 @@
# MA 02110-1301, USA.
#
+
# The "make check" target in the Makefile passes in
# "CC=$(CC_FOR_TARGET)". But, if the user invokes runtest directly,
# these flags may not be set.
@@ -36,18 +37,32 @@ remote_exec host "sh -c \"rm -rf tmpdir; mkdir -p tmpdir\""
if { "$CHECK_TARGET" == "check-install" } {
set ::env(GPROFNG) "$PREFIX/bin/gprofng"
} else {
- # Make a temporary install dir to run gprofng from, and point at it
- remote_exec host "sh -c \"$MAKE -C .. install-gprofng MAKEFLAGS=program_transform_name= DESTDIR=$BUILDDIR/tmpdir/root\""
- set ::env(GPROFNG) [exec find $BUILDDIR/tmpdir -type f -name gprofng -perm -u+x | head -1]
-
- set x [exec find $BUILDDIR/tmpdir -type d -name gprofng | head -1]
- set ::env(LD_LIBRARY_PATH) "$x:$x/.."
-
- set x [exec find $BUILDDIR/tmpdir -type f -name gprofng.rc | head -1]
- set ::env(GPROFNG_SYSCONFDIR) [exec dirname $x]
+ set ld_library_path "${BUILDDIR}/src/.libs:${BUILDDIR}/libcollector/.libs"
+ set orig_ld_library_path ""
+ catch { set orig_ld_library_path $::env(LD_LIBRARY_PATH) }
+ if [file exists "${BUILDDIR}/../bfd/.libs/libbfd.a"] {
+ append ld_library_path ":${BUILDDIR}/../bfd/.libs"
+ }
+ if [file exists "${BUILDDIR}/../opcodes/.libs/libopcodes.a"] {
+ append ld_library_path ":${BUILDDIR}/../opcodes/.libs"
+ }
+ if [file exists "${BUILDDIR}/../libsframe/.libs/libsframe.a"] {
+ append ld_library_path ":${BUILDDIR}/../libsframe/.libs"
+ }
+ if [file exists "${BUILDDIR}/../libiberty/libiberty.a"] {
+ append ld_library_path ":${BUILDDIR}/../libiberty"
+ }
- puts "### LD_LIBRARY_PATH: $env(LD_LIBRARY_PATH)"
- puts "### GPROFNG_SYSCONFDIR: $env(GPROFNG_SYSCONFDIR)"
+ set f [open "gprofng_wraper" w+]
+ puts $f "#!/usr/bin/bash"
+ puts $f "LD_LIBRARY_PATH=$ld_library_path:$orig_ld_library_path"
+ puts $f "GPROFNG_SYSCONFDIR=$env(srcroot)/src"
+ puts $f "GPROFNG_PRELOAD_LIBDIRS=$BUILDDIR/libcollector/.libs"
+ puts $f "export LD_LIBRARY_PATH GPROFNG_SYSCONFDIR GPROFNG_PRELOAD_LIBDIRS"
+ puts $f "${BUILDDIR}/src/gprofng \"\$@\""
+ close $f
+ file attributes gprofng_wraper -permissions +rx
+ set ::env(GPROFNG) "$BUILDDIR/gprofng_wraper"
}
puts "### GPROFNG: $env(GPROFNG)"
diff --git a/gprofng/testsuite/lib/display-lib.exp b/gprofng/testsuite/lib/display-lib.exp
index 4843c36..32e8ce5 100644
--- a/gprofng/testsuite/lib/display-lib.exp
+++ b/gprofng/testsuite/lib/display-lib.exp
@@ -26,8 +26,8 @@ proc run_native_host_cmd { command } {
verbose -log "$command"
set run_output ""
try {
- send_log "% timeout $TEST_TIMEOUT sh -c '$command' 2>&1\n"
- set run_output [exec "timeout" $TEST_TIMEOUT "sh" "-c" "$command" "2>&1"]
+ send_log "% timeout $TEST_TIMEOUT sh -c '$command' 2>@1\n"
+ set run_output [exec "timeout" $TEST_TIMEOUT "sh" "-c" "$command" "2>@1"]
set status 0
} trap CHILDSTATUS {results options} {
set status [lindex [dict get $options -errorcode] 2]