callgrind_annotate broken after cmake migration? #31957

issue maflcko openend this issue on February 26, 2025
  1. maflcko commented at 3:48 pm on February 26, 2025: member

    Steps to reproduce on a fresh install of Ubuntu LTS 24.04:

    • Install packages and clone repo: ( export DEBIAN_FRONTEND=noninteractive && apt update && apt install git ccache make build-essential libtool cmake autotools-dev automake pkg-config bsdmainutils python3 libevent-dev libboost-dev libsqlite3-dev valgrind -y && git clone https://github.com/bitcoin/bitcoin.git b-c ) && cd b-c
    • git checkout 338bc2cd261ba3daf7fb494f8cb4a534762e292c # cmake migration (allows to test autotools and cmake on the same commit)
    • Apply a diff to create more function calls in one hotspot (optional):
     0diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
     1index c2c725d676..704c060749 100644
     2--- a/src/test/util_tests.cpp
     3+++ b/src/test/util_tests.cpp
     4@@ -273,13 +273,15 @@ BOOST_AUTO_TEST_CASE(util_ReplaceAll)
     5         ReplaceAll(test, search, substitute);
     6         BOOST_CHECK_EQUAL(test, expected);
     7     };
     8-
     9+    int i{10000};
    10+while (i-->0){
    11     test_replaceall("", "foo", original);
    12     test_replaceall(original, "foo", "foo");
    13     test_replaceall("%s", "foo", "A test \"foo\" string 'foo'.");
    14     test_replaceall("\"", "foo", "A test foo%sfoo string '%s'.");
    15     test_replaceall("'", "foo", "A test \"%s\" string foo%sfoo.");
    16 }
    17+}
    18 
    19 BOOST_AUTO_TEST_CASE(util_TrimString)
    20 {
    
    • Then create two out-of-tree builds, run a test in callgrind, and annotate it:
    • ./autogen.sh && rm -rf ./bld-a && mkdir bld-a && ( cd bld-a && ../configure && make -j$(nproc) )
    • rm -rf ./bld-c && cmake -B ./bld-c && cmake --build ./bld-c -j $(nproc)
    • valgrind --tool=callgrind --callgrind-out-file=cg-a-%p.out ./bld-a/src/test/test_bitcoin -t util_tests/util_ReplaceAll
    • valgrind --tool=callgrind --callgrind-out-file=cg-c-%p.out ./bld-c/src/test/test_bitcoin -t util_tests/util_ReplaceAll
    • callgrind_annotate ./cg-a-40328.out
    • callgrind_annotate ./cg-c-39984.out

    The cmake version of the last call will print a warning:

     0--------------------------------------------------------------------------------
     1The following files chosen for auto-annotation could not be found:
     2--------------------------------------------------------------------------------
     3  ./bld-c/src/crypto/./src/compat/byteswap.h
     4  ./bld-c/src/crypto/./src/crypto/sha256.cpp
     5  ./bld-c/src/crypto/./src/crypto/sha512.cpp
     6  ./bld-c/src/test/./src/test/crypto_tests.cpp
     7  ./bld-c/src/test/./src/test/util_tests.cpp
     8  ./bld-c/src/util/./src/random.cpp
     9  ./bld-c/src/util/./src/util/string.cpp
    10...
    

    It also seems not possible to fix with --include=dir, as the path look a bit odd (non-existing)

  2. maflcko added the label Build system on Feb 26, 2025
  3. maflcko added the label Tests on Feb 26, 2025
  4. hebasto commented at 1:47 pm on March 26, 2025: member
    Are there any requirements for debug info when using the valgrind --tool=callgrind + callgrind_annotate toolset? Are there any incompatible or unsupported compiler flags?
  5. hebasto commented at 1:52 pm on March 26, 2025: member

    I’ve tested the master branch @ c0b7159de47592c95c6db061de682b4af4058102 with the diff from #31957#issue-2882058716 on Ubuntu 24.04:

     0$ callgrind_annotate ./cg-c-72381.out
     1<snip>
     2...
     3--------------------------------------------------------------------------------
     4The following files chosen for auto-annotation could not be found:
     5--------------------------------------------------------------------------------
     6  ./elf/../sysdeps/generic/dl-new-hash.h
     7  ./elf/../sysdeps/x86_64/dl-machine.h
     8  ./elf/./elf/dl-lookup.c
     9  ./elf/./elf/dl-reloc.c
    10  ./elf/./elf/do-rel.h
    11  ./malloc/./malloc/arena.c
    12  ./malloc/./malloc/malloc.c
    13  ./string/../sysdeps/x86_64/multiarch/../multiarch/strcmp-sse2.S
    14  ./string/../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S
    15  ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
    16  ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
    17  ./string/../sysdeps/x86_64/multiarch/strchr-avx2.S
    18
    19--------------------------------------------------------------------------------
    20Ir                   
    21--------------------------------------------------------------------------------
    22787,159,045 (83.13%)  events annotated
    

    UPD. When configured -DWITH_CCACHE=OFF:

     0--------------------------------------------------------------------------------
     1The following files chosen for auto-annotation could not be found:
     2--------------------------------------------------------------------------------
     3  ./elf/../sysdeps/generic/dl-new-hash.h
     4  ./elf/../sysdeps/x86_64/dl-machine.h
     5  ./elf/./elf/dl-lookup.c
     6  ./elf/./elf/dl-reloc.c
     7  ./elf/./elf/do-rel.h
     8  ./malloc/./malloc/arena.c
     9  ./malloc/./malloc/malloc.c
    10  ./string/../sysdeps/x86_64/multiarch/../multiarch/strcmp-sse2.S
    11  ./string/../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S
    12  ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
    13  ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
    14  ./string/../sysdeps/x86_64/multiarch/strchr-avx2.S
    15  build/./compat/byteswap.h
    16  build/./crypto/sha256.cpp
    17  build/./crypto/sha512.cpp
    18  build/./random.cpp
    19  build/./test/crypto_tests.cpp
    20  build/./test/util_tests.cpp
    21  build/./util/string.cpp
    22
    23--------------------------------------------------------------------------------
    
  6. maflcko commented at 3:28 pm on March 26, 2025: member

    I’ve tested the master branch @ c0b7159 with the diff from #31957 (comment) on Ubuntu 24.04:

    I can’t reproduce. What are the exact steps to reproduce from a fresh install of the operating system, like in OP?


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-03-29 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me